diff options
Diffstat (limited to 'install/ui/controllers/user.js')
-rwxr-xr-x | install/ui/controllers/user.js | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/install/ui/controllers/user.js b/install/ui/controllers/user.js new file mode 100755 index 00000000..0a9ddcc3 --- /dev/null +++ b/install/ui/controllers/user.js @@ -0,0 +1,96 @@ +$.Controller.extend('IPA.Controllers.UserSearchTable', +{ +}, +{ + init: function(el) { + this.tbody = $('tbody', this.element); + this.row = $('tr', this.tbody).first(); + + IPA.Models.User.find([], { all: true }, this.callback('list')); + }, + list: function(users) { + this.tbody.empty(); + + for (var i=0; i<users.length; i++) { + var user = users[i]; + + var tr = this.row.clone(); + tr.appendTo(this.tbody); + + var input = $('input[name="select"]', tr); + input.val(user.uid[0]); + + var span = $('span[name="uid"]', tr); + span.text(user.uid[0]); + + span = $('span[name="cn"]', tr); + span.text(user.cn[0]); + } + }, + 'input[name="add"] click': function(el, ev) { + + var dialog = $('<div/>'); + + dialog.append('Login name: '); + + var uid = $('<input/>', { + name: 'uid' + }).appendTo(dialog); + + dialog.append('<br/>'); + dialog.append('First name: '); + + var givenname = $('<input/>', { + name: 'givenname' + }).appendTo(dialog); + + dialog.append('<br/>'); + dialog.append('Last name: '); + + var sn = $('<input/>', { + name: 'sn' + }).appendTo(dialog); + + var list = this.callback('list'); + dialog.dialog({ + title: 'Add', + modal: true, + buttons: { + 'Add': function() { + IPA.Models.User.add( + [uid.val()], + { + givenname: givenname.val(), + sn: sn.val() + }, + function(data, text_status, xhr) { + IPA.Models.User.find([], { all: true }, list); + + dialog.dialog('destroy'); + dialog.remove(); + } + ); + }, + 'Cancel': function() { + dialog.dialog('destroy'); + dialog.remove(); + } + } + }); + + ev.preventDefault(); + }, + 'input[name="delete"] click': function(el, ev) { + var args = []; + $('input[name="select"]:checked', this.tbody).each(function() { + args.push($(this).val()); + }); + + var list = this.callback('list'); + IPA.Models.User.del(args, {},function(data, text_status, xhr) { + IPA.Models.User.find([], { all: true }, list); + }); + + ev.preventDefault(); + } +}); |