forked from AkkomaGang/admin-fe
Fetch the list of frontends and save them in state
This commit is contained in:
parent
8a39058467
commit
04d2f4bcca
3 changed files with 31 additions and 0 deletions
|
@ -68,4 +68,23 @@ export async function removeSettings(configs, authHost, token) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function fetchFrontends(authHost, token) {
|
||||||
|
return await request({
|
||||||
|
baseURL: baseName(authHost),
|
||||||
|
url: `/api/pleroma/admin/frontends`,
|
||||||
|
method: 'get',
|
||||||
|
headers: authHeaders(token)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function installFrontend(name, ref, file, buildUrl, buildDir, authHost, token) {
|
||||||
|
return await request({
|
||||||
|
baseURL: baseName(authHost),
|
||||||
|
url: `/api/pleroma/admin/frontends/install`,
|
||||||
|
method: 'post',
|
||||||
|
headers: authHeaders(token),
|
||||||
|
data: { name, ref, file, build_url: buildUrl, build_dir: buildDir }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const authHeaders = (token) => token ? { 'Authorization': `Bearer ${getToken()}` } : {}
|
const authHeaders = (token) => token ? { 'Authorization': `Bearer ${getToken()}` } : {}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import {
|
import {
|
||||||
deleteInstanceDocument,
|
deleteInstanceDocument,
|
||||||
fetchDescription,
|
fetchDescription,
|
||||||
|
fetchFrontends,
|
||||||
fetchSettings,
|
fetchSettings,
|
||||||
getInstanceDocument,
|
getInstanceDocument,
|
||||||
removeSettings,
|
removeSettings,
|
||||||
|
@ -13,6 +14,7 @@ const settings = {
|
||||||
state: {
|
state: {
|
||||||
activeTab: 'instance',
|
activeTab: 'instance',
|
||||||
configDisabled: true,
|
configDisabled: true,
|
||||||
|
frontends: [],
|
||||||
db: {},
|
db: {},
|
||||||
description: [],
|
description: [],
|
||||||
instancePanel: '',
|
instancePanel: '',
|
||||||
|
@ -41,6 +43,9 @@ const settings = {
|
||||||
SET_DESCRIPTION: (state, data) => {
|
SET_DESCRIPTION: (state, data) => {
|
||||||
state.description = data
|
state.description = data
|
||||||
},
|
},
|
||||||
|
SET_FRONTENDS: (state, data) => {
|
||||||
|
state.frontends = data
|
||||||
|
},
|
||||||
SET_LOADING: (state, status) => {
|
SET_LOADING: (state, status) => {
|
||||||
state.loading = status
|
state.loading = status
|
||||||
},
|
},
|
||||||
|
@ -86,6 +91,10 @@ const settings = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
|
async FetchFrontends({ commit, getters }) {
|
||||||
|
const { data } = await fetchFrontends(getters.authHost, getters.token)
|
||||||
|
commit('SET_FRONTENDS', data)
|
||||||
|
},
|
||||||
async FetchInstanceDocument({ commit, getters }, name) {
|
async FetchInstanceDocument({ commit, getters }, name) {
|
||||||
const { data } = await getInstanceDocument(name, getters.authHost, getters.token)
|
const { data } = await getInstanceDocument(name, getters.authHost, getters.token)
|
||||||
if (name === 'instance-panel') {
|
if (name === 'instance-panel') {
|
||||||
|
|
|
@ -123,6 +123,9 @@ export default {
|
||||||
return _.get(this.settings.settings, [':pleroma', ':static_fe']) || {}
|
return _.get(this.settings.settings, [':pleroma', ':static_fe']) || {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
async mounted() {
|
||||||
|
await this.$store.dispatch('FetchFrontends')
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async onSubmit() {
|
async onSubmit() {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue