summaryrefslogtreecommitdiffstats
path: root/install/static/user.js
diff options
context:
space:
mode:
Diffstat (limited to 'install/static/user.js')
-rw-r--r--install/static/user.js243
1 files changed, 238 insertions, 5 deletions
diff --git a/install/static/user.js b/install/static/user.js
index 53a84359..9a58e31c 100644
--- a/install/static/user.js
+++ b/install/static/user.js
@@ -1,3 +1,49 @@
+
+var qs = ipa_parse_qs();
+
+var user_details_lists = [
+ ['identity', 'Identity Details', [
+ ['title', 'Title'],
+ ['givenname', 'First Name'],
+ ['sn', 'Last Name'],
+ ['cn', 'Full Name'],
+ ['displayname', 'Dispaly Name'],
+ ['initials', 'Initials']
+ ]
+ ],
+ ['account', 'Account Details', [
+ ['call_a_status', 'Account Status'],
+ ['uid', 'Login'],
+ ['call_a_password', 'Password'],
+ ['uidnumber', 'UID'],
+ ['gidnumber', 'GID'],
+ ['homedirectory', 'homedirectory']
+ ]
+ ],
+ ['contact', 'Contact Details', [
+ ['mail', 'E-mail Address'],
+ ['call_a_numbers', 'Numbers']
+ ]
+ ],
+ ['address', 'Mailing Address', [
+ ['street', 'Address'],
+ ['location', 'City'],
+ ['call_a_st', 'State'],
+ ['postalcode', 'ZIP']
+ ]
+ ],
+ ['employee', 'Employee Information', [
+ ['ou', 'Org. Unit'],
+ ['call_a_manager', 'Manager']
+ ]
+ ],
+ ['misc', 'Misc. Information', [
+ ['carlicense', 'Car License']
+ ]
+ ]
+];
+
+
function setupUser(facet){
if (facet == "details"){
setupUserDetails()
@@ -47,8 +93,28 @@ function setupAddUser(){
function setupUserDetails(){
showContent();
- $('#content').load("user-details.inc");
sampleData = "sampledata/usershow.json";
+ $('#content').load("user-details.inc", [], renderUserDetails);
+}
+
+function renderUserDetails()
+{
+ ipa_details_init('user');
+ ipa_details_create(user_details_lists, $('#content'));
+
+ if (qs['principal']) {
+ ipa_cmd(
+ 'find', [], {'krbprincipalname': qs['principal']},
+ on_win_find, null, 'user'
+ );
+ return;
+ }
+
+ if (!qs['pkey'])
+ return;
+
+ ipa_details_load(qs['pkey'], on_win);
+ $('h1').text('Managing user: ' + qs['pkey']);
}
function renderSimpleColumn(current,cell){
@@ -66,7 +132,7 @@ function renderUserLinks(current, cell){
}).appendTo(cell);
$("<a/>",{
- href: "#?tab=user&facet=group&pkey="+current.uid,
+ href: "#tab=user&facet=details&pkey="+current.uid,
click:setupUserGroupMembership,
html: "[G]"
}).appendTo(cell);
@@ -243,14 +309,16 @@ function populateUserEnrollments(userData){
function setupUserGroupMembership(){
- showSearch();
- $("#filter").css("display","none");
+ $("#searchButtons").html("");
+
$("<input/>",{
type: 'button',
value: 'enroll',
click: setupUserGroupEnrollmentSearch
}).appendTo("#searchButtons");
+
+ showSearch();
var columnHeaders = document.createElement("tr");
for (var i =0 ; i != groupMembershipColumns.length ;i++){
var th = document.createElement("th");
@@ -263,4 +331,169 @@ function setupUserGroupMembership(){
ipa_cmd( 'show', [qs['pkey']], {}, populateUserEnrollments, populateUserGroupFailure, 'user' );
-} \ No newline at end of file
+}
+
+/* user-details.inc javascript */
+
+function on_win(data, textStatus, xhr)
+{
+ if (data['error'])
+ alert(data['error']['message']);
+}
+
+function on_win_find(data, textStatus, xhr)
+{
+ if (data['error']) {
+ alert(data['error']['message']);
+ return;
+ }
+
+ var result = data.result.result;
+ if (result.length == 1) {
+ var entry_attrs = result[0];
+ qs['pkey'] = entry_attrs['uid'][0];
+
+ ipa_details_load(qs['pkey'], on_win);
+ $('h1').text('Managing user: ' + qs['pkey']);
+ }
+}
+
+function reset_on_click()
+{
+ ipa_details_reset();
+ return (false);
+}
+
+function update_on_click()
+{
+ ipa_details_update(qs['pkey'], on_win);
+ return (false);
+}
+
+/* Account status Toggle button */
+
+function toggle_on_click(obj)
+{
+ var jobj = $(obj);
+ var val = jobj.attr('title');
+ if (val == 'Active') {
+ ipa_cmd(
+ 'lock', [qs['pkey']], {}, on_lock_win, on_fail,
+ ipa_objs['user']['name']
+ );
+ } else {
+ ipa_cmd(
+ 'unlock', [qs['pkey']], {}, on_lock_win, on_fail,
+ ipa_objs['user']['name']
+ );
+ }
+ return (false);
+}
+
+function on_lock_win(data, textStatus, xhr)
+{
+ if (data['error']) {
+ alert(data['error']['message']);
+ return;
+ }
+
+ var jobj = $('a[title=Active]');
+ if (jobj.length) {
+ if (ipa_details_cache) {
+ var memberof = ipa_details_cache['memberof'];
+ if (memberof) {
+ memberof.push(
+ 'cn=inactivated,cn=account inactivation'
+ );
+ } else {
+ memberof = ['cn=inactivated,cn=account inactivation'];
+ }
+ ipa_details_cache['memberof'] = memberof;
+ a_status(jobj.parent().prev(), ipa_details_cache);
+ jobj.parent().remove()
+ }
+ return;
+ }
+
+ var jobj = $('a[title=Inactive]');
+ if (jobj.length) {
+ if (ipa_details_cache) {
+ var memberof = ipa_details_cache['memberof'];
+ if (memberof) {
+ for (var i = 0; i < memberof.length; ++i) {
+ if (memberof[i].indexOf('cn=inactivated,cn=account inactivation') != -1) {
+ memberof.splice(i, 1);
+ break;
+ }
+ }
+ } else {
+ memberof = [];
+ }
+ ipa_details_cache['memberof'] = memberof;
+ a_status(jobj.parent().prev(), ipa_details_cache);
+ jobj.parent().remove();
+ }
+ return;
+ }
+}
+
+/* ATTRIBUTE CALLBACKS */
+
+var toggle_temp = 'S <a href="jslink" onclick="return (toggle_on_click(this))" title="S">Toggle</a>';
+function a_status(jobj, result, mode)
+{
+ if (mode != IPA_DETAILS_POPULATE)
+ return;
+
+ var memberof = result['memberof'];
+ if (memberof) {
+ for (var i = 0; i < memberof.length; ++i) {
+ if (memberof[i].indexOf('cn=inactivated,cn=account inactivation') != -1) {
+ var t = toggle_temp.replace(/S/g, 'Inactive');
+ ipa_insert_first_dd(jobj, t);
+ return;
+ }
+ }
+ }
+ ipa_insert_first_dd(jobj, toggle_temp.replace(/S/g, 'Inactive'));
+}
+
+var pwd_temp = '<a href="jslink" onclick="return (resetpwd_on_click(this))" title="A">Reset Password</a>';
+function a_password(jobj, result, mode)
+{
+ if (mode == IPA_DETAILS_POPULATE)
+ ipa_insert_first_dd(jobj, pwd_temp.replace('A', 'userpassword'));
+}
+
+var select_temp = '<select title="st"></select>';
+var option_temp = '<option value="V">V</option>';
+var states = [
+ 'AL', 'AK', 'AS', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE', 'DC', 'FM',
+ 'FL', 'GA', 'GU', 'HI', 'ID', 'IL', 'IN', 'IA', 'KS', 'KY', 'LA',
+ 'ME', 'MH', 'MD', 'MA', 'MI', 'MN', 'MS', 'MO', 'MT', 'NE', 'NV',
+ 'NH', 'NJ', 'NM', 'NY', 'NC', 'ND', 'MP', 'OH', 'OK', 'OR', 'PW',
+ 'PA', 'PR', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT', 'VI', 'VA',
+ 'WA', 'WV', 'WI', 'WY', '',
+];
+function a_st(jobj, result, mode)
+{
+ if (mode != IPA_DETAILS_POPULATE)
+ return;
+
+ var next = jobj.next();
+ next.css('clear', 'none');
+ next.css('width', '70px');
+
+ ipa_insert_first_dd(jobj, select_temp);
+
+ var sel = jobj.next().children().first();
+ for (var i = 0; i < states.length; ++i)
+ sel.append(option_temp.replace(/V/g, states[i]));
+
+ var st = result['st'];
+ if (st)
+ sel.val(st);
+ else
+ sel.val('');
+}
+