summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2011-03-24 16:55:21 -0500
committerEndi S. Dewata <edewata@redhat.com>2011-03-25 18:32:29 -0400
commit80363a24af57761c17eb958d354d7ff07d353406 (patch)
tree5949b79f7db5fd4faf5ad8d64330d1a20947f179
parent9a9391b572bc09c17bad0735946667df568402d8 (diff)
downloadfreeipa-80363a24af57761c17eb958d354d7ff07d353406.zip
freeipa-80363a24af57761c17eb958d354d7ff07d353406.tar.gz
freeipa-80363a24af57761c17eb958d354d7ff07d353406.tar.xz
Prototypemaster
-rwxr-xr-xinstall/ui/controllers/user.js96
-rwxr-xr-xinstall/ui/models/user.js43
-rwxr-xr-xinstall/ui/test.html60
-rwxr-xr-xinstall/ui/test/functional/functional.html25
-rwxr-xr-xinstall/ui/test/functional/user.js31
5 files changed, 255 insertions, 0 deletions
diff --git a/install/ui/controllers/user.js b/install/ui/controllers/user.js
new file mode 100755
index 0000000..0a9ddcc
--- /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();
+ }
+});
diff --git a/install/ui/models/user.js b/install/ui/models/user.js
new file mode 100755
index 0000000..7d934fb
--- /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 0000000..bcab5dd
--- /dev/null
+++ b/install/ui/test.html
@@ -0,0 +1,60 @@
+<html>
+<head>
+ <title>IPA</title>
+
+ <script type="text/javascript" src="json2.js"></script>
+
+ <script type='text/javascript' src='steal/steal.js'></script>
+
+ <script type="text/javascript">
+steal.plugins(
+ 'jquery/controller',
+ 'jquery/controller/subscribe',
+ 'jquery/model').start();
+ </script>
+
+ <script type="text/javascript" src="jquery.cookie.js"></script>
+ <script type="text/javascript" src="jquery-ui.js"></script>
+ <script type="text/javascript" src="jquery.ba-bbq.js"></script>
+ <script type='text/javascript' src='ipa.js'></script>
+
+ <script type="text/javascript" src="develop.js"></script>
+
+ <link rel="stylesheet" type="text/css" href="jquery-ui.css" />
+ <script type="text/javascript" src="models/user.js"></script>
+ <script type="text/javascript" src="controllers/user.js"></script>
+
+</head>
+<body>
+
+<span name="search">
+
+<table>
+<thead>
+ <th><input type="checkbox"></th>
+ <th>User Login</th>
+ <th>Full Name</th>
+</thead>
+<tbody>
+<tr>
+ <td><input type="checkbox" name="select"></td>
+ <td><span name="uid"></span></td>
+ <td><span name="cn"></span></td>
+</tr>
+</tbody>
+</table>
+
+<input name="add" type="button" value="Add">
+<input name="delete" type="button" value="Delete">
+
+</span>
+
+<script type="text/javascript">
+$(function() {
+ IPA.init();
+ $('span[name=search]').ipa_user_search_table();
+});
+</script>
+
+</body>
+</html>
diff --git a/install/ui/test/functional/functional.html b/install/ui/test/functional/functional.html
new file mode 100755
index 0000000..89760f5
--- /dev/null
+++ b/install/ui/test/functional/functional.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>IPA Functional Test Suite</title>
+
+ <script type='text/javascript' src='../../steal/steal.js'></script>
+
+ <script type="text/javascript">
+steal.plugins(
+ 'jquery',
+ 'funcunit').start();
+ </script>
+
+ <script type='text/javascript' src='user.js'></script>
+
+ <link rel="stylesheet" href="../qunit.css" type="text/css" media="screen">
+</head>
+<body>
+ <h1 id="qunit-header">IPA Functional Test Suite</h1>
+ <h2 id="qunit-banner"></h2>
+ <div id="qunit-testrunner-toolbar"></div>
+ <h2 id="qunit-userAgent"></h2>
+ <ol id="qunit-tests"></ol>
+</body>
+</html>
diff --git a/install/ui/test/functional/user.js b/install/ui/test/functional/user.js
new file mode 100755
index 0000000..d8039ec
--- /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');
+});