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

Implement Search for MediaproxyCache

parent 997a9a6d
No related branches found
No related tags found
No related merge requests found
...@@ -31,4 +31,13 @@ export async function removeBannedUrls(urls, authHost, token) { ...@@ -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()}` } : {} const authHeaders = (token) => token ? { 'Authorization': `Bearer ${getToken()}` } : {}
import { listBannedUrls, purgeUrls, removeBannedUrls } from '@/api/mediaProxyCache' import { listBannedUrls, purgeUrls, removeBannedUrls, searchBannedUrls } from '@/api/mediaProxyCache'
import { Message } from 'element-ui' import { Message } from 'element-ui'
import i18n from '@/lang' import i18n from '@/lang'
...@@ -47,6 +47,21 @@ const mediaProxyCache = { ...@@ -47,6 +47,21 @@ const mediaProxyCache = {
async RemoveBannedUrls({ dispatch, getters, state }, urls) { async RemoveBannedUrls({ dispatch, getters, state }, urls) {
await removeBannedUrls(urls, getters.authHost, getters.token) await removeBannedUrls(urls, getters.authHost, getters.token)
dispatch('ListBannedUrls', { page: state.currentPage }) 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)
}
} }
} }
} }
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
align="center" align="center"
width="55"/> width="55"/>
<el-table-column :min-width="isDesktop ? 320 : 120" prop="url"> <el-table-column :min-width="isDesktop ? 320 : 120" prop="url">
<template slot="header"> <template slot="header" slot-scope="scope">
<el-input <el-input
:placeholder="$t('users.search')" :placeholder="$t('users.search')"
v-model="search" v-model="search"
...@@ -106,6 +106,7 @@ export default { ...@@ -106,6 +106,7 @@ export default {
}, },
created() { created() {
this.handleDebounceSearchInput = debounce((query) => { this.handleDebounceSearchInput = debounce((query) => {
this.$store.dispatch('SearchUrls', { query, page: 1 })
}, 500) }, 500)
}, },
mounted() { mounted() {
......
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