forked from AkkomaGang/admin-fe
Add ability to remove multiple urls
This commit is contained in:
parent
a2649dbb64
commit
4c32a0708f
3 changed files with 26 additions and 8 deletions
|
@ -102,7 +102,8 @@ export default {
|
||||||
remove: 'Remove from Cachex',
|
remove: 'Remove from Cachex',
|
||||||
evictObjectsHeader: 'Evict object from the MediaProxy cache',
|
evictObjectsHeader: 'Evict object from the MediaProxy cache',
|
||||||
listBannedUrlsHeader: 'List of all banned MediaProxy URLs',
|
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: 'Documentation',
|
documentation: 'Documentation',
|
||||||
|
|
|
@ -43,8 +43,9 @@ const mediaProxyCache = {
|
||||||
dispatch('ListBannedUrls', state.currentPage)
|
dispatch('ListBannedUrls', state.currentPage)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async RemoveBannedUrls({ commit, getters }, urls) {
|
async RemoveBannedUrls({ dispatch, getters, state }, urls) {
|
||||||
await removeBannedUrls(urls, getters.authHost, getters.token)
|
await removeBannedUrls(urls, getters.authHost, getters.token)
|
||||||
|
dispatch('ListBannedUrls', state.currentPage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,14 +28,20 @@
|
||||||
align="center"
|
align="center"
|
||||||
width="55"/>
|
width="55"/>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
:label="$t('mediaProxyCache.url')"
|
|
||||||
:min-width="isDesktop ? 320 : 120"
|
:min-width="isDesktop ? 320 : 120"
|
||||||
prop="url"/>
|
prop="url"/>
|
||||||
<el-table-column
|
<el-table-column>
|
||||||
:label="$t('mediaProxyCache.actions')">
|
<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">
|
<template slot-scope="scope">
|
||||||
<el-button
|
<el-button
|
||||||
size="mini"
|
size="mini"
|
||||||
|
class="remove-url-button"
|
||||||
@click="removeUrl(scope.row.url)">{{ $t('mediaProxyCache.remove') }}</el-button>
|
@click="removeUrl(scope.row.url)">{{ $t('mediaProxyCache.remove') }}</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
@ -65,6 +71,9 @@ export default {
|
||||||
},
|
},
|
||||||
loading() {
|
loading() {
|
||||||
return this.$store.state.mediaProxyCache.loading
|
return this.$store.state.mediaProxyCache.loading
|
||||||
|
},
|
||||||
|
removeSelectedDisabled() {
|
||||||
|
return this.selectedUrls.length === 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
@ -76,14 +85,18 @@ export default {
|
||||||
evictURL() {
|
evictURL() {
|
||||||
const urls = this.urls.split(',').map(url => url.trim()).filter(el => el.length > 0)
|
const urls = this.urls.split(',').map(url => url.trim()).filter(el => el.length > 0)
|
||||||
this.$store.dispatch('PurgeUrls', { urls, ban: this.ban })
|
this.$store.dispatch('PurgeUrls', { urls, ban: this.ban })
|
||||||
this.url = ''
|
this.urls = ''
|
||||||
},
|
},
|
||||||
handleSelectionChange(value) {
|
handleSelectionChange(value) {
|
||||||
this.$data.selectedUrls = value
|
this.$data.selectedUrls = value
|
||||||
},
|
},
|
||||||
removeUrl(url) {
|
removeSelected() {
|
||||||
const urls = typeof this.url === 'string' ? [this.url] : this.url
|
const urls = this.selectedUrls.map(el => el.url)
|
||||||
this.$store.dispatch('RemoveBannedUrls', urls)
|
this.$store.dispatch('RemoveBannedUrls', urls)
|
||||||
|
this.selectedUrls = []
|
||||||
|
},
|
||||||
|
removeUrl(url) {
|
||||||
|
this.$store.dispatch('RemoveBannedUrls', [this.url])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,6 +133,9 @@ h1 {
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
margin: 10px 15px;
|
margin: 10px 15px;
|
||||||
}
|
}
|
||||||
|
.remove-url-button {
|
||||||
|
width: 150px;
|
||||||
|
}
|
||||||
.url-input {
|
.url-input {
|
||||||
margin-right: 15px;
|
margin-right: 15px;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue