2011-01-14 11:16:25 -06:00
|
|
|
/*jsl:import ipa.js */
|
|
|
|
/*jsl:import navigation.js */
|
|
|
|
|
2010-09-16 09:28:07 -05:00
|
|
|
/* Authors:
|
|
|
|
* Pavel Zuna <pzuna@redhat.com>
|
2011-04-20 19:11:10 -05:00
|
|
|
* Endi S. Dewata <edewata@redhat.com>
|
2010-09-16 09:28:07 -05:00
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Red Hat
|
|
|
|
* see file 'COPYING' for use and warranty information
|
|
|
|
*
|
2010-12-09 06:59:11 -06:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
2010-09-16 09:28:07 -05:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2010-12-09 06:59:11 -06:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2010-09-16 09:28:07 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* REQUIRES: everything, this file puts it all togheter */
|
|
|
|
|
|
|
|
/* tabs definition for IPA webUI */
|
2010-09-28 18:20:02 -05:00
|
|
|
|
2011-04-20 19:11:10 -05:00
|
|
|
IPA.admin_navigation = function(spec) {
|
2010-09-28 18:20:02 -05:00
|
|
|
|
2011-04-20 19:11:10 -05:00
|
|
|
spec = spec || {};
|
|
|
|
|
2011-06-13 23:18:57 -05:00
|
|
|
spec.name = 'admin';
|
|
|
|
|
2011-04-20 19:11:10 -05:00
|
|
|
spec.tabs = [
|
|
|
|
{name: 'identity', label: IPA.messages.tabs.identity, children: [
|
|
|
|
{entity: 'user'},
|
|
|
|
{entity: 'group'},
|
|
|
|
{entity: 'host'},
|
|
|
|
{entity: 'hostgroup'},
|
|
|
|
{entity: 'netgroup'},
|
2011-07-22 14:39:16 -05:00
|
|
|
{entity: 'service'},
|
2012-02-15 08:00:16 -06:00
|
|
|
{name:'dns', label: IPA.messages.tabs.dns, children:[
|
|
|
|
{entity: 'dnszone'},
|
|
|
|
{entity: 'dnsconfig'},
|
2011-07-08 11:06:30 -05:00
|
|
|
{entity: 'dnsrecord', hidden:true}
|
|
|
|
]
|
2011-07-22 14:39:16 -05:00
|
|
|
}
|
|
|
|
]},
|
|
|
|
{name: 'policy', label: IPA.messages.tabs.policy, children: [
|
2011-04-20 19:11:10 -05:00
|
|
|
{name: 'hbac', label: IPA.messages.tabs.hbac, children: [
|
|
|
|
{entity: 'hbacrule'},
|
|
|
|
{entity: 'hbacsvc'},
|
2011-11-16 21:07:20 -06:00
|
|
|
{entity: 'hbacsvcgroup'},
|
|
|
|
{entity: 'hbactest'}
|
2011-01-25 18:39:08 -06:00
|
|
|
]},
|
2011-04-20 19:11:10 -05:00
|
|
|
{name: 'sudo', label: IPA.messages.tabs.sudo, children: [
|
|
|
|
{entity: 'sudorule'},
|
|
|
|
{entity: 'sudocmd'},
|
|
|
|
{entity: 'sudocmdgroup'}
|
2011-01-25 18:39:08 -06:00
|
|
|
]},
|
2011-06-28 12:39:10 -05:00
|
|
|
{name:'automount',
|
|
|
|
label: IPA.messages.tabs.automount,
|
|
|
|
children:[
|
2012-02-15 08:00:16 -06:00
|
|
|
{entity: 'automountlocation', hidden:true, depth: -1},
|
|
|
|
{entity: 'automountmap', hidden: true, depth: -1},
|
|
|
|
{entity: 'automountkey', hidden: true, depth: -1}]},
|
2011-04-20 19:11:10 -05:00
|
|
|
{entity: 'pwpolicy'},
|
2012-01-13 08:34:55 -06:00
|
|
|
{entity: 'krbtpolicy'},
|
2012-01-25 06:06:15 -06:00
|
|
|
{entity: 'selinuxusermap'},
|
2012-02-03 04:37:09 -06:00
|
|
|
{name: 'automember', label: IPA.messages.tabs.automember,
|
2012-01-25 06:06:15 -06:00
|
|
|
children: [
|
|
|
|
{ name: 'amgroup', entity: 'automember',
|
2012-02-03 04:37:09 -06:00
|
|
|
facet: 'searchgroup', label: IPA.messages.objects.automember.usergrouprules},
|
2012-01-25 06:06:15 -06:00
|
|
|
{ name: 'amhostgroup', entity: 'automember',
|
2012-02-03 04:37:09 -06:00
|
|
|
facet: 'searchhostgroup', label: IPA.messages.objects.automember.hostgrouprules}
|
2012-01-25 06:06:15 -06:00
|
|
|
]}
|
2010-11-19 14:57:40 -06:00
|
|
|
]},
|
2011-04-20 19:11:10 -05:00
|
|
|
{name: 'ipaserver', label: IPA.messages.tabs.ipaserver, children: [
|
|
|
|
{name: 'rolebased', label: IPA.messages.tabs.role, children: [
|
|
|
|
{entity: 'role'},
|
|
|
|
{entity: 'privilege'},
|
|
|
|
{entity: 'permission'}
|
2011-04-11 13:49:36 -05:00
|
|
|
]},
|
2011-04-20 19:11:10 -05:00
|
|
|
{entity: 'selfservice'},
|
|
|
|
{entity: 'delegation'},
|
2012-08-23 07:17:34 -05:00
|
|
|
{entity: 'idrange'},
|
2012-07-04 08:15:10 -05:00
|
|
|
{entity: 'trust'},
|
|
|
|
{entity: 'config'}
|
2011-01-25 18:39:08 -06:00
|
|
|
]}];
|
2011-01-25 20:58:49 -06:00
|
|
|
|
2011-04-20 19:11:10 -05:00
|
|
|
var that = IPA.navigation(spec);
|
2010-09-16 09:28:07 -05:00
|
|
|
|
2011-04-20 19:11:10 -05:00
|
|
|
return that;
|
2011-01-25 18:39:08 -06:00
|
|
|
};
|
2010-09-21 15:22:45 -05:00
|
|
|
|
2011-04-20 19:11:10 -05:00
|
|
|
IPA.self_serv_navigation = function(spec) {
|
|
|
|
|
|
|
|
spec = spec || {};
|
|
|
|
|
2011-06-13 23:18:57 -05:00
|
|
|
spec.name = 'self-service';
|
|
|
|
|
2011-04-20 19:11:10 -05:00
|
|
|
spec.tabs = [
|
2011-05-06 14:32:51 -05:00
|
|
|
{name: 'identity', label: IPA.messages.tabs.identity, children: [
|
2011-06-13 23:18:57 -05:00
|
|
|
{entity: 'user'}
|
2011-04-20 19:11:10 -05:00
|
|
|
]}];
|
|
|
|
|
|
|
|
var that = IPA.navigation(spec);
|
|
|
|
|
|
|
|
that.update = function() {
|
2011-04-28 17:38:21 -05:00
|
|
|
var pkey = that.get_state('user-pkey');
|
|
|
|
var facet = that.get_state('user-facet');
|
2011-04-20 19:11:10 -05:00
|
|
|
|
|
|
|
if (pkey && facet) {
|
|
|
|
that.navigation_update();
|
2010-10-15 13:06:23 -05:00
|
|
|
|
2011-04-20 19:11:10 -05:00
|
|
|
} else {
|
|
|
|
var state = {
|
2011-07-06 16:39:49 -05:00
|
|
|
'navigation': 'identity',
|
|
|
|
'identity': 'user',
|
2011-04-20 19:11:10 -05:00
|
|
|
'user-pkey': pkey || IPA.whoami_pkey,
|
|
|
|
'user-facet': facet || 'details'
|
|
|
|
};
|
2011-04-28 17:38:21 -05:00
|
|
|
that.push_state(state);
|
2011-04-20 19:11:10 -05:00
|
|
|
}
|
|
|
|
};
|
2010-12-01 15:44:44 -06:00
|
|
|
|
2011-04-20 19:11:10 -05:00
|
|
|
return that;
|
|
|
|
};
|
2010-12-01 15:44:44 -06:00
|
|
|
|
2010-09-16 09:28:07 -05:00
|
|
|
/* main (document onready event handler) */
|
|
|
|
$(function() {
|
|
|
|
|
2011-06-01 11:14:53 -05:00
|
|
|
|
|
|
|
|
2011-01-26 19:58:06 -06:00
|
|
|
/* main loop (hashchange event handler) */
|
|
|
|
function window_hashchange(evt){
|
2011-04-20 19:11:10 -05:00
|
|
|
IPA.nav.update();
|
2011-01-26 19:58:06 -06:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:11:10 -05:00
|
|
|
function create_navigation() {
|
2010-12-01 15:44:44 -06:00
|
|
|
var whoami = IPA.whoami;
|
2011-04-20 19:11:10 -05:00
|
|
|
var factory;
|
2010-12-01 15:44:44 -06:00
|
|
|
|
2011-07-11 10:08:53 -05:00
|
|
|
|
2010-12-01 15:44:44 -06:00
|
|
|
if (whoami.hasOwnProperty('memberof_group') &&
|
2011-04-20 19:11:10 -05:00
|
|
|
whoami.memberof_group.indexOf('admins') !== -1) {
|
|
|
|
factory = IPA.admin_navigation;
|
2011-07-11 10:08:53 -05:00
|
|
|
} else if (whoami.hasOwnProperty('memberofindirect_group')&&
|
|
|
|
whoami.memberofindirect_group.indexOf('admins') !== -1) {
|
|
|
|
factory = IPA.admin_navigation;
|
2011-10-13 13:48:55 -05:00
|
|
|
} else if (whoami.hasOwnProperty('memberof_role') &&
|
|
|
|
whoami.memberof_role.length > 0) {
|
2011-04-20 19:11:10 -05:00
|
|
|
factory = IPA.admin_navigation;
|
2012-07-04 03:28:43 -05:00
|
|
|
} else if (whoami.hasOwnProperty('memberofindirect_role') &&
|
|
|
|
whoami.memberofindirect_role.length > 0) {
|
|
|
|
factory = IPA.admin_navigation;
|
2011-04-20 19:11:10 -05:00
|
|
|
} else {
|
|
|
|
factory = IPA.self_serv_navigation;
|
|
|
|
}
|
2010-12-01 15:44:44 -06:00
|
|
|
|
2011-04-20 19:11:10 -05:00
|
|
|
return factory({
|
2011-04-28 19:17:58 -05:00
|
|
|
container: $('#navigation'),
|
|
|
|
content: $('#content')
|
2011-04-20 19:11:10 -05:00
|
|
|
});
|
2010-12-01 15:44:44 -06:00
|
|
|
}
|
|
|
|
|
2010-11-17 21:15:09 -06:00
|
|
|
|
2011-11-09 18:48:04 -06:00
|
|
|
function init_on_success(data, text_status, xhr) {
|
2010-09-21 15:22:45 -05:00
|
|
|
$(window).bind('hashchange', window_hashchange);
|
2010-09-30 15:37:33 -05:00
|
|
|
|
2010-11-17 21:15:09 -06:00
|
|
|
var whoami = IPA.whoami;
|
2011-04-20 19:11:10 -05:00
|
|
|
IPA.whoami_pkey = whoami.uid[0];
|
2012-06-28 07:42:29 -05:00
|
|
|
$('#loggedinas .login').text(whoami.cn[0]);
|
2010-10-27 22:32:30 -05:00
|
|
|
$('#loggedinas a').fragment(
|
2011-04-20 19:11:10 -05:00
|
|
|
{'user-facet': 'details', 'user-pkey': IPA.whoami_pkey}, 2);
|
2010-09-30 15:37:33 -05:00
|
|
|
|
2012-02-24 08:31:55 -06:00
|
|
|
$('#logout').click(function() {
|
|
|
|
IPA.logout();
|
|
|
|
return false;
|
|
|
|
}).text(IPA.messages.login.logout);
|
|
|
|
|
2012-06-28 07:42:29 -05:00
|
|
|
$('.header-loggedinas').css('visibility','visible');
|
|
|
|
IPA.update_password_expiration();
|
|
|
|
|
2011-04-20 19:11:10 -05:00
|
|
|
IPA.nav = create_navigation();
|
|
|
|
IPA.nav.create();
|
|
|
|
IPA.nav.update();
|
2010-10-27 22:32:30 -05:00
|
|
|
|
|
|
|
$('#login_header').html(IPA.messages.login.header);
|
|
|
|
}
|
2010-09-16 09:28:07 -05:00
|
|
|
|
|
|
|
|
2010-09-29 00:52:56 -05:00
|
|
|
function init_on_error(xhr, text_status, error_thrown) {
|
2011-04-28 19:17:58 -05:00
|
|
|
var container = $('#content').empty();
|
2011-04-20 19:11:10 -05:00
|
|
|
container.append('<p>Error: '+error_thrown.name+'</p>');
|
|
|
|
container.append('<p>'+error_thrown.message+'</p>');
|
2010-09-29 00:52:56 -05:00
|
|
|
}
|
2010-09-16 09:28:07 -05:00
|
|
|
|
2011-11-09 18:48:04 -06:00
|
|
|
IPA.init({
|
|
|
|
on_success: init_on_success,
|
|
|
|
on_error: init_on_error
|
|
|
|
});
|
2010-09-29 00:52:56 -05:00
|
|
|
});
|