diff options
| author | Zephyrrus <[email protected]> | 2020-07-10 01:17:00 +0300 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-07-10 01:17:00 +0300 |
| commit | a721681944e9eb06742e5b3f71c71aed9c1c117d (patch) | |
| tree | 93ff9fd13a0434d91fb1ae7ca0da48d6929c4d00 /src/site/pages/dashboard/admin/settings.vue | |
| parent | feat: backend pagination for albums (diff) | |
| parent | refactor: finish refactoring all the components to use vuex (diff) | |
| download | host.fuwn.me-a721681944e9eb06742e5b3f71c71aed9c1c117d.tar.xz host.fuwn.me-a721681944e9eb06742e5b3f71c71aed9c1c117d.zip | |
Merge pull request #1 from Zephyrrus/feature/store_refactor
Feature/store refactor
Diffstat (limited to 'src/site/pages/dashboard/admin/settings.vue')
| -rw-r--r-- | src/site/pages/dashboard/admin/settings.vue | 109 |
1 files changed, 66 insertions, 43 deletions
diff --git a/src/site/pages/dashboard/admin/settings.vue b/src/site/pages/dashboard/admin/settings.vue index 2d59fff..7f6a0fe 100644 --- a/src/site/pages/dashboard/admin/settings.vue +++ b/src/site/pages/dashboard/admin/settings.vue @@ -6,87 +6,112 @@ <Sidebar /> </div> <div class="column"> - <h2 class="subtitle">Service settings</h2> + <h2 class="subtitle"> + Service settings + </h2> <hr> - <b-field label="Service name" + <b-field + label="Service name" message="Please enter the name which this service is gonna be identified as" horizontal> - <b-input v-model="options.serviceName" + <b-input + v-model="settings.serviceName" expanded /> </b-field> - <b-field label="Upload folder" + <b-field + label="Upload folder" message="Where to store the files relative to the working directory" horizontal> - <b-input v-model="options.uploadFolder" + <b-input + v-model="settings.uploadFolder" expanded /> </b-field> - <b-field label="Links per album" + <b-field + label="Links per album" message="Maximum links allowed per album" horizontal> - <b-input v-model="options.linksPerAlbum" + <b-input + v-model="settings.linksPerAlbum" type="number" expanded /> </b-field> - <b-field label="Max upload size" + <b-field + label="Max upload size" message="Maximum allowed file size in MB" horizontal> - <b-input v-model="options.maxUploadSize" + <b-input + v-model="settings.maxUploadSize" expanded /> </b-field> - <b-field label="Filename length" + <b-field + label="Filename length" message="How many characters long should the generated filenames be" horizontal> - <b-input v-model="options.filenameLength" + <b-input + v-model="settings.filenameLength" expanded /> </b-field> - <b-field label="Album link length" + <b-field + label="Album link length" message="How many characters a link for an album should have" horizontal> - <b-input v-model="options.albumLinkLength" + <b-input + v-model="settings.albumLinkLength" expanded /> </b-field> - <b-field label="Generate thumbnails" + <b-field + label="Generate thumbnails" message="Generate thumbnails when uploading a file if possible" horizontal> - <b-switch v-model="options.generateThumbnails" + <b-switch + v-model="settings.generateThumbnails" :true-value="true" :false-value="false" /> </b-field> - <b-field label="Generate zips" + <b-field + label="Generate zips" message="Allow generating zips to download entire albums" horizontal> - <b-switch v-model="options.generateZips" + <b-switch + v-model="settings.generateZips" :true-value="true" :false-value="false" /> </b-field> - <b-field label="Public mode" + <b-field + label="Public mode" message="Enable anonymous uploades" horizontal> - <b-switch v-model="options.publicMode" + <b-switch + v-model="settings.publicMode" :true-value="true" :false-value="false" /> </b-field> - <b-field label="Enable creating account" + <b-field + label="Enable creating account" message="Enable creating new accounts in the platform" horizontal> - <b-switch v-model="options.enableAccounts" + <b-switch + v-model="settings.enableAccounts" :true-value="true" :false-value="false" /> </b-field> <div class="mb2 mt2 text-center"> - <button class="button is-primary" - @click="promptRestartService">Save and restart service</button> + <button + class="button is-primary" + @click="promptRestartService"> + Save and restart service + </button> </div> </div> </div> @@ -95,39 +120,37 @@ </template> <script> +import { mapState } from 'vuex'; import Sidebar from '~/components/sidebar/Sidebar.vue'; export default { components: { - Sidebar - }, - middleware: ['auth', 'admin'], - data() { - return { - options: {} - }; + Sidebar, }, + middleware: ['auth', 'admin', ({ store }) => { + try { + store.dispatch('admin/fetchSettings'); + } catch (e) { + // eslint-disable-next-line no-console + console.error(e); + } + }], metaInfo() { return { title: 'Settings' }; }, - mounted() { - this.getSettings(); - }, + computed: mapState({ + settings: (state) => state.admin.settings, + }), methods: { - async getSettings() { - const response = await this.$axios.$get(`service/config`); - this.options = response.config; - }, promptRestartService() { this.$buefy.dialog.confirm({ message: 'Keep in mind that restarting only works if you have PM2 or something similar set up. Continue?', - onConfirm: () => this.restartService() + onConfirm: () => this.restartService(), }); }, - async restartService() { - const response = await this.$axios.$post(`service/restart`); - this.$buefy.toast.open(response.message); - } - } + restartService() { + this.$handler.executeAction('admin/restartService'); + }, + }, }; </script> |