mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Refactored facet.load().
The load() in IPA.facet has been modified to accept the complete data returned by the server instead of just the result. This is needed by HBAC Test to access other attributes returned in the test result. Ticket #388
This commit is contained in:
parent
a8ea42bda8
commit
caa9d52666
@ -716,7 +716,7 @@ IPA.permission_target_policy = function (widget_name) {
|
|||||||
for (var i=0; i<targets.length; i++) {
|
for (var i=0; i<targets.length; i++) {
|
||||||
var target = targets[i];
|
var target = targets[i];
|
||||||
|
|
||||||
if(data[target]) {
|
if(data.result.result[target]) {
|
||||||
that.select_target(target);
|
that.select_target(target);
|
||||||
} else {
|
} else {
|
||||||
that.set_target_visible(target, false);
|
that.set_target_visible(target, false);
|
||||||
|
@ -30,7 +30,6 @@ IPA.entity_adder_dialog = function(spec) {
|
|||||||
var that = IPA.dialog(spec);
|
var that = IPA.dialog(spec);
|
||||||
|
|
||||||
that.method = spec.method || 'add';
|
that.method = spec.method || 'add';
|
||||||
that.pre_execute_hook = spec.pre_execute_hook;
|
|
||||||
that.on_error = spec.on_error ;
|
that.on_error = spec.on_error ;
|
||||||
that.retry = typeof spec.retry !== 'undefined' ? spec.retry : true;
|
that.retry = typeof spec.retry !== 'undefined' ? spec.retry : true;
|
||||||
that.command = null;
|
that.command = null;
|
||||||
@ -107,26 +106,18 @@ IPA.entity_adder_dialog = function(spec) {
|
|||||||
IPA.nav.show_entity_page(that.entity, 'default', pkey);
|
IPA.nav.show_entity_page(that.entity, 'default', pkey);
|
||||||
}
|
}
|
||||||
|
|
||||||
that.add = function(on_success, on_error) {
|
that.create_add_command = function(record) {
|
||||||
|
|
||||||
var pkey_name = that.entity.metadata.primary_key;
|
var pkey_name = that.entity.metadata.primary_key;
|
||||||
|
|
||||||
var command = IPA.command({
|
var command = IPA.command({
|
||||||
entity: that.entity.name,
|
entity: that.entity.name,
|
||||||
method: that.method,
|
method: that.method,
|
||||||
retry: that.retry,
|
retry: that.retry
|
||||||
on_success: on_success,
|
|
||||||
on_error: on_error
|
|
||||||
});
|
});
|
||||||
that.command = command;
|
|
||||||
|
|
||||||
command.add_args(that.entity.get_primary_key_prefix());
|
command.add_args(that.entity.get_primary_key_prefix());
|
||||||
|
|
||||||
if (!that.validate()) return;
|
|
||||||
|
|
||||||
var record = {};
|
|
||||||
that.save(record);
|
|
||||||
|
|
||||||
var fields = that.fields.get_fields();
|
var fields = that.fields.get_fields();
|
||||||
for (var j=0; j<fields.length; j++) {
|
for (var j=0; j<fields.length; j++) {
|
||||||
var field = fields[j];
|
var field = fields[j];
|
||||||
@ -145,11 +136,21 @@ IPA.entity_adder_dialog = function(spec) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (that.pre_execute_hook) {
|
return command;
|
||||||
that.pre_execute_hook(command);
|
};
|
||||||
}
|
|
||||||
|
|
||||||
command.execute();
|
that.add = function(on_success, on_error) {
|
||||||
|
|
||||||
|
if (!that.validate()) return;
|
||||||
|
|
||||||
|
var record = {};
|
||||||
|
that.save(record);
|
||||||
|
|
||||||
|
that.command = that.create_add_command(record);
|
||||||
|
that.command.on_success = on_success;
|
||||||
|
that.command.on_error = on_error;
|
||||||
|
|
||||||
|
that.command.execute();
|
||||||
};
|
};
|
||||||
|
|
||||||
that.create = function() {
|
that.create = function() {
|
||||||
@ -172,6 +173,7 @@ IPA.entity_adder_dialog = function(spec) {
|
|||||||
|
|
||||||
// methods that should be invoked by subclasses
|
// methods that should be invoked by subclasses
|
||||||
that.entity_adder_dialog_create = that.create;
|
that.entity_adder_dialog_create = that.create;
|
||||||
|
that.entity_adder_dialog_create_add_command = that.create_add_command;
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
||||||
|
@ -753,11 +753,6 @@ IPA.association_facet = function (spec) {
|
|||||||
var column;
|
var column;
|
||||||
var i;
|
var i;
|
||||||
|
|
||||||
var adder_columns = spec.adder_columns || [];
|
|
||||||
for (i=0; i<adder_columns.length; i++) {
|
|
||||||
that.create_adder_column(adder_columns[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
var pkey_name;
|
var pkey_name;
|
||||||
if (that.other_entity) {
|
if (that.other_entity) {
|
||||||
pkey_name = IPA.metadata.objects[that.other_entity].primary_key;
|
pkey_name = IPA.metadata.objects[that.other_entity].primary_key;
|
||||||
@ -765,12 +760,24 @@ IPA.association_facet = function (spec) {
|
|||||||
|
|
||||||
if (!that.columns.length){
|
if (!that.columns.length){
|
||||||
that.create_column({
|
that.create_column({
|
||||||
name: pkey_name,
|
name: pkey_name
|
||||||
primary_key: true,
|
|
||||||
link: spec.link
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var columns = that.columns.values;
|
||||||
|
for (i=0; i<columns.length; i++) {
|
||||||
|
column = columns[i];
|
||||||
|
column.link = spec.link;
|
||||||
|
}
|
||||||
|
|
||||||
|
var other_entity = IPA.get_entity(that.other_entity);
|
||||||
|
that.init_table(other_entity);
|
||||||
|
|
||||||
|
var adder_columns = spec.adder_columns || [];
|
||||||
|
for (i=0; i<adder_columns.length; i++) {
|
||||||
|
that.create_adder_column(adder_columns[i]);
|
||||||
|
}
|
||||||
|
|
||||||
if (!that.adder_columns.length) {
|
if (!that.adder_columns.length) {
|
||||||
that.create_adder_column({
|
that.create_adder_column({
|
||||||
name: pkey_name,
|
name: pkey_name,
|
||||||
@ -783,9 +790,6 @@ IPA.association_facet = function (spec) {
|
|||||||
column = adder_columns[i];
|
column = adder_columns[i];
|
||||||
column.entity_name = that.other_entity;
|
column.entity_name = that.other_entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
var other_entity = IPA.get_entity(that.other_entity);
|
|
||||||
that.init_table(other_entity);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
that.get_records_command_name = function() {
|
that.get_records_command_name = function() {
|
||||||
@ -882,10 +886,6 @@ IPA.association_facet = function (spec) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
that.create_content = function(container) {
|
|
||||||
that.table.create(container);
|
|
||||||
};
|
|
||||||
|
|
||||||
that.show = function() {
|
that.show = function() {
|
||||||
that.facet_show();
|
that.facet_show();
|
||||||
|
|
||||||
@ -903,7 +903,7 @@ IPA.association_facet = function (spec) {
|
|||||||
title = title.replace('${primary_key}', pkey);
|
title = title.replace('${primary_key}', pkey);
|
||||||
title = title.replace('${other_entity}', label);
|
title = title.replace('${other_entity}', label);
|
||||||
|
|
||||||
var pkeys = that.data[that.get_attribute_name()];
|
var pkeys = that.data.result.result[that.get_attribute_name()];
|
||||||
|
|
||||||
var dialog = IPA.association_adder_dialog({
|
var dialog = IPA.association_adder_dialog({
|
||||||
title: title,
|
title: title,
|
||||||
@ -995,8 +995,8 @@ IPA.association_facet = function (spec) {
|
|||||||
dialog.open(that.container);
|
dialog.open(that.container);
|
||||||
};
|
};
|
||||||
|
|
||||||
that.load_pkeys = function(result) {
|
that.get_pkeys = function(data) {
|
||||||
that.pkeys = that.data[that.get_attribute_name()] || [];
|
return data.result.result[that.get_attribute_name()] || [];
|
||||||
};
|
};
|
||||||
|
|
||||||
that.refresh = function() {
|
that.refresh = function() {
|
||||||
@ -1020,10 +1020,13 @@ IPA.association_facet = function (spec) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
command.on_success = function(data, text_status, xhr) {
|
command.on_success = function(data, text_status, xhr) {
|
||||||
that.load(data.result.result);
|
that.load(data);
|
||||||
};
|
};
|
||||||
|
|
||||||
command.on_error = that.on_error;
|
command.on_error = function(xhr, text_status, error_thrown) {
|
||||||
|
that.redirect_error(error_thrown);
|
||||||
|
that.report_error(error_thrown);
|
||||||
|
};
|
||||||
|
|
||||||
command.execute();
|
command.execute();
|
||||||
};
|
};
|
||||||
|
@ -160,6 +160,7 @@ IPA.automount.key_entity = function(spec) {
|
|||||||
|
|
||||||
that.builder.containing_entity('automountmap').
|
that.builder.containing_entity('automountmap').
|
||||||
details_facet({
|
details_facet({
|
||||||
|
factory: IPA.automount.key_details_facet,
|
||||||
sections: [
|
sections: [
|
||||||
{
|
{
|
||||||
name:'identity',
|
name:'identity',
|
||||||
@ -173,24 +174,7 @@ IPA.automount.key_entity = function(spec) {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
disable_breadcrumb: false,
|
disable_breadcrumb: false
|
||||||
pre_execute_hook : function (command){
|
|
||||||
var entity_name = this.entity_name;
|
|
||||||
var info = IPA.nav.get_state(entity_name + '-info');
|
|
||||||
var key = IPA.nav.get_state(entity_name + '-pkey');
|
|
||||||
|
|
||||||
|
|
||||||
if (command.args.length ==3){
|
|
||||||
command.args.pop();
|
|
||||||
}
|
|
||||||
if (command.method === 'mod'){
|
|
||||||
command.options['newautomountinformation'] =
|
|
||||||
command.options['automountinformation'];
|
|
||||||
|
|
||||||
}
|
|
||||||
command.options['automountkey'] = key;
|
|
||||||
command.options['automountinformation'] = info;
|
|
||||||
}
|
|
||||||
}).
|
}).
|
||||||
adder_dialog({
|
adder_dialog({
|
||||||
show_edit_page : function(entity, result){
|
show_edit_page : function(entity, result){
|
||||||
@ -210,6 +194,44 @@ IPA.automount.key_entity = function(spec) {
|
|||||||
return that;
|
return that;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
IPA.automount.key_details_facet = function(spec) {
|
||||||
|
|
||||||
|
var that = IPA.details_facet(spec);
|
||||||
|
|
||||||
|
that.create_update_command = function() {
|
||||||
|
|
||||||
|
var command = that.details_facet_create_update_command();
|
||||||
|
|
||||||
|
command.args.pop();
|
||||||
|
|
||||||
|
var key = IPA.nav.get_state(that.entity.name + '-pkey');
|
||||||
|
var info = IPA.nav.get_state(that.entity.name + '-info');
|
||||||
|
|
||||||
|
command.options.newautomountinformation = command.options.automountinformation;
|
||||||
|
command.options.automountkey = key;
|
||||||
|
command.options.automountinformation = info;
|
||||||
|
|
||||||
|
return command;
|
||||||
|
};
|
||||||
|
|
||||||
|
that.create_refresh_command = function() {
|
||||||
|
|
||||||
|
var command = that.details_facet_create_refresh_command();
|
||||||
|
|
||||||
|
command.args.pop();
|
||||||
|
|
||||||
|
var key = IPA.nav.get_state(that.entity.name + '-pkey');
|
||||||
|
var info = IPA.nav.get_state(that.entity.name + '-info');
|
||||||
|
|
||||||
|
command.options.automountkey = key;
|
||||||
|
command.options.automountinformation = info;
|
||||||
|
|
||||||
|
return command;
|
||||||
|
};
|
||||||
|
|
||||||
|
return that;
|
||||||
|
};
|
||||||
|
|
||||||
IPA.automount_key_column = function(spec) {
|
IPA.automount_key_column = function(spec) {
|
||||||
|
|
||||||
var that = IPA.column(spec);
|
var that = IPA.column(spec);
|
||||||
|
@ -173,7 +173,7 @@ IPA.facet_policy = function() {
|
|||||||
that.post_create = function() {
|
that.post_create = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
that.post_load = function() {
|
that.post_load = function(data) {
|
||||||
};
|
};
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
@ -235,8 +235,6 @@ IPA.details_facet = function(spec) {
|
|||||||
var that = IPA.facet(spec);
|
var that = IPA.facet(spec);
|
||||||
|
|
||||||
that.entity = spec.entity;
|
that.entity = spec.entity;
|
||||||
that.pre_execute_hook = spec.pre_execute_hook;
|
|
||||||
that.post_update_hook = spec.post_update_hook;
|
|
||||||
that.update_command_name = spec.update_command_name || 'mod';
|
that.update_command_name = spec.update_command_name || 'mod';
|
||||||
that.command_mode = spec.command_mode || 'save'; // [save, info]
|
that.command_mode = spec.command_mode || 'save'; // [save, info]
|
||||||
|
|
||||||
@ -274,7 +272,7 @@ IPA.details_facet = function(spec) {
|
|||||||
if (!pkey_name){
|
if (!pkey_name){
|
||||||
return pkey;
|
return pkey;
|
||||||
}
|
}
|
||||||
var pkey_val = that.data[pkey_name];
|
var pkey_val = that.data.result.result[pkey_name];
|
||||||
if (pkey_val instanceof Array) {
|
if (pkey_val instanceof Array) {
|
||||||
pkey.push(pkey_val[0]);
|
pkey.push(pkey_val[0]);
|
||||||
} else {
|
} else {
|
||||||
@ -457,7 +455,7 @@ IPA.details_facet = function(spec) {
|
|||||||
var fields = that.fields.get_fields();
|
var fields = that.fields.get_fields();
|
||||||
for (var i=0; i<fields.length; i++) {
|
for (var i=0; i<fields.length; i++) {
|
||||||
var field = fields[i];
|
var field = fields[i];
|
||||||
field.load(data);
|
field.load(data.result.result);
|
||||||
}
|
}
|
||||||
that.policies.post_load(data);
|
that.policies.post_load(data);
|
||||||
that.enable_update(false);
|
that.enable_update(false);
|
||||||
@ -515,17 +513,7 @@ IPA.details_facet = function(spec) {
|
|||||||
|
|
||||||
|
|
||||||
that.on_update_success = function(data, text_status, xhr) {
|
that.on_update_success = function(data, text_status, xhr) {
|
||||||
|
that.load(data);
|
||||||
if (data.error)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (that.post_update_hook) {
|
|
||||||
that.post_update_hook(data, text_status);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var result = data.result.result;
|
|
||||||
that.load(result);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
that.on_update_error = function(xhr, text_status, error_thrown) {
|
that.on_update_error = function(xhr, text_status, error_thrown) {
|
||||||
@ -543,7 +531,7 @@ IPA.details_facet = function(spec) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
that.create_fields_update_command = function(update_info, on_win, on_fail) {
|
that.create_fields_update_command = function(update_info) {
|
||||||
|
|
||||||
var args = that.get_primary_key();
|
var args = that.get_primary_key();
|
||||||
var command = IPA.command({
|
var command = IPA.command({
|
||||||
@ -553,9 +541,7 @@ IPA.details_facet = function(spec) {
|
|||||||
options: {
|
options: {
|
||||||
all: true,
|
all: true,
|
||||||
rights: true
|
rights: true
|
||||||
},
|
}
|
||||||
on_success: on_win,
|
|
||||||
on_error: on_fail
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//set command options
|
//set command options
|
||||||
@ -564,12 +550,10 @@ IPA.details_facet = function(spec) {
|
|||||||
return command;
|
return command;
|
||||||
};
|
};
|
||||||
|
|
||||||
that.create_batch_update_command = function(update_info, on_win, on_fail) {
|
that.create_batch_update_command = function(update_info) {
|
||||||
|
|
||||||
var batch = IPA.batch_command({
|
var batch = IPA.batch_command({
|
||||||
'name': that.entity.name + '_details_update',
|
name: that.entity.name + '_details_update'
|
||||||
'on_success': on_win,
|
|
||||||
'on_error': on_fail
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var new_update_info = IPA.update_info_builder.copy(update_info);
|
var new_update_info = IPA.update_info_builder.copy(update_info);
|
||||||
@ -599,21 +583,11 @@ IPA.details_facet = function(spec) {
|
|||||||
dialog.open();
|
dialog.open();
|
||||||
};
|
};
|
||||||
|
|
||||||
that.update = function(on_win, on_fail) {
|
that.create_update_command = function() {
|
||||||
|
|
||||||
var on_success = function(data, text_status, xhr) {
|
|
||||||
that.on_update_success(data, text_status, xhr);
|
|
||||||
if (on_win) on_win.call(this, data, text_status, xhr);
|
|
||||||
};
|
|
||||||
|
|
||||||
var on_error = function(xhr, text_status, error_thrown) {
|
|
||||||
that.on_update_error(xhr, text_status, error_thrown);
|
|
||||||
if (on_fail) on_fail.call(this, xhr, text_status, error_thrown);
|
|
||||||
};
|
|
||||||
|
|
||||||
var command, update_info;
|
var command, update_info;
|
||||||
|
|
||||||
if(that.command_mode === 'info') {
|
if (that.command_mode === 'info') {
|
||||||
update_info = that.get_update_info();
|
update_info = that.get_update_info();
|
||||||
} else {
|
} else {
|
||||||
update_info = that.save_as_update_info(true, true);
|
update_info = that.save_as_update_info(true, true);
|
||||||
@ -621,19 +595,28 @@ IPA.details_facet = function(spec) {
|
|||||||
|
|
||||||
if (update_info.commands.length <= 0) {
|
if (update_info.commands.length <= 0) {
|
||||||
//normal command
|
//normal command
|
||||||
command = that.create_fields_update_command(update_info,
|
command = that.create_fields_update_command(update_info);
|
||||||
on_success,
|
|
||||||
on_error);
|
|
||||||
} else {
|
} else {
|
||||||
//batch command
|
//batch command
|
||||||
command = that.create_batch_update_command(update_info,
|
command = that.create_batch_update_command(update_info);
|
||||||
on_success,
|
|
||||||
on_error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (that.pre_execute_hook){
|
return command;
|
||||||
that.pre_execute_hook(command);
|
};
|
||||||
}
|
|
||||||
|
that.update = function(on_success, on_error) {
|
||||||
|
|
||||||
|
var command = that.create_update_command();
|
||||||
|
|
||||||
|
command.on_success = function(data, text_status, xhr) {
|
||||||
|
that.on_update_success(data, text_status, xhr);
|
||||||
|
if (on_success) on_success.call(this, data, text_status, xhr);
|
||||||
|
};
|
||||||
|
|
||||||
|
command.on_error = function(xhr, text_status, error_thrown) {
|
||||||
|
that.on_update_error(xhr, text_status, error_thrown);
|
||||||
|
if (on_error) on_error.call(this, xhr, text_status, error_thrown);
|
||||||
|
};
|
||||||
|
|
||||||
command.execute();
|
command.execute();
|
||||||
};
|
};
|
||||||
@ -642,9 +625,7 @@ IPA.details_facet = function(spec) {
|
|||||||
return that.entity.name+'_show';
|
return that.entity.name+'_show';
|
||||||
};
|
};
|
||||||
|
|
||||||
that.refresh = function() {
|
that.create_refresh_command = function() {
|
||||||
|
|
||||||
that.pkey = IPA.nav.get_state(that.entity.name+'-pkey');
|
|
||||||
|
|
||||||
var command = IPA.command({
|
var command = IPA.command({
|
||||||
name: that.get_refresh_command_name(),
|
name: that.get_refresh_command_name(),
|
||||||
@ -655,21 +636,30 @@ IPA.details_facet = function(spec) {
|
|||||||
|
|
||||||
if (that.pkey) {
|
if (that.pkey) {
|
||||||
command.args = that.get_primary_key(true);
|
command.args = that.get_primary_key(true);
|
||||||
|
}
|
||||||
|
|
||||||
} else if (that.entity.redirect_facet) {
|
return command;
|
||||||
|
};
|
||||||
|
|
||||||
|
that.refresh = function() {
|
||||||
|
|
||||||
|
that.pkey = IPA.nav.get_state(that.entity.name+'-pkey');
|
||||||
|
|
||||||
|
if (!that.pkey && that.entity.redirect_facet) {
|
||||||
that.redirect();
|
that.redirect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var command = that.create_refresh_command();
|
||||||
|
|
||||||
command.on_success = function(data, text_status, xhr) {
|
command.on_success = function(data, text_status, xhr) {
|
||||||
that.load(data.result.result);
|
that.load(data);
|
||||||
};
|
};
|
||||||
|
|
||||||
command.on_error = that.on_error;
|
command.on_error = function(xhr, text_status, error_thrown) {
|
||||||
|
that.redirect_error(error_thrown);
|
||||||
if (that.pre_execute_hook) {
|
that.report_error(error_thrown);
|
||||||
that.pre_execute_hook(command);
|
};
|
||||||
}
|
|
||||||
|
|
||||||
command.execute();
|
command.execute();
|
||||||
};
|
};
|
||||||
@ -733,7 +723,9 @@ IPA.details_facet = function(spec) {
|
|||||||
|
|
||||||
that.init();
|
that.init();
|
||||||
|
|
||||||
that.details_facet_create_content = that.create_content;
|
// methods that should be invoked by subclasses
|
||||||
|
that.details_facet_create_update_command = that.create_update_command;
|
||||||
|
that.details_facet_create_refresh_command = that.create_refresh_command;
|
||||||
that.details_facet_load = that.load;
|
that.details_facet_load = that.load;
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
|
@ -496,174 +496,158 @@ IPA.dns.record_entity = function(spec) {
|
|||||||
|
|
||||||
that.builder.containing_entity('dnszone').
|
that.builder.containing_entity('dnszone').
|
||||||
details_facet({
|
details_facet({
|
||||||
post_update_hook:function(data){
|
factory: IPA.dns.record_details_facet,
|
||||||
var result = data.result.result;
|
|
||||||
if (result.idnsname) {
|
|
||||||
this.load(result);
|
|
||||||
} else {
|
|
||||||
this.reset();
|
|
||||||
var dialog = IPA.dnsrecord_redirection_dialog();
|
|
||||||
dialog.open(this.container);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
disable_breadcrumb: false,
|
disable_breadcrumb: false,
|
||||||
sections:[
|
sections: [
|
||||||
{
|
{
|
||||||
name:'identity',
|
name: 'identity',
|
||||||
label: IPA.messages.details.identity,
|
label: IPA.messages.details.identity,
|
||||||
fields:[
|
fields: [
|
||||||
{
|
{
|
||||||
type: 'dnsrecord_host_link',
|
type: 'dnsrecord_host_link',
|
||||||
name: 'idnsname',
|
name: 'idnsname',
|
||||||
other_entity:'host',
|
other_entity: 'host',
|
||||||
label:IPA.get_entity_param(
|
label: IPA.get_entity_param(
|
||||||
'dnsrecord', 'idnsname').label
|
'dnsrecord', 'idnsname').label
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name:'standard',
|
name: 'standard',
|
||||||
label:IPA.messages.objects.dnsrecord.standard,
|
label: IPA.messages.objects.dnsrecord.standard,
|
||||||
fields:[
|
fields: [
|
||||||
{
|
{
|
||||||
type: 'multivalued',
|
type: 'multivalued',
|
||||||
name: 'arecord',
|
name: 'arecord',
|
||||||
metadata: {primary_key: false},
|
metadata: { primary_key: false },
|
||||||
label:'A'
|
label: 'A'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'multivalued',
|
type: 'multivalued',
|
||||||
name: 'aaaarecord',
|
name: 'aaaarecord',
|
||||||
metadata: {primary_key: false},
|
metadata: { primary_key: false },
|
||||||
label:'AAAA'
|
label: 'AAAA'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'multivalued',
|
type: 'multivalued',
|
||||||
name: 'ptrrecord',
|
name: 'ptrrecord',
|
||||||
metadata: {primary_key: false},
|
metadata: { primary_key: false },
|
||||||
label:'PTR'
|
label: 'PTR'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'multivalued',
|
type: 'multivalued',
|
||||||
name: 'srvrecord',
|
name: 'srvrecord',
|
||||||
metadata: {primary_key: false},
|
metadata: { primary_key: false },
|
||||||
label:'SRV'
|
label: 'SRV'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'multivalued',
|
type: 'multivalued',
|
||||||
name: 'txtrecord',
|
name: 'txtrecord',
|
||||||
metadata: {primary_key: false},
|
metadata: { primary_key: false },
|
||||||
label:'TXT'
|
label: 'TXT'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'multivalued',
|
type: 'multivalued',
|
||||||
name: 'cnamerecord',
|
name: 'cnamerecord',
|
||||||
metadata: {primary_key: false},
|
metadata: { primary_key: false },
|
||||||
label:'CNAME'
|
label: 'CNAME'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'multivalued',
|
type: 'multivalued',
|
||||||
label:'MX',
|
label:'MX',
|
||||||
metadata: {primary_key: false},
|
metadata: { primary_key: false },
|
||||||
name:"mxrecord"
|
name: 'mxrecord'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'multivalued',
|
type: 'multivalued',
|
||||||
label:'NS',
|
label:'NS',
|
||||||
metadata: {primary_key: false},
|
metadata: { primary_key: false },
|
||||||
name:"nsrecord"
|
name: 'nsrecord'
|
||||||
}
|
}
|
||||||
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name:'unusual',
|
name: 'other',
|
||||||
label:IPA.messages.objects.dnsrecord.other,
|
label: IPA.messages.objects.dnsrecord.other,
|
||||||
fields:[
|
fields: [
|
||||||
{
|
{
|
||||||
type: 'multivalued',
|
type: 'multivalued',
|
||||||
label:'AFSDB',
|
name: 'afsdbrecord',
|
||||||
metadata: {primary_key: false},
|
metadata: { primary_key: false },
|
||||||
name: "afsdbrecord"
|
label: 'AFSDB'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'multivalued',
|
type: 'multivalued',
|
||||||
label:'CERT',
|
name: 'certrecord',
|
||||||
metadata: {primary_key: false},
|
metadata: { primary_key: false },
|
||||||
name:"certrecord"
|
label: 'CERT'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'multivalued',
|
type: 'multivalued',
|
||||||
label:'DNAME',
|
name: 'dnamerecord',
|
||||||
metadata: {primary_key: false},
|
metadata: { primary_key: false },
|
||||||
name:"dnamerecord"
|
label: 'DNAME'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'multivalued',
|
type: 'multivalued',
|
||||||
label:'DSRECORD',
|
name: 'dsrecord',
|
||||||
metadata: {primary_key: false},
|
metadata: { primary_key: false },
|
||||||
name:"dsrecord"
|
label: 'DSRECORD'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'multivalued',
|
type: 'multivalued',
|
||||||
label:'KEY',
|
name: 'keyrecord',
|
||||||
metadata: {primary_key: false},
|
metadata: { primary_key: false },
|
||||||
name:"keyrecord"
|
label: 'KEY'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'multivalued',
|
type: 'multivalued',
|
||||||
label:'KX',
|
name: 'kxrecord',
|
||||||
metadata: {primary_key: false},
|
metadata: { primary_key: false },
|
||||||
name:"kxrecord"
|
label: 'KX'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'multivalued',
|
type: 'multivalued',
|
||||||
label:'LOC',
|
name: 'locrecord',
|
||||||
metadata: {primary_key: false},
|
metadata: { primary_key: false },
|
||||||
name:"locrecord"
|
label: 'LOC'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'multivalued',
|
type: 'multivalued',
|
||||||
label:'NAPTR',
|
name: 'naptrrecord',
|
||||||
name:"naptrrecord"
|
metadata: { primary_key: false },
|
||||||
|
label: 'NAPTR'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'multivalued',
|
type: 'multivalued',
|
||||||
label:'NSEC',
|
name: 'nsecrecord',
|
||||||
metadata: {primary_key: false},
|
metadata: { primary_key: false },
|
||||||
name:"nsecrecord"
|
label: 'NSEC'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'multivalued',
|
type: 'multivalued',
|
||||||
label:'RRSIG',
|
name: 'rrsigrecord',
|
||||||
metadata: {primary_key: false},
|
metadata: { primary_key: false },
|
||||||
name:"rrsigrecord"
|
label: 'RRSIG'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'multivalued',
|
type: 'multivalued',
|
||||||
label:'SIG',
|
name: 'sigrecord',
|
||||||
metadata: {primary_key: false},
|
metadata: { primary_key: false },
|
||||||
name:"sigrecord"
|
label: 'SIG'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'multivalued',
|
type: 'multivalued',
|
||||||
label:'SSHFP',
|
name: 'sshfprecord',
|
||||||
metadata: {primary_key: false},
|
metadata: { primary_key: false },
|
||||||
name:"sshfprecord"
|
label: 'SSHFP'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}).
|
}).
|
||||||
adder_dialog({
|
adder_dialog({
|
||||||
pre_execute_hook: function(command) {
|
factory: IPA.dns.record_adder_dialog,
|
||||||
var record_type = command.options.record_type;
|
|
||||||
var record_data = command.options.record_data;
|
|
||||||
|
|
||||||
delete command.options.record_type;
|
|
||||||
delete command.options.record_data;
|
|
||||||
command.options[record_type] = record_data;
|
|
||||||
},
|
|
||||||
fields: [
|
fields: [
|
||||||
'idnsname',
|
'idnsname',
|
||||||
{
|
{
|
||||||
@ -684,6 +668,47 @@ IPA.dns.record_entity = function(spec) {
|
|||||||
return that;
|
return that;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
IPA.dns.record_adder_dialog = function(spec) {
|
||||||
|
|
||||||
|
var that = IPA.entity_adder_dialog(spec);
|
||||||
|
|
||||||
|
that.create_add_command = function(record) {
|
||||||
|
|
||||||
|
var command = that.entity_adder_dialog_create_add_command(record);
|
||||||
|
|
||||||
|
var record_type = command.options.record_type;
|
||||||
|
var record_data = command.options.record_data;
|
||||||
|
|
||||||
|
delete command.options.record_type;
|
||||||
|
delete command.options.record_data;
|
||||||
|
|
||||||
|
command.options[record_type] = record_data;
|
||||||
|
|
||||||
|
return command;
|
||||||
|
};
|
||||||
|
|
||||||
|
return that;
|
||||||
|
};
|
||||||
|
|
||||||
|
IPA.dns.record_details_facet = function(spec) {
|
||||||
|
|
||||||
|
var that = IPA.details_facet(spec);
|
||||||
|
|
||||||
|
that.on_update_success = function(data, text_status, xhr) {
|
||||||
|
|
||||||
|
if (!data.result.result.idnsname) {
|
||||||
|
that.reset();
|
||||||
|
var dialog = IPA.dnsrecord_redirection_dialog();
|
||||||
|
dialog.open(that.container);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
that.load(data);
|
||||||
|
};
|
||||||
|
|
||||||
|
return that;
|
||||||
|
};
|
||||||
|
|
||||||
IPA.dnsrecord_redirection_dialog = function(spec) {
|
IPA.dnsrecord_redirection_dialog = function(spec) {
|
||||||
spec = spec || {};
|
spec = spec || {};
|
||||||
spec.title = spec.title || IPA.messages.dialogs.redirection;
|
spec.title = spec.title || IPA.messages.dialogs.redirection;
|
||||||
|
@ -85,8 +85,8 @@ IPA.entitle.entity = function(spec) {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}).
|
}).
|
||||||
search_facet({
|
facet({
|
||||||
factory: IPA.entitle.search_facet,
|
factory: IPA.entitle.certificates_facet,
|
||||||
name: 'certificates',
|
name: 'certificates',
|
||||||
label: IPA.messages.objects.entitle.certificates,
|
label: IPA.messages.objects.entitle.certificates,
|
||||||
facet_group: 'certificates',
|
facet_group: 'certificates',
|
||||||
@ -365,7 +365,7 @@ IPA.entitle.details_facet = function(spec) {
|
|||||||
// that.register_offline_button.css('display', 'none');
|
// that.register_offline_button.css('display', 'none');
|
||||||
}
|
}
|
||||||
|
|
||||||
that.load(data.result.result);
|
that.load(data);
|
||||||
|
|
||||||
summary.empty();
|
summary.empty();
|
||||||
}
|
}
|
||||||
@ -375,13 +375,15 @@ IPA.entitle.details_facet = function(spec) {
|
|||||||
that.register_online_button.css('display', 'inline');
|
that.register_online_button.css('display', 'inline');
|
||||||
// that.register_offline_button.css('display', 'inline');
|
// that.register_offline_button.css('display', 'inline');
|
||||||
|
|
||||||
var result = {
|
var data = {};
|
||||||
|
data.result = {};
|
||||||
|
data.result.result = {
|
||||||
uuid: '',
|
uuid: '',
|
||||||
product: '',
|
product: '',
|
||||||
quantity: 0,
|
quantity: 0,
|
||||||
consumed: 0
|
consumed: 0
|
||||||
};
|
};
|
||||||
that.load(result);
|
that.load(data);
|
||||||
|
|
||||||
summary.empty();
|
summary.empty();
|
||||||
summary.append(error_thrown.name+': '+error_thrown.message);
|
summary.append(error_thrown.name+': '+error_thrown.message);
|
||||||
@ -395,13 +397,17 @@ IPA.entitle.details_facet = function(spec) {
|
|||||||
return that;
|
return that;
|
||||||
};
|
};
|
||||||
|
|
||||||
IPA.entitle.search_facet = function(spec) {
|
IPA.entitle.certificates_facet = function(spec) {
|
||||||
|
|
||||||
spec = spec || {};
|
spec = spec || {};
|
||||||
spec.disable_facet_tabs = false;
|
spec.disable_facet_tabs = false;
|
||||||
spec.selectable = false;
|
spec.selectable = false;
|
||||||
|
|
||||||
var that = IPA.search_facet(spec);
|
var that = IPA.table_facet(spec);
|
||||||
|
|
||||||
|
var init = function() {
|
||||||
|
that.init_table(that.entity);
|
||||||
|
};
|
||||||
|
|
||||||
that.create_header = function(container) {
|
that.create_header = function(container) {
|
||||||
|
|
||||||
@ -455,16 +461,7 @@ IPA.entitle.search_facet = function(spec) {
|
|||||||
that.import_button.css('display', 'inline');
|
that.import_button.css('display', 'inline');
|
||||||
}
|
}
|
||||||
|
|
||||||
that.load(data.result.result);
|
that.load(data);
|
||||||
|
|
||||||
var summary = $('span[name=summary]', that.table.tfoot).empty();
|
|
||||||
if (data.result.truncated) {
|
|
||||||
var message = IPA.messages.search.truncated;
|
|
||||||
message = message.replace('${counter}', data.result.count);
|
|
||||||
summary.text(message);
|
|
||||||
} else {
|
|
||||||
summary.text(data.result.summary);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function on_error(xhr, text_status, error_thrown) {
|
function on_error(xhr, text_status, error_thrown) {
|
||||||
@ -472,8 +469,7 @@ IPA.entitle.search_facet = function(spec) {
|
|||||||
that.consume_button.css('display', 'none');
|
that.consume_button.css('display', 'none');
|
||||||
that.import_button.css('display', 'inline');
|
that.import_button.css('display', 'inline');
|
||||||
|
|
||||||
var summary = $('span[name=summary]', that.table.tfoot).empty();
|
that.table.summary.text(error_thrown.name+': '+error_thrown.message);
|
||||||
summary.append(error_thrown.name+': '+error_thrown.message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
that.entity.get_status(
|
that.entity.get_status(
|
||||||
@ -485,6 +481,8 @@ IPA.entitle.search_facet = function(spec) {
|
|||||||
on_error);
|
on_error);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
init();
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ IPA.facet = function(spec) {
|
|||||||
|
|
||||||
that.load = function(data) {
|
that.load = function(data) {
|
||||||
that.data = data;
|
that.data = data;
|
||||||
that.header.load(data);
|
that.header.load(data.result.result);
|
||||||
};
|
};
|
||||||
|
|
||||||
that.clear = function() {
|
that.clear = function() {
|
||||||
@ -141,21 +141,20 @@ IPA.facet = function(spec) {
|
|||||||
that.entity.redirect_facet);
|
that.entity.redirect_facet);
|
||||||
};
|
};
|
||||||
|
|
||||||
var redirect_errors = [4001];
|
var redirect_error_codes = [4001];
|
||||||
|
|
||||||
that.on_error = function(xhr, text_status, error_thrown) {
|
that.redirect_error = function(error_thrown) {
|
||||||
|
|
||||||
/*If the error is in talking to the server, don't attempt to redirect,
|
/*If the error is in talking to the server, don't attempt to redirect,
|
||||||
as there is nothing any other facet can do either. */
|
as there is nothing any other facet can do either. */
|
||||||
if (that.entity.redirect_facet) {
|
if (that.entity.redirect_facet) {
|
||||||
for (var i=0; i<redirect_errors.length; i++) {
|
for (var i=0; i<redirect_error_codes.length; i++) {
|
||||||
if (error_thrown.code === redirect_errors[i]) {
|
if (error_thrown.code === redirect_error_codes[i]) {
|
||||||
that.redirect();
|
that.redirect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
that.report_error(error_thrown);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -439,22 +438,130 @@ IPA.table_facet = function(spec) {
|
|||||||
return that;
|
return that;
|
||||||
};
|
};
|
||||||
|
|
||||||
that.load = function(result) {
|
that.create_content = function(container) {
|
||||||
that.facet_load(result);
|
that.table.create(container);
|
||||||
|
};
|
||||||
|
|
||||||
|
that.load = function(data) {
|
||||||
|
that.facet_load(data);
|
||||||
|
|
||||||
that.table.current_page = 1;
|
that.table.current_page = 1;
|
||||||
that.table.total_pages = 1;
|
that.table.total_pages = 1;
|
||||||
|
|
||||||
if (that.pagination) {
|
if (that.pagination) {
|
||||||
that.table.load_page(result);
|
that.load_page(data);
|
||||||
} else {
|
} else {
|
||||||
that.table.load(result);
|
that.load_all(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
that.table.current_page_input.val(that.table.current_page);
|
that.table.current_page_input.val(that.table.current_page);
|
||||||
that.table.total_pages_span.text(that.table.total_pages);
|
that.table.total_pages_span.text(that.table.total_pages);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
that.load_all = function(data) {
|
||||||
|
|
||||||
|
that.table.empty();
|
||||||
|
|
||||||
|
var result = data.result.result;
|
||||||
|
for (var i=0; i<result.length; i++) {
|
||||||
|
var record = that.table.get_record(result[i], 0);
|
||||||
|
that.table.add_record(record);
|
||||||
|
}
|
||||||
|
|
||||||
that.table.unselect_all();
|
that.table.unselect_all();
|
||||||
|
|
||||||
|
if (data.result.truncated) {
|
||||||
|
var message = IPA.messages.search.truncated;
|
||||||
|
message = message.replace('${counter}', data.result.count);
|
||||||
|
that.table.summary.text(message);
|
||||||
|
} else {
|
||||||
|
that.table.summary.text(data.result.summary);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
that.get_pkeys = function(data){
|
||||||
|
return [];
|
||||||
|
};
|
||||||
|
|
||||||
|
that.load_page = function(data) {
|
||||||
|
|
||||||
|
that.pkeys = that.get_pkeys(data);
|
||||||
|
|
||||||
|
if (that.pkeys.length) {
|
||||||
|
that.table.total_pages =
|
||||||
|
Math.ceil(that.pkeys.length / that.table.page_length);
|
||||||
|
} else {
|
||||||
|
that.table.total_pages = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete that.table.current_page;
|
||||||
|
|
||||||
|
var state = {};
|
||||||
|
var page = parseInt(IPA.nav.get_state(that.entity_name+'-page'), 10) || 1;
|
||||||
|
if (page < 1) {
|
||||||
|
state[that.entity_name+'-page'] = 1;
|
||||||
|
IPA.nav.push_state(state);
|
||||||
|
return;
|
||||||
|
} else if (page > that.table.total_pages) {
|
||||||
|
state[that.entity_name+'-page'] = that.table.total_pages;
|
||||||
|
IPA.nav.push_state(state);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
that.table.current_page = page;
|
||||||
|
|
||||||
|
if (!that.pkeys || !that.pkeys.length) {
|
||||||
|
that.table.empty();
|
||||||
|
that.table.summary.text(IPA.messages.association.no_entries);
|
||||||
|
that.table.unselect_all();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
that.pkeys.sort();
|
||||||
|
var total = that.pkeys.length;
|
||||||
|
|
||||||
|
var start = (that.table.current_page - 1) * that.table.page_length + 1;
|
||||||
|
var end = that.table.current_page * that.table.page_length;
|
||||||
|
end = end > total ? total : end;
|
||||||
|
|
||||||
|
var summary = IPA.messages.association.paging;
|
||||||
|
summary = summary.replace('${start}', start);
|
||||||
|
summary = summary.replace('${end}', end);
|
||||||
|
summary = summary.replace('${total}', total);
|
||||||
|
that.table.summary.text(summary);
|
||||||
|
|
||||||
|
that.values = that.pkeys.slice(start-1, end);
|
||||||
|
|
||||||
|
var columns = that.table.columns.values;
|
||||||
|
if (columns.length == 1) { // show pkey only
|
||||||
|
var name = columns[0].name;
|
||||||
|
that.table.empty();
|
||||||
|
for (var i=0; i<that.values.length; i++) {
|
||||||
|
var record = {};
|
||||||
|
record[name] = that.values[i];
|
||||||
|
that.table.add_record(record);
|
||||||
|
}
|
||||||
|
that.table.unselect_all();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get and show additional fields
|
||||||
|
that.get_records(
|
||||||
|
function(data, text_status, xhr) {
|
||||||
|
var results = data.result.results;
|
||||||
|
that.table.empty();
|
||||||
|
for (var i=0; i<results.length; i++) {
|
||||||
|
var record = results[i].result;
|
||||||
|
that.table.add_record(record);
|
||||||
|
}
|
||||||
|
that.table.unselect_all();
|
||||||
|
},
|
||||||
|
function(xhr, text_status, error_thrown) {
|
||||||
|
that.table.empty();
|
||||||
|
var summary = that.table.summary.empty();
|
||||||
|
summary.append(error_thrown.name+': '+error_thrown.message);
|
||||||
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
that.get_records_command_name = function() {
|
that.get_records_command_name = function() {
|
||||||
@ -518,7 +625,11 @@ IPA.table_facet = function(spec) {
|
|||||||
for (var i=0; i<columns.length; i++) {
|
for (var i=0; i<columns.length; i++) {
|
||||||
var column = columns[i];
|
var column = columns[i];
|
||||||
|
|
||||||
if (column.link) {
|
var metadata = IPA.get_entity_param(entity.name, column.name);
|
||||||
|
column.primary_key = metadata && metadata.primary_key;
|
||||||
|
column.link = (column.link === undefined ? true : column.link) && column.primary_key;
|
||||||
|
|
||||||
|
if (column.link && column.primary_key) {
|
||||||
column.link_handler = function(value) {
|
column.link_handler = function(value) {
|
||||||
IPA.nav.show_page(entity.name, 'default', value);
|
IPA.nav.show_page(entity.name, 'default', value);
|
||||||
return false;
|
return false;
|
||||||
@ -558,95 +669,6 @@ IPA.table_facet = function(spec) {
|
|||||||
state[that.entity_name+'-page'] = page;
|
state[that.entity_name+'-page'] = page;
|
||||||
IPA.nav.push_state(state);
|
IPA.nav.push_state(state);
|
||||||
};
|
};
|
||||||
|
|
||||||
that.table.load = function(result) {
|
|
||||||
|
|
||||||
that.table.empty();
|
|
||||||
|
|
||||||
for (var i=0; i<result.length; i++) {
|
|
||||||
var record = that.table.get_record(result[i], 0);
|
|
||||||
that.table.add_record(record);
|
|
||||||
}
|
|
||||||
|
|
||||||
that.table.unselect_all();
|
|
||||||
};
|
|
||||||
|
|
||||||
that.table.load_page = function(result) {
|
|
||||||
|
|
||||||
that.load_pkeys(result);
|
|
||||||
|
|
||||||
if (that.pkeys.length) {
|
|
||||||
that.table.total_pages =
|
|
||||||
Math.ceil(that.pkeys.length / that.table.page_length);
|
|
||||||
} else {
|
|
||||||
that.table.total_pages = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
delete that.table.current_page;
|
|
||||||
|
|
||||||
var state = {};
|
|
||||||
var page = parseInt(IPA.nav.get_state(that.entity_name+'-page'), 10) || 1;
|
|
||||||
if (page < 1) {
|
|
||||||
state[that.entity_name+'-page'] = 1;
|
|
||||||
IPA.nav.push_state(state);
|
|
||||||
return;
|
|
||||||
} else if (page > that.table.total_pages) {
|
|
||||||
state[that.entity_name+'-page'] = that.table.total_pages;
|
|
||||||
IPA.nav.push_state(state);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
that.table.current_page = page;
|
|
||||||
|
|
||||||
if (!that.pkeys || !that.pkeys.length) {
|
|
||||||
that.table.empty();
|
|
||||||
that.table.summary.text(IPA.messages.association.no_entries);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
that.pkeys.sort();
|
|
||||||
var total = that.pkeys.length;
|
|
||||||
|
|
||||||
var start = (that.table.current_page - 1) * that.table.page_length + 1;
|
|
||||||
var end = that.table.current_page * that.table.page_length;
|
|
||||||
end = end > total ? total : end;
|
|
||||||
|
|
||||||
var summary = IPA.messages.association.paging;
|
|
||||||
summary = summary.replace('${start}', start);
|
|
||||||
summary = summary.replace('${end}', end);
|
|
||||||
summary = summary.replace('${total}', total);
|
|
||||||
that.table.summary.text(summary);
|
|
||||||
|
|
||||||
that.values = that.pkeys.slice(start-1, end);
|
|
||||||
|
|
||||||
var columns = that.table.columns.values;
|
|
||||||
if (columns.length == 1) { // show pkey only
|
|
||||||
var name = columns[0].name;
|
|
||||||
that.table.empty();
|
|
||||||
for (var i=0; i<that.values.length; i++) {
|
|
||||||
var entry = {};
|
|
||||||
entry[name] = that.values[i];
|
|
||||||
that.table.add_record(entry);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get and show additional fields
|
|
||||||
that.get_records(
|
|
||||||
function(data, text_status, xhr) {
|
|
||||||
var results = data.result.results;
|
|
||||||
that.table.empty();
|
|
||||||
for (var i=0; i<results.length; i++) {
|
|
||||||
var record = results[i].result;
|
|
||||||
that.table.add_record(record);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
function(xhr, text_status, error_thrown) {
|
|
||||||
that.table.empty();
|
|
||||||
var summary = that.table.summary.empty();
|
|
||||||
summary.append(error_thrown.name+': '+error_thrown.message);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
init();
|
init();
|
||||||
@ -702,14 +724,16 @@ IPA.facet_builder = function(entity) {
|
|||||||
|
|
||||||
that.build_facet = function(spec) {
|
that.build_facet = function(spec) {
|
||||||
|
|
||||||
var type = spec.type || 'details';
|
|
||||||
//do common logic
|
//do common logic
|
||||||
spec.entity = entity;
|
spec.entity = entity;
|
||||||
|
|
||||||
//prepare spec based on type
|
//prepare spec based on type
|
||||||
var prepare_method = that.prepare_methods[type];
|
var type = spec.type;
|
||||||
if(prepare_method) {
|
if (type) {
|
||||||
prepare_method.call(that, spec);
|
var prepare_method = that.prepare_methods[type];
|
||||||
|
if (prepare_method) {
|
||||||
|
prepare_method.call(that, spec);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//add facet
|
//add facet
|
||||||
|
@ -58,15 +58,11 @@ IPA.group.entity = function(spec) {
|
|||||||
association_facet({
|
association_facet({
|
||||||
name: 'member_user',
|
name: 'member_user',
|
||||||
columns:[
|
columns:[
|
||||||
{
|
'uid',
|
||||||
name: 'uid',
|
'uidnumber',
|
||||||
primary_key: true,
|
'mail',
|
||||||
link: true
|
'telephonenumber',
|
||||||
},
|
'title'
|
||||||
{name: 'uidnumber'},
|
|
||||||
{name: 'mail'},
|
|
||||||
{name: 'telephonenumber'},
|
|
||||||
{name: 'title'}
|
|
||||||
],
|
],
|
||||||
adder_columns:[
|
adder_columns:[
|
||||||
{
|
{
|
||||||
|
@ -89,12 +89,8 @@ IPA.hbac.service_entity = function(spec) {
|
|||||||
name: 'memberof_hbacsvcgroup',
|
name: 'memberof_hbacsvcgroup',
|
||||||
associator: IPA.serial_associator,
|
associator: IPA.serial_associator,
|
||||||
columns:[
|
columns:[
|
||||||
{
|
'cn',
|
||||||
name: 'cn',
|
'description'
|
||||||
primary_key: true,
|
|
||||||
link: true
|
|
||||||
},
|
|
||||||
{ name: 'description' }
|
|
||||||
],
|
],
|
||||||
adder_columns: [
|
adder_columns: [
|
||||||
{
|
{
|
||||||
@ -154,12 +150,8 @@ IPA.hbac.service_group_entity = function(spec) {
|
|||||||
association_facet({
|
association_facet({
|
||||||
name: 'member_hbacsvc',
|
name: 'member_hbacsvc',
|
||||||
columns:[
|
columns:[
|
||||||
{
|
'cn',
|
||||||
name: 'cn',
|
'description'
|
||||||
primary_key: true,
|
|
||||||
link: true
|
|
||||||
},
|
|
||||||
{ name: 'description' }
|
|
||||||
],
|
],
|
||||||
adder_columns: [
|
adder_columns: [
|
||||||
{
|
{
|
||||||
|
@ -48,22 +48,9 @@ IPA.search_facet = function(spec) {
|
|||||||
|
|
||||||
that.managed_entity = IPA.get_entity(that.managed_entity_name);
|
that.managed_entity = IPA.get_entity(that.managed_entity_name);
|
||||||
|
|
||||||
var columns = that.columns.values;
|
|
||||||
for (var i=0; i<columns.length; i++) {
|
|
||||||
var column = columns[i];
|
|
||||||
|
|
||||||
var metadata = IPA.get_entity_param(that.managed_entity_name, column.name);
|
|
||||||
column.primary_key = metadata && metadata.primary_key;
|
|
||||||
column.link = column.primary_key;
|
|
||||||
}
|
|
||||||
|
|
||||||
that.init_table(that.managed_entity);
|
that.init_table(that.managed_entity);
|
||||||
};
|
};
|
||||||
|
|
||||||
that.create_content = function(container) {
|
|
||||||
that.table.create(container);
|
|
||||||
};
|
|
||||||
|
|
||||||
that.create_header = function(container) {
|
that.create_header = function(container) {
|
||||||
|
|
||||||
that.facet_create_header(container);
|
that.facet_create_header(container);
|
||||||
@ -124,7 +111,6 @@ IPA.search_facet = function(spec) {
|
|||||||
}).appendTo(that.controls);
|
}).appendTo(that.controls);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
that.show = function() {
|
that.show = function() {
|
||||||
that.facet_show();
|
that.facet_show();
|
||||||
|
|
||||||
@ -178,45 +164,24 @@ IPA.search_facet = function(spec) {
|
|||||||
IPA.nav.push_state(state);
|
IPA.nav.push_state(state);
|
||||||
};
|
};
|
||||||
|
|
||||||
that.load_pkeys = function(result) {
|
that.get_pkeys = function(data) {
|
||||||
that.pkeys = [];
|
var result = data.result.result;
|
||||||
|
var pkey_name = that.managed_entity.metadata.primary_key;
|
||||||
|
var pkeys = [];
|
||||||
for (var i=0; i<result.length; i++) {
|
for (var i=0; i<result.length; i++) {
|
||||||
var record = result[i];
|
var record = result[i];
|
||||||
var values = record[that.managed_entity.metadata.primary_key];
|
var values = record[pkey_name];
|
||||||
that.pkeys.push(values[0]);
|
pkeys.push(values[0]);
|
||||||
}
|
}
|
||||||
return that.pkeys;
|
return pkeys;
|
||||||
};
|
|
||||||
|
|
||||||
that.on_error = function(xhr, text_status, error_thrown) {
|
|
||||||
that.report_error(error_thrown);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
that.get_search_command_name = function() {
|
that.get_search_command_name = function() {
|
||||||
return that.managed_entity.name + '_find' + (that.pagination ? "_pkeys" : "");
|
return that.managed_entity.name + '_find' + (that.pagination ? '_pkeys' : '');
|
||||||
};
|
};
|
||||||
|
|
||||||
that.refresh = function() {
|
that.refresh = function() {
|
||||||
|
|
||||||
function on_success(data, text_status, xhr) {
|
|
||||||
|
|
||||||
that.load(data.result.result);
|
|
||||||
|
|
||||||
if (data.result.truncated) {
|
|
||||||
var message = IPA.messages.search.truncated;
|
|
||||||
message = message.replace('${counter}', data.result.count);
|
|
||||||
that.table.summary.text(message);
|
|
||||||
} else {
|
|
||||||
that.table.summary.text(data.result.summary);
|
|
||||||
}
|
|
||||||
|
|
||||||
that.table.current_page_input.val(that.table.current_page);
|
|
||||||
that.table.total_pages_span.text(that.table.total_pages);
|
|
||||||
|
|
||||||
that.filter.focus();
|
|
||||||
that.select_changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
var filter = [];
|
var filter = [];
|
||||||
var current_entity = that.managed_entity;
|
var current_entity = that.managed_entity;
|
||||||
filter.unshift(IPA.nav.get_state(current_entity.name+'-filter'));
|
filter.unshift(IPA.nav.get_state(current_entity.name+'-filter'));
|
||||||
@ -233,9 +198,7 @@ IPA.search_facet = function(spec) {
|
|||||||
args: filter,
|
args: filter,
|
||||||
options: {
|
options: {
|
||||||
all: that.search_all
|
all: that.search_all
|
||||||
},
|
}
|
||||||
on_success: on_success,
|
|
||||||
on_error: that.on_error
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (that.pagination) {
|
if (that.pagination) {
|
||||||
@ -243,6 +206,15 @@ IPA.search_facet = function(spec) {
|
|||||||
command.set_option('sizelimit', 0);
|
command.set_option('sizelimit', 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
command.on_success = function(data, text_status, xhr) {
|
||||||
|
that.filter.focus();
|
||||||
|
that.load(data);
|
||||||
|
};
|
||||||
|
|
||||||
|
command.on_error = function(xhr, text_status, error_thrown) {
|
||||||
|
that.report_error(error_thrown);
|
||||||
|
};
|
||||||
|
|
||||||
command.execute();
|
command.execute();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -260,7 +232,6 @@ IPA.search_facet = function(spec) {
|
|||||||
init();
|
init();
|
||||||
|
|
||||||
// methods that should be invoked by subclasses
|
// methods that should be invoked by subclasses
|
||||||
that.search_facet_create_content = that.create_content;
|
|
||||||
that.search_facet_refresh = that.refresh;
|
that.search_facet_refresh = that.refresh;
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
|
@ -87,12 +87,8 @@ IPA.sudo.command_entity = function(spec) {
|
|||||||
name: 'memberof_sudocmdgroup',
|
name: 'memberof_sudocmdgroup',
|
||||||
associator: IPA.serial_associator,
|
associator: IPA.serial_associator,
|
||||||
columns:[
|
columns:[
|
||||||
{
|
'cn',
|
||||||
name: 'cn',
|
'description'
|
||||||
primary_key: true,
|
|
||||||
link: true
|
|
||||||
},
|
|
||||||
{ name: 'description' }
|
|
||||||
],
|
],
|
||||||
adder_columns: [
|
adder_columns: [
|
||||||
{
|
{
|
||||||
@ -152,12 +148,8 @@ IPA.sudo.command_group_entity = function(spec) {
|
|||||||
association_facet({
|
association_facet({
|
||||||
name: 'member_sudocmd',
|
name: 'member_sudocmd',
|
||||||
columns: [
|
columns: [
|
||||||
{
|
'sudocmd',
|
||||||
name: 'sudocmd',
|
'description'
|
||||||
primary_key: true,
|
|
||||||
link: true
|
|
||||||
},
|
|
||||||
{ name: 'description' }
|
|
||||||
],
|
],
|
||||||
adder_columns: [
|
adder_columns: [
|
||||||
{
|
{
|
||||||
|
@ -185,8 +185,13 @@ var get_visible_rows = function(section) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
test("Testing aci grouptarget.", function() {
|
test("Testing aci grouptarget.", function() {
|
||||||
var sample_data_filter_only = { targetgroup:"ipausers" };
|
var data = {};
|
||||||
target_facet.load(sample_data_filter_only);
|
data.result = {};
|
||||||
|
data.result.result = {
|
||||||
|
targetgroup: 'ipausers'
|
||||||
|
};
|
||||||
|
|
||||||
|
target_facet.load(data);
|
||||||
|
|
||||||
same(target_widget.target, 'targetgroup' , 'group control selected');
|
same(target_widget.target, 'targetgroup' , 'group control selected');
|
||||||
|
|
||||||
@ -200,9 +205,13 @@ test("Testing aci grouptarget.", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("Testing type target.", function() {
|
test("Testing type target.", function() {
|
||||||
var sample_data = { type:"hostgroup" };
|
var data = {};
|
||||||
|
data.result = {};
|
||||||
|
data.result.result = {
|
||||||
|
type: 'hostgroup'
|
||||||
|
};
|
||||||
|
|
||||||
target_facet.load(sample_data);
|
target_facet.load(data);
|
||||||
|
|
||||||
same(target_widget.target, 'type', 'type selected');
|
same(target_widget.target, 'type', 'type selected');
|
||||||
|
|
||||||
@ -210,7 +219,7 @@ test("Testing type target.", function() {
|
|||||||
var record = {};
|
var record = {};
|
||||||
target_facet.save(record);
|
target_facet.save(record);
|
||||||
|
|
||||||
same(record.type[0], sample_data.type,
|
same(record.type[0], data.result.result.type,
|
||||||
"saved type matches sample data");
|
"saved type matches sample data");
|
||||||
|
|
||||||
same(get_visible_rows(target_widget), ['type', 'attrs'],
|
same(get_visible_rows(target_widget), ['type', 'attrs'],
|
||||||
@ -223,9 +232,13 @@ test("Testing type target.", function() {
|
|||||||
|
|
||||||
test("Testing filter target.", function() {
|
test("Testing filter target.", function() {
|
||||||
|
|
||||||
var sample_data = { filter:"somevalue" };
|
var data = {};
|
||||||
|
data.result = {};
|
||||||
|
data.result.result = {
|
||||||
|
filter: 'somevalue'
|
||||||
|
};
|
||||||
|
|
||||||
target_facet.load(sample_data);
|
target_facet.load(data);
|
||||||
|
|
||||||
var record = {};
|
var record = {};
|
||||||
target_facet.save(record);
|
target_facet.save(record);
|
||||||
@ -234,21 +247,24 @@ test("Testing filter target.", function() {
|
|||||||
|
|
||||||
same(get_visible_rows(target_widget), ['filter'], 'filter row visible');
|
same(get_visible_rows(target_widget), ['filter'], 'filter row visible');
|
||||||
|
|
||||||
ok(record.filter[0], sample_data.filter, 'filter set correctly');
|
ok(record.filter[0], data.result.result.filter, 'filter set correctly');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
test("Testing subtree target.", function() {
|
test("Testing subtree target.", function() {
|
||||||
|
|
||||||
var sample_data = {
|
var data = {};
|
||||||
subtree:"ldap:///cn=*,cn=roles,cn=accounts,dc=example,dc=co"};
|
data.result = {};
|
||||||
|
data.result.result = {
|
||||||
|
subtree: 'ldap:///cn=*,cn=roles,cn=accounts,dc=example,dc=co'
|
||||||
|
};
|
||||||
|
|
||||||
target_facet.load(sample_data);
|
target_facet.load(data);
|
||||||
var record = {};
|
var record = {};
|
||||||
target_facet.save(record);
|
target_facet.save(record);
|
||||||
|
|
||||||
same(record.subtree[0], sample_data.subtree, 'subtree set correctly');
|
same(record.subtree[0], data.result.result.subtree, 'subtree set correctly');
|
||||||
|
|
||||||
same(get_visible_rows(target_widget), ['subtree'], 'subtree row visible');
|
same(get_visible_rows(target_widget), ['subtree'], 'subtree row visible');
|
||||||
});
|
});
|
||||||
|
@ -112,7 +112,9 @@ test("Testing IPA.details_section.create().", function() {
|
|||||||
|
|
||||||
test("Testing details lifecycle: create, load.", function(){
|
test("Testing details lifecycle: create, load.", function(){
|
||||||
|
|
||||||
var result = {};
|
var data = {};
|
||||||
|
data.result = {};
|
||||||
|
data.result.result = {};
|
||||||
|
|
||||||
IPA.command({
|
IPA.command({
|
||||||
entity: 'user',
|
entity: 'user',
|
||||||
@ -242,7 +244,7 @@ test("Testing details lifecycle: create, load.", function(){
|
|||||||
|
|
||||||
facet.create(facet_container);
|
facet.create(facet_container);
|
||||||
|
|
||||||
facet.load(result);
|
facet.load(data);
|
||||||
|
|
||||||
var contact = $('.details-section[name=contact]', facet_container);
|
var contact = $('.details-section[name=contact]', facet_container);
|
||||||
|
|
||||||
@ -314,10 +316,12 @@ test("Testing IPA.details_section_create again()",function() {
|
|||||||
var details = $("<div/>");
|
var details = $("<div/>");
|
||||||
container.append(details);
|
container.append(details);
|
||||||
|
|
||||||
var result = {};
|
var data = {};
|
||||||
|
data.result = {};
|
||||||
|
data.result.result = {};
|
||||||
|
|
||||||
section.create(container);
|
section.create(container);
|
||||||
facet.load(result);
|
facet.load(data);
|
||||||
|
|
||||||
var table = $('table', container);
|
var table = $('table', container);
|
||||||
|
|
||||||
|
@ -32,10 +32,7 @@ IPA.user.entity = function(spec) {
|
|||||||
that.init = function() {
|
that.init = function() {
|
||||||
that.entity_init();
|
that.entity_init();
|
||||||
|
|
||||||
var link = true;
|
var link = IPA.nav.name == 'self-service' ? false : undefined;
|
||||||
if (IPA.nav && IPA.nav.name == 'self-service') {
|
|
||||||
link = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
that.builder.search_facet({
|
that.builder.search_facet({
|
||||||
columns: [
|
columns: [
|
||||||
|
Loading…
Reference in New Issue
Block a user