2011-05-16 22:23:20 -05:00
|
|
|
/*jsl:import jquery.ordered-map.js */
|
2010-08-06 09:01:44 -05:00
|
|
|
/* Authors:
|
|
|
|
* Pavel Zuna <pzuna@redhat.com>
|
2011-01-14 11:16:25 -06:00
|
|
|
* Adam Young <ayoung@redhat.com>
|
|
|
|
* Endi Dewata <edewata@redhat.com>
|
2010-08-06 09:01:44 -05:00
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Red Hat
|
|
|
|
* see file 'COPYING' for use and warranty information
|
|
|
|
*
|
2010-12-09 06:59:11 -06:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
2010-08-06 09:01:44 -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-08-06 09:01:44 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2011-05-16 22:23:20 -05:00
|
|
|
/* REQUIRES: jquery.ordered-map.js */
|
2010-11-01 15:32:07 -05:00
|
|
|
/*global $:true, location:true */
|
2010-08-06 09:01:44 -05:00
|
|
|
|
2010-11-01 15:32:07 -05:00
|
|
|
var IPA = ( function () {
|
2010-08-06 09:01:44 -05:00
|
|
|
|
2010-11-01 15:32:07 -05:00
|
|
|
var that = {
|
|
|
|
jsonrpc_id: 0
|
|
|
|
};
|
2010-09-16 09:28:07 -05:00
|
|
|
|
2010-10-27 22:32:30 -05:00
|
|
|
that.use_static_files = false;
|
2010-11-15 12:20:07 -06:00
|
|
|
that.json_url = '/ipa/json';
|
|
|
|
if (that.use_static_files){
|
2011-01-12 13:47:29 -06:00
|
|
|
that.json_url = 'test/data';
|
2010-11-15 12:20:07 -06:00
|
|
|
}
|
|
|
|
|
2010-10-27 22:32:30 -05:00
|
|
|
that.ajax_options = {
|
|
|
|
type: 'POST',
|
|
|
|
contentType: 'application/json',
|
|
|
|
dataType: 'json',
|
|
|
|
async: true,
|
|
|
|
processData: false
|
|
|
|
};
|
|
|
|
|
|
|
|
that.metadata = {};
|
2011-02-16 12:46:59 -06:00
|
|
|
that.messages = {};
|
2010-11-17 21:15:09 -06:00
|
|
|
that.whoami = {};
|
|
|
|
|
2011-05-16 22:23:20 -05:00
|
|
|
that.entities = $.ordered_map();
|
2011-01-19 20:10:18 -06:00
|
|
|
that.entity_factories = {};
|
|
|
|
|
2011-04-12 02:13:30 -05:00
|
|
|
that.network_call_count = 0;
|
|
|
|
|
2010-10-27 22:32:30 -05:00
|
|
|
/* initialize the IPA JSON-RPC helper
|
|
|
|
* arguments:
|
|
|
|
* url - JSON-RPC URL to use (optional) */
|
2010-11-01 15:32:07 -05:00
|
|
|
that.init = function (url, use_static_files, on_success, on_error) {
|
|
|
|
if (url) {
|
2010-10-27 22:32:30 -05:00
|
|
|
that.json_url = url;
|
2010-11-01 15:32:07 -05:00
|
|
|
}
|
2010-10-27 22:32:30 -05:00
|
|
|
|
2010-11-01 15:32:07 -05:00
|
|
|
if (use_static_files) {
|
2010-10-27 22:32:30 -05:00
|
|
|
that.use_static_files = use_static_files;
|
2010-11-01 15:32:07 -05:00
|
|
|
}
|
2010-10-27 22:32:30 -05:00
|
|
|
|
|
|
|
$.ajaxSetup(that.ajax_options);
|
|
|
|
|
2011-04-12 02:13:30 -05:00
|
|
|
var batch = IPA.batch_command({
|
|
|
|
name: 'ipa_init',
|
2011-08-03 15:26:54 -05:00
|
|
|
retry: false,
|
2011-04-12 02:13:30 -05:00
|
|
|
on_success: on_success,
|
2011-08-03 15:26:54 -05:00
|
|
|
on_error: function(xhr, text_status, error_thrown) {
|
|
|
|
|
|
|
|
// On IE the request is missing after authentication,
|
|
|
|
// so the request needs to be resent.
|
|
|
|
if (error_thrown.name == 'IPA Error 909') {
|
|
|
|
batch.execute();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
var ajax = this;
|
|
|
|
|
|
|
|
var dialog = IPA.error_dialog({
|
|
|
|
xhr: xhr,
|
|
|
|
text_status: text_status,
|
|
|
|
error_thrown: error_thrown,
|
|
|
|
command: batch
|
|
|
|
});
|
|
|
|
|
|
|
|
dialog.on_cancel = function() {
|
|
|
|
dialog.close();
|
|
|
|
if (on_error) {
|
|
|
|
on_error.call(ajax, xhr, text_status, error_thrown);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
dialog.open();
|
|
|
|
}
|
|
|
|
}
|
2011-04-12 02:13:30 -05:00
|
|
|
});
|
2010-11-17 21:15:09 -06:00
|
|
|
|
2011-04-12 02:13:30 -05:00
|
|
|
batch.add_command(IPA.command({
|
|
|
|
method: 'json_metadata',
|
|
|
|
on_success: function(data, text_status, xhr) {
|
|
|
|
that.metadata = data;
|
|
|
|
}
|
|
|
|
}));
|
2010-11-17 21:15:09 -06:00
|
|
|
|
2011-04-12 02:13:30 -05:00
|
|
|
batch.add_command(IPA.command({
|
|
|
|
method: 'i18n_messages',
|
|
|
|
on_success: function(data, text_status, xhr) {
|
|
|
|
that.messages = data.messages;
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
|
|
|
|
batch.add_command(IPA.command({
|
|
|
|
entity: 'user',
|
|
|
|
method: 'find',
|
|
|
|
options: {
|
|
|
|
whoami: true,
|
|
|
|
all: true
|
|
|
|
},
|
|
|
|
on_success: function(data, text_status, xhr) {
|
|
|
|
that.whoami = data.result[0];
|
|
|
|
}
|
|
|
|
}));
|
2010-11-17 21:15:09 -06:00
|
|
|
|
2011-04-12 02:13:30 -05:00
|
|
|
batch.add_command(IPA.command({
|
|
|
|
method: 'env',
|
|
|
|
on_success: function(data, text_status, xhr) {
|
|
|
|
that.env = data.result;
|
|
|
|
}
|
|
|
|
}));
|
2011-02-16 12:46:59 -06:00
|
|
|
|
2011-04-12 02:13:30 -05:00
|
|
|
batch.add_command(IPA.command({
|
|
|
|
entity: 'dns',
|
|
|
|
method: 'is_enabled',
|
|
|
|
on_success: function(data, text_status, xhr) {
|
|
|
|
that.dns_enabled = data.result;
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
|
2011-07-05 16:59:05 -05:00
|
|
|
batch.add_command(IPA.command({
|
|
|
|
entity: 'hbacrule',
|
|
|
|
method: 'find',
|
|
|
|
options:{"accessruletype":"deny"},
|
|
|
|
on_success: function(data, text_status, xhr) {
|
|
|
|
that.hbac_deny_rules = data;
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
|
2011-04-12 02:13:30 -05:00
|
|
|
batch.execute();
|
2010-10-27 22:32:30 -05:00
|
|
|
};
|
|
|
|
|
2011-04-28 19:17:58 -05:00
|
|
|
that.get_entities = function() {
|
2011-05-16 22:23:20 -05:00
|
|
|
return that.entities.values;
|
2010-10-27 22:32:30 -05:00
|
|
|
};
|
|
|
|
|
removing setters setup and init
change widget and widget unit tests to hold on to entity, not entity name.
Replacing entity_name with entity.name in most places.
The one exception is columns for table_widget.
Widgets that refer to other entities have to have late resolution of the entity object, due to circular dependencies.
cleanup entity assignment.
removed template and layout,
merged setup into create
adder dialogs adjust height for external
removed init from widget, isection, association, facet, host and service
Make unit tests use factory.
fix functional tests to click find link correctly.
tweak to activation test, but still broken.
moved initialization code to the end
use --all for hbacrule find, so the type shows up now
fixed dns exception code and exception handling for get_entity
replace metadata look up with value from entity.
fixed author lines
removed duplicate columns in managed by facets.
tweak to nav fix in order to initialize tab.
more defensive code
update metadata for true false
one line init for entity_name in widget
move init code to end of constructor functions
moved constants to start of function for adder_dialog
external fields for dialogs initialized at dialog creation
sudo sections: move add fields and columns to widget definition.
The parameter validation in IPA.column ...This is precondition checking. Note that it merely throws an exception if the entity_name is not set. I want this stuff at the top of the function so that it is obvious to people looking to use them what is required. I added a comment to make this clear, but I'd like to keep precondition checking at the top of the function.
decreased the scope of the pkey_name and moved the initiailzation fof columns into the setup_column function for association_tables
return false at the end of click handler
removed blank labels in sudo command section
fix radio buttons for sudo category
fixed table side for adder dialogs with external fields
comments for future direction with add_columns
https://fedorahosted.org/freeipa/ticket/1451
https://fedorahosted.org/freeipa/ticket/1462
https://fedorahosted.org/freeipa/ticket/1493
https://fedorahosted.org/freeipa/ticket/1497
https://fedorahosted.org/freeipa/ticket/1532
https://fedorahosted.org/freeipa/ticket/1534
2011-07-25 11:15:14 -05:00
|
|
|
|
|
|
|
|
2011-04-28 19:17:58 -05:00
|
|
|
that.get_entity = function(name) {
|
2011-05-23 09:39:09 -05:00
|
|
|
var entity = that.entities.get(name);
|
|
|
|
if (!entity){
|
|
|
|
var factory = that.entity_factories[name];
|
removing setters setup and init
change widget and widget unit tests to hold on to entity, not entity name.
Replacing entity_name with entity.name in most places.
The one exception is columns for table_widget.
Widgets that refer to other entities have to have late resolution of the entity object, due to circular dependencies.
cleanup entity assignment.
removed template and layout,
merged setup into create
adder dialogs adjust height for external
removed init from widget, isection, association, facet, host and service
Make unit tests use factory.
fix functional tests to click find link correctly.
tweak to activation test, but still broken.
moved initialization code to the end
use --all for hbacrule find, so the type shows up now
fixed dns exception code and exception handling for get_entity
replace metadata look up with value from entity.
fixed author lines
removed duplicate columns in managed by facets.
tweak to nav fix in order to initialize tab.
more defensive code
update metadata for true false
one line init for entity_name in widget
move init code to end of constructor functions
moved constants to start of function for adder_dialog
external fields for dialogs initialized at dialog creation
sudo sections: move add fields and columns to widget definition.
The parameter validation in IPA.column ...This is precondition checking. Note that it merely throws an exception if the entity_name is not set. I want this stuff at the top of the function so that it is obvious to people looking to use them what is required. I added a comment to make this clear, but I'd like to keep precondition checking at the top of the function.
decreased the scope of the pkey_name and moved the initiailzation fof columns into the setup_column function for association_tables
return false at the end of click handler
removed blank labels in sudo command section
fix radio buttons for sudo category
fixed table side for adder dialogs with external fields
comments for future direction with add_columns
https://fedorahosted.org/freeipa/ticket/1451
https://fedorahosted.org/freeipa/ticket/1462
https://fedorahosted.org/freeipa/ticket/1493
https://fedorahosted.org/freeipa/ticket/1497
https://fedorahosted.org/freeipa/ticket/1532
https://fedorahosted.org/freeipa/ticket/1534
2011-07-25 11:15:14 -05:00
|
|
|
if (!factory){
|
|
|
|
return null;
|
|
|
|
}
|
2011-04-20 19:11:10 -05:00
|
|
|
try {
|
2011-05-23 09:39:09 -05:00
|
|
|
entity = factory();
|
2011-04-20 19:11:10 -05:00
|
|
|
that.add_entity(entity);
|
|
|
|
} catch (e) {
|
removing setters setup and init
change widget and widget unit tests to hold on to entity, not entity name.
Replacing entity_name with entity.name in most places.
The one exception is columns for table_widget.
Widgets that refer to other entities have to have late resolution of the entity object, due to circular dependencies.
cleanup entity assignment.
removed template and layout,
merged setup into create
adder dialogs adjust height for external
removed init from widget, isection, association, facet, host and service
Make unit tests use factory.
fix functional tests to click find link correctly.
tweak to activation test, but still broken.
moved initialization code to the end
use --all for hbacrule find, so the type shows up now
fixed dns exception code and exception handling for get_entity
replace metadata look up with value from entity.
fixed author lines
removed duplicate columns in managed by facets.
tweak to nav fix in order to initialize tab.
more defensive code
update metadata for true false
one line init for entity_name in widget
move init code to end of constructor functions
moved constants to start of function for adder_dialog
external fields for dialogs initialized at dialog creation
sudo sections: move add fields and columns to widget definition.
The parameter validation in IPA.column ...This is precondition checking. Note that it merely throws an exception if the entity_name is not set. I want this stuff at the top of the function so that it is obvious to people looking to use them what is required. I added a comment to make this clear, but I'd like to keep precondition checking at the top of the function.
decreased the scope of the pkey_name and moved the initiailzation fof columns into the setup_column function for association_tables
return false at the end of click handler
removed blank labels in sudo command section
fix radio buttons for sudo category
fixed table side for adder dialogs with external fields
comments for future direction with add_columns
https://fedorahosted.org/freeipa/ticket/1451
https://fedorahosted.org/freeipa/ticket/1462
https://fedorahosted.org/freeipa/ticket/1493
https://fedorahosted.org/freeipa/ticket/1497
https://fedorahosted.org/freeipa/ticket/1532
https://fedorahosted.org/freeipa/ticket/1534
2011-07-25 11:15:14 -05:00
|
|
|
if (e.expected){
|
|
|
|
/*expected exceptions thrown by builder just mean that
|
|
|
|
entities are not to be registered. */
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
if (e.message){
|
|
|
|
alert(e.message);
|
|
|
|
}else{
|
|
|
|
alert(e);
|
|
|
|
}
|
2011-05-23 09:39:09 -05:00
|
|
|
return null;
|
2011-04-11 13:49:36 -05:00
|
|
|
}
|
2011-01-19 20:10:18 -06:00
|
|
|
}
|
2011-05-23 09:39:09 -05:00
|
|
|
return entity;
|
|
|
|
};
|
|
|
|
|
|
|
|
that.add_entity = function(entity) {
|
|
|
|
that.entities.put(entity.name, entity);
|
|
|
|
};
|
|
|
|
|
|
|
|
that.remove_entity = function(name) {
|
|
|
|
that.entities.remove(name);
|
2011-01-19 20:10:18 -06:00
|
|
|
};
|
2010-11-15 15:41:21 -06:00
|
|
|
|
2011-04-12 02:13:30 -05:00
|
|
|
that.display_activity_icon = function() {
|
|
|
|
that.network_call_count++;
|
2011-04-28 19:17:58 -05:00
|
|
|
$('.network-activity-indicator').css('visibility', 'visible');
|
2011-04-12 02:13:30 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
that.hide_activity_icon = function() {
|
|
|
|
that.network_call_count--;
|
|
|
|
|
|
|
|
if (0 === that.network_call_count) {
|
2011-04-28 19:17:58 -05:00
|
|
|
$('.network-activity-indicator').css('visibility', 'hidden');
|
2011-04-12 02:13:30 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-10-27 22:32:30 -05:00
|
|
|
return that;
|
2010-11-01 15:32:07 -05:00
|
|
|
}());
|
2010-08-06 09:01:44 -05:00
|
|
|
|
2011-04-12 02:13:30 -05:00
|
|
|
/**
|
|
|
|
* Call an IPA command over JSON-RPC.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* name - command name (optional)
|
|
|
|
* entity - command entity (optional)
|
|
|
|
* method - command method
|
|
|
|
* args - list of arguments, e.g. [username]
|
|
|
|
* options - dict of options, e.g. {givenname: 'Pavel'}
|
|
|
|
* on_success - callback function if command succeeds
|
|
|
|
* on_error - callback function if command fails
|
|
|
|
*/
|
2011-02-16 12:46:59 -06:00
|
|
|
IPA.command = function(spec) {
|
2010-11-04 21:42:37 -05:00
|
|
|
|
|
|
|
spec = spec || {};
|
|
|
|
|
|
|
|
var that = {};
|
2010-11-15 11:10:55 -06:00
|
|
|
|
2010-11-18 20:59:08 -06:00
|
|
|
that.name = spec.name;
|
2011-04-12 02:13:30 -05:00
|
|
|
|
|
|
|
that.entity = spec.entity;
|
2010-11-04 21:42:37 -05:00
|
|
|
that.method = spec.method;
|
|
|
|
|
2010-11-15 11:10:55 -06:00
|
|
|
that.args = $.merge([], spec.args || []);
|
|
|
|
that.options = $.extend({}, spec.options || {});
|
2010-11-04 21:42:37 -05:00
|
|
|
|
2010-11-15 11:10:55 -06:00
|
|
|
that.on_success = spec.on_success;
|
|
|
|
that.on_error = spec.on_error;
|
2010-11-04 21:42:37 -05:00
|
|
|
|
2011-04-11 20:22:38 -05:00
|
|
|
that.retry = typeof spec.retry == 'undefined' ? true : spec.retry;
|
|
|
|
|
2011-08-23 11:27:41 -05:00
|
|
|
that.error_message = spec.error_message || (IPA.messages.dialogs ?
|
|
|
|
IPA.messages.dialogs.batch_error_message : 'Some operations failed.');
|
|
|
|
|
2011-04-12 02:13:30 -05:00
|
|
|
that.get_command = function() {
|
|
|
|
return (that.entity ? that.entity+'_' : '') + that.method;
|
|
|
|
};
|
|
|
|
|
2010-11-15 11:10:55 -06:00
|
|
|
that.add_arg = function(arg) {
|
|
|
|
that.args.push(arg);
|
2010-11-04 21:42:37 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
that.set_option = function(name, value) {
|
2010-11-15 11:10:55 -06:00
|
|
|
that.options[name] = value;
|
2010-11-04 21:42:37 -05:00
|
|
|
};
|
|
|
|
|
2011-05-27 12:04:20 -05:00
|
|
|
that.add_option = function(name, value) {
|
|
|
|
var values = that.options[name];
|
|
|
|
if (!values) {
|
|
|
|
values = [];
|
|
|
|
that.options[name] = values;
|
|
|
|
}
|
|
|
|
values.push(value);
|
|
|
|
};
|
|
|
|
|
2010-11-04 21:42:37 -05:00
|
|
|
that.get_option = function(name) {
|
2010-11-15 11:10:55 -06:00
|
|
|
return that.options[name];
|
2010-11-04 21:42:37 -05:00
|
|
|
};
|
|
|
|
|
2010-11-15 11:10:55 -06:00
|
|
|
that.execute = function() {
|
2011-04-12 02:13:30 -05:00
|
|
|
|
|
|
|
function dialog_open(xhr, text_status, error_thrown) {
|
2011-08-03 15:26:54 -05:00
|
|
|
|
|
|
|
var ajax = this;
|
|
|
|
|
2011-08-05 10:12:21 -05:00
|
|
|
var dialog = IPA.error_dialog({
|
|
|
|
xhr: xhr,
|
|
|
|
text_status: text_status,
|
|
|
|
error_thrown: error_thrown,
|
|
|
|
command: that
|
2011-04-12 02:13:30 -05:00
|
|
|
});
|
2011-08-03 15:26:54 -05:00
|
|
|
|
|
|
|
dialog.on_cancel = function() {
|
|
|
|
dialog.close();
|
|
|
|
if (that.on_error) {
|
|
|
|
that.on_error.call(ajax, xhr, text_status, error_thrown);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-08-05 10:12:21 -05:00
|
|
|
dialog.open();
|
2011-04-12 02:13:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
function error_handler(xhr, text_status, error_thrown) {
|
|
|
|
|
|
|
|
IPA.hide_activity_icon();
|
|
|
|
|
|
|
|
if (xhr.status === 401) {
|
2011-04-28 19:17:58 -05:00
|
|
|
error_thrown = {}; // error_thrown is string
|
2011-04-12 02:13:30 -05:00
|
|
|
error_thrown.name = 'Kerberos ticket no longer valid.';
|
|
|
|
if (IPA.messages && IPA.messages.ajax) {
|
|
|
|
error_thrown.message = IPA.messages.ajax["401"];
|
|
|
|
} else {
|
|
|
|
error_thrown.message =
|
|
|
|
"Your kerberos ticket is no longer valid. "+
|
|
|
|
"Please run kinit and then click 'Retry'. "+
|
|
|
|
"If this is your first time running the IPA Web UI "+
|
|
|
|
"<a href='/ipa/config/unauthorized.html'>"+
|
|
|
|
"follow these directions</a> to configure your browser.";
|
|
|
|
}
|
2011-06-03 10:49:42 -05:00
|
|
|
|
|
|
|
} else if (!error_thrown) {
|
|
|
|
error_thrown = {
|
|
|
|
name: xhr.responseText || 'Unknown Error',
|
|
|
|
message: xhr.statusText || 'Unknown Error'
|
|
|
|
};
|
|
|
|
|
|
|
|
} else if (typeof error_thrown == 'string') {
|
|
|
|
error_thrown = {
|
|
|
|
name: error_thrown,
|
|
|
|
message: error_thrown
|
|
|
|
};
|
2011-04-12 02:13:30 -05:00
|
|
|
}
|
|
|
|
|
2011-04-11 20:22:38 -05:00
|
|
|
if (that.retry) {
|
|
|
|
dialog_open.call(this, xhr, text_status, error_thrown);
|
|
|
|
|
|
|
|
} else if (that.on_error) {
|
2011-08-05 10:12:21 -05:00
|
|
|
//custom error handling, maintaining AJAX call's context
|
2011-04-11 20:22:38 -05:00
|
|
|
that.on_error.call(this, xhr, text_status, error_thrown);
|
|
|
|
}
|
2011-04-12 02:13:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
function success_handler(data, text_status, xhr) {
|
|
|
|
|
|
|
|
if (!data) {
|
2011-06-03 10:49:42 -05:00
|
|
|
// error_handler() calls IPA.hide_activity_icon()
|
|
|
|
error_handler.call(this, xhr, text_status, /* error_thrown */ {
|
2011-05-20 11:27:58 -05:00
|
|
|
name: 'HTTP Error '+xhr.status,
|
2011-04-12 02:13:30 -05:00
|
|
|
url: this.url,
|
2011-06-03 10:49:42 -05:00
|
|
|
message: data ? xhr.statusText : 'No response'
|
|
|
|
});
|
2011-04-12 02:13:30 -05:00
|
|
|
|
|
|
|
} else if (data.error) {
|
2011-04-11 20:22:38 -05:00
|
|
|
// error_handler() calls IPA.hide_activity_icon()
|
2011-04-12 02:13:30 -05:00
|
|
|
error_handler.call(this, xhr, text_status, /* error_thrown */ {
|
2011-05-20 11:27:58 -05:00
|
|
|
name: 'IPA Error '+data.error.code,
|
2011-08-05 10:12:21 -05:00
|
|
|
message: data.error.message,
|
|
|
|
data: data
|
2011-04-12 02:13:30 -05:00
|
|
|
});
|
|
|
|
|
2011-08-23 11:27:41 -05:00
|
|
|
} else {
|
2011-04-11 20:22:38 -05:00
|
|
|
IPA.hide_activity_icon();
|
2011-08-23 11:27:41 -05:00
|
|
|
|
|
|
|
var ajax = this;
|
|
|
|
var failed = that.get_failed(that, data.result, text_status, xhr);
|
|
|
|
if (!failed.is_empty()) {
|
|
|
|
var dialog = IPA.error_dialog({
|
|
|
|
xhr: xhr,
|
|
|
|
text_status: text_status,
|
|
|
|
error_thrown: {
|
|
|
|
name: IPA.messages.dialogs ? IPA.messages.dialogs.batch_error_title :
|
|
|
|
'Operations Error',
|
|
|
|
message: that.error_message
|
|
|
|
},
|
|
|
|
command: that,
|
|
|
|
errors: failed.errors,
|
|
|
|
visible_buttons: ['ok']
|
|
|
|
});
|
|
|
|
|
|
|
|
dialog.on_ok = function() {
|
|
|
|
dialog.close();
|
|
|
|
if (that.on_success) that.on_success.call(ajax, data, text_status, xhr);
|
|
|
|
};
|
|
|
|
|
|
|
|
dialog.open();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
//custom success handling, maintaining AJAX call's context
|
|
|
|
if (that.on_success) that.on_success.call(this, data, text_status, xhr);
|
|
|
|
}
|
2011-04-12 02:13:30 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var url = IPA.json_url;
|
|
|
|
|
|
|
|
var command = that.get_command();
|
|
|
|
|
|
|
|
if (IPA.use_static_files) {
|
|
|
|
url += '/' + (that.name ? that.name : command) + '.json';
|
|
|
|
}
|
|
|
|
|
|
|
|
var data = {
|
|
|
|
method: command,
|
|
|
|
params: [that.args, that.options]
|
|
|
|
};
|
|
|
|
|
|
|
|
var request = {
|
|
|
|
url: url,
|
|
|
|
data: JSON.stringify(data),
|
|
|
|
success: success_handler,
|
|
|
|
error: error_handler
|
|
|
|
};
|
|
|
|
|
|
|
|
IPA.display_activity_icon();
|
|
|
|
$.ajax(request);
|
2010-11-04 21:42:37 -05:00
|
|
|
};
|
|
|
|
|
2011-08-17 08:06:41 -05:00
|
|
|
that.get_failed = function(command, result, text_status, xhr) {
|
|
|
|
var errors = IPA.error_list();
|
|
|
|
if(result && result.failed) {
|
|
|
|
for(var association in result.failed) {
|
|
|
|
for(var member_name in result.failed[association]) {
|
|
|
|
var member = result.failed[association][member_name];
|
|
|
|
for(var i = 0; i < member.length; i++) {
|
|
|
|
if(member[i].length > 1) {
|
|
|
|
var name = 'IPA Error';
|
|
|
|
var message = member[i][1];
|
|
|
|
if(member[i][0])
|
|
|
|
message = member[i][0] + ': ' + message;
|
|
|
|
errors.add(command, name, message, text_status);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return errors;
|
|
|
|
};
|
|
|
|
|
2010-11-15 11:10:55 -06:00
|
|
|
that.to_json = function() {
|
|
|
|
var json = {};
|
|
|
|
|
2011-04-12 02:13:30 -05:00
|
|
|
json.method = that.get_command();
|
2010-11-15 11:10:55 -06:00
|
|
|
|
|
|
|
json.params = [];
|
|
|
|
json.params[0] = that.args || [];
|
|
|
|
json.params[1] = that.options || {};
|
|
|
|
|
|
|
|
return json;
|
|
|
|
};
|
|
|
|
|
2010-11-04 21:42:37 -05:00
|
|
|
that.to_string = function() {
|
2011-04-12 02:13:30 -05:00
|
|
|
var string = that.get_command().replace(/_/g, '-');
|
2010-11-04 21:42:37 -05:00
|
|
|
|
2010-11-15 11:10:55 -06:00
|
|
|
for (var i=0; i<that.args.length; i++) {
|
|
|
|
string += ' '+that.args[i];
|
2010-11-04 21:42:37 -05:00
|
|
|
}
|
|
|
|
|
2010-11-15 11:10:55 -06:00
|
|
|
for (var name in that.options) {
|
|
|
|
string += ' --'+name+'=\''+that.options[name]+'\'';
|
2010-11-04 21:42:37 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return string;
|
|
|
|
};
|
|
|
|
|
|
|
|
return that;
|
2011-01-14 11:16:25 -06:00
|
|
|
};
|
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
IPA.batch_command = function (spec) {
|
2010-11-04 21:42:37 -05:00
|
|
|
|
|
|
|
spec = spec || {};
|
|
|
|
|
|
|
|
spec.method = 'batch';
|
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
var that = IPA.command(spec);
|
2010-11-04 21:42:37 -05:00
|
|
|
|
2010-11-15 11:10:55 -06:00
|
|
|
that.commands = [];
|
2011-08-17 08:06:41 -05:00
|
|
|
that.errors = IPA.error_list();
|
2011-08-11 03:28:50 -05:00
|
|
|
that.show_error = typeof spec.show_error == 'undefined' ?
|
|
|
|
true : spec.show_error;
|
2010-11-15 11:10:55 -06:00
|
|
|
|
2010-11-04 21:42:37 -05:00
|
|
|
that.add_command = function(command) {
|
2010-11-15 11:10:55 -06:00
|
|
|
that.commands.push(command);
|
|
|
|
that.add_arg(command.to_json());
|
|
|
|
};
|
|
|
|
|
|
|
|
that.add_commands = function(commands) {
|
|
|
|
for (var i=0; i<commands.length; i++) {
|
|
|
|
that.add_command(commands[i]);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
that.execute = function() {
|
2011-08-17 08:06:41 -05:00
|
|
|
that.errors.clear();
|
2011-04-12 02:13:30 -05:00
|
|
|
|
|
|
|
IPA.command({
|
|
|
|
name: that.name,
|
|
|
|
entity: that.entity,
|
|
|
|
method: that.method,
|
|
|
|
args: that.args,
|
|
|
|
options: that.options,
|
2011-08-03 15:26:54 -05:00
|
|
|
retry: that.retry,
|
2011-04-12 02:13:30 -05:00
|
|
|
on_success: function(data, text_status, xhr) {
|
2011-01-10 20:14:51 -06:00
|
|
|
|
2010-11-15 11:10:55 -06:00
|
|
|
for (var i=0; i<that.commands.length; i++) {
|
|
|
|
var command = that.commands[i];
|
|
|
|
var result = data.result.results[i];
|
|
|
|
|
2011-08-11 03:28:50 -05:00
|
|
|
var name = '';
|
|
|
|
var message = '';
|
|
|
|
|
2010-11-15 11:10:55 -06:00
|
|
|
if (!result) {
|
2011-08-11 03:28:50 -05:00
|
|
|
name = 'Internal Error '+xhr.status;
|
|
|
|
message = result ? xhr.statusText : "Internal error";
|
|
|
|
|
2011-08-17 08:06:41 -05:00
|
|
|
that.errors.add(command, name, message, text_status);
|
2011-08-11 03:28:50 -05:00
|
|
|
|
2011-08-03 15:26:54 -05:00
|
|
|
if (command.on_error) command.on_error.call(
|
|
|
|
this,
|
|
|
|
xhr,
|
|
|
|
text_status,
|
2010-11-15 11:10:55 -06:00
|
|
|
{
|
2011-08-11 03:28:50 -05:00
|
|
|
name: name,
|
|
|
|
message: message
|
2010-11-15 11:10:55 -06:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
} else if (result.error) {
|
2011-08-11 03:28:50 -05:00
|
|
|
name = 'IPA Error ' + (result.error.code || '');
|
|
|
|
message = result.error.message || result.error;
|
|
|
|
|
2011-08-17 08:06:41 -05:00
|
|
|
that.errors.add(command, name, message, text_status);
|
2011-08-11 03:28:50 -05:00
|
|
|
|
2011-08-03 15:26:54 -05:00
|
|
|
if (command.on_error) command.on_error.call(
|
|
|
|
this,
|
2010-11-15 11:10:55 -06:00
|
|
|
xhr,
|
|
|
|
text_status,
|
|
|
|
{
|
2011-08-11 03:28:50 -05:00
|
|
|
name: name,
|
2011-08-17 08:06:41 -05:00
|
|
|
message: message,
|
|
|
|
data: result
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2011-08-23 11:27:41 -05:00
|
|
|
} else {
|
|
|
|
var failed = that.get_failed(command, result, text_status, xhr);
|
2011-08-17 08:06:41 -05:00
|
|
|
that.errors.add_range(failed);
|
|
|
|
|
2011-08-03 15:26:54 -05:00
|
|
|
if (command.on_success) command.on_success.call(this, result, text_status, xhr);
|
2010-11-15 11:10:55 -06:00
|
|
|
}
|
|
|
|
}
|
2011-08-11 03:28:50 -05:00
|
|
|
//check for partial errors and show error dialog
|
2011-08-17 08:06:41 -05:00
|
|
|
if(that.show_error && that.errors.errors.length > 0) {
|
2011-08-23 11:27:41 -05:00
|
|
|
var ajax = this;
|
2011-08-11 03:28:50 -05:00
|
|
|
var dialog = IPA.error_dialog({
|
|
|
|
xhr: xhr,
|
|
|
|
text_status: text_status,
|
|
|
|
error_thrown: {
|
|
|
|
name: IPA.messages.dialogs ? IPA.messages.dialogs.batch_error_title :
|
|
|
|
'Operations Error',
|
|
|
|
message: that.error_message
|
|
|
|
},
|
|
|
|
command: that,
|
2011-08-17 08:06:41 -05:00
|
|
|
errors: that.errors.errors,
|
2011-08-11 03:28:50 -05:00
|
|
|
visible_buttons: ['ok']
|
|
|
|
});
|
2011-08-23 11:27:41 -05:00
|
|
|
|
|
|
|
dialog.on_ok = function() {
|
|
|
|
dialog.close();
|
|
|
|
if (that.on_success) that.on_success.call(ajax, data, text_status, xhr);
|
|
|
|
};
|
|
|
|
|
2011-08-11 03:28:50 -05:00
|
|
|
dialog.open();
|
2011-08-23 11:27:41 -05:00
|
|
|
|
|
|
|
} else {
|
|
|
|
if (that.on_success) that.on_success.call(this, data, text_status, xhr);
|
2011-08-11 03:28:50 -05:00
|
|
|
}
|
2010-11-15 11:10:55 -06:00
|
|
|
},
|
2011-04-12 02:13:30 -05:00
|
|
|
on_error: function(xhr, text_status, error_thrown) {
|
2010-11-15 11:10:55 -06:00
|
|
|
// TODO: undefined behavior
|
2011-01-12 13:47:29 -06:00
|
|
|
if (that.on_error) {
|
2011-08-03 15:26:54 -05:00
|
|
|
that.on_error.call(this, xhr, text_status, error_thrown);
|
2011-01-12 13:47:29 -06:00
|
|
|
}
|
2011-02-21 18:36:42 -06:00
|
|
|
}
|
2011-04-12 02:13:30 -05:00
|
|
|
}).execute();
|
2010-08-06 09:01:44 -05:00
|
|
|
};
|
|
|
|
|
2011-04-12 02:13:30 -05:00
|
|
|
return that;
|
2011-01-14 11:16:25 -06:00
|
|
|
};
|
2010-08-06 09:01:44 -05:00
|
|
|
|
|
|
|
/* helper function used to retrieve information about an attribute */
|
2011-02-16 12:46:59 -06:00
|
|
|
IPA.get_entity_param = function(entity_name, name) {
|
|
|
|
|
|
|
|
var metadata = IPA.metadata.objects[entity_name];
|
|
|
|
if (!metadata) {
|
2010-11-01 15:32:07 -05:00
|
|
|
return null;
|
|
|
|
}
|
2010-09-24 18:50:29 -05:00
|
|
|
|
2011-02-16 12:46:59 -06:00
|
|
|
var params = metadata.takes_params;
|
|
|
|
if (!params) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (var i=0; i<params.length; i++) {
|
|
|
|
if (params[i].name === name) {
|
|
|
|
return params[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
};
|
|
|
|
|
2011-04-26 16:21:25 -05:00
|
|
|
IPA.get_method_arg = function(method_name, name) {
|
|
|
|
|
|
|
|
var metadata = IPA.metadata.methods[method_name];
|
|
|
|
if (!metadata) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
var args = metadata.takes_args;
|
|
|
|
if (!args) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (var i=0; i<args.length; i++) {
|
|
|
|
if (args[i].name === name) {
|
|
|
|
return args[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
};
|
|
|
|
|
|
|
|
IPA.get_method_option = function(method_name, name) {
|
2010-08-06 09:01:44 -05:00
|
|
|
|
2011-02-16 12:46:59 -06:00
|
|
|
var metadata = IPA.metadata.methods[method_name];
|
|
|
|
if (!metadata) {
|
|
|
|
return null;
|
2010-11-01 15:32:07 -05:00
|
|
|
}
|
2011-02-16 12:46:59 -06:00
|
|
|
|
|
|
|
var options = metadata.takes_options;
|
|
|
|
if (!options) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (var i=0; i<options.length; i++) {
|
|
|
|
if (options[i].name === name) {
|
|
|
|
return options[i];
|
2010-11-01 15:32:07 -05:00
|
|
|
}
|
2010-08-06 09:01:44 -05:00
|
|
|
}
|
|
|
|
|
2011-02-16 12:46:59 -06:00
|
|
|
return null;
|
2011-01-14 11:16:25 -06:00
|
|
|
};
|
2010-09-16 09:28:07 -05:00
|
|
|
|
|
|
|
/* helper function used to retrieve attr name with members of type `member` */
|
2011-02-16 12:46:59 -06:00
|
|
|
IPA.get_member_attribute = function(obj_name, member) {
|
|
|
|
|
|
|
|
var obj = IPA.metadata.objects[obj_name];
|
2011-01-12 18:51:22 -06:00
|
|
|
if (!obj) {
|
2010-11-01 15:32:07 -05:00
|
|
|
return null;
|
|
|
|
}
|
2011-02-16 12:46:59 -06:00
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
var attribute_members = obj.attribute_members;
|
2010-09-16 09:28:07 -05:00
|
|
|
for (var a in attribute_members) {
|
|
|
|
var objs = attribute_members[a];
|
2010-11-01 15:32:07 -05:00
|
|
|
for (var i = 0; i < objs.length; i += 1) {
|
|
|
|
if (objs[i] === member){
|
2010-09-16 09:28:07 -05:00
|
|
|
return a;
|
2010-11-01 15:32:07 -05:00
|
|
|
}
|
2010-09-16 09:28:07 -05:00
|
|
|
}
|
|
|
|
}
|
2011-01-14 11:16:25 -06:00
|
|
|
|
2011-02-16 12:46:59 -06:00
|
|
|
return null;
|
2011-01-17 09:10:00 -06:00
|
|
|
};
|
|
|
|
|
2011-01-10 20:14:51 -06:00
|
|
|
IPA.create_network_spinner = function(){
|
|
|
|
return $('<span />',{
|
|
|
|
'class':'network-activity-indicator',
|
|
|
|
html: '<img src="spinner_small.gif" />'});
|
2011-01-14 11:16:25 -06:00
|
|
|
};
|
2011-05-26 17:57:39 -05:00
|
|
|
|
|
|
|
IPA.dirty_dialog = function(spec) {
|
|
|
|
|
|
|
|
spec = spec || {};
|
|
|
|
spec.title = spec.title || IPA.messages.dialogs.dirty_title;
|
|
|
|
spec.width = spec.width || '25em';
|
|
|
|
|
|
|
|
var that = IPA.dialog(spec);
|
|
|
|
that.facet = spec.facet;
|
|
|
|
that.message = spec.message || IPA.messages.dialogs.dirty_message;
|
|
|
|
|
|
|
|
that.create = function() {
|
|
|
|
that.container.append(that.message);
|
|
|
|
};
|
|
|
|
|
|
|
|
that.add_button(IPA.messages.buttons.update, function() {
|
|
|
|
that.facet.update(function() {
|
|
|
|
that.close();
|
|
|
|
that.callback();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
that.add_button(IPA.messages.buttons.reset, function() {
|
|
|
|
that.facet.reset();
|
|
|
|
that.close();
|
|
|
|
that.callback();
|
|
|
|
});
|
|
|
|
|
|
|
|
that.add_button(IPA.messages.buttons.cancel, function() {
|
|
|
|
that.close();
|
|
|
|
});
|
|
|
|
|
|
|
|
that.callback = function() {
|
|
|
|
};
|
|
|
|
|
|
|
|
return that;
|
removing setters setup and init
change widget and widget unit tests to hold on to entity, not entity name.
Replacing entity_name with entity.name in most places.
The one exception is columns for table_widget.
Widgets that refer to other entities have to have late resolution of the entity object, due to circular dependencies.
cleanup entity assignment.
removed template and layout,
merged setup into create
adder dialogs adjust height for external
removed init from widget, isection, association, facet, host and service
Make unit tests use factory.
fix functional tests to click find link correctly.
tweak to activation test, but still broken.
moved initialization code to the end
use --all for hbacrule find, so the type shows up now
fixed dns exception code and exception handling for get_entity
replace metadata look up with value from entity.
fixed author lines
removed duplicate columns in managed by facets.
tweak to nav fix in order to initialize tab.
more defensive code
update metadata for true false
one line init for entity_name in widget
move init code to end of constructor functions
moved constants to start of function for adder_dialog
external fields for dialogs initialized at dialog creation
sudo sections: move add fields and columns to widget definition.
The parameter validation in IPA.column ...This is precondition checking. Note that it merely throws an exception if the entity_name is not set. I want this stuff at the top of the function so that it is obvious to people looking to use them what is required. I added a comment to make this clear, but I'd like to keep precondition checking at the top of the function.
decreased the scope of the pkey_name and moved the initiailzation fof columns into the setup_column function for association_tables
return false at the end of click handler
removed blank labels in sudo command section
fix radio buttons for sudo category
fixed table side for adder dialogs with external fields
comments for future direction with add_columns
https://fedorahosted.org/freeipa/ticket/1451
https://fedorahosted.org/freeipa/ticket/1462
https://fedorahosted.org/freeipa/ticket/1493
https://fedorahosted.org/freeipa/ticket/1497
https://fedorahosted.org/freeipa/ticket/1532
https://fedorahosted.org/freeipa/ticket/1534
2011-07-25 11:15:14 -05:00
|
|
|
};
|
2011-08-05 10:12:21 -05:00
|
|
|
|
|
|
|
IPA.error_dialog = function(spec) {
|
2011-08-03 15:26:54 -05:00
|
|
|
|
2011-08-05 10:12:21 -05:00
|
|
|
var that = IPA.dialog(spec);
|
|
|
|
|
|
|
|
var init = function() {
|
|
|
|
spec = spec || {};
|
|
|
|
|
|
|
|
that.id = 'error_dialog';
|
|
|
|
that.xhr = spec.xhr || {};
|
|
|
|
that.text_status = spec.text_status || '';
|
|
|
|
that.error_thrown = spec.error_thrown || {};
|
|
|
|
that.command = spec.command;
|
|
|
|
that.title = spec.error_thrown.name;
|
2011-08-11 03:28:50 -05:00
|
|
|
that.errors = spec.errors;
|
|
|
|
that.visible_buttons = spec.visible_buttons || ['retry', 'cancel'];
|
2011-08-05 10:12:21 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
that.create = function() {
|
|
|
|
if (that.error_thrown.url) {
|
|
|
|
$('<p/>', {
|
|
|
|
text: 'URL: '+that.error_thrown.url
|
|
|
|
}).appendTo(that.container);
|
|
|
|
}
|
|
|
|
|
|
|
|
$('<p/>', {
|
2011-08-23 11:27:41 -05:00
|
|
|
html: that.error_thrown.message
|
2011-08-05 10:12:21 -05:00
|
|
|
}).appendTo(that.container);
|
2011-08-11 03:28:50 -05:00
|
|
|
|
|
|
|
if(that.errors && that.errors.length > 0) {
|
|
|
|
//render errors
|
|
|
|
var errors_title_div = $('<div />', {
|
|
|
|
'class': 'errors_title'
|
|
|
|
}).appendTo(that.container);
|
|
|
|
|
|
|
|
var show_details = $('<a />', {
|
|
|
|
href: '#',
|
|
|
|
title: IPA.messages.dialogs.show_details,
|
|
|
|
text: IPA.messages.dialogs.show_details
|
|
|
|
}).appendTo(errors_title_div);
|
|
|
|
|
|
|
|
var hide_details = $('<a />', {
|
|
|
|
href: '#',
|
|
|
|
title: IPA.messages.dialogs.hide_details,
|
|
|
|
text: IPA.messages.dialogs.hide_details,
|
|
|
|
style : 'display: none'
|
|
|
|
}).appendTo(errors_title_div);
|
|
|
|
|
|
|
|
var errors_container = $('<ul />', {
|
|
|
|
'class' : 'error-container',
|
|
|
|
style : 'display: none'
|
|
|
|
}).appendTo(that.container);
|
|
|
|
|
|
|
|
for(var i=0; i < that.errors.length; i++) {
|
|
|
|
var error = that.errors[i];
|
|
|
|
if(error.message) {
|
|
|
|
var error_div = $('<li />', {
|
|
|
|
text: error.message
|
|
|
|
}).appendTo(errors_container);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
show_details.click(function() {
|
|
|
|
errors_container.show();
|
|
|
|
show_details.hide();
|
|
|
|
hide_details.show();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
hide_details.click(function() {
|
|
|
|
errors_container.hide();
|
|
|
|
hide_details.hide();
|
|
|
|
show_details.show();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
}
|
2011-08-05 10:12:21 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
that.create_buttons = function() {
|
|
|
|
/**
|
|
|
|
* When a user initially opens the Web UI without a Kerberos
|
|
|
|
* ticket, the messages including the button labels have not
|
|
|
|
* been loaded yet, so the button labels need default values.
|
|
|
|
*/
|
2011-08-11 03:28:50 -05:00
|
|
|
var label;
|
2011-08-05 10:12:21 -05:00
|
|
|
|
2011-08-11 03:28:50 -05:00
|
|
|
if(that.visible_buttons.indexOf('retry') > -1) {
|
|
|
|
label = IPA.messages.buttons ? IPA.messages.buttons.retry : 'Retry';
|
|
|
|
that.add_button(label, function() {
|
|
|
|
that.on_retry();
|
|
|
|
});
|
|
|
|
}
|
2011-08-05 10:12:21 -05:00
|
|
|
|
2011-08-11 03:28:50 -05:00
|
|
|
if(that.visible_buttons.indexOf('ok') > -1) {
|
|
|
|
label = IPA.messages.buttons ? IPA.messages.buttons.ok : 'OK';
|
|
|
|
that.add_button(label, function() {
|
|
|
|
that.on_ok();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if(that.visible_buttons.indexOf('cancel') > -1) {
|
|
|
|
label = IPA.messages.buttons ? IPA.messages.buttons.cancel : 'Cancel';
|
|
|
|
that.add_button(label, function() {
|
|
|
|
that.on_cancel();
|
|
|
|
});
|
|
|
|
}
|
2011-08-05 10:12:21 -05:00
|
|
|
};
|
|
|
|
|
2011-08-03 15:26:54 -05:00
|
|
|
that.on_retry = function() {
|
|
|
|
that.close();
|
|
|
|
that.command.execute();
|
|
|
|
};
|
|
|
|
|
2011-08-11 03:28:50 -05:00
|
|
|
that.on_ok = function() {
|
|
|
|
that.close();
|
|
|
|
};
|
|
|
|
|
2011-08-03 15:26:54 -05:00
|
|
|
that.on_cancel = function() {
|
|
|
|
that.close();
|
|
|
|
};
|
|
|
|
|
2011-08-05 10:12:21 -05:00
|
|
|
init();
|
|
|
|
that.create_buttons();
|
|
|
|
|
|
|
|
return that;
|
|
|
|
};
|
2011-08-17 08:06:41 -05:00
|
|
|
|
|
|
|
IPA.error_list = function() {
|
|
|
|
var that = {};
|
|
|
|
|
|
|
|
that.clear = function() {
|
|
|
|
that.errors = [];
|
|
|
|
};
|
|
|
|
|
|
|
|
that.add = function(command, name, message, status) {
|
|
|
|
that.errors.push({
|
|
|
|
command: command,
|
|
|
|
name: name,
|
|
|
|
message: message,
|
|
|
|
status: status
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
that.add_range = function(error_list) {
|
|
|
|
that.errors = that.errors.concat(error_list.errors);
|
|
|
|
};
|
|
|
|
|
|
|
|
that.is_empty = function () {
|
|
|
|
return that.errors.length === 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
that.clear();
|
|
|
|
return that;
|
|
|
|
};
|