summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/htdocs/luci-static/resources
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2020-04-14 18:27:45 +0200
committerJo-Philipp Wich <jo@mein.io>2020-04-14 18:29:13 +0200
commite6f77d5d72c0e13ed3eb370419abab52c4920a32 (patch)
tree70ae7ce0596fc1ea83d3a39cfb259360f8072a98 /modules/luci-base/htdocs/luci-static/resources
parent6c82e2a678241a19b5f9414b1987b825b7bca90a (diff)
build: luci.mk: gracefully handle missing or unversioned po subdirectories
Fixes: #3911 Fixes: 9d8e99f9b build: gracefully handle non-Git source trees Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base/htdocs/luci-static/resources')
-rw-r--r--modules/luci-base/htdocs/luci-static/resources/luci.js48
1 files changed, 44 insertions, 4 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/luci.js b/modules/luci-base/htdocs/luci-static/resources/luci.js
index 11ca2fdfca..63c9d9ee6c 100644
--- a/modules/luci-base/htdocs/luci-static/resources/luci.js
+++ b/modules/luci-base/htdocs/luci-static/resources/luci.js
@@ -2051,7 +2051,15 @@
* methods are overwritten with `null`.
*/
addFooter: function() {
- var footer = E([]);
+ var footer = E([]),
+ vp = document.getElementById('view'),
+ readonly = true;
+
+ vp.querySelectorAll('.cbi-map').forEach(function(map) {
+ var m = DOM.findClassInstance(map);
+ if (m && !m.readonly)
+ readonly = false;
+ });
var saveApplyBtn = this.handleSaveApply ? new L.ui.ComboButton('0', {
0: [ _('Save & Apply') ],
@@ -2061,7 +2069,8 @@
0: 'btn cbi-button cbi-button-apply important',
1: 'btn cbi-button cbi-button-negative important'
},
- click: L.ui.createHandlerFn(this, 'handleSaveApply')
+ click: L.ui.createHandlerFn(this, 'handleSaveApply'),
+ disabled: readonly || null
}).render() : E([]);
if (this.handleSaveApply || this.handleSave || this.handleReset) {
@@ -2069,11 +2078,13 @@
saveApplyBtn, ' ',
this.handleSave ? E('button', {
'class': 'cbi-button cbi-button-save',
- 'click': L.ui.createHandlerFn(this, 'handleSave')
+ 'click': L.ui.createHandlerFn(this, 'handleSave'),
+ 'disabled': readonly || null
}, [ _('Save') ]) : '', ' ',
this.handleReset ? E('button', {
'class': 'cbi-button cbi-button-reset',
- 'click': L.ui.createHandlerFn(this, 'handleReset')
+ 'click': L.ui.createHandlerFn(this, 'handleReset'),
+ 'disabled': readonly || null
}, [ _('Reset') ]) : ''
]));
}
@@ -3063,6 +3074,35 @@
},
/**
+ * Check whether the current session has been granted the given ACL
+ * group permissions.
+ *
+ * @param {string} aclGroupName
+ * The ACL group name to check.
+ *
+ * @return {boolean|null}
+ * Returns `null` if the session does not have the specified grant,
+ * returns `false` if the permissions are granted readonly or
+ * `true` if they're granted read/write.
+ */
+ hasAcl: function(aclGroupName) {
+ if (!this.isObject(this.env.accessgroups) ||
+ !this.env.accessgroups.hasOwnProperty(aclGroupName) ||
+ !Array.isArray(this.env.accessgroups[aclGroupName]))
+ return null;
+
+ for (var i = 0; i < this.env.accessgroups[aclGroupName].length; i++)
+ if (this.env.accessgroups[aclGroupName][i] == 'write')
+ return true;
+
+ for (var i = 0; i < this.env.accessgroups[aclGroupName].length; i++)
+ if (this.env.accessgroups[aclGroupName][i] == 'read')
+ return false;
+
+ return null;
+ },
+
+ /**
* Deprecated wrapper around {@link LuCI.poll.remove Poll.remove()}.
*
* @deprecated