Move notification settings to notifications view
This commit is contained in:
+31
-14
@@ -1,13 +1,13 @@
|
||||
<script setup>
|
||||
|
||||
import { ref, onMounted } from 'vue';
|
||||
import { Switch } from '@cloudron/pankow';
|
||||
import { ref, useTemplateRef } from 'vue';
|
||||
import { Switch, Dialog } from '@cloudron/pankow';
|
||||
import SettingsItem from '../components/SettingsItem.vue';
|
||||
import Section from '../components/Section.vue';
|
||||
import ProfileModel from '../models/ProfileModel.js';
|
||||
|
||||
const profileModel = ProfileModel.create();
|
||||
|
||||
const dialogItem = useTemplateRef('dialogItem');
|
||||
const busy = ref(false);
|
||||
const appUpp = ref(false);
|
||||
const appDown = ref(false);
|
||||
@@ -34,10 +34,12 @@ async function onSubmit() {
|
||||
const [error] = await profileModel.setNotificationConfig(config);
|
||||
if (error) return console.error(error);
|
||||
|
||||
dialogItem.value.close();
|
||||
|
||||
busy.value = false;
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
async function open() {
|
||||
const [error, result] = await profileModel.get();
|
||||
if (error) return console.error(error);
|
||||
|
||||
@@ -51,54 +53,69 @@ onMounted(async () => {
|
||||
diskSpace.value = config.indexOf('diskSpace') !== -1;
|
||||
cloudronUpdateFailed.value = config.indexOf('cloudronUpdateFailed') !== -1;
|
||||
reboot.value = config.indexOf('reboot') !== -1;
|
||||
|
||||
dialogItem.value.open();
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
open
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Section :title="$t('notifications.settings.title')">
|
||||
<Dialog ref="dialogItem"
|
||||
:title="$t('notifications.settings.title')"
|
||||
:confirm-label="$t('main.dialog.save')"
|
||||
confirm-style="primary"
|
||||
:confirm-busy="busy"
|
||||
:confirm-active="!busy"
|
||||
:reject-label="$t('main.dialog.close')"
|
||||
reject-style="secondary"
|
||||
@confirm="onSubmit"
|
||||
>
|
||||
|
||||
<div>{{ $t('notifications.settingsDialog.description') }}</div>
|
||||
<br/>
|
||||
|
||||
<SettingsItem>
|
||||
<div>{{ $t('notifications.settings.appUp') }}</div>
|
||||
<Switch v-model="appUpp" :disabled="busy" @change="onSubmit()"/>
|
||||
<Switch v-model="appUpp" :disabled="busy"/>
|
||||
</SettingsItem>
|
||||
|
||||
<SettingsItem>
|
||||
<div>{{ $t('notifications.settings.appDown') }}</div>
|
||||
<Switch v-model="appDown" :disabled="busy" @change="onSubmit()"/>
|
||||
<Switch v-model="appDown" :disabled="busy"/>
|
||||
</SettingsItem>
|
||||
|
||||
<SettingsItem>
|
||||
<div>{{ $t('notifications.settings.appOutOfMemory') }}</div>
|
||||
<Switch v-model="appOutOfMemory" :disabled="busy" @change="onSubmit()"/>
|
||||
<Switch v-model="appOutOfMemory" :disabled="busy"/>
|
||||
</SettingsItem>
|
||||
|
||||
<SettingsItem>
|
||||
<div>{{ $t('notifications.settings.backupFailed') }}</div>
|
||||
<Switch v-model="backupFailed" :disabled="busy" @change="onSubmit()"/>
|
||||
<Switch v-model="backupFailed" :disabled="busy"/>
|
||||
</SettingsItem>
|
||||
|
||||
<SettingsItem>
|
||||
<div>{{ $t('notifications.settings.certificateRenewalFailed') }}</div>
|
||||
<Switch v-model="certificateRenewalFailed" :disabled="busy" @change="onSubmit()"/>
|
||||
<Switch v-model="certificateRenewalFailed" :disabled="busy"/>
|
||||
</SettingsItem>
|
||||
|
||||
<SettingsItem>
|
||||
<div>{{ $t('notifications.settings.diskSpace') }}</div>
|
||||
<Switch v-model="diskSpace" :disabled="busy" @change="onSubmit()"/>
|
||||
<Switch v-model="diskSpace" :disabled="busy"/>
|
||||
</SettingsItem>
|
||||
|
||||
<SettingsItem>
|
||||
<div>{{ $t('notifications.settings.cloudronUpdateFailed') }}</div>
|
||||
<Switch v-model="cloudronUpdateFailed" :disabled="busy" @change="onSubmit()"/>
|
||||
<Switch v-model="cloudronUpdateFailed" :disabled="busy"/>
|
||||
</SettingsItem>
|
||||
|
||||
<SettingsItem>
|
||||
<div>{{ $t('notifications.settings.rebootRequired') }}</div>
|
||||
<Switch v-model="reboot" :disabled="busy" @change="onSubmit()"/>
|
||||
<Switch v-model="reboot" :disabled="busy"/>
|
||||
</SettingsItem>
|
||||
</Section>
|
||||
</Dialog>
|
||||
</template>
|
||||
@@ -2,10 +2,11 @@
|
||||
|
||||
import { marked } from 'marked';
|
||||
import { eachLimit } from 'async';
|
||||
import { ref, onMounted, inject } from 'vue';
|
||||
import { ref, onMounted, inject, useTemplateRef } from 'vue';
|
||||
import { Button, ButtonGroup } from '@cloudron/pankow';
|
||||
import { prettyDate } from '@cloudron/pankow/utils';
|
||||
import Section from '../components/Section.vue';
|
||||
import NotificationSettingsDialog from '../components/NotificationSettingsDialog.vue';
|
||||
import NotificationsModel from '../models/NotificationsModel.js';
|
||||
|
||||
const notificationsModel = NotificationsModel.create();
|
||||
@@ -96,6 +97,11 @@ async function onLoadMore() {
|
||||
busy.value = false;
|
||||
}
|
||||
|
||||
const notificationSettingsDialog = useTemplateRef('notificationSettingsDialog');
|
||||
function onOpenSettings() {
|
||||
notificationSettingsDialog.value.open();
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await refresh();
|
||||
|
||||
@@ -106,6 +112,8 @@ onMounted(async () => {
|
||||
|
||||
<template>
|
||||
<div class="content">
|
||||
<NotificationSettingsDialog ref="notificationSettingsDialog"/>
|
||||
|
||||
<Section :title="$t('notifications.title')">
|
||||
<template #filter-bar>
|
||||
<ButtonGroup>
|
||||
@@ -115,6 +123,7 @@ onMounted(async () => {
|
||||
</template>
|
||||
<template #header-buttons>
|
||||
<Button secondary @click="onMarkAllNotificationRead()" :loading="notificationsAllBusy" :disabled="notificationsAllBusy">{{ $t('notifications.markAllAsRead') }}</Button>
|
||||
<Button @click="onOpenSettings" icon="fa fa-screwdriver-wrench" tool/>
|
||||
</template>
|
||||
|
||||
<div class="notification-list">
|
||||
|
||||
@@ -4,7 +4,6 @@ import { ref, onMounted, useTemplateRef, inject } from 'vue';
|
||||
import { Button, SingleSelect, Dialog, TextInput, InputGroup, FormGroup } from '@cloudron/pankow';
|
||||
import { setLanguage } from '../i18n.js';
|
||||
import { TOKEN_TYPES } from '../constants.js';
|
||||
import NotificationSettings from '../components/NotificationSettings.vue';
|
||||
import AppPasswords from '../components/AppPasswords.vue';
|
||||
import SettingsItem from '../components/SettingsItem.vue';
|
||||
import EditableField from '../components/EditableField.vue';
|
||||
@@ -262,7 +261,6 @@ onMounted(async () => {
|
||||
</div>
|
||||
</Section>
|
||||
|
||||
<NotificationSettings v-if="profile.isAtLeastAdmin"/>
|
||||
<AppPasswords/>
|
||||
<ApiTokens v-if="profile.isAtLeastAdmin"/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user