added admin settings gui

This commit is contained in:
Jonathan Treffler 2024-04-23 20:17:41 +02:00 committed by root
parent b79f6cab6b
commit 31a419b536
7 changed files with 1489 additions and 828 deletions

2
.gitignore vendored
View file

@ -4,4 +4,4 @@
/build/
node_modules/
/.php-cs-fixer.cache
js/*hot-update.*
js/

View file

@ -1,4 +1,21 @@
<?php
return [
"routes" => [
[
'name' => 'AdminSettings#index',
'url' => '/adminSettings',
'verb' => 'GET'
],
[
'name' => 'AdminSettings#show',
'url' => '/adminSettings/{key}',
'verb' => 'GET'
],
[
'name' => 'AdminSettings#update',
'url' => '/adminSettings/{key}',
'verb' => 'PATCH'
],
]
];

2189
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -21,7 +21,9 @@
},
"dependencies": {
"@nextcloud/axios": "^2.3.0",
"@nextcloud/vue": "^7.4.0",
"@nextcloud/router": "^3.0.1",
"@nextcloud/vue": "^8.11.2",
"debounce-fn": "^6.0.0",
"vue": "^2.7.14"
},
"browserslist": [

50
src/AdminSettings.vue Normal file
View file

@ -0,0 +1,50 @@
<template>
<div>
<NcSettingsSection
name="Groupfolder Filesystem Snapshots"
:limit-width="false">
<div v-if="!loading">
<Field :is="setting.sensitive ? NcPasswordField : NcTextField"
v-for="setting in app_settings"
:key="setting.id"
class="settings_field"
:value="settings?.[setting.id]"
:label="setting.name"
@update:value="(newValue) => updateSetting(setting.id, newValue)" />
</div>
</NcSettingsSection>
</div>
</template>
<script setup>
import { ref } from "vue";
import debounceFunction from 'debounce-fn';
import { NcSettingsSection, NcTextField, NcPasswordField } from "@nextcloud/vue"
import { adminSettingsApi } from "./adminSettingsApi.js";
let loading = ref(true);
let settings = ref({});
const app_settings = [
{id: "filesystem_mountpoint_path", name: "Filesystem Mountpoint Path"},
{id: "filesystem_snapshots_path", name: "Filesystem Snapshots Path"},
];
adminSettingsApi.getAllSettings().then((result) => {
settings.value = result;
loading.value = false;
});
const updateSetting = debounceFunction((key, value) => {
console.log("updateSetting", key, value);
settings.value[key] = value;
adminSettingsApi.setSetting(key, value).then(() => {
});
})
</script>
<style scoped>
.settings_field {
margin-bottom: 20px;
}
</style>

View file

@ -0,0 +1,9 @@
import Vue from 'vue'
import App from './AdminSettings.vue'
Vue.mixin({ methods: { t, n } })
export default new Vue({
el: '#groupfolder_filesystem_snapshots_admin_settings',
render: h => h(App),
})

16
src/adminSettingsApi.js Normal file
View file

@ -0,0 +1,16 @@
import axios from "@nextcloud/axios"
import { generateUrl } from "@nextcloud/router"
axios.defaults.baseURL = generateUrl("/apps/groupfolder_filesystem_snapshots")
export const adminSettingsApi = {
getAllSettings() {
return axios.get("/adminSettings").then((res) => res.data)
},
getSetting(key) {
return axios.get("/adminSettings/" + key).then((res) => res.data)
},
setSetting(key, value) {
return axios.patch("/adminSettings/" + key, { value }).then((res) => res.data)
},
}