Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/quota_warning.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2017-08-17 17:35:24 +0300
committerJoas Schilling <coding@schilljs.com>2017-08-17 17:35:24 +0300
commitfa5de5b1f7d7b1a69a812d1699b66d44004bfa50 (patch)
treece8ab53081b81724858d7cbc6157bbf6aefb4cc5 /js
parent5540119fab8a28d0793496b5baaf1a745e4fc6d4 (diff)
Add a UI to change the config settings
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'js')
-rw-r--r--js/settings.js83
1 files changed, 83 insertions, 0 deletions
diff --git a/js/settings.js b/js/settings.js
new file mode 100644
index 0000000..5a2c763
--- /dev/null
+++ b/js/settings.js
@@ -0,0 +1,83 @@
+/**
+ * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.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/>.
+ *
+ */
+
+
+(function(OC, OCA, _) {
+ OCA.QuotaWarning = {
+ timeouts: {
+ 'info_percentage': undefined,
+ 'warning_percentage': undefined,
+ 'alert_percentage': undefined
+ },
+
+ init: function() {
+ $('.percentage-option > input').on('change keyup', function() {
+ var $el = $(this);
+ OCA.QuotaWarning._saveInput($el);
+ });
+
+ $('.email-option > input').on('change', function() {
+ var $el = $(this);
+ OCA.QuotaWarning._saveCheckbox($el);
+ });
+ },
+
+ _saveInput: function($el) {
+ var field = $el.attr('id').substring(14);
+ if (!_.isUndefined(this.timeouts[field])) {
+ clearTimeout(this.timeouts[field]);
+ }
+
+ this.timeouts[field] = setTimeout(_.bind(this._saveInputHandler, this, field, $el.val()), 750);
+ },
+
+ _saveInputHandler: function(field, value) {
+ OC.msg.startAction('#quota_warning_feedback', t('quota_warning', 'Saving…'));
+ OCP.AppConfig.setValue(
+ 'quota_warning',
+ field,
+ value,
+ {
+ success: function() {
+ OC.msg.finishedSuccess('#quota_warning_feedback', t('quota_warning', 'Saved!'));
+ }
+ }
+ );
+ },
+
+ _saveCheckbox: function($el) {
+ OC.msg.startAction('#quota_warning_feedback', t('quota_warning', 'Saving…'));
+ OCP.AppConfig.setValue(
+ 'quota_warning',
+ $el.attr('id').substring(14),
+ $el.attr('checked') ? 'yes' : 'no',
+ {
+ success: function() {
+ OC.msg.finishedSuccess('#quota_warning_feedback', t('quota_warning', 'Saved!'));
+ }
+ }
+ );
+ }
+ };
+})(OC, OCA, _);
+
+$(document).ready(function(){
+ OCA.QuotaWarning.init();
+});