-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add copyright, resolve eslint comments
Signed-off-by: Топонен Никита <Toponen@lanit.ru>
- Loading branch information
1 parent
3a54e27
commit fa9831f
Showing
2 changed files
with
111 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,30 @@ | ||
/** | ||
* @copyright Copyright (c) 2022 Nikita Toponen <natoponen@gmail.com> | ||
* | ||
* @license AGPL-3.0-or-later | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
import Vue from 'vue' | ||
import AdminSettings from './views/AdminSettings' | ||
import AdminSettings from './views/AdminSettings.vue' | ||
|
||
Vue.prototype.t = t | ||
Vue.prototype.n = n | ||
|
||
export default new Vue({ | ||
el: '#notifications-admin-settings', | ||
render: h => h(AdminSettings), | ||
}) | ||
el: '#notifications-admin-settings', | ||
render: h => h(AdminSettings), | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,105 @@ | ||
<!-- | ||
- @copyright Copyright (c) 2022 Nikita Toponen <natoponen@gmail.com> | ||
- | ||
- @license GNU AGPL version 3 or any later version | ||
- | ||
- This program is free software: you can redistribute it and/or modify | ||
- it under the terms of the GNU Affero General Public License as | ||
- published by the Free Software Foundation, either version 3 of the | ||
- License, or (at your option) any later version. | ||
- | ||
- This program is distributed in the hope that it will be useful, | ||
- but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
- GNU Affero General Public License for more details. | ||
- | ||
- You should have received a copy of the GNU Affero General Public License | ||
- along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
- | ||
--> | ||
|
||
<template> | ||
<SettingsSection :title="t('notifications', 'Notifications defaults')"> | ||
<p class="settings-hint"> | ||
{{ t('notifications', 'Configure the default notification settings for new users') }} | ||
</p> | ||
<SettingsSection :title="t('notifications', 'Notifications defaults')"> | ||
<p class="settings-hint"> | ||
{{ t('notifications', 'Configure the default notification settings for new users') }} | ||
</p> | ||
|
||
<p> | ||
<label for="notify_setting_batchtime" class="notification-frequency__label"> | ||
{{ t('notifications', 'Send email reminders about unhandled notifications after:') }} | ||
</label> | ||
<select id="notify_setting_batchtime" | ||
v-model="config.setting_batchtime" | ||
class="notification-frequency__select" | ||
@change="updateSettings()"> | ||
<option v-for="option in batchtime_options" :key="option.value" :value="option.value"> | ||
{{ option.text }} | ||
</option> | ||
</select> | ||
</p> | ||
<p> | ||
<label for="notify_setting_batchtime" class="notification-frequency__label"> | ||
{{ t('notifications', 'Send email reminders about unhandled notifications after:') }} | ||
</label> | ||
<select id="notify_setting_batchtime" | ||
v-model="config.setting_batchtime" | ||
class="notification-frequency__select" | ||
@change="updateSettings()"> | ||
<option v-for="option in batchtime_options" :key="option.value" :value="option.value"> | ||
{{ option.text }} | ||
</option> | ||
</select> | ||
</p> | ||
|
||
<CheckboxRadioSwitch :checked.sync="config.sound_notification" | ||
@update:checked="updateSettings"> | ||
{{ t('notifications', 'Play sound when a new notification arrives') }} | ||
</CheckboxRadioSwitch> | ||
<CheckboxRadioSwitch :checked.sync="config.sound_talk" | ||
@update:checked="updateSettings"> | ||
{{ t('notifications', 'Play sound when a call started (requires Nextcloud Talk)') }} | ||
</CheckboxRadioSwitch> | ||
</SettingsSection> | ||
<CheckboxRadioSwitch :checked.sync="config.sound_notification" | ||
@update:checked="updateSettings"> | ||
{{ t('notifications', 'Play sound when a new notification arrives') }} | ||
</CheckboxRadioSwitch> | ||
<CheckboxRadioSwitch :checked.sync="config.sound_talk" | ||
@update:checked="updateSettings"> | ||
{{ t('notifications', 'Play sound when a call started (requires Nextcloud Talk)') }} | ||
</CheckboxRadioSwitch> | ||
</SettingsSection> | ||
</template> | ||
|
||
<script> | ||
import axios from '@nextcloud/axios' | ||
import { generateOcsUrl } from '@nextcloud/router' | ||
import { loadState } from '@nextcloud/initial-state' | ||
import { showSuccess, showError } from '@nextcloud/dialogs' | ||
import {generateOcsUrl} from '@nextcloud/router' | ||
import {loadState} from '@nextcloud/initial-state' | ||
import {showSuccess, showError} from '@nextcloud/dialogs' | ||
import CheckboxRadioSwitch from '@nextcloud/vue/dist/Components/CheckboxRadioSwitch' | ||
import SettingsSection from '@nextcloud/vue/dist/Components/SettingsSection' | ||
|
||
const EmailFrequency = { | ||
EMAIL_SEND_OFF: 0, | ||
EMAIL_SEND_HOURLY: 1, | ||
EMAIL_SEND_3HOURLY: 2, | ||
EMAIL_SEND_DAILY: 3, | ||
EMAIL_SEND_WEEKLY: 4, | ||
EMAIL_SEND_OFF: 0, | ||
EMAIL_SEND_HOURLY: 1, | ||
EMAIL_SEND_3HOURLY: 2, | ||
EMAIL_SEND_DAILY: 3, | ||
EMAIL_SEND_WEEKLY: 4, | ||
} | ||
|
||
export default { | ||
name: 'AdminSettings', | ||
components: { | ||
CheckboxRadioSwitch, | ||
SettingsSection, | ||
}, | ||
name: 'AdminSettings', | ||
components: { | ||
CheckboxRadioSwitch, | ||
SettingsSection, | ||
}, | ||
|
||
data() { | ||
return { | ||
batchtime_options: [ | ||
{ text: t('notifications', 'Never'), value: EmailFrequency.EMAIL_SEND_OFF }, | ||
{ text: t('notifications', '1 hour'), value: EmailFrequency.EMAIL_SEND_HOURLY }, | ||
{ text: t('notifications', '3 hours'), value: EmailFrequency.EMAIL_SEND_3HOURLY }, | ||
{ text: t('notifications', '1 day'), value: EmailFrequency.EMAIL_SEND_DAILY }, | ||
{ text: t('notifications', '1 week'), value: EmailFrequency.EMAIL_SEND_WEEKLY }, | ||
], | ||
config: loadState('notifications', 'config'), | ||
} | ||
}, | ||
data() { | ||
return { | ||
batchtime_options: [ | ||
{text: t('notifications', 'Never'), value: EmailFrequency.EMAIL_SEND_OFF}, | ||
{text: t('notifications', '1 hour'), value: EmailFrequency.EMAIL_SEND_HOURLY}, | ||
{text: t('notifications', '3 hours'), value: EmailFrequency.EMAIL_SEND_3HOURLY}, | ||
{text: t('notifications', '1 day'), value: EmailFrequency.EMAIL_SEND_DAILY}, | ||
{text: t('notifications', '1 week'), value: EmailFrequency.EMAIL_SEND_WEEKLY}, | ||
], | ||
config: loadState('notifications', 'config'), | ||
} | ||
}, | ||
|
||
methods: { | ||
async updateSettings() { | ||
try { | ||
const form = new FormData() | ||
form.append('batchSetting', this.config.setting_batchtime) | ||
form.append('soundNotification', this.config.sound_notification ? 'yes' : 'no') | ||
form.append('soundTalk', this.config.sound_talk ? 'yes' : 'no') | ||
await axios.post(generateOcsUrl('apps/notifications/api/v2/settings/admin'), form) | ||
showSuccess(t('notifications', 'Your settings have been updated.')) | ||
} catch (error) { | ||
showError(t('notifications', 'An error occurred while updating your settings.')) | ||
console.error(error) | ||
} | ||
}, | ||
}, | ||
methods: { | ||
async updateSettings() { | ||
try { | ||
const form = new FormData() | ||
form.append('batchSetting', this.config.setting_batchtime) | ||
form.append('soundNotification', this.config.sound_notification ? 'yes' : 'no') | ||
form.append('soundTalk', this.config.sound_talk ? 'yes' : 'no') | ||
await axios.post(generateOcsUrl('apps/notifications/api/v2/settings/admin'), form) | ||
showSuccess(t('notifications', 'Your settings have been updated.')) | ||
} catch (error) { | ||
showError(t('notifications', 'An error occurred while updating your settings.')) | ||
console.error(error) | ||
} | ||
}, | ||
}, | ||
} | ||
|
||
</script> | ||
</script> |