mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-01-17 03:41:55 -06:00
65c9442e26
The HBAC Service search and details pages have been added under the HBAC tab. This requires some changes to the framework. Currently the navigation framework doesn't support multiple entities under one tab. As a temporary solution, an 'entity' URL parameter is used to determine the entity to be displayed. This parameter is now only used by HBAC tab, but its use might be expanded later. The navigation framework needs be redesigned to provide more flexibility. The search page in all entities except DNS records have been changed to use the ipa_search_widget. The Select/Unselect All checbox and Delete button now work correctly and consistently. The Add dialog has been enhanced to render and work in a more consistent way while still supporting custom widgets & layouts. For the search page, the Add button will refresh the search results and clear the fields in the dialog box. The framework now provides some extension points which can be overriden by the subclasses: - init(): for initialization and configuration - create(): for creating the layout dynamically or from template - setup(): for setting the look and feel - load(): for loading the data Entity and facet initialization is now done after IPA.init(). This is to ensure the metadata is loaded first so the entities and facets can use localized messages/labels/titles. The group entity has been partially converted to use the new framework. The unit tests have been updated accordingly.
280 lines
7.0 KiB
JavaScript
280 lines
7.0 KiB
JavaScript
/* Authors:
|
|
* Endi Sukma Dewata <edewata@redhat.com>
|
|
*
|
|
* Copyright (C) 2010 Red Hat
|
|
* see file 'COPYING' for use and warranty information
|
|
*
|
|
* 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; version 2 only
|
|
*
|
|
* 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
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
*/
|
|
|
|
/* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */
|
|
|
|
function ipa_service() {
|
|
|
|
var that = ipa_entity({
|
|
'name': 'service'
|
|
});
|
|
|
|
that.super_init = that.super('init');
|
|
|
|
that.init = function() {
|
|
|
|
var dialog = ipa_service_add_dialog({
|
|
'name': 'add',
|
|
'title': 'Add New Service'
|
|
});
|
|
that.add_dialog(dialog);
|
|
dialog.init();
|
|
|
|
var facet = ipa_service_search_facet({
|
|
'name': 'search',
|
|
'label': 'Search'
|
|
});
|
|
that.add_facet(facet);
|
|
|
|
facet = ipa_service_details_facet({
|
|
'name': 'details',
|
|
'label': 'Details'
|
|
});
|
|
that.add_facet(facet);
|
|
|
|
facet = ipa_association_facet({
|
|
'name': 'associate'
|
|
});
|
|
that.add_facet(facet);
|
|
|
|
that.create_association({
|
|
'name': 'host',
|
|
'add_method': 'add_host',
|
|
'delete_method': 'remove_host'
|
|
});
|
|
|
|
that.super_init();
|
|
};
|
|
|
|
return that;
|
|
}
|
|
|
|
IPA.add_entity(ipa_service());
|
|
|
|
function ipa_service_add_dialog(spec) {
|
|
|
|
spec = spec || {};
|
|
|
|
var that = ipa_add_dialog(spec);
|
|
|
|
that.super_init = that.super('init');
|
|
|
|
that.init = function() {
|
|
|
|
this.super_init();
|
|
|
|
this.add_field(ipa_widget({
|
|
name: 'krbprincipalname',
|
|
label: 'Principal'
|
|
}));
|
|
|
|
this.add_field(ipa_text_widget({name:'service', label:'Service'}));
|
|
this.add_field(ipa_text_widget({name:'host', label:'Host Name'}));
|
|
};
|
|
|
|
that.create = function() {
|
|
|
|
var table = $('<table/>').appendTo(that.container);
|
|
|
|
var field = that.get_field('service');
|
|
|
|
var tr = $('<tr/>').appendTo(table);
|
|
|
|
var td = $('<td/>', {
|
|
'style': 'vertical-align: top;'
|
|
}).appendTo(tr);
|
|
td.append(field.label+': ');
|
|
|
|
td = $('<td/>', {
|
|
'style': 'vertical-align: top;'
|
|
}).appendTo(tr);
|
|
|
|
$('<input/>', {
|
|
'type': 'text',
|
|
'name': 'service',
|
|
'size': 20
|
|
}).appendTo(td);
|
|
|
|
field = that.get_field('host');
|
|
|
|
tr = $('<tr/>').appendTo(table);
|
|
|
|
td = $('<td/>', {
|
|
'style': 'vertical-align: top;'
|
|
}).appendTo(tr);
|
|
td.append(field.label+': ');
|
|
|
|
td = $('<td/>', {
|
|
'style': 'vertical-align: top;'
|
|
}).appendTo(tr);
|
|
|
|
$('<input/>', {
|
|
'type': 'text',
|
|
'name': 'host',
|
|
'size': 40
|
|
}).appendTo(td);
|
|
};
|
|
|
|
that.get_record = function() {
|
|
var record = {};
|
|
|
|
var field = that.get_field('service');
|
|
var service = field.save(that.container)[0];
|
|
|
|
field = that.get_field('host');
|
|
var host = field.save(that.container)[0];
|
|
|
|
record['krbprincipalname'] = service+'/'+host;
|
|
|
|
return record;
|
|
};
|
|
|
|
return that;
|
|
}
|
|
|
|
function ipa_service_search_facet(spec) {
|
|
|
|
spec = spec || {};
|
|
|
|
var that = ipa_search_facet(spec);
|
|
|
|
that.super_init = that.super('init');
|
|
|
|
that.init = function() {
|
|
|
|
this.create_column({name:'krbprincipalname', label:'Principal'});
|
|
|
|
this.create_column({
|
|
name: 'quick_links',
|
|
label: 'Quick Links',
|
|
setup: ipa_entity_quick_links
|
|
});
|
|
|
|
that.super_init();
|
|
};
|
|
|
|
return that;
|
|
}
|
|
|
|
function ipa_service_details_facet(spec) {
|
|
|
|
spec = spec || {};
|
|
|
|
var that = ipa_details_facet(spec);
|
|
|
|
that.super_init = that.super('init');
|
|
|
|
that.init = function() {
|
|
|
|
var section = this.create_section({name:'details', label:'Service Details'});
|
|
|
|
section.create_field({
|
|
name: 'krbprincipalname',
|
|
label: 'Principal'
|
|
});
|
|
|
|
section.create_field({
|
|
name: 'service',
|
|
label: 'Service',
|
|
load: service_service_load
|
|
});
|
|
|
|
section.create_field({
|
|
name: 'host',
|
|
label: 'Host Name',
|
|
load: service_host_load
|
|
});
|
|
|
|
section = this.create_section({name:'provisioning', label:'Provisioning'});
|
|
|
|
section.create_field({
|
|
name: 'provisioning_status',
|
|
label: 'Status',
|
|
load: service_provisioning_status_load
|
|
});
|
|
|
|
section = this.create_section({name:'certificate', label:'Service Certificate'});
|
|
|
|
section.create_field({
|
|
name: 'certificate_status',
|
|
label: 'Status',
|
|
load: service_usercertificate_load
|
|
});
|
|
|
|
that.super_init();
|
|
};
|
|
|
|
return that;
|
|
}
|
|
|
|
function service_service_load(container, result) {
|
|
var dt = $('dt[title='+this.name+']', container);
|
|
if (!dt.length) return;
|
|
|
|
var krbprincipalname = result['krbprincipalname'][0];
|
|
var service = krbprincipalname.replace(/\/.*$/, '');
|
|
var dd = ipa_create_first_dd(this.name, service);
|
|
dt.after(dd);
|
|
}
|
|
|
|
function service_host_load(container, result) {
|
|
var dt = $('dt[title='+this.name+']', container);
|
|
if (!dt.length) return;
|
|
|
|
var krbprincipalname = result['krbprincipalname'][0];
|
|
var host = krbprincipalname.replace(/^.*\//, '').replace(/@.*$/, '');
|
|
var dd = ipa_create_first_dd(this.name, host);
|
|
dt.after(dd);
|
|
}
|
|
|
|
function service_provisioning_status_load(container, result) {
|
|
// skip provisioning_status
|
|
}
|
|
|
|
function service_usercertificate_load(container, result) {
|
|
|
|
var dt = $('dt[title='+this.name+']', container);
|
|
if (!dt.length) return;
|
|
|
|
var panel = certificate_status_panel({
|
|
'entity_type': 'service',
|
|
'entity_label': 'Service',
|
|
'result': result,
|
|
'get_entity_pkey': function(result) {
|
|
var values = result['krbprincipalname'];
|
|
return values ? values[0] : null;
|
|
},
|
|
'get_entity_name': function(result) {
|
|
var value = this.get_entity_pkey(result);
|
|
return value ? value.replace(/@.*$/, '') : null;
|
|
},
|
|
'get_entity_principal': function(result) {
|
|
return this.get_entity_pkey(result);
|
|
},
|
|
'get_entity_certificate': function(result) {
|
|
var values = result['usercertificate'];
|
|
return values ? values[0].__base64__ : null;
|
|
}
|
|
});
|
|
|
|
var dd = ipa_create_first_dd(this.name, panel);
|
|
dt.after(dd);
|
|
}
|