2011-01-14 11:16:25 -06:00
|
|
|
/*jsl:import ipa.js */
|
|
|
|
/*jsl:import search.js */
|
|
|
|
|
2010-10-06 16:24:58 -05:00
|
|
|
/* Authors:
|
|
|
|
* Adam Young <ayoung@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-10-06 16:24:58 -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-10-06 16:24:58 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */
|
|
|
|
|
|
|
|
/* DNS */
|
2011-01-19 20:10:18 -06:00
|
|
|
IPA.entity_factories.dnszone = function() {
|
2011-02-08 15:41:24 -06:00
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
var that = IPA.entity({
|
2010-12-03 23:29:05 -06:00
|
|
|
name: 'dnszone'
|
|
|
|
});
|
2010-10-22 08:41:34 -05:00
|
|
|
|
2010-12-03 23:29:05 -06:00
|
|
|
that.init = function() {
|
2011-01-19 20:10:18 -06:00
|
|
|
|
2011-02-08 15:41:24 -06:00
|
|
|
that.facet(
|
|
|
|
IPA.search_facet({
|
|
|
|
name: 'search',
|
|
|
|
label: 'Search',
|
|
|
|
entity_name: that.name
|
|
|
|
}).
|
|
|
|
column({name:'idnsname'}).
|
|
|
|
dialog(
|
|
|
|
IPA.add_dialog({
|
|
|
|
name: 'add',
|
|
|
|
title: 'Add DNS Zone'
|
|
|
|
}).
|
|
|
|
field(IPA.text_widget({ name: 'idnsname', undo: false})).
|
|
|
|
field(IPA.text_widget({ name: 'idnssoamname', undo: false})).
|
|
|
|
field(IPA.text_widget({ name: 'idnssoarname', undo: false}))));
|
|
|
|
|
|
|
|
that.facet(
|
|
|
|
IPA.details_facet({name:'details'}).
|
|
|
|
section(
|
|
|
|
IPA.stanza({name:'identity', label:'DNS Zone Settings'}).
|
|
|
|
input({name:'idnsname'}).
|
|
|
|
input({name:'idnszoneactive'}).
|
|
|
|
input({name:'idnssoamname'}).
|
|
|
|
input({name:'idnssoarname'}).
|
|
|
|
input({name:'idnssoaserial'}).
|
|
|
|
input({name:'idnssoarefresh'}).
|
|
|
|
input({name:'idnssoaretry'}).
|
|
|
|
input({name:'idnssoaexpire'}).
|
|
|
|
input({name:'idnssoaminimum'}).
|
|
|
|
input({name:'dnsttl'}).
|
|
|
|
input({name:'dnsclass'}).
|
|
|
|
input({name:'idnsallowdynupdate'}).
|
|
|
|
input({name:'idnsupdatepolicy'})));
|
|
|
|
|
|
|
|
that.facet(
|
|
|
|
IPA.records_facet({
|
|
|
|
'name': 'records',
|
|
|
|
'label': IPA.metadata.dnsrecord.label
|
|
|
|
}));
|
2010-12-03 23:29:05 -06:00
|
|
|
|
|
|
|
that.create_association_facets();
|
|
|
|
that.entity_init();
|
2010-12-06 16:30:10 -06:00
|
|
|
};
|
2010-10-06 16:24:58 -05:00
|
|
|
|
2010-12-03 23:29:05 -06:00
|
|
|
return that;
|
2011-01-19 20:10:18 -06:00
|
|
|
};
|
2010-10-06 16:24:58 -05:00
|
|
|
|
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
IPA.records_facet = function (spec){
|
2010-10-22 08:41:34 -05:00
|
|
|
|
2010-10-27 22:32:30 -05:00
|
|
|
spec = spec || {};
|
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
var that = IPA.facet(spec);
|
2010-10-27 22:32:30 -05:00
|
|
|
|
|
|
|
that.record = null;
|
2010-10-22 08:41:34 -05:00
|
|
|
|
|
|
|
var record_types =[ 'a', 'aaaa', 'dname', 'cname', 'mx', 'ns', 'ptr',
|
2011-02-11 14:50:24 -06:00
|
|
|
'srv', 'txt', 'a6', 'afsdb', 'cert', 'ds',
|
|
|
|
'key', 'kx', 'loc', 'naptr', 'nsec',
|
|
|
|
'rrsig', 'sshfp'];
|
2010-10-22 08:41:34 -05:00
|
|
|
|
|
|
|
function create_type_select(id,add_none) {
|
|
|
|
var type_select = $('<select/>',{
|
|
|
|
id: id
|
|
|
|
});
|
|
|
|
|
|
|
|
if (add_none){
|
|
|
|
type_select.append($('<option/>',{
|
|
|
|
text: '(any)',
|
|
|
|
value: ''
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
for (var t = 0 ; t < record_types.length ; t += 1){
|
|
|
|
var record_type = record_types[t].toUpperCase();
|
|
|
|
|
|
|
|
type_select.append($('<option/>',{
|
|
|
|
text: record_type,
|
|
|
|
value: record_type
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
return type_select;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var entry_attrs = {};
|
|
|
|
|
|
|
|
|
|
|
|
function add_click(){
|
|
|
|
|
|
|
|
var add_dialog = $('<div/>',{
|
|
|
|
id: 'add_dns_resource_record',
|
|
|
|
title: 'Add DNS Resource Record'
|
|
|
|
});
|
|
|
|
var dl = $('<dl></dl>').appendTo(add_dialog);
|
|
|
|
dl.append('<dt>Resource</dt>');
|
|
|
|
dl.append( $('<dd/>').
|
|
|
|
append($('<input type="text" id="dns-record-resource" />')));
|
|
|
|
dl.append('<dt>Type</dt>');
|
|
|
|
dl.append( $('<dd/>').append(create_type_select('dns-record-type')));
|
|
|
|
dl.append('<dt>Data</dt>');
|
|
|
|
dl.append($('<dd/>').append($('<textarea/>',{
|
|
|
|
id: 'dns-record-data',
|
|
|
|
rows:"8",
|
|
|
|
cols:"20"
|
|
|
|
})));
|
|
|
|
|
|
|
|
|
|
|
|
function add(evt, called_from_add_and_edit) {
|
|
|
|
var params = [];
|
|
|
|
var options = {};
|
|
|
|
function add_win(data, text_status, xhr) {
|
|
|
|
reload();
|
2010-10-27 22:32:30 -05:00
|
|
|
}
|
2010-10-22 08:41:34 -05:00
|
|
|
|
|
|
|
function add_fail(data, text_status, xhr) {
|
2010-10-27 22:32:30 -05:00
|
|
|
}
|
2010-10-22 08:41:34 -05:00
|
|
|
|
2010-12-02 13:14:59 -06:00
|
|
|
params.push( $.bbq.getState(that.entity_name+'-pkey', true));
|
2010-10-22 08:41:34 -05:00
|
|
|
params.push(add_dialog.find('#dns-record-resource').val());
|
|
|
|
|
2010-12-02 13:14:59 -06:00
|
|
|
var key = add_dialog.find('#dns-record-type').val().toLowerCase()+
|
|
|
|
"record";
|
|
|
|
var value = add_dialog.find('#dns-record-data').val();
|
|
|
|
options[key] = value;
|
|
|
|
|
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
IPA.cmd('dnsrecord_add', params, options, add_win, add_fail);
|
2010-10-22 08:41:34 -05:00
|
|
|
//add_dialog.dialog('close');
|
2010-10-27 22:32:30 -05:00
|
|
|
}
|
2010-10-22 08:41:34 -05:00
|
|
|
|
|
|
|
function add_and_close(evt) {
|
|
|
|
add(evt, true);
|
|
|
|
add_dialog.dialog('close');
|
2010-10-27 22:32:30 -05:00
|
|
|
}
|
2010-10-22 08:41:34 -05:00
|
|
|
|
|
|
|
function cancel() {
|
|
|
|
add_dialog.dialog('close');
|
2010-10-27 22:32:30 -05:00
|
|
|
}
|
2010-10-22 08:41:34 -05:00
|
|
|
|
|
|
|
|
|
|
|
add_dialog.dialog({
|
|
|
|
modal: true,
|
|
|
|
buttons: {
|
|
|
|
'Add many': add,
|
|
|
|
'Add and Close': add_and_close,
|
|
|
|
'Cancel': cancel
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function delete_records(records_table){
|
|
|
|
|
2010-12-02 13:14:59 -06:00
|
|
|
var zone = $.bbq.getState('dnszone-pkey', true);
|
2010-10-22 08:41:34 -05:00
|
|
|
|
|
|
|
var thead = records_table.find('thead');
|
|
|
|
thead.find("INPUT[type='checkbox']").
|
|
|
|
attr('checked', false);
|
|
|
|
|
|
|
|
var i = 0;
|
|
|
|
|
|
|
|
var tbody = records_table.find('tbody');
|
|
|
|
|
|
|
|
|
|
|
|
var delete_dialog = $('<div/>', {
|
2010-11-08 19:39:40 -06:00
|
|
|
title: IPA.messages.button.remove
|
2010-10-22 08:41:34 -05:00
|
|
|
});
|
|
|
|
var to_delete_table =
|
|
|
|
$('<table class="search-table" >'+
|
|
|
|
'<thead><tr><th>Resource</th><th>Type</th></tr></thead>'+
|
|
|
|
'<tbody></tbody></table>').appendTo(delete_dialog);
|
|
|
|
|
|
|
|
var to_delete_body = to_delete_table.find('tbody');
|
|
|
|
var delete_list = [];
|
|
|
|
tbody.find("INPUT[type='checkbox']").each(
|
|
|
|
function(index, box){
|
|
|
|
if (box.checked){
|
|
|
|
var tr = $(box).parents('tr');
|
|
|
|
var resource = $(tr).find('[title="idnsname"]').text();
|
|
|
|
var type = $(tr).find('[title="type"]').
|
2010-12-02 13:14:59 -06:00
|
|
|
text().toLowerCase();
|
2010-10-22 08:41:34 -05:00
|
|
|
var data = $(tr).find('[title="data"]').text();
|
2011-01-12 13:47:29 -06:00
|
|
|
var rectype=type+"record";
|
2010-12-02 13:14:59 -06:00
|
|
|
|
|
|
|
var options = {};
|
|
|
|
options[rectype]=data;
|
|
|
|
|
|
|
|
var command = {
|
|
|
|
"method":"dnsrecord_del",
|
|
|
|
"params":[[zone,resource], options]};
|
|
|
|
delete_list.push(command);
|
2010-10-22 08:41:34 -05:00
|
|
|
to_delete_body.append(
|
|
|
|
$('<tr></tr>').
|
|
|
|
append($('<td></td>',{html:resource}).
|
|
|
|
after($('<td></td>',{html:type}))));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
function delete_on_click() {
|
|
|
|
var delete_count = delete_list.length;
|
|
|
|
function delete_complete(){
|
|
|
|
reload();
|
|
|
|
delete_dialog.dialog('close');
|
|
|
|
}
|
2010-12-02 13:14:59 -06:00
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
IPA.cmd('batch', delete_list, {},
|
2010-12-02 13:14:59 -06:00
|
|
|
delete_complete,delete_complete);
|
2010-10-27 22:32:30 -05:00
|
|
|
}
|
2010-10-22 08:41:34 -05:00
|
|
|
|
|
|
|
function cancel_on_click() {
|
|
|
|
delete_dialog.dialog('close');
|
2010-10-27 22:32:30 -05:00
|
|
|
}
|
2010-10-22 08:41:34 -05:00
|
|
|
|
|
|
|
|
2011-01-12 13:47:29 -06:00
|
|
|
if (delete_list.length === 0){
|
2010-10-22 08:41:34 -05:00
|
|
|
return;
|
2011-01-12 13:47:29 -06:00
|
|
|
}
|
2010-10-22 08:41:34 -05:00
|
|
|
delete_dialog.append($('<P/>',
|
2010-10-27 22:32:30 -05:00
|
|
|
{text: IPA.messages.search.delete_confirm}));
|
2010-10-22 08:41:34 -05:00
|
|
|
|
|
|
|
delete_dialog.dialog({
|
|
|
|
modal: true,
|
|
|
|
buttons: {
|
|
|
|
'Delete': delete_on_click,
|
2010-10-27 22:32:30 -05:00
|
|
|
'Cancel': cancel_on_click
|
|
|
|
}
|
2010-10-22 08:41:34 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-10-27 22:32:30 -05:00
|
|
|
that.is_dirty = function() {
|
|
|
|
var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
|
|
|
|
var record = $.bbq.getState(that.entity_name + '-record', true) || '';
|
|
|
|
return pkey != that.pkey || record != that.record;
|
|
|
|
};
|
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
function create(container) {
|
2010-10-27 22:32:30 -05:00
|
|
|
|
2011-01-25 20:15:05 -06:00
|
|
|
container.attr('title', that.entity_name);
|
2010-10-22 08:41:34 -05:00
|
|
|
|
2011-01-25 20:15:05 -06:00
|
|
|
$('<h1/>',{
|
|
|
|
}).append(IPA.create_network_spinner()).
|
|
|
|
appendTo(container);
|
2010-10-22 08:41:34 -05:00
|
|
|
|
2011-01-25 20:15:05 -06:00
|
|
|
var details = $('<div/>', {
|
|
|
|
'class': 'content'
|
|
|
|
}).appendTo(container);
|
2010-10-22 08:41:34 -05:00
|
|
|
|
2011-01-12 13:47:29 -06:00
|
|
|
var div = $('<div class="search-controls"></div>').
|
2011-01-25 20:15:05 -06:00
|
|
|
appendTo(details);
|
2010-10-22 08:41:34 -05:00
|
|
|
|
|
|
|
var control_span =$('<span class="record-filter"></span>').appendTo(div);
|
|
|
|
control_span.append('Resource');
|
|
|
|
control_span.append($('<input />',{
|
|
|
|
type: "text",
|
|
|
|
id: 'dns-record-resource-filter',
|
2010-10-27 22:32:30 -05:00
|
|
|
name: 'search-' + that.entity_name + '-filter'
|
2010-10-22 08:41:34 -05:00
|
|
|
}));
|
|
|
|
|
2011-02-11 19:40:01 -06:00
|
|
|
/*
|
|
|
|
THe OLD DNS plugin allowed for search based on record type.
|
|
|
|
This one does not. If the plugin gets modified to support
|
|
|
|
Record type searches, uncomment the followin lines and
|
|
|
|
adjust the code that modifies the search parameters.
|
2010-10-22 08:41:34 -05:00
|
|
|
|
2011-02-11 19:40:01 -06:00
|
|
|
control_span.append('Type');
|
|
|
|
create_type_select('dns-record-type-filter',true).
|
|
|
|
appendTo(control_span);
|
|
|
|
*/
|
2010-10-22 08:41:34 -05:00
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
IPA.button({
|
HBAC Details Page
The UI framework has been extended to include a collection of widgets:
- ipa_widget: base class
- ipa_text_widget: text field
- ipa_radio_widget: radio button
- ipa_textarea_widget: textarea
- ipa_button_widget: button
- ipa_column_widget: column for table
- ipa_table_widget: table
These widgets can be used to create input controls. They can also be
extended to create custom controls.
The framework has also been enhanced to support custom layouts. This
can be used to change the look of the application without changing
the code. Initially this is only available in details section.
Layout consists of a collection of HTML templates. Each template is a
complete and valid HTML file representing a portion of a page. The
template will be loaded and initialized by the code, then filled with
the data from the server. The layouts are located in
install/static/layouts/<name> folder.
By default, if no templates are used, the fields in the details page
are rendered vertically using dd/dt/dd tags. For pages that require
different layout, a custom UI needs to be developed. There are two ways
to do that:
- write a custom widget to generate the UI dynamically
- create an HTML template and write the initialization code
For components that are quite complex or used frequently, it's might
be better to use the first method. For simple pages that are used only
in one location or need to support customization, the second method
might be preferable. Other benefits of templates:
- cleaner code and UI separation
- more flexibility in customization
- new pages can be developed quickly and require less coding
- multiple templates can be used with the same initialization code
- easier to maintain
The HBAC details page has been implemented using both methods. By
default it will use custom widgets to generate the page. To use a
custom layout, add the following parameter to the URL, then reload
the page:
&layout=<name>
Currently the only available layout is 'default' which produces the
same look as the custom widgets.
The HBAC details page is usable, but it still needs additional work.
The access time is not working yet. There is no undo button, hint,
or validation yet.
The table in the association facet has also been changed to use
ipa_association_widget which is derived from ipa_table_widget.
The Makefile has been updated to include the layouts. The unit tests
have been updated as well.
2010-11-02 20:16:55 -05:00
|
|
|
'label': IPA.messages.button.find,
|
|
|
|
'icon': 'ui-icon-search',
|
2011-01-12 13:47:29 -06:00
|
|
|
'click': function(){refresh();}
|
HBAC Details Page
The UI framework has been extended to include a collection of widgets:
- ipa_widget: base class
- ipa_text_widget: text field
- ipa_radio_widget: radio button
- ipa_textarea_widget: textarea
- ipa_button_widget: button
- ipa_column_widget: column for table
- ipa_table_widget: table
These widgets can be used to create input controls. They can also be
extended to create custom controls.
The framework has also been enhanced to support custom layouts. This
can be used to change the look of the application without changing
the code. Initially this is only available in details section.
Layout consists of a collection of HTML templates. Each template is a
complete and valid HTML file representing a portion of a page. The
template will be loaded and initialized by the code, then filled with
the data from the server. The layouts are located in
install/static/layouts/<name> folder.
By default, if no templates are used, the fields in the details page
are rendered vertically using dd/dt/dd tags. For pages that require
different layout, a custom UI needs to be developed. There are two ways
to do that:
- write a custom widget to generate the UI dynamically
- create an HTML template and write the initialization code
For components that are quite complex or used frequently, it's might
be better to use the first method. For simple pages that are used only
in one location or need to support customization, the second method
might be preferable. Other benefits of templates:
- cleaner code and UI separation
- more flexibility in customization
- new pages can be developed quickly and require less coding
- multiple templates can be used with the same initialization code
- easier to maintain
The HBAC details page has been implemented using both methods. By
default it will use custom widgets to generate the page. To use a
custom layout, add the following parameter to the URL, then reload
the page:
&layout=<name>
Currently the only available layout is 'default' which produces the
same look as the custom widgets.
The HBAC details page is usable, but it still needs additional work.
The access time is not working yet. There is no undo button, hint,
or validation yet.
The table in the association facet has also been changed to use
ipa_association_widget which is derived from ipa_table_widget.
The Makefile has been updated to include the layouts. The unit tests
have been updated as well.
2010-11-02 20:16:55 -05:00
|
|
|
}).appendTo(control_span);
|
2010-10-22 08:41:34 -05:00
|
|
|
|
2011-01-18 07:50:23 -06:00
|
|
|
var action_panel_ul = $('.action-panel .entity-facet', that.container).
|
|
|
|
last();
|
2010-12-02 13:14:59 -06:00
|
|
|
|
|
|
|
var action_controls = $('<li/>',{
|
|
|
|
"class":"action-controls"}).appendTo(action_panel_ul);
|
|
|
|
|
|
|
|
|
2011-01-24 21:30:28 -06:00
|
|
|
IPA.action_button({
|
HBAC Details Page
The UI framework has been extended to include a collection of widgets:
- ipa_widget: base class
- ipa_text_widget: text field
- ipa_radio_widget: radio button
- ipa_textarea_widget: textarea
- ipa_button_widget: button
- ipa_column_widget: column for table
- ipa_table_widget: table
These widgets can be used to create input controls. They can also be
extended to create custom controls.
The framework has also been enhanced to support custom layouts. This
can be used to change the look of the application without changing
the code. Initially this is only available in details section.
Layout consists of a collection of HTML templates. Each template is a
complete and valid HTML file representing a portion of a page. The
template will be loaded and initialized by the code, then filled with
the data from the server. The layouts are located in
install/static/layouts/<name> folder.
By default, if no templates are used, the fields in the details page
are rendered vertically using dd/dt/dd tags. For pages that require
different layout, a custom UI needs to be developed. There are two ways
to do that:
- write a custom widget to generate the UI dynamically
- create an HTML template and write the initialization code
For components that are quite complex or used frequently, it's might
be better to use the first method. For simple pages that are used only
in one location or need to support customization, the second method
might be preferable. Other benefits of templates:
- cleaner code and UI separation
- more flexibility in customization
- new pages can be developed quickly and require less coding
- multiple templates can be used with the same initialization code
- easier to maintain
The HBAC details page has been implemented using both methods. By
default it will use custom widgets to generate the page. To use a
custom layout, add the following parameter to the URL, then reload
the page:
&layout=<name>
Currently the only available layout is 'default' which produces the
same look as the custom widgets.
The HBAC details page is usable, but it still needs additional work.
The access time is not working yet. There is no undo button, hint,
or validation yet.
The table in the association facet has also been changed to use
ipa_association_widget which is derived from ipa_table_widget.
The Makefile has been updated to include the layouts. The unit tests
have been updated as well.
2010-11-02 20:16:55 -05:00
|
|
|
'label': IPA.messages.button.add,
|
|
|
|
'icon': 'ui-icon-plus',
|
|
|
|
'click': add_click
|
2010-12-02 13:14:59 -06:00
|
|
|
}).appendTo(action_controls);
|
2010-10-22 08:41:34 -05:00
|
|
|
|
2011-01-24 21:30:28 -06:00
|
|
|
IPA.action_button({
|
2010-11-08 19:39:40 -06:00
|
|
|
'label': IPA.messages.button.remove,
|
HBAC Details Page
The UI framework has been extended to include a collection of widgets:
- ipa_widget: base class
- ipa_text_widget: text field
- ipa_radio_widget: radio button
- ipa_textarea_widget: textarea
- ipa_button_widget: button
- ipa_column_widget: column for table
- ipa_table_widget: table
These widgets can be used to create input controls. They can also be
extended to create custom controls.
The framework has also been enhanced to support custom layouts. This
can be used to change the look of the application without changing
the code. Initially this is only available in details section.
Layout consists of a collection of HTML templates. Each template is a
complete and valid HTML file representing a portion of a page. The
template will be loaded and initialized by the code, then filled with
the data from the server. The layouts are located in
install/static/layouts/<name> folder.
By default, if no templates are used, the fields in the details page
are rendered vertically using dd/dt/dd tags. For pages that require
different layout, a custom UI needs to be developed. There are two ways
to do that:
- write a custom widget to generate the UI dynamically
- create an HTML template and write the initialization code
For components that are quite complex or used frequently, it's might
be better to use the first method. For simple pages that are used only
in one location or need to support customization, the second method
might be preferable. Other benefits of templates:
- cleaner code and UI separation
- more flexibility in customization
- new pages can be developed quickly and require less coding
- multiple templates can be used with the same initialization code
- easier to maintain
The HBAC details page has been implemented using both methods. By
default it will use custom widgets to generate the page. To use a
custom layout, add the following parameter to the URL, then reload
the page:
&layout=<name>
Currently the only available layout is 'default' which produces the
same look as the custom widgets.
The HBAC details page is usable, but it still needs additional work.
The access time is not working yet. There is no undo button, hint,
or validation yet.
The table in the association facet has also been changed to use
ipa_association_widget which is derived from ipa_table_widget.
The Makefile has been updated to include the layouts. The unit tests
have been updated as well.
2010-11-02 20:16:55 -05:00
|
|
|
'icon': 'ui-icon-trash',
|
|
|
|
'click': function(){delete_records(records_table);}
|
2010-12-02 13:14:59 -06:00
|
|
|
}).appendTo(action_controls);
|
|
|
|
|
2010-10-22 08:41:34 -05:00
|
|
|
div.append('<span class="records-buttons"></span>');
|
|
|
|
|
|
|
|
var records_results = $('<div/>', {
|
2010-10-27 22:32:30 -05:00
|
|
|
'class': 'records-results'
|
2011-01-25 20:15:05 -06:00
|
|
|
}).appendTo(details);
|
2010-10-22 08:41:34 -05:00
|
|
|
|
|
|
|
var records_table = $('<table/>', {
|
2010-10-27 22:32:30 -05:00
|
|
|
'class': 'search-table'
|
2010-10-22 08:41:34 -05:00
|
|
|
}).appendTo(records_results);
|
|
|
|
|
|
|
|
var thead = $('<thead><tr></tr></thead>').appendTo(records_table);
|
2010-10-27 22:32:30 -05:00
|
|
|
var tbody = $('<tbody></tbody>').appendTo(records_table);
|
|
|
|
var tfoot = $('<tfoot></tfoot>').appendTo(records_table);
|
2010-10-22 08:41:34 -05:00
|
|
|
|
|
|
|
var tr = thead.find('tr');
|
|
|
|
tr.append($('<th style="width: 15px" />').append(
|
|
|
|
$('<input />',{
|
|
|
|
type: 'checkbox',
|
|
|
|
click : function (evt){
|
|
|
|
tbody.find("INPUT[type='checkbox']").
|
|
|
|
attr('checked', this.checked);
|
|
|
|
}
|
2011-01-12 13:47:29 -06:00
|
|
|
})));
|
2010-12-03 23:29:05 -06:00
|
|
|
tr.append($('<th/>',{
|
2011-01-12 18:51:22 -06:00
|
|
|
text: IPA.get_param_info("dnsrecord", "idnsname").label }));
|
2010-12-03 23:29:05 -06:00
|
|
|
tr.append($('<th>Record Type</th>'));
|
2010-10-22 08:41:34 -05:00
|
|
|
tr.append($('<th>Data</th>'));
|
|
|
|
|
2011-01-25 20:15:05 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
function setup(container){
|
|
|
|
|
|
|
|
that.facet_setup(container);
|
|
|
|
|
|
|
|
that.pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
|
|
|
|
that.record = $.bbq.getState(that.entity_name + '-record', true) || '';
|
|
|
|
|
|
|
|
|
|
|
|
$('h1',container).
|
|
|
|
html("<span id='headerpkey' />Records for DNS Zone:" + that.pkey);
|
|
|
|
|
|
|
|
|
|
|
|
//commented out until data is searchable
|
|
|
|
//control_span.append('Data');
|
|
|
|
//control_span.append($('<input />',{
|
|
|
|
// type: "text",
|
|
|
|
// id: 'dns-record-data-filter',
|
|
|
|
// name: 'search-' + obj_name + '-filter'
|
|
|
|
//}));
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-11-18 20:17:14 -06:00
|
|
|
refresh();
|
2010-10-22 08:41:34 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function load_on_win(data){
|
2010-12-02 13:14:59 -06:00
|
|
|
display(that.entity_name,data);
|
2010-10-22 08:41:34 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
function load_on_fail(data){
|
2010-12-02 13:14:59 -06:00
|
|
|
display(that.entity_name,data);
|
2010-10-22 08:41:34 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
function reload(){
|
2010-11-18 20:17:14 -06:00
|
|
|
refresh();
|
2010-10-22 08:41:34 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-18 20:17:14 -06:00
|
|
|
function refresh(){
|
2010-10-22 08:41:34 -05:00
|
|
|
|
|
|
|
var options = {};
|
|
|
|
|
2011-01-12 13:47:29 -06:00
|
|
|
var resource_filter = that.container.
|
|
|
|
find("#dns-record-resource-filter").val();
|
2011-02-11 19:40:01 -06:00
|
|
|
// if (resource_filter){
|
|
|
|
// options.idnsname = resource_filter;
|
|
|
|
// }
|
2010-10-22 08:41:34 -05:00
|
|
|
|
2010-11-18 20:17:14 -06:00
|
|
|
var type_filter = that.container.find("#dns-record-type-filter").val();
|
2010-10-22 08:41:34 -05:00
|
|
|
if (type_filter){
|
|
|
|
options.type = type_filter;
|
|
|
|
}
|
|
|
|
|
2010-11-18 20:17:14 -06:00
|
|
|
var data_filter = that.container.find("#dns-record-data-filter").val();
|
2010-10-22 08:41:34 -05:00
|
|
|
if (data_filter){
|
|
|
|
options.data = data_filter;
|
|
|
|
}
|
|
|
|
|
2011-02-11 19:40:01 -06:00
|
|
|
var pkey = [$.bbq.getState(that.entity_name + '-pkey', true)];
|
|
|
|
|
|
|
|
if (resource_filter){
|
|
|
|
pkey.push(resource_filter);
|
|
|
|
}
|
|
|
|
IPA.cmd('dnsrecord_find',pkey,options,load_on_win, load_on_fail);
|
2010-10-22 08:41:34 -05:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function generate_tr(thead, tbody, result){
|
|
|
|
var tr = $('<tr></tr>').appendTo(tbody);
|
|
|
|
|
|
|
|
search_generate_checkbox_td(tr, /*pkey_value*/ '');
|
|
|
|
|
|
|
|
//TODO get this fixed on the back end. For now, workaround
|
|
|
|
|
|
|
|
if (result.idnsname){
|
|
|
|
tr.append($('<td/>',{
|
|
|
|
title:'idnsname',
|
|
|
|
text: result.idnsname[0]
|
|
|
|
}));
|
|
|
|
}else{
|
|
|
|
tr.append($('<td/>',{
|
|
|
|
title:'idnsname',
|
|
|
|
text: result.dn.split(',')[0].split('=')[1]
|
|
|
|
}));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for (var i = 0; i < record_types.length; i += 1){
|
|
|
|
var field_name = record_types[i];
|
|
|
|
var field = result[field_name+'record'];
|
|
|
|
if ( field ){
|
|
|
|
var record_type = field_name;
|
|
|
|
var record_data = field[0];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tr.append($('<td/>',{
|
|
|
|
title:'type',
|
|
|
|
text: record_type
|
|
|
|
}));
|
|
|
|
tr.append($('<td/>',{
|
|
|
|
title:'data',
|
|
|
|
text: record_data
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
|
|
|
//TODO this is cut and pasted from search, we need to unify
|
|
|
|
function display(obj_name, data){
|
HBAC Details Page
The UI framework has been extended to include a collection of widgets:
- ipa_widget: base class
- ipa_text_widget: text field
- ipa_radio_widget: radio button
- ipa_textarea_widget: textarea
- ipa_button_widget: button
- ipa_column_widget: column for table
- ipa_table_widget: table
These widgets can be used to create input controls. They can also be
extended to create custom controls.
The framework has also been enhanced to support custom layouts. This
can be used to change the look of the application without changing
the code. Initially this is only available in details section.
Layout consists of a collection of HTML templates. Each template is a
complete and valid HTML file representing a portion of a page. The
template will be loaded and initialized by the code, then filled with
the data from the server. The layouts are located in
install/static/layouts/<name> folder.
By default, if no templates are used, the fields in the details page
are rendered vertically using dd/dt/dd tags. For pages that require
different layout, a custom UI needs to be developed. There are two ways
to do that:
- write a custom widget to generate the UI dynamically
- create an HTML template and write the initialization code
For components that are quite complex or used frequently, it's might
be better to use the first method. For simple pages that are used only
in one location or need to support customization, the second method
might be preferable. Other benefits of templates:
- cleaner code and UI separation
- more flexibility in customization
- new pages can be developed quickly and require less coding
- multiple templates can be used with the same initialization code
- easier to maintain
The HBAC details page has been implemented using both methods. By
default it will use custom widgets to generate the page. To use a
custom layout, add the following parameter to the URL, then reload
the page:
&layout=<name>
Currently the only available layout is 'default' which produces the
same look as the custom widgets.
The HBAC details page is usable, but it still needs additional work.
The access time is not working yet. There is no undo button, hint,
or validation yet.
The table in the association facet has also been changed to use
ipa_association_widget which is derived from ipa_table_widget.
The Makefile has been updated to include the layouts. The unit tests
have been updated as well.
2010-11-02 20:16:55 -05:00
|
|
|
var selector = '.entity-container[title=' + obj_name + ']';
|
2010-10-22 08:41:34 -05:00
|
|
|
var thead = $(selector + ' thead');
|
|
|
|
var tbody = $(selector + ' tbody');
|
|
|
|
var tfoot = $(selector + ' tfoot');
|
|
|
|
|
|
|
|
tbody.find('tr').remove();
|
|
|
|
|
|
|
|
var result = data.result.result;
|
|
|
|
for (var i = 0; i < result.length; ++i){
|
|
|
|
generate_tr(thead, tbody, result[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data.result.truncated) {
|
|
|
|
tfoot.text(
|
|
|
|
'Query returned results than configured size limit will show.' +
|
2011-01-12 13:47:29 -06:00
|
|
|
'First ' + data.result.count + ' results shown.' );
|
2010-10-22 08:41:34 -05:00
|
|
|
} else {
|
|
|
|
tfoot.text(data.result.summary);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
that.create = create;
|
2010-10-22 08:41:34 -05:00
|
|
|
that.setup = setup;
|
2010-11-18 20:17:14 -06:00
|
|
|
that.refresh = refresh;
|
2010-10-22 08:41:34 -05:00
|
|
|
|
|
|
|
return that;
|
2011-01-14 11:16:25 -06:00
|
|
|
};
|
2010-10-22 08:41:34 -05:00
|
|
|
|
|
|
|
|
2010-10-06 16:24:58 -05:00
|
|
|
/**Automount*/
|
|
|
|
|
2011-02-08 15:41:24 -06:00
|
|
|
IPA.entity_factories.automountlocation = function() {
|
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
var that = IPA.entity({
|
2010-12-03 23:29:05 -06:00
|
|
|
name: 'automountlocation'
|
|
|
|
});
|
2010-10-06 16:24:58 -05:00
|
|
|
|
2010-12-03 23:29:05 -06:00
|
|
|
that.init = function() {
|
|
|
|
|
2011-02-08 15:41:24 -06:00
|
|
|
that.facet(
|
|
|
|
IPA.search_facet({
|
|
|
|
name: 'search',
|
|
|
|
label: 'Search',
|
|
|
|
entity_name: that.name
|
|
|
|
}).
|
|
|
|
column({name:'cn'}).
|
|
|
|
dialog(
|
|
|
|
IPA.add_dialog({
|
|
|
|
name: 'add',
|
|
|
|
title: 'Add Automount Location'
|
|
|
|
}).
|
|
|
|
field(IPA.text_widget({ name: 'cn', undo: false}))));
|
|
|
|
|
|
|
|
that.facet(
|
|
|
|
IPA.details_facet({name:'details'}).
|
|
|
|
section(
|
|
|
|
IPA.stanza({name:'identity', label:'Automount Location Settings'}).
|
|
|
|
input({name:'cn'})));
|
2010-12-06 16:30:10 -06:00
|
|
|
|
2010-12-03 23:29:05 -06:00
|
|
|
that.create_association_facets();
|
|
|
|
that.entity_init();
|
2011-01-12 13:47:29 -06:00
|
|
|
};
|
2011-02-08 15:41:24 -06:00
|
|
|
|
2010-12-03 23:29:05 -06:00
|
|
|
return that;
|
2011-01-19 20:10:18 -06:00
|
|
|
};
|
2010-10-06 16:24:58 -05:00
|
|
|
|
|
|
|
|
|
|
|
/**pwpolicy*/
|
|
|
|
|
|
|
|
|
2011-01-19 20:10:18 -06:00
|
|
|
IPA.entity_factories.pwpolicy = function() {
|
2011-02-08 15:41:24 -06:00
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
var that = IPA.entity({
|
2010-12-03 23:29:05 -06:00
|
|
|
name: 'pwpolicy'
|
|
|
|
});
|
2010-10-06 16:24:58 -05:00
|
|
|
|
2010-12-03 23:29:05 -06:00
|
|
|
that.init = function() {
|
2010-12-06 16:30:10 -06:00
|
|
|
|
2011-02-08 15:41:24 -06:00
|
|
|
that.facet(
|
|
|
|
IPA.search_facet({
|
|
|
|
name: 'search',
|
|
|
|
label: 'Search',
|
|
|
|
entity_name: that.name
|
|
|
|
}).
|
|
|
|
column({name:'cn'}).
|
|
|
|
dialog(
|
|
|
|
IPA.add_dialog({
|
|
|
|
name: 'add',
|
|
|
|
title: 'Add Password Policy',
|
|
|
|
entity_name:'pwpolicy'
|
|
|
|
}).
|
|
|
|
field(IPA.text_widget({name: 'cn', undo: false}))));
|
|
|
|
|
|
|
|
that.facet(
|
|
|
|
IPA.details_facet({name:'details'}).
|
|
|
|
section(
|
|
|
|
IPA.stanza({name:'identity', label:'Password Policy'}).
|
|
|
|
input({name:'krbmaxpwdlife'}).
|
|
|
|
input({name:'krbminpwdlife'}).
|
|
|
|
input({name:'krbpwdhistorylength'}).
|
|
|
|
input({name:'krbpwdmindiffchars'}).
|
|
|
|
input({name:'krbpwdminlength'})));
|
2010-12-06 16:30:10 -06:00
|
|
|
|
2010-12-03 23:29:05 -06:00
|
|
|
that.create_association_facets();
|
|
|
|
that.entity_init();
|
|
|
|
|
2010-12-06 16:30:10 -06:00
|
|
|
};
|
2011-02-08 15:41:24 -06:00
|
|
|
|
2010-12-03 23:29:05 -06:00
|
|
|
return that;
|
2011-01-19 20:10:18 -06:00
|
|
|
};
|
2010-10-06 16:24:58 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
krbtpolicy
|
|
|
|
Does not have search
|
|
|
|
*/
|
2011-01-19 20:10:18 -06:00
|
|
|
IPA.entity_factories.krbtpolicy = function() {
|
2011-02-08 15:41:24 -06:00
|
|
|
|
2011-01-19 20:10:18 -06:00
|
|
|
var that = IPA.entity({
|
|
|
|
name: 'krbtpolicy'
|
|
|
|
});
|
2010-10-06 16:24:58 -05:00
|
|
|
|
2011-02-08 15:41:24 -06:00
|
|
|
that.facet(
|
|
|
|
IPA.details_facet({
|
|
|
|
name: 'details'
|
|
|
|
}).
|
|
|
|
section(
|
|
|
|
IPA.stanza({name: 'identity', label: 'Kerberos ticket policy'}).
|
|
|
|
//input({name: 'uid',label:' '}).
|
|
|
|
input({name: 'krbmaxrenewableage'}).
|
|
|
|
input({name: 'krbmaxticketlife'})));
|
|
|
|
|
2011-01-19 20:10:18 -06:00
|
|
|
return that;
|
|
|
|
};
|