feat: fetch all settings if admin

This commit is contained in:
Pitu 2021-06-17 03:39:58 +09:00
parent ff343727d2
commit 30808a3574
2 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,17 @@
const Route = require('../../structures/Route');
const Util = require('../../utils/Util');
class configGET extends Route {
constructor() {
super('/service/config/all', 'get', { adminOnly: true });
}
run(req, res) {
return res.json({
message: 'Successfully retrieved config',
config: Util.config
});
}
}
module.exports = configGET;

View File

@ -11,6 +11,7 @@ export const state = () => ({
files: []
},
file: {},
settings: {},
statistics: {},
settingsSchema: {
type: null,
@ -19,6 +20,12 @@ export const state = () => ({
});
export const actions = {
async fetchSettings({ commit }) {
const response = await this.$axios.$get('service/config/all');
commit('setSettings', response);
return response;
},
async fetchStatistics({ commit }, category) {
const url = category ? `service/statistics/${category}` : 'service/statistics';
const response = await this.$axios.$get(url);
@ -105,6 +112,9 @@ export const mutations = {
state.statistics = statistics;
}
},
setSettings(state, { config }) {
state.settings = config;
},
setSettingsSchema(state, { schema }) {
state.settingsSchema = schema;
},