feat: fetch settings from api
This commit is contained in:
parent
334c3d1c34
commit
50d13e2ae7
|
@ -60,13 +60,7 @@ export default {
|
||||||
linkExactActiveClass: 'is-active'
|
linkExactActiveClass: 'is-active'
|
||||||
},
|
},
|
||||||
env: {
|
env: {
|
||||||
development: process.env.NODE_ENV !== 'production',
|
development: process.env.NODE_ENV !== 'production'
|
||||||
version: process.env.npm_package_version,
|
|
||||||
serviceName: Util.config.serviceName,
|
|
||||||
maxFileSize: Util.config.maxSize,
|
|
||||||
chunkSize: Util.config.chunkSize,
|
|
||||||
publicMode: Util.config.publicMode,
|
|
||||||
userAccounts: Util.config.userAccounts
|
|
||||||
},
|
},
|
||||||
axios: {
|
axios: {
|
||||||
baseURL: `${process.env.NODE_ENV === 'production' ? '' : 'http://localhost:5000'}/api`
|
baseURL: `${process.env.NODE_ENV === 'production' ? '' : 'http://localhost:5000'}/api`
|
||||||
|
|
|
@ -3,20 +3,21 @@ const Util = require('../../utils/Util');
|
||||||
|
|
||||||
class configGET extends Route {
|
class configGET extends Route {
|
||||||
constructor() {
|
constructor() {
|
||||||
super('/service/config', 'get', { adminOnly: true });
|
super('/service/config', 'get', { bypassAuth: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
run(req, res) {
|
run(req, res) {
|
||||||
return res.json({
|
return res.json({
|
||||||
message: 'Successfully retrieved config',
|
message: 'Successfully retrieved config',
|
||||||
config: {
|
config: {
|
||||||
|
version: process.env.npm_package_version,
|
||||||
serviceName: Util.config.serviceName,
|
serviceName: Util.config.serviceName,
|
||||||
maxUploadSize: Util.config.maxSize,
|
maxUploadSize: Util.config.maxSize,
|
||||||
filenameLength: Util.config.generatedFilenameLength,
|
filenameLength: Util.config.generatedFilenameLength,
|
||||||
albumLinkLength: Util.config.generatedAlbumLength,
|
albumLinkLength: Util.config.generatedAlbumLength,
|
||||||
generateZips: Util.config.generateZips,
|
chunkSize: Util.config.chunkSize,
|
||||||
publicMode: Util.config.publicMode,
|
publicMode: Util.config.publicMode,
|
||||||
enableAccounts: Util.config.userAccounts
|
userAccounts: Util.config.userAccounts
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
href="https://github.com/pitu"
|
href="https://github.com/pitu"
|
||||||
class="no-block">Pitu</a>
|
class="no-block">Pitu</a>
|
||||||
</span><br>
|
</span><br>
|
||||||
<span>v{{ version }}</span>
|
<span>{{ version }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="column is-narrow bottom-up">
|
<div class="column is-narrow bottom-up">
|
||||||
<a href="https://github.com/weebdev/chibisafe">GitHub</a>
|
<a href="https://github.com/weebdev/chibisafe">GitHub</a>
|
||||||
|
|
|
@ -124,7 +124,7 @@ export default {
|
||||||
parallelChunkUploads: false,
|
parallelChunkUploads: false,
|
||||||
chunkSize: this.config.chunkSize * 1000000,
|
chunkSize: this.config.chunkSize * 1000000,
|
||||||
chunksUploaded: this.dropzoneChunksUploaded,
|
chunksUploaded: this.dropzoneChunksUploaded,
|
||||||
maxFilesize: this.config.maxFileSize,
|
maxFilesize: this.config.maxUploadSize,
|
||||||
previewTemplate: this.$refs.template.innerHTML,
|
previewTemplate: this.$refs.template.innerHTML,
|
||||||
dictDefaultMessage: 'Drag & Drop your files or click to browse',
|
dictDefaultMessage: 'Drag & Drop your files or click to browse',
|
||||||
headers: { Accept: 'application/vnd.chibisafe.json' }
|
headers: { Accept: 'application/vnd.chibisafe.json' }
|
||||||
|
|
|
@ -1,11 +1,33 @@
|
||||||
export const state = () => ({
|
export const state = () => ({
|
||||||
development: process.env.development,
|
development: process.env.development,
|
||||||
version: process.env.version,
|
version: '',
|
||||||
URL: process.env.development ? 'http://localhost:5000' : '/',
|
URL: process.env.development ? 'http://localhost:5000' : '/',
|
||||||
baseURL: `${process.env.development ? 'http://localhost:5000' : ''}/api`,
|
baseURL: `${process.env.development ? 'http://localhost:5000' : ''}/api`,
|
||||||
serviceName: process.env.serviceName,
|
serviceName: '',
|
||||||
maxFileSize: process.env.maxFilesize,
|
maxFileSize: '',
|
||||||
chunkSize: process.env.chunkSize,
|
chunkSize: 0,
|
||||||
publicMode: process.env.publicMode,
|
publicMode: false,
|
||||||
userAccounts: process.env.userAccounts
|
userAccounts: false
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const mutations = {
|
||||||
|
setSettings(state, { config }) {
|
||||||
|
state.version = `v${config.version}`;
|
||||||
|
state.serviceName = config.serviceName;
|
||||||
|
state.maxUploadSize = config.maxUploadSize;
|
||||||
|
state.filenameLength = config.filenameLength;
|
||||||
|
state.albumLinkLength = config.albumLinkLength;
|
||||||
|
state.chunkSize = config.chunkSize;
|
||||||
|
state.publicMode = config.publicMode;
|
||||||
|
state.userAccounts = config.userAccounts;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const actions = {
|
||||||
|
async fetchSettings({ commit }) {
|
||||||
|
const response = await this.$axios.$get('service/config');
|
||||||
|
commit('setSettings', response);
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import config from '../../../dist/config.json';
|
|
||||||
|
|
||||||
export const actions = {
|
export const actions = {
|
||||||
async nuxtServerInit({ commit, dispatch }) {
|
async nuxtServerInit({ commit, dispatch }) {
|
||||||
commit('config/set', config);
|
await dispatch('config/fetchSettings');
|
||||||
const cookies = this.$cookies.getAll();
|
const cookies = this.$cookies.getAll();
|
||||||
if (!cookies.token) return dispatch('auth/logout');
|
if (!cookies.token) return dispatch('auth/logout');
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue