diff options
author | Petr Vobornik <pvoborni@redhat.com> | 2014-03-10 17:05:51 +0100 |
---|---|---|
committer | Petr Vobornik <pvoborni@redhat.com> | 2014-03-27 14:54:08 +0100 |
commit | 06a7a1b3cb277284448dd8344940395f0b29cd70 (patch) | |
tree | 2204bfebe49d3a2224fd4d5828c4980956ea4a26 | |
parent | d5cf0b273ad511d6cb99fbcb900eff528fe172df (diff) | |
download | freeipa-06a7a1b3cb277284448dd8344940395f0b29cd70.tar.gz freeipa-06a7a1b3cb277284448dd8344940395f0b29cd70.tar.xz freeipa-06a7a1b3cb277284448dd8344940395f0b29cd70.zip |
webui: replace IPA.command usage with rpc.command
Replace all IPA.command, IPA.batch_command and IPA.concurrent_command usages
by equivalents from rpc module.
Reviewed-By: Adam Misnyovszki <amisnyov@redhat.com>
25 files changed, 189 insertions, 168 deletions
diff --git a/install/ui/doc/categories.json b/install/ui/doc/categories.json index f5df41926..2634986f2 100644 --- a/install/ui/doc/categories.json +++ b/install/ui/doc/categories.json @@ -7,9 +7,9 @@ "classes": [ "IPA.object", "IPA.observer", - "IPA.command", - "IPA.batch_command", - "IPA.concurrent_command", + "rpc.command", + "rpc.batch_command", + "rpc.concurrent_command", "entity.entity" ] }, diff --git a/install/ui/src/freeipa/add.js b/install/ui/src/freeipa/add.js index 22761c5ad..0a0942e97 100644 --- a/install/ui/src/freeipa/add.js +++ b/install/ui/src/freeipa/add.js @@ -19,8 +19,8 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -define(['./ipa', './jquery', './navigation', './text', './field', './widget', './dialog'], - function(IPA, $, navigation, text) { +define(['./ipa', './jquery', './navigation', './rpc', './text', './field', './widget', './dialog'], + function(IPA, $, navigation, rpc, text) { /** * Entity adder dialog @@ -42,11 +42,11 @@ IPA.entity_adder_dialog = function(spec) { that.method = spec.method || 'add'; /** @property {Function} on_error Custom add error handler */ that.on_error = spec.on_error ; - /** @property {boolean} retry=true Allow retry on error (same as in IPA.command)*/ + /** @property {boolean} retry=true Allow retry on error (same as in rpc.command)*/ that.retry = typeof spec.retry !== 'undefined' ? spec.retry : true; /** * Add command - * @property {IPA.command} + * @property {rpc.command} * @protected */ that.command = null; @@ -184,7 +184,7 @@ IPA.entity_adder_dialog = function(spec) { var pkey_name = that.entity.metadata.primary_key; - var command = IPA.command({ + var command = rpc.command({ entity: that.entity.name, method: that.method, retry: that.retry diff --git a/install/ui/src/freeipa/association.js b/install/ui/src/freeipa/association.js index 0c337bdff..0eef1e8da 100644 --- a/install/ui/src/freeipa/association.js +++ b/install/ui/src/freeipa/association.js @@ -31,13 +31,14 @@ define([ './navigation', './phases', './reg', + './rpc', './spec_util', './text', './facet', './search', './dialog'], function(lang, Deferred, metadata_provider, IPA, $, navigation, - phases, reg, su, text) { + phases, reg, rpc, su, text) { /** * Association module @@ -93,7 +94,7 @@ IPA.serial_associator = function(spec) { return; } - var batch = IPA.batch_command({ + var batch = rpc.batch_command({ on_success: that.on_success, on_error: that.on_error }); @@ -105,7 +106,7 @@ IPA.serial_associator = function(spec) { options = {}; options[that.entity.name] = that.pkey; - command = IPA.command({ + command = rpc.command({ entity: that.other_entity.name, method: that.method, args: args, @@ -140,7 +141,7 @@ IPA.bulk_associator = function(spec) { return; } - var command = IPA.command({ + var command = rpc.command({ entity: that.entity.name, method: that.method, args: [that.pkey], @@ -313,7 +314,7 @@ IPA.association_adder_dialog = function(spec) { } } - IPA.command({ + rpc.command({ entity: that.other_entity.name, method: 'find', args: [that.get_filter()], @@ -668,7 +669,7 @@ IPA.association_table_widget = function (spec) { var pkey = that.facet.get_pkey(); - var command = IPA.command({ + var command = rpc.command({ entity: that.entity.name, method: that.add_method, args: [pkey], @@ -732,7 +733,7 @@ IPA.association_table_widget = function (spec) { var pkey = that.facet.get_pkey(); - var command = IPA.command({ + var command = rpc.command({ entity: that.entity.name, method: that.remove_method, args: [pkey], @@ -795,7 +796,7 @@ IPA.association_table_field = function (spec) { } var pkey = that.facet.get_pkey(); - IPA.command({ + rpc.command({ entity: that.entity.name, method: 'show', args: [pkey], @@ -1246,7 +1247,7 @@ exp.association_facet = IPA.association_facet = function (spec, no_init) { var pkeys = that.get_pkeys(); - var command = IPA.command({ + var command = rpc.command({ entity: that.entity.name, method: 'show', args: pkeys @@ -1407,7 +1408,7 @@ exp.attribute_facet = IPA.attribute_facet = function(spec, no_init) { var pkey = that.get_pkeys(); - var command = IPA.command({ + var command = rpc.command({ entity: that.entity.name, method: 'show', args: pkey @@ -1492,7 +1493,7 @@ exp.attribute_facet = IPA.attribute_facet = function(spec, no_init) { var pkey = that.get_pkeys(); - var command = IPA.command({ + var command = rpc.command({ entity: that.entity.name, method: that.remove_method, args: pkey, diff --git a/install/ui/src/freeipa/automember.js b/install/ui/src/freeipa/automember.js index 50fc69741..e9619b731 100644 --- a/install/ui/src/freeipa/automember.js +++ b/install/ui/src/freeipa/automember.js @@ -25,12 +25,13 @@ define([ './navigation', './phases', './reg', + './rpc', './text', './details', './search', './association', './entity'], - function(metadata_provider, IPA, $, navigation, phases, reg, text) { + function(metadata_provider, IPA, $, navigation, phases, reg, rpc, text) { var exp = IPA.automember = {}; @@ -524,7 +525,7 @@ IPA.automember.condition_widget = function(spec) { that.create_remove_command = function(values, on_success, on_error) { - var batch = IPA.batch_command({ + var batch = rpc.batch_command({ name: 'automember_remove_condition', on_success: on_success, on_error: on_error @@ -628,7 +629,7 @@ IPA.automember.default_group_widget = function(spec) { method = 'default_group_' + method; var command_name = that.entity.name + that.group_type + '_' + method; - var command = IPA.command({ + var command = rpc.command({ name: command_name, entity: that.entity.name, method: method, @@ -726,7 +727,7 @@ IPA.automember.rebuild_action = function(spec) { options['type'] = 'hostgroup'; } - var command = IPA.command({ + var command = rpc.command({ entity: 'automember', method: 'rebuild', options: options, diff --git a/install/ui/src/freeipa/certificate.js b/install/ui/src/freeipa/certificate.js index bd9f7459a..7a7ece0e1 100755 --- a/install/ui/src/freeipa/certificate.js +++ b/install/ui/src/freeipa/certificate.js @@ -27,9 +27,10 @@ define([ './menu', './phases', './reg', + './rpc', './text', './dialog'], - function(lang, metadata_provider, IPA, $, menu, phases, reg, text) { + function(lang, metadata_provider, IPA, $, menu, phases, reg, rpc, text) { var exp = IPA.cert = {}; @@ -517,7 +518,7 @@ IPA.cert.load_policy = function(spec) { }; that.load_revocation_reason = function(serial_number) { - IPA.command({ + rpc.command({ entity: 'cert', method: 'show', args: [serial_number], @@ -643,7 +644,7 @@ IPA.cert.request_action = function(spec) { message: request_message, request: function(values) { - IPA.command({ + rpc.command({ entity: 'cert', method: 'request', args: [values.request], @@ -702,7 +703,7 @@ IPA.cert.revoke_action = function(spec) { var certificate = facet.certificate; - IPA.command({ + rpc.command({ entity: 'cert', method: 'revoke', args: [certificate.serial_number], @@ -759,7 +760,7 @@ IPA.cert.restore_action = function(spec) { var certificate = facet.certificate; - IPA.command({ + rpc.command({ entity: 'cert', method: 'remove_hold', args: [certificate.serial_number], diff --git a/install/ui/src/freeipa/details.js b/install/ui/src/freeipa/details.js index 206b55ab8..8b3eddb1f 100644 --- a/install/ui/src/freeipa/details.js +++ b/install/ui/src/freeipa/details.js @@ -28,11 +28,12 @@ define([ './jquery', './phases', './reg', + './rpc', './spec_util', './text', './facet', './add'], - function(lang, builder, IPA, $, phases, reg, su, text) { + function(lang, builder, IPA, $, phases, reg, rpc, su, text) { /** * Details module @@ -825,7 +826,7 @@ exp.details_facet = IPA.details_facet = function(spec, no_init) { * Adds update info as command options * @protected * @param {details.update_info} update_info - * @param {IPA.command} command + * @param {rpc.command} command */ that.add_fields_to_command = function(update_info, command) { @@ -833,7 +834,7 @@ exp.details_facet = IPA.details_facet = function(spec, no_init) { var field_info = update_info.fields[i]; if (field_info.field.flags.indexOf('no_command') > -1) continue; var values = field_info.field.save(); - IPA.command_builder.add_field_option( + exp.command_builder.add_field_option( command, field_info.field, values); @@ -844,7 +845,7 @@ exp.details_facet = IPA.details_facet = function(spec, no_init) { * Create update command based on field part of update info * @protected * @param {details.update_info} update_info - * @return {IPA.command} + * @return {rpc.command} */ that.create_fields_update_command = function(update_info) { @@ -853,7 +854,7 @@ exp.details_facet = IPA.details_facet = function(spec, no_init) { var options = { all: true }; if (that.check_rights) options.rights = true; - var command = IPA.command({ + var command = rpc.command({ entity: that.entity.name, method: that.update_command_name, args: args, @@ -873,11 +874,11 @@ exp.details_facet = IPA.details_facet = function(spec, no_init) { * to reflect field part of update info (if present). * @protected * @param {details.update_info} update_info - * @return {IPA.batch_command} + * @return {rpc.batch_command} */ that.create_batch_update_command = function(update_info) { - var batch = IPA.batch_command({ + var batch = rpc.batch_command({ name: that.entity.name + '_details_update' }); @@ -915,7 +916,7 @@ exp.details_facet = IPA.details_facet = function(spec, no_init) { /** * Create update command * @protected - * @return {IPA.command/IPA.batch_command} + * @return {rpc.command|rpc.batch_command} */ that.create_update_command = function() { @@ -975,14 +976,14 @@ exp.details_facet = IPA.details_facet = function(spec, no_init) { /** * Create refresh command * @protected - * @return {IPA.command} + * @return {rpc.command} */ that.create_refresh_command = function() { var options = { all: true }; if (that.check_rights) options.rights = true; - var command = IPA.command({ + var command = rpc.command({ name: that.get_refresh_command_name(), entity: that.entity.name, method: 'show', @@ -1169,7 +1170,7 @@ exp.update_info = IPA.update_info = function(spec) { /** * Create new command info and add it to collection - * @param {IPA.command} command + * @param {rpc.command} command * @param {number} priority */ that.append_command = function (command, priority) { @@ -1191,7 +1192,7 @@ exp.command_info = IPA.command_info = function(spec) { /** * Command - * @property {IPA.command} + * @property {rpc.command} */ that.command = spec.command; @@ -1268,7 +1269,7 @@ exp.update_info_builder = IPA.update_info_builder = function() { /** * Create new command info - * @param {IPA.command} command + * @param {rpc.command} command * @param {number} priority * @return {details.command_info} */ @@ -1309,16 +1310,15 @@ exp.update_info_builder = IPA.update_info_builder = function() { * Field add/mod command builder * * @class details.command_builder - * @alternateClassName IPA.command_builder * @singleton */ -exp.command_builder = IPA.command_builder = function() { +exp.command_builder = function() { var that = IPA.object(); /** * Add option to command with field values - * @param {IPA.command} command + * @param {rpc.command} command * @param {IPA.field} field * @param {Array} values */ @@ -1790,7 +1790,7 @@ exp.object_action = IPA.object_action = function(spec) { var entity_name = facet.entity.name; var pkeys = facet.get_pkeys(); - IPA.command({ + rpc.command({ entity: entity_name, method: that.method, args: pkeys, diff --git a/install/ui/src/freeipa/dialogs/password.js b/install/ui/src/freeipa/dialogs/password.js index d0fdcc846..35f96e4b7 100644 --- a/install/ui/src/freeipa/dialogs/password.js +++ b/install/ui/src/freeipa/dialogs/password.js @@ -24,9 +24,10 @@ define([ '../ipa', '../phases', '../reg', + '../rpc', '../text', '../dialog'], - function(lang, builder, IPA, phases, reg, text) { + function(lang, builder, IPA, phases, reg, rpc, text) { var dialogs = {}; // dummy object /** @@ -211,7 +212,7 @@ dialogs.password.dialog = function(spec) { that.create_command = function() { var options = that.make_otions(); - var command = IPA.command({ + var command = rpc.command({ entity: that.entity.name, method: that.method, args: that.pkeys, diff --git a/install/ui/src/freeipa/dns.js b/install/ui/src/freeipa/dns.js index 3ef5620f4..1432eb910 100644 --- a/install/ui/src/freeipa/dns.js +++ b/install/ui/src/freeipa/dns.js @@ -28,12 +28,13 @@ define([ './menu', './phases', './reg', + './rpc', './text', './details', './search', './association', './entity'], - function(IPA, $, NET, navigation, menu, phases, reg, text) { + function(IPA, $, NET, navigation, menu, phases, reg, rpc, text) { var exp = IPA.dns = { zone_permission_name: 'Manage DNS zone ${dnszone}' @@ -340,7 +341,7 @@ IPA.dnszone_details_facet = function(spec, no_init) { var pkey = that.get_pkey(); - var batch = IPA.batch_command({ + var batch = rpc.batch_command({ name: 'dnszone_details_refresh' }); @@ -357,7 +358,7 @@ IPA.dnszone_details_facet = function(spec, no_init) { var permission_name = IPA.dns.zone_permission_name.replace('${dnszone}', pkey); - var permission_command = IPA.command({ + var permission_command = rpc.command({ entity: 'permission', method: 'show', args: [permission_name], @@ -595,7 +596,7 @@ IPA.dns.add_permission_action = function(spec) { var pkey = facet.get_pkey(); - var command = IPA.command({ + var command = rpc.command({ entity: 'dnszone', method: 'add_permission', args: [pkey], @@ -625,7 +626,7 @@ IPA.dns.remove_permission_action = function(spec) { var pkey = facet.get_pkey(); - var command = IPA.command({ + var command = rpc.command({ entity: 'dnszone', method: 'remove_permission', args: [pkey], @@ -668,7 +669,7 @@ IPA.dns.record_search_facet = function(spec) { that.get_records = function(pkeys, on_success, on_error) { - var batch = IPA.batch_command({ + var batch = rpc.batch_command({ name: that.get_records_command_name(), on_success: on_success, on_error: on_error @@ -679,7 +680,7 @@ IPA.dns.record_search_facet = function(spec) { for (var i=0; i<pkeys.length; i++) { var pkey = pkeys[i]; - var command = IPA.command({ + var command = rpc.command({ entity: that.table.entity.name, method: 'show', args: [zone, pkey], @@ -1205,7 +1206,7 @@ IPA.dns.record_adder_dialog = function(spec) { var that = IPA.entity_adder_dialog(spec); - that.on_error = IPA.create_4304_error_handler(that); + that.on_error = rpc.create_4304_error_handler(that); return that; }; @@ -1799,7 +1800,7 @@ IPA.dns.record_type_table_widget = function(spec) { that.remove = function(values, pkey, on_success, on_error) { var pkeys = that.facet.get_pkeys(); - var command = IPA.command({ + var command = rpc.command({ entity: that.entity.name, method: 'del', args: pkeys, @@ -1838,7 +1839,7 @@ IPA.dns.record_type_table_widget = function(spec) { var cancel_button = dialog.buttons.get('cancel'); dialog.buttons.empty(); - dialog.on_error = IPA.create_4304_error_handler(dialog); + dialog.on_error = rpc.create_4304_error_handler(dialog); dialog.get_add_message = function() { var label = that.entity.metadata.label_singular; @@ -2229,7 +2230,7 @@ IPA.dns.ptr_redirection_dialog = function(spec) { that.append_status(text.get('@i18n:objects.dnsrecord.ptr_redir_zones')); - var command = IPA.command({ + var command = rpc.command({ entity: 'dnszone', method: 'find', options: { @@ -2284,7 +2285,7 @@ IPA.dns.ptr_redirection_dialog = function(spec) { var record_name = that.reverse_address.substring(0,i1 - 1); that.record_keys = [that.zone, record_name]; - var command = IPA.command({ + var command = rpc.command({ entity: 'dnsrecord', method: 'show', args: that.record_keys, @@ -2321,7 +2322,7 @@ IPA.dns.ptr_redirection_dialog = function(spec) { var ptr = that.dns_record.name +'.' + that.dns_record.zone; - var command = IPA.command({ + var command = rpc.command({ entity: 'dnsrecord', method: 'add', args: that.record_keys, diff --git a/install/ui/src/freeipa/facet.js b/install/ui/src/freeipa/facet.js index 68f93fcef..823ea2793 100644 --- a/install/ui/src/freeipa/facet.js +++ b/install/ui/src/freeipa/facet.js @@ -35,13 +35,15 @@ define([ './navigation', './phases', './reg', + './rpc', './spec_util', './text', './dialog', './field', './widget' ], function(declare, lang, construct, on, Stateful, Evented, - Singleton_registry, builder, IPA, $, navigation, phases, reg, su, text) { + Singleton_registry, builder, IPA, $, + navigation, phases, reg, rpc, su, text) { /** * Facet module @@ -1883,7 +1885,7 @@ exp.table_facet = IPA.table_facet = function(spec, no_init) { */ that.create_get_records_command = function(pkeys, on_success, on_error) { - var batch = IPA.batch_command({ + var batch = rpc.batch_command({ name: that.get_records_command_name(), on_success: on_success, on_error: on_error @@ -1892,7 +1894,7 @@ exp.table_facet = IPA.table_facet = function(spec, no_init) { for (var i=0; i<pkeys.length; i++) { var pkey = pkeys[i]; - var command = IPA.command({ + var command = rpc.command({ entity: that.table.entity.name, method: 'show', args: [pkey] diff --git a/install/ui/src/freeipa/field.js b/install/ui/src/freeipa/field.js index ef50ebf2a..ab04fcacf 100644 --- a/install/ui/src/freeipa/field.js +++ b/install/ui/src/freeipa/field.js @@ -33,9 +33,10 @@ define([ './navigation', './phases', './reg', + './rpc', './text'], function(array, lang, metadata_provider, builder, datetime, IPA, $, - navigation, phases, reg, text) { + navigation, phases, reg, rpc, text) { /** * Field module @@ -1294,7 +1295,7 @@ IPA.link_field = function(spec) { return; } - IPA.command({ + rpc.command({ entity: that.other_entity.name, method: 'show', args: that.other_pkeys(), @@ -1370,7 +1371,7 @@ IPA.enable_field = function(spec) { method = that.enable_method; } - var command = IPA.command({ + var command = rpc.command({ entity: that.entity.name, method: method, args: that.facet.get_pkeys(), @@ -1577,4 +1578,4 @@ exp.register = function() { phases.on('registration', exp.register); return exp; -});
\ No newline at end of file +}); diff --git a/install/ui/src/freeipa/hbac.js b/install/ui/src/freeipa/hbac.js index 18024953b..34ee642ae 100644 --- a/install/ui/src/freeipa/hbac.js +++ b/install/ui/src/freeipa/hbac.js @@ -24,13 +24,14 @@ define([ './jquery', './phases', './reg', + './rpc', './association', './details', './entity', './rule', './search' ], - function(IPA, $, phases, reg) { + function(IPA, $, phases, reg, rpc) { var exp = IPA.hbac = { //priority of commands in details facet diff --git a/install/ui/src/freeipa/hbactest.js b/install/ui/src/freeipa/hbactest.js index 93155b5ac..1bf90b766 100644 --- a/install/ui/src/freeipa/hbactest.js +++ b/install/ui/src/freeipa/hbactest.js @@ -25,13 +25,14 @@ define([ './navigation', './phases', './reg', + './rpc', './text', './details', './search', './association', './entity', './hbac'], - function(metadata_provider, IPA, $, navigation, phases, reg, text) { + function(metadata_provider, IPA, $, navigation, phases, reg, rpc, text) { var exp = {}; @@ -235,7 +236,7 @@ IPA.hbac.test_facet = function(spec) { var filter = that.state.filter; - var command = IPA.command({ + var command = rpc.command({ name: that.get_search_command_name(), entity: that.managed_entity.name, method: 'find', @@ -675,7 +676,7 @@ IPA.hbac.test_run_facet = function(spec) { that.run = function() { - var command = IPA.command({ method: 'hbactest' }); + var command = rpc.command({ method: 'hbactest' }); var options = {}; var validation_results = { diff --git a/install/ui/src/freeipa/host.js b/install/ui/src/freeipa/host.js index 8b6692282..c76b7ca8c 100644 --- a/install/ui/src/freeipa/host.js +++ b/install/ui/src/freeipa/host.js @@ -23,13 +23,14 @@ define(['./ipa', './jquery', './phases', './reg', + './rpc', './text', './details', './search', './association', './entity', './certificate'], - function(IPA, $, phases, reg, text) { + function(IPA, $, phases, reg, rpc, text) { var exp = IPA.host = {}; @@ -459,7 +460,7 @@ IPA.host_adder_dialog = function(spec) { that.container.addClass('host-adder-dialog'); }; - that.on_error = IPA.create_4304_error_handler(that); + that.on_error = rpc.create_4304_error_handler(that); return that; }; @@ -509,7 +510,7 @@ IPA.dnszone_select_widget = function(spec) { var that = IPA.entity_select_widget(spec); that.create_search_command = function(filter) { - return IPA.command({ + return rpc.command({ entity: that.other_entity.name, method: 'find', args: [filter], @@ -672,7 +673,7 @@ IPA.host_unprovision_dialog = function(spec) { var pkey = that.facet.get_pkeys(); - var command = IPA.command({ + var command = rpc.command({ name: that.entity.name+'_disable_'+pkey, entity: that.entity.name, method: 'disable', diff --git a/install/ui/src/freeipa/ipa.js b/install/ui/src/freeipa/ipa.js index 7ff7872a8..3d84f9114 100644 --- a/install/ui/src/freeipa/ipa.js +++ b/install/ui/src/freeipa/ipa.js @@ -31,8 +31,10 @@ define([ './metadata', './builder', './reg', - './text'], - function(keys, $, JSON, i18n, datetime, metadata_provider, builder, reg, text) { + './rpc', + './text', + 'exports' + ], function(keys, $, JSON, i18n, datetime, metadata_provider, builder, reg, rpc, text, exports) { /** * @class @@ -44,11 +46,11 @@ define([ * and move them to separate modules. * */ -var IPA = function() { +var IPA = function () { - var that = { - jsonrpc_id: 0 - }; + var that = exports; + + that.jsonrpc_id = 0; // live server path that.url = '/ipa/ui/'; @@ -130,7 +132,7 @@ var IPA = function() { $.ajaxSetup(that.ajax_options); - var batch = IPA.batch_command({ + var batch = rpc.batch_command({ name: 'ipa_init', retry: false, on_success: function() { @@ -168,7 +170,7 @@ var IPA = function() { } }); - batch.add_command(IPA.command({ + batch.add_command(rpc.command({ method: 'i18n_messages', on_success: function(data, text_status, xhr) { that.messages = data.texts; @@ -176,7 +178,7 @@ var IPA = function() { } })); - batch.add_command(IPA.command({ + batch.add_command(rpc.command({ entity: 'config', method: 'show', on_success: function(data, text_status, xhr) { @@ -186,7 +188,7 @@ var IPA = function() { batch.add_command(that.get_whoami_command(true)); - batch.add_command(IPA.command({ + batch.add_command(rpc.command({ method: 'env', on_success: function(data, text_status, xhr) { that.env = data.result; @@ -194,7 +196,7 @@ var IPA = function() { } })); - batch.add_command(IPA.command({ + batch.add_command(rpc.command({ entity: 'dns', method: 'is_enabled', on_success: function(data, text_status, xhr) { @@ -202,7 +204,7 @@ var IPA = function() { } })); - batch.add_command(IPA.command({ + batch.add_command(rpc.command({ entity: 'trustconfig', method: 'show', retry: false, @@ -224,7 +226,7 @@ var IPA = function() { * in a batch. */ that.get_whoami_command = function(batch) { - return IPA.command({ + return rpc.command({ entity: 'user', method: 'find', options: { @@ -247,7 +249,7 @@ var IPA = function() { */ that.init_metadata = function(params) { - var objects = IPA.command({ + var objects = rpc.command({ name: 'ipa_init_objects', method: 'json_metadata', options: { @@ -258,7 +260,7 @@ var IPA = function() { } }); - var commands = IPA.command({ + var commands = rpc.command({ name: 'ipa_init_commands', method: 'json_metadata', options: { @@ -269,7 +271,7 @@ var IPA = function() { } }); - var metadata_command = IPA.concurrent_command({ + var metadata_command = rpc.concurrent_command({ commands: [ objects, commands @@ -822,9 +824,9 @@ IPA.error_dialog = function(spec) { that.text_status = spec.text_status || ''; /** @property {{name:string,message:string}} error_thrown Command's error */ that.error_thrown = spec.error_thrown || {}; - /** @property {IPA.command} command Command */ + /** @property {rpc.command} command Command */ that.command = spec.command; - /** @property {IPA.error_list} errors Errors */ + /** @property {rpc.error_list} errors Errors */ that.errors = spec.errors; /** @property {string[]} visible_buttons=['retry', 'cancel'] Visible button names */ that.visible_buttons = spec.visible_buttons || ['retry', 'cancel']; diff --git a/install/ui/src/freeipa/rpc.js b/install/ui/src/freeipa/rpc.js index f2878dda3..bd5184650 100644 --- a/install/ui/src/freeipa/rpc.js +++ b/install/ui/src/freeipa/rpc.js @@ -28,9 +28,7 @@ define([ './text', 'exports' ], - function(lang, IPA, text, exports) { - -var rpc = {}; + function(lang, IPA, text, rpc /*exports*/) { /** * Call an IPA command over JSON-RPC. @@ -379,14 +377,14 @@ rpc.command = function(spec) { /** * Parse successful command result and get all errors. * @protected - * @param {IPA.command} command + * @param {rpc.command} command * @param {Object} result * @param {string} text_status * @param {XMLHttpRequest} xhr - * @return {IPA.error_list} + * @return {rpc.error_list} */ that.get_failed = function(command, result, text_status, xhr) { - var errors = IPA.error_list(); + var errors = rpc.error_list(); if(result && result.failed) { for(var association in result.failed) { for(var member_name in result.failed[association]) { @@ -461,7 +459,7 @@ rpc.command = function(spec) { * @extends rpc.command * * @param {Object} spec - * @param {Array.<IPA.command>} spec.commands - IPA commands to be executed + * @param {rpc.command[]} spec.commands - IPA commands to be executed * @param {Function} spec.on_success - callback function if command succeeds * @param {Function} spec.on_error - callback function if command fails */ @@ -471,12 +469,12 @@ rpc.batch_command = function(spec) { spec.method = 'batch'; - var that = IPA.command(spec); + var that = rpc.command(spec); - /** @property {IPA.command[]} commands Commands */ + /** @property {rpc.command[]} commands Commands */ that.commands = []; - /** @property {IPA.error_list} errors Errors */ - that.errors = IPA.error_list(); + /** @property {rpc.error_list} errors Errors */ + that.errors = rpc.error_list(); /** * Show error if some command fail @@ -487,7 +485,7 @@ rpc.batch_command = function(spec) { /** * Add command - * @param {IPA.command} command + * @param {rpc.command} command */ that.add_command = function(command) { that.commands.push(command); @@ -496,7 +494,7 @@ rpc.batch_command = function(spec) { /** * Add commands - * @param {IPA.command[]} commands + * @param {rpc.command[]} commands */ that.add_commands = function(commands) { for (var i=0; i<commands.length; i++) { @@ -510,7 +508,7 @@ rpc.batch_command = function(spec) { that.execute = function() { that.errors.clear(); - var command = IPA.command({ + var command = rpc.command({ name: that.name, entity: that.entity, method: that.method, @@ -830,7 +828,7 @@ rpc.concurrent_command = function(spec) { * * Collection for RPC command errors. * - * @class IPA.error_list + * @class rpc.error_list * @private */ rpc.error_list = function() { @@ -869,7 +867,7 @@ rpc.error_list = function() { }; /** - * Error handler for IPA.command which handles error #4304 as success. + * Error handler for rpc.command which handles error #4304 as success. * * 4304 is raised when part of an operation succeeds and the part that failed * isn't critical. @@ -917,14 +915,5 @@ rpc.create_4304_error_handler = function(adder_dialog) { }; }; -// backwards compatibility: -IPA.error_list = rpc.error_list; -IPA.create_4304_error_handler = rpc.create_4304_error_handler; -IPA.command = rpc.command; -IPA.batch_command = rpc.batch_command; -IPA.concurrent_command = rpc.concurrent_command; - -lang.mixin(exports, rpc); - return rpc; });
\ No newline at end of file diff --git a/install/ui/src/freeipa/rule.js b/install/ui/src/freeipa/rule.js index 332342bf8..c262c6a86 100644 --- a/install/ui/src/freeipa/rule.js +++ b/install/ui/src/freeipa/rule.js @@ -23,11 +23,12 @@ define([ './jquery', './phases', './reg', + './rpc', './details', './search', './association', './entity'], - function(IPA, $, phases, reg) { + function(IPA, $, phases, reg, rpc) { IPA.rule_details_widget = function(spec) { @@ -221,7 +222,7 @@ IPA.rule_association_table_field = function(spec) { if (values.length > 0) { //no need to delete if has no values - var command = IPA.command({ + var command = rpc.command({ entity: that.entity.name, method: that.widget.remove_method, args: that.facet.get_pkeys() diff --git a/install/ui/src/freeipa/search.js b/install/ui/src/freeipa/search.js index 394de3e8c..9400b6aec 100644 --- a/install/ui/src/freeipa/search.js +++ b/install/ui/src/freeipa/search.js @@ -26,10 +26,11 @@ define([ './jquery', './phases', './reg', + './rpc', './spec_util', './text', './facet'], - function(IPA, $, phases, reg, su, text, mod_facet) { + function(IPA, $, phases, reg, rpc, su, text, mod_facet) { var exp = {}; @@ -235,7 +236,7 @@ IPA.search_facet = function(spec, no_init) { var args = that.get_refresh_command_args(); - var command = IPA.command({ + var command = rpc.command({ name: that.get_search_command_name(), entity: that.managed_entity.name, method: 'find', @@ -312,12 +313,12 @@ IPA.search_deleter_dialog = function(spec) { that.pkey_prefix = spec.pkey_prefix || []; that.create_command = function() { - var batch = IPA.batch_command({ + var batch = rpc.batch_command({ error_message: '@i18n:search.partial_delete' }); for (var i=0; i<that.values.length; i++) { - var command = IPA.command({ + var command = rpc.command({ entity: that.entity.name, method: 'del' }); @@ -475,7 +476,7 @@ IPA.batch_items_action = function(spec) { var pkeys = facet.get_pkeys(); if (!pkeys[0]) pkeys = []; // correction for search facet - that.batch = IPA.batch_command({ + that.batch = rpc.batch_command({ name: entity.name + '_batch_'+ that.method, on_success: that.get_on_success(facet, on_success) }); @@ -492,7 +493,7 @@ IPA.batch_items_action = function(spec) { }; that.create_action_command = function(facet, keys) { - var command = IPA.command({ + var command = rpc.command({ entity: facet.managed_entity.name, method: that.method, args: keys, diff --git a/install/ui/src/freeipa/service.js b/install/ui/src/freeipa/service.js index 241f22753..09880a937 100644 --- a/install/ui/src/freeipa/service.js +++ b/install/ui/src/freeipa/service.js @@ -23,12 +23,13 @@ define([ './jquery', './phases', './reg', + './rpc', './text', './details', './search', './association', './entity'], - function(IPA, $, phases, reg, text) { + function(IPA, $, phases, reg, rpc, text) { var exp =IPA.service = {}; @@ -410,7 +411,7 @@ IPA.service.unprovision_dialog = function(spec) { var principal_f = that.facet.fields.get_field('krbprincipalname'); var pkey = principal_f.values[0]; - IPA.command({ + rpc.command({ entity: that.entity.name, method: 'disable', args: [pkey], diff --git a/install/ui/src/freeipa/sudo.js b/install/ui/src/freeipa/sudo.js index 17e55b08d..d0b0539ef 100644 --- a/install/ui/src/freeipa/sudo.js +++ b/install/ui/src/freeipa/sudo.js @@ -23,6 +23,7 @@ define([ './jquery', './phases', './reg', + './rpc', './text', './association', './entity', @@ -30,7 +31,7 @@ define([ './rule', './search' ], - function(IPA, $, phases, reg, text) { + function(IPA, $, phases, reg, rpc, text) { var exp = IPA.sudo = { //priority of commands in details facet @@ -822,7 +823,7 @@ IPA.sudo.options_section = function(spec) { var pkey = that.facet.get_pkey(); - var command = IPA.command({ + var command = rpc.command({ entity: 'sudorule', method: 'add_option', args: [pkey], @@ -878,7 +879,7 @@ IPA.sudo.options_section = function(spec) { dialog.execute = function() { - var batch = IPA.batch_command({ + var batch = rpc.batch_command({ on_success: function(data) { //last successful result of batch results contains valid data var result; @@ -905,7 +906,7 @@ IPA.sudo.options_section = function(spec) { }); for (var i=0; i<values.length; i++) { - var command = IPA.command({ + var command = rpc.command({ entity: 'sudorule', method: 'remove_option', args: [pkey] @@ -923,7 +924,7 @@ IPA.sudo.options_section = function(spec) { }; that.reload = function() { - var command = IPA.command({ + var command = rpc.command({ entity: that.facet.entity.name, method: 'show', args: that.facet.get_pkeys(), diff --git a/install/ui/src/freeipa/user.js b/install/ui/src/freeipa/user.js index 6c5fbac4d..e6b252649 100644 --- a/install/ui/src/freeipa/user.js +++ b/install/ui/src/freeipa/user.js @@ -26,13 +26,14 @@ define([ './jquery', './phases', './reg', + './rpc', './text', './details', './search', './association', './entity', './certificate'], - function(IPA, $, phases, reg, text) { + function(IPA, $, phases, reg, rpc, text) { /** * User module @@ -366,7 +367,7 @@ IPA.user.details_facet = function(spec) { var pkey = that.get_pkey(); - var batch = IPA.batch_command({ + var batch = rpc.batch_command({ name: 'user_details_refresh' }); @@ -381,7 +382,7 @@ IPA.user.details_facet = function(spec) { batch.add_command(user_command); - var pwpolicy_command = IPA.command({ + var pwpolicy_command = rpc.command({ entity: 'pwpolicy', method: 'show', options: { @@ -406,7 +407,7 @@ IPA.user.details_facet = function(spec) { batch.add_command(pwpolicy_command); - var krbtpolicy_command = IPA.command({ + var krbtpolicy_command = rpc.command({ entity: 'krbtpolicy', method: 'show', args: [ pkey ], @@ -623,7 +624,7 @@ IPA.user_password_dialog = function(spec) { that.set_password = function(pkey, current_password, password, on_success, on_error) { - var command = IPA.command({ + var command = rpc.command({ method: 'passwd', args: [ pkey ], options: { diff --git a/install/ui/src/freeipa/widget.js b/install/ui/src/freeipa/widget.js index 6f3e1b1ef..a9b77694e 100644 --- a/install/ui/src/freeipa/widget.js +++ b/install/ui/src/freeipa/widget.js @@ -34,10 +34,11 @@ define(['dojo/_base/array', './jquery', './phases', './reg', + './rpc', './text' ], function(array, lang, Evented, has, keys, on, builder, datetime, IPA, $, - phases, reg, text) { + phases, reg, rpc, text) { /** * Widget module @@ -2933,7 +2934,7 @@ IPA.attribute_table_widget = function(spec) { var pkeys = that.get_pkeys(); - var command = IPA.command({ + var command = rpc.command({ entity: that.entity.name, method: that.remove_command || 'del', args: pkeys, @@ -3543,7 +3544,7 @@ IPA.entity_select_widget = function(spec) { that.filter_options = spec.filter_options || {}; that.create_search_command = function(filter) { - return IPA.command({ + return rpc.command({ entity: that.other_entity.name, method: 'find', args: [filter], diff --git a/install/ui/test/association_tests.js b/install/ui/test/association_tests.js index 40daacee8..7580c5fe6 100644 --- a/install/ui/test/association_tests.js +++ b/install/ui/test/association_tests.js @@ -19,8 +19,14 @@ */ -define(['freeipa/ipa', 'freeipa/jquery', 'freeipa/association', 'freeipa/entity'], function(IPA, $) { - return function() { +define([ + 'freeipa/ipa', + 'freeipa/jquery', + 'freeipa/rpc', + 'freeipa/association', + 'freeipa/entity' +], function(IPA, $, rpc) + { return function() { module('association'); @@ -29,7 +35,7 @@ test("Testing serial_associator().", function() { expect(11); - var orig_ipa_batch_command = IPA.batch_command; + var orig_ipa_batch_command = rpc.batch_command; var user = IPA.entity({ name: 'user' }); var group = IPA.entity({ name: 'group' }); @@ -43,13 +49,13 @@ test("Testing serial_associator().", function() { params.values = ['user1', 'user2', 'user3']; - IPA.batch_command = function(spec) { + rpc.batch_command = function(spec) { var that = orig_ipa_batch_command(spec); that.execute = function() { equals(that.commands.length, params.values.length, - 'Checking IPA.batch_command command count'); + 'Checking rpc.batch_command command count'); var i, command; @@ -58,15 +64,15 @@ test("Testing serial_associator().", function() { equals( command.entity, params.other_entity.name, - 'Checking IPA.command() parameter: entity'); + 'Checking rpc.command() parameter: entity'); equals( command.method, params.method, - 'Checking IPA.command() parameter: method'); + 'Checking rpc.command() parameter: method'); equals( command.args[0], 'user'+(i+1), - 'Checking IPA.command() parameter: primary key'); + 'Checking rpc.command() parameter: primary key'); } that.on_success({}); @@ -82,14 +88,14 @@ test("Testing serial_associator().", function() { var associator = IPA.serial_associator(params); associator.execute(); - IPA.batch_command = orig_ipa_batch_command; + rpc.batch_command = orig_ipa_batch_command; }); test("Testing bulk_associator().", function() { expect(4); - var orig_ipa_command = IPA.command; + var orig_ipa_command = rpc.command; var counter = 0; @@ -105,7 +111,7 @@ test("Testing bulk_associator().", function() { params.values = ['user1', 'user2', 'user3']; - IPA.command = function(spec) { + rpc.command = function(spec) { var that = orig_ipa_command(spec); @@ -114,15 +120,15 @@ test("Testing bulk_associator().", function() { equals( that.method, params.method, - 'Checking IPA.command() parameter: method'); + 'Checking rpc.command() parameter: method'); equals( that.args[0], params.pkey, - 'Checking IPA.command() parameter: primary key'); + 'Checking rpc.command() parameter: primary key'); equals( that.options[params.other_entity.name], 'user1,user2,user3', - 'Checking IPA.command() parameter: options[\""+params.other_entity+"\"]'); + 'Checking rpc.command() parameter: options[\""+params.other_entity+"\"]'); that.on_success({}); }; @@ -137,7 +143,7 @@ test("Testing bulk_associator().", function() { var associator = IPA.bulk_associator(params); associator.execute(); - IPA.command = orig_ipa_command; + rpc.command = orig_ipa_command; }); };});
\ No newline at end of file diff --git a/install/ui/test/details_tests.js b/install/ui/test/details_tests.js index c911d1b61..c6c33bd17 100644 --- a/install/ui/test/details_tests.js +++ b/install/ui/test/details_tests.js @@ -25,10 +25,11 @@ define([ 'freeipa/details', 'freeipa/facet', 'freeipa/reg', + 'freeipa/rpc', 'freeipa/entity', 'freeipa/field', 'freeipa/widget'], - function(md, IPA, $, mod_details, mod_facet, reg) { + function(md, IPA, $, mod_details, mod_facet, reg, rpc) { return function() { var details_container; @@ -127,15 +128,15 @@ test("Testing details lifecycle: create, load.", function(){ data.result = {}; data.result.result = {}; - IPA.command({ + rpc.command({ entity: 'user', method: 'show', args: ['kfrog'], on_success: function(data, text_status, xhr) { - ok(true, "IPA.command() succeeded."); + ok(true, "rpc.command() succeeded."); }, on_error: function(xhr, text_status, error_thrown) { - ok(false, "IPA.command() failed: "+error_thrown); + ok(false, "rpc.command() failed: "+error_thrown); } }).execute(); diff --git a/install/ui/test/ipa_tests.js b/install/ui/test/ipa_tests.js index 8ac782ef8..52110c481 100644 --- a/install/ui/test/ipa_tests.js +++ b/install/ui/test/ipa_tests.js @@ -18,8 +18,14 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -define(['freeipa/ipa', 'freeipa/jquery', 'freeipa/dialog', 'freeipa/widget', - 'freeipa/details'], function(IPA, $) { +define([ + 'freeipa/ipa', + 'freeipa/jquery', + 'freeipa/rpc', + 'freeipa/dialog', + 'freeipa/widget', + 'freeipa/details'], + function(IPA, $, rpc) { return function() { module('ipa'); @@ -88,7 +94,7 @@ test("Testing IPA.get_member_attribute().", function() { "IPA.get_member_attribute(null, \"group\")"); }); -test("Testing successful IPA.command().", function() { +test("Testing successful rpc.command().", function() { var method = 'method'; var args = ['arg1', 'arg2', 'arg3']; @@ -138,7 +144,7 @@ test("Testing successful IPA.command().", function() { request.success(xhr, text_status, error_thrown); }; - IPA.command({ + rpc.command({ entity: object, method: method, args: args, @@ -164,7 +170,7 @@ test("Testing successful IPA.command().", function() { $.ajax = orig; }); -test("Testing unsuccessful IPA.command().", function() { +test("Testing unsuccessful rpc.command().", function() { var method = 'method'; var args = ['arg1', 'arg2', 'arg3']; @@ -209,7 +215,7 @@ test("Testing unsuccessful IPA.command().", function() { request.error(xhr, text_status, error_thrown); }; - IPA.command({ + rpc.command({ entity: object, method: method, args: args, diff --git a/ipatests/test_webui/ui_driver.py b/ipatests/test_webui/ui_driver.py index f0b9b4362..0e10c6b52 100644 --- a/ipatests/test_webui/ui_driver.py +++ b/ipatests/test_webui/ui_driver.py @@ -521,9 +521,9 @@ class UI_driver(object): var args = arguments[1]; var options = arguments[2]; var callback = arguments[arguments.length - 1]; - var IPA = require('freeipa/ipa'); + var rpc = require('freeipa/rpc'); - var cmd = IPA.command({ + var cmd = rpc.command({ method: method, args: args, options: options, |