Implement Search for MediaproxyCache

This commit is contained in:
Angelina Filippova 2020-08-14 03:06:51 +03:00
parent 997a9a6d47
commit 7638fa71bd
3 changed files with 27 additions and 2 deletions

View file

@ -31,4 +31,13 @@ export async function removeBannedUrls(urls, authHost, token) {
})
}
export async function searchBannedUrls(query, page, pageSize, authHost, token) {
return await request({
baseURL: baseName(authHost),
url: `/api/pleroma/admin/media_proxy_caches?query=${query}&page=${page}&page_size=${pageSize}`,
method: 'get',
headers: authHeaders(token)
})
}
const authHeaders = (token) => token ? { 'Authorization': `Bearer ${getToken()}` } : {}

View file

@ -1,4 +1,4 @@
import { listBannedUrls, purgeUrls, removeBannedUrls } from '@/api/mediaProxyCache'
import { listBannedUrls, purgeUrls, removeBannedUrls, searchBannedUrls } from '@/api/mediaProxyCache'
import { Message } from 'element-ui'
import i18n from '@/lang'
@ -47,6 +47,21 @@ const mediaProxyCache = {
async RemoveBannedUrls({ dispatch, getters, state }, urls) {
await removeBannedUrls(urls, getters.authHost, getters.token)
dispatch('ListBannedUrls', { page: state.currentPage })
},
async SearchUrls({ commit, dispatch, getters, state }, { query, page }) {
if (query.length === 0) {
commit('SET_SEARCH_QUERY', query)
dispatch('ListBannedUrls', { page })
} else {
commit('SET_LOADING', true)
commit('SET_SEARCH_QUERY', query)
const response = await searchBannedUrls(query, page, state.pageSize, getters.authHost, getters.token)
commit('SET_BANNED_URLS', response.data.urls)
commit('SET_TOTAL_URLS_COUNT', response.data.count)
commit('SET_PAGE', page)
commit('SET_LOADING', false)
}
}
}
}

View file

@ -28,7 +28,7 @@
align="center"
width="55"/>
<el-table-column :min-width="isDesktop ? 320 : 120" prop="url">
<template slot="header">
<template slot="header" slot-scope="scope">
<el-input
:placeholder="$t('users.search')"
v-model="search"
@ -106,6 +106,7 @@ export default {
},
created() {
this.handleDebounceSearchInput = debounce((query) => {
this.$store.dispatch('SearchUrls', { query, page: 1 })
}, 500)
},
mounted() {