2010-09-16 09:28:07 -05:00
|
|
|
/* Authors:
|
|
|
|
* Pavel Zuna <pzuna@redhat.com>
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
|
|
|
|
|
|
|
var admin_tab_set = [
|
2010-10-06 16:24:58 -05:00
|
|
|
{name:'identity', children:[
|
2010-12-07 12:17:12 -06:00
|
|
|
{name:'user', entity:'user'},
|
|
|
|
{name:'group', entity:'group'},
|
|
|
|
{name:'host', entity:'host'},
|
|
|
|
{name:'hostgroup', entity:'hostgroup'},
|
|
|
|
{name:'netgroup', entity:'netgroup'},
|
|
|
|
{name:'service', entity:'service'}
|
2010-09-28 18:20:02 -05:00
|
|
|
]},
|
2010-10-06 16:24:58 -05:00
|
|
|
{name:'policy', children:[
|
2010-12-07 12:17:12 -06:00
|
|
|
{name:'dnszone', entity:'dnszone'},
|
2011-01-11 07:31:09 -06:00
|
|
|
{name:'hbacrule', entity:'hbacrule', children:[
|
2010-12-07 12:17:12 -06:00
|
|
|
{name:'hbacsvc', entity:'hbacsvc'},
|
|
|
|
{name:'hbacsvcgroup', entity:'hbacsvcgroup'}
|
2010-11-19 14:57:40 -06:00
|
|
|
]},
|
2010-12-07 12:17:12 -06:00
|
|
|
{name:'sudorule', entity:'sudorule',children:[
|
|
|
|
{name:'sudocmd', entity:'sudocmd'},
|
|
|
|
{name:'sudocmdgroup', entity:'sudocmdgroup'}
|
2010-11-19 14:57:40 -06:00
|
|
|
]},
|
2010-12-07 12:17:12 -06:00
|
|
|
{name:'pwpolicy', entity:'pwpolicy'},
|
|
|
|
{name:'krbtpolicy', entity:'krbtpolicy'}
|
2010-10-06 16:24:58 -05:00
|
|
|
]},
|
|
|
|
{name:'ipaserver', children: [
|
2010-10-25 18:55:57 -05:00
|
|
|
{name:'role',entity:'role' ,children:[
|
|
|
|
{name:'privilege',entity:'privilege' },
|
|
|
|
{name:'permission', entity:'permission'}
|
|
|
|
]},
|
|
|
|
{name:'selfservice' ,entity:'selfservice'},
|
|
|
|
{name:'delegation' ,entity:'delegation'},
|
2010-12-07 12:17:12 -06:00
|
|
|
{name:'config', entity:'config'}
|
2010-09-28 18:20:02 -05:00
|
|
|
]}
|
2010-09-16 09:28:07 -05:00
|
|
|
];
|
|
|
|
|
2010-09-30 15:37:33 -05:00
|
|
|
var self_serv_tab_set =
|
2010-09-21 15:22:45 -05:00
|
|
|
[
|
2010-12-07 12:17:12 -06:00
|
|
|
{ name:'identity', children: [
|
|
|
|
{name:'user', entity:'user'}]}];
|
2010-09-21 15:22:45 -05:00
|
|
|
|
2010-10-15 13:06:23 -05:00
|
|
|
|
2010-11-19 14:57:40 -06:00
|
|
|
IPA.tab_state = function(entity_name){
|
|
|
|
|
|
|
|
var state = {};
|
|
|
|
|
|
|
|
for (var top_tab_index = 0;
|
|
|
|
top_tab_index < IPA.tab_set.length;
|
|
|
|
top_tab_index += 1){
|
|
|
|
var top_tab = IPA.tab_set[top_tab_index];
|
|
|
|
for (var subtab_index = 0;
|
|
|
|
subtab_index < top_tab.children.length;
|
|
|
|
subtab_index += 1){
|
|
|
|
if(top_tab.children[subtab_index].name){
|
|
|
|
if (top_tab.children[subtab_index].name === entity_name){
|
|
|
|
state.navigation = top_tab_index;
|
|
|
|
state[top_tab.name] = subtab_index;
|
|
|
|
return state;
|
|
|
|
}else if (top_tab.children[subtab_index].children){
|
|
|
|
var nested_entities = top_tab.children[subtab_index].children;
|
|
|
|
for (var nested_index = 0;
|
|
|
|
nested_index < nested_entities.length;
|
|
|
|
nested_index += 1){
|
|
|
|
if (nested_entities[nested_index].name === entity_name){
|
|
|
|
state.navigation = top_tab_index;
|
|
|
|
state[top_tab.name] = subtab_index;
|
2010-11-29 11:52:08 -06:00
|
|
|
state[ top_tab.children[subtab_index].name+'-entity'] = entity_name;
|
2010-11-19 14:57:40 -06:00
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-10-15 13:06:23 -05:00
|
|
|
|
2010-12-01 15:44:44 -06:00
|
|
|
|
|
|
|
|
2010-09-16 09:28:07 -05:00
|
|
|
/* main (document onready event handler) */
|
|
|
|
$(function() {
|
|
|
|
|
2010-12-01 15:44:44 -06:00
|
|
|
function should_show_all_ui(){
|
|
|
|
var whoami = IPA.whoami;
|
|
|
|
|
|
|
|
if (whoami.hasOwnProperty('memberof_group') &&
|
|
|
|
whoami.memberof_group.indexOf('admins') !== -1) return true;
|
|
|
|
|
|
|
|
return whoami.hasOwnProperty('memberof_rolegroup') &&
|
|
|
|
whoami.memberof_rolegroup.length > 0;
|
|
|
|
}
|
|
|
|
|
2010-11-17 21:15:09 -06:00
|
|
|
|
|
|
|
function init_on_win(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;
|
|
|
|
IPA.whoami_pkey=whoami.uid[0];
|
2010-11-23 15:32:17 -06:00
|
|
|
$('#loggedinas').find('strong').text(whoami.cn[0]);
|
2010-10-27 22:32:30 -05:00
|
|
|
$('#loggedinas a').fragment(
|
2010-11-17 21:15:09 -06:00
|
|
|
{'user-facet':'details', 'user-pkey':IPA.whoami_pkey},2);
|
2010-09-30 15:37:33 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
for (var i=0; i<IPA.entities.length; i++) {
|
|
|
|
var entity = IPA.entities[i];
|
|
|
|
entity.init();
|
|
|
|
}
|
|
|
|
|
2010-10-27 22:32:30 -05:00
|
|
|
var navigation = $('#navigation');
|
2010-09-16 09:28:07 -05:00
|
|
|
|
2010-12-01 15:44:44 -06:00
|
|
|
if (should_show_all_ui()){
|
2010-11-19 14:57:40 -06:00
|
|
|
IPA.tab_set = admin_tab_set;
|
2010-10-27 22:32:30 -05:00
|
|
|
nav_create(admin_tab_set, navigation, 'tabs');
|
|
|
|
} else {
|
2010-11-19 14:57:40 -06:00
|
|
|
IPA.tab_set = self_serv_tab_set;
|
2010-10-27 22:32:30 -05:00
|
|
|
nav_create(self_serv_tab_set, navigation, 'tabs');
|
2010-09-27 23:35:09 -05:00
|
|
|
|
2010-11-17 21:15:09 -06:00
|
|
|
var state = {'user-pkey':IPA.whoami_pkey ,
|
2010-10-27 22:32:30 -05:00
|
|
|
'user-facet': jQuery.bbq.getState('user-facet') ||
|
|
|
|
'details'};
|
|
|
|
$.bbq.pushState(state);
|
2010-09-21 15:22:45 -05:00
|
|
|
}
|
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) {
|
|
|
|
var navigation = $('#navigation').empty();
|
|
|
|
navigation.append('<p>Error: '+error_thrown.name+'</p>');
|
2010-10-28 09:50:34 -05:00
|
|
|
navigation.append('<p>'+error_thrown.title+'</p>');
|
2010-09-29 00:52:56 -05:00
|
|
|
navigation.append('<p>'+error_thrown.message+'</p>');
|
|
|
|
}
|
2010-09-16 09:28:07 -05:00
|
|
|
|
2010-10-27 22:32:30 -05:00
|
|
|
IPA.init(null, null, init_on_win, init_on_error);
|
2010-09-29 00:52:56 -05:00
|
|
|
});
|
2010-09-16 09:28:07 -05:00
|
|
|
|
|
|
|
/* main loop (hashchange event handler) */
|
|
|
|
function window_hashchange(evt)
|
|
|
|
{
|
2010-09-30 15:37:33 -05:00
|
|
|
nav_update_tabs();
|
2010-09-16 09:28:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/* builder function for unimplemented tab content */
|
|
|
|
function unimplemented_tab(jobj)
|
|
|
|
{
|
|
|
|
jobj.text('Not implemented yet!');
|
|
|
|
}
|
|
|
|
|