Skip to content
Snippets Groups Projects
Commit 4c32a070 authored by Angelina Filippova's avatar Angelina Filippova
Browse files

Add ability to remove multiple urls

parent a2649dbb
No related branches found
No related tags found
1 merge request!142Add ability to evict and ban URLs from the Pleroma MediaProxy cache
Pipeline #28233 passed
......@@ -102,7 +102,8 @@ export default {
remove: 'Remove from Cachex',
evictObjectsHeader: 'Evict object from the MediaProxy cache',
listBannedUrlsHeader: 'List of all banned MediaProxy URLs',
multipleInput: 'You can enter a single URL or several comma separated links'
multipleInput: 'You can enter a single URL or several comma separated links',
removeSelected: 'Remove Selected'
},
documentation: {
documentation: 'Documentation',
......
......@@ -43,8 +43,9 @@ const mediaProxyCache = {
dispatch('ListBannedUrls', state.currentPage)
}
},
async RemoveBannedUrls({ commit, getters }, urls) {
async RemoveBannedUrls({ dispatch, getters, state }, urls) {
await removeBannedUrls(urls, getters.authHost, getters.token)
dispatch('ListBannedUrls', state.currentPage)
}
}
}
......
......@@ -28,14 +28,20 @@
align="center"
width="55"/>
<el-table-column
:label="$t('mediaProxyCache.url')"
:min-width="isDesktop ? 320 : 120"
prop="url"/>
<el-table-column
:label="$t('mediaProxyCache.actions')">
<el-table-column>
<template slot="header">
<el-button
:disabled="removeSelectedDisabled"
size="mini"
class="remove-url-button"
@click="removeSelected()">{{ $t('mediaProxyCache.removeSelected') }}</el-button>
</template>
<template slot-scope="scope">
<el-button
size="mini"
class="remove-url-button"
@click="removeUrl(scope.row.url)">{{ $t('mediaProxyCache.remove') }}</el-button>
</template>
</el-table-column>
......@@ -65,6 +71,9 @@ export default {
},
loading() {
return this.$store.state.mediaProxyCache.loading
},
removeSelectedDisabled() {
return this.selectedUrls.length === 0
}
},
mounted() {
......@@ -76,14 +85,18 @@ export default {
evictURL() {
const urls = this.urls.split(',').map(url => url.trim()).filter(el => el.length > 0)
this.$store.dispatch('PurgeUrls', { urls, ban: this.ban })
this.url = ''
this.urls = ''
},
handleSelectionChange(value) {
this.$data.selectedUrls = value
},
removeUrl(url) {
const urls = typeof this.url === 'string' ? [this.url] : this.url
removeSelected() {
const urls = this.selectedUrls.map(el => el.url)
this.$store.dispatch('RemoveBannedUrls', urls)
this.selectedUrls = []
},
removeUrl(url) {
this.$store.dispatch('RemoveBannedUrls', [this.url])
}
}
}
......@@ -120,6 +133,9 @@ h1 {
justify-content: space-between;
margin: 10px 15px;
}
.remove-url-button {
width: 150px;
}
.url-input {
margin-right: 15px;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment