forked from AkkomaGang/admin-fe
Implement Search for MediaproxyCache
This commit is contained in:
parent
997a9a6d47
commit
7638fa71bd
3 changed files with 27 additions and 2 deletions
|
@ -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()}` } : {}
|
||||||
|
|
|
@ -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 { Message } from 'element-ui'
|
||||||
import i18n from '@/lang'
|
import i18n from '@/lang'
|
||||||
|
|
||||||
|
@ -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 @@
|
||||||
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 {
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.handleDebounceSearchInput = debounce((query) => {
|
this.handleDebounceSearchInput = debounce((query) => {
|
||||||
|
this.$store.dispatch('SearchUrls', { query, page: 1 })
|
||||||
}, 500)
|
}, 500)
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
|
Loading…
Reference in a new issue