add admin settings
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* @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/>.
|
||||
*/
|
||||
|
||||
const elements = [
|
||||
'side-menu-background-color',
|
||||
'side-menu-current-app-background-color',
|
||||
'side-menu-text-color',
|
||||
'side-menu-save',
|
||||
'side-menu-opener',
|
||||
'side-menu-cache',
|
||||
];
|
||||
|
||||
const selector = '#side-menu-message';
|
||||
|
||||
const saveSettings = (key) => {
|
||||
const element = elements[key]
|
||||
const name = $('#' + element).attr('name')
|
||||
let value = $('#' + element).val()
|
||||
const size = elements.length
|
||||
|
||||
if (element === 'side-menu-cache') {
|
||||
value++
|
||||
}
|
||||
|
||||
OCP.AppConfig.setValue('side_menu', name, value, {
|
||||
success: () => {
|
||||
OC.msg.finishedSuccess(
|
||||
selector,
|
||||
t('settings', (key + 1) + '/' + size)
|
||||
)
|
||||
|
||||
if (key < size -1) {
|
||||
saveSettings(++key)
|
||||
} else {
|
||||
OC.msg.finishedSuccess(selector, t('settings', 'Saved'))
|
||||
}
|
||||
},
|
||||
error: () => {
|
||||
OC.msg.finishedError(selector, t('side_menu', 'Error while saving "' + element + '"'))
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(() => {
|
||||
$('#side-menu-save').on('click', (event) => {
|
||||
event.preventDefault()
|
||||
OC.msg.startSaving(selector)
|
||||
|
||||
saveSettings(0)
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user