luci-base: widgets.js: add user and group select
Signed-off-by: Richard Yu <yurichard3839@gmail.com>
This commit is contained in:
parent
d18ef580f2
commit
02a0291d14
2 changed files with 53 additions and 0 deletions
|
@ -3,6 +3,19 @@
|
||||||
'require form';
|
'require form';
|
||||||
'require network';
|
'require network';
|
||||||
'require firewall';
|
'require firewall';
|
||||||
|
'require fs';
|
||||||
|
|
||||||
|
function getUsers() {
|
||||||
|
return fs.lines('/etc/passwd').then(function(lines) {
|
||||||
|
return lines.map(function(line) { return line.split(/:/)[0] });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function getGroups() {
|
||||||
|
return fs.lines('/etc/group').then(function(lines) {
|
||||||
|
return lines.map(function(line) { return line.split(/:/)[0] });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var CBIZoneSelect = form.ListValue.extend({
|
var CBIZoneSelect = form.ListValue.extend({
|
||||||
__name__: 'CBI.ZoneSelect',
|
__name__: 'CBI.ZoneSelect',
|
||||||
|
@ -559,10 +572,48 @@ var CBIDeviceSelect = form.ListValue.extend({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var CBIUserSelect = form.ListValue.extend({
|
||||||
|
__name__: 'CBI.UserSelect',
|
||||||
|
|
||||||
|
load: function(section_id) {
|
||||||
|
return getUsers().then(L.bind(function(users) {
|
||||||
|
for (var i = 0; i < users.length; i++) {
|
||||||
|
this.value(users[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.super('load', section_id);
|
||||||
|
}, this));
|
||||||
|
},
|
||||||
|
|
||||||
|
filter: function(section_id, value) {
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
var CBIGroupSelect = form.ListValue.extend({
|
||||||
|
__name__: 'CBI.GroupSelect',
|
||||||
|
|
||||||
|
load: function(section_id) {
|
||||||
|
return getGroups().then(L.bind(function(groups) {
|
||||||
|
for (var i = 0; i < groups.length; i++) {
|
||||||
|
this.value(groups[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.super('load', section_id);
|
||||||
|
}, this));
|
||||||
|
},
|
||||||
|
|
||||||
|
filter: function(section_id, value) {
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
return L.Class.extend({
|
return L.Class.extend({
|
||||||
ZoneSelect: CBIZoneSelect,
|
ZoneSelect: CBIZoneSelect,
|
||||||
ZoneForwards: CBIZoneForwards,
|
ZoneForwards: CBIZoneForwards,
|
||||||
NetworkSelect: CBINetworkSelect,
|
NetworkSelect: CBINetworkSelect,
|
||||||
DeviceSelect: CBIDeviceSelect,
|
DeviceSelect: CBIDeviceSelect,
|
||||||
|
UserSelect: CBIUserSelect,
|
||||||
|
GroupSelect: CBIGroupSelect,
|
||||||
});
|
});
|
||||||
|
|
|
@ -30,6 +30,8 @@
|
||||||
"/etc/filesystems": [ "read" ],
|
"/etc/filesystems": [ "read" ],
|
||||||
"/etc/rc.local": [ "read" ],
|
"/etc/rc.local": [ "read" ],
|
||||||
"/etc/sysupgrade.conf": [ "read" ],
|
"/etc/sysupgrade.conf": [ "read" ],
|
||||||
|
"/etc/passwd": [ "read" ],
|
||||||
|
"/etc/group": [ "read" ],
|
||||||
"/proc/filesystems": [ "read" ],
|
"/proc/filesystems": [ "read" ],
|
||||||
"/proc/mtd": [ "read" ],
|
"/proc/mtd": [ "read" ],
|
||||||
"/proc/partitions": [ "read" ],
|
"/proc/partitions": [ "read" ],
|
||||||
|
|
Loading…
Reference in a new issue