From 80363a24af57761c17eb958d354d7ff07d353406 Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Thu, 24 Mar 2011 16:55:21 -0500 Subject: Prototype --- install/ui/controllers/user.js | 96 ++++++++++++++++++++++++++++++ install/ui/models/user.js | 43 +++++++++++++ install/ui/test.html | 60 +++++++++++++++++++ install/ui/test/functional/functional.html | 25 ++++++++ install/ui/test/functional/user.js | 31 ++++++++++ 5 files changed, 255 insertions(+) create mode 100755 install/ui/controllers/user.js create mode 100755 install/ui/models/user.js create mode 100755 install/ui/test.html create mode 100755 install/ui/test/functional/functional.html create mode 100755 install/ui/test/functional/user.js 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'); + + dialog.append('Login name: '); + + var uid = $('', { + name: 'uid' + }).appendTo(dialog); + + dialog.append('
'); + dialog.append('First name: '); + + var givenname = $('', { + name: 'givenname' + }).appendTo(dialog); + + dialog.append('
'); + dialog.append('Last name: '); + + var sn = $('', { + 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(); + } +}); diff --git a/install/ui/models/user.js b/install/ui/models/user.js new file mode 100755 index 00000000..7d934fb1 --- /dev/null +++ b/install/ui/models/user.js @@ -0,0 +1,43 @@ +$.Model.extend('IPA.Models.User', +{ + find: function(args, options, success, error) { + + var command = IPA.command({ + method: 'user_find', + args: args, + options: options, + on_success: function(data, text_status, xhr) { + var users = data.result.result; + success.call(this, users, text_status, xhr); + }, + on_error: error + }); + + command.execute(); + }, + add: function(args, options, success, error) { + + var command = IPA.command({ + method: 'user_add', + args: args, + options: options, + on_success: success, + on_error: error + }); + + command.execute(); + }, + del: function(args, options, success, error) { + + var command = IPA.command({ + method: 'user_del', + args: args, + options: options, + on_success: success, + on_error: error + }); + + command.execute(); + } +}, +{}); diff --git a/install/ui/test.html b/install/ui/test.html new file mode 100755 index 00000000..bcab5dd9 --- /dev/null +++ b/install/ui/test.html @@ -0,0 +1,60 @@ + + + IPA + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
User LoginFull Name
+ + + + +
+ + + + + diff --git a/install/ui/test/functional/functional.html b/install/ui/test/functional/functional.html new file mode 100755 index 00000000..89760f58 --- /dev/null +++ b/install/ui/test/functional/functional.html @@ -0,0 +1,25 @@ + + + + IPA Functional Test Suite + + + + + + + + + + +

IPA Functional Test Suite

+

+
+

+
    + + diff --git a/install/ui/test/functional/user.js b/install/ui/test/functional/user.js new file mode 100755 index 00000000..d8039ecb --- /dev/null +++ b/install/ui/test/functional/user.js @@ -0,0 +1,31 @@ +module("test", { + setup: function(){ + S.open("//test.html"); + } +}); + +test("Add User", function(){ + S('span[name="search"] input[name="add"]').click(); + + S('div.ui-dialog input[name="uid"]').type('testuser'); + S('div.ui-dialog input[name="givenname"]').type('Test'); + S('div.ui-dialog input[name="sn"]').type('User'); + + S('div.ui-dialog button').click(); + + S('span[name="search"] input[name="select"][value="testuser"]').exists(); + + ok(true, 'Added Test User'); +}); + +test("Delete User", function(){ + + var checkbox = S('span[name="search"] input[name="select"][value="testuser"]'); + checkbox.click(); + + S('span[name="search"] input[name="delete"]').click(); + + checkbox.missing(); + + ok(true, 'Deleted Test User'); +}); -- cgit