diff --git a/src/lang/en.js b/src/lang/en.js index 68e6f84a..cb82b4cd 100644 --- a/src/lang/en.js +++ b/src/lang/en.js @@ -103,7 +103,11 @@ export default { 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', - removeSelected: 'Remove Selected' + removeSelected: 'Remove Selected', + enable: 'Enable', + invalidationAndMediaProxy: 'MediaProxy and Invalidation to evict and ban MediaProxy objects', + confirmEnablingMediaProxy: 'Are you sure you want to enable Media Proxy and Media Cache object Invalidation?', + enableMediaProxySuccessMessage: 'Media Proxy and Media Cache object Invalidation were enabled' }, documentation: { documentation: 'Documentation', diff --git a/src/store/modules/mediaProxyCache.js b/src/store/modules/mediaProxyCache.js index 5a5307da..da50f411 100644 --- a/src/store/modules/mediaProxyCache.js +++ b/src/store/modules/mediaProxyCache.js @@ -1,5 +1,5 @@ import { listBannedUrls, purgeUrls, removeBannedUrls, searchBannedUrls } from '@/api/mediaProxyCache' -import { fetchSettings } from '@/api/settings' +import { fetchSettings, updateSettings } from '@/api/settings' import { Message } from 'element-ui' import i18n from '@/lang' @@ -30,6 +30,19 @@ const mediaProxyCache = { } }, actions: { + async EnableMediaProxy({ dispatch, getters, state }) { + const configs = [{ + group: ':pleroma', + key: ':media_proxy', + value: [ + { tuple: [':enabled', true] }, + { tuple: [':invalidation', [{ tuple: [':enabled', true] }]] } + ] + }] + await updateSettings(configs, getters.authHost, getters.token) + + dispatch('FetchMediaProxySetting') + }, async FetchMediaProxySetting({ commit, getters }) { const { data } = await fetchSettings(getters.authHost, getters.token) const mediaProxySettings = data.configs.find(el => el.key === ':media_proxy') diff --git a/src/views/mediaProxyCache/index.vue b/src/views/mediaProxyCache/index.vue index 47475244..9d34aa2b 100644 --- a/src/views/mediaProxyCache/index.vue +++ b/src/views/mediaProxyCache/index.vue @@ -1,10 +1,10 @@ @@ -121,6 +125,26 @@ export default { this.$store.dispatch('ListBannedUrls', { page: 1 }) }, methods: { + enableMediaProxy() { + this.$confirm( + this.$t('mediaProxyCache.confirmEnablingMediaProxy'), + { + confirmButtonText: 'Yes', + cancelButtonText: 'Cancel', + type: 'warning' + }).then(() => { + this.$message({ + type: 'success', + message: this.$t('mediaProxyCache.enableMediaProxySuccessMessage') + }) + this.$store.dispatch('EnableMediaProxy') + }).catch(() => { + this.$message({ + type: 'info', + message: 'Canceled' + }) + }) + }, evictURL() { const urls = this.urls.split(',').map(url => url.trim()).filter(el => el.length > 0) this.$store.dispatch('PurgeUrls', { urls, ban: this.ban }) @@ -148,6 +172,12 @@ export default { h1 { margin: 0; } +.enable-mediaproxy-container { + margin: 10px 15px; + button { + font-size: 16px; + } +} .expl { color: #666666; font-size: 13px;