diff --git a/install/ui/dialog.js b/install/ui/dialog.js index 964d5f5fc..08fba4580 100644 --- a/install/ui/dialog.js +++ b/install/ui/dialog.js @@ -105,6 +105,9 @@ IPA.dialog = function(spec) { }; that.init = function() { + + that.entity = IPA.get_entity(that.entity_name); + for (var i=0; i', { + type: 'button', + name: 'register', + value: 'Register' + }).appendTo(buttons); + $('', { type: 'button', name: 'consume', @@ -108,15 +197,29 @@ IPA.entitle.search_facet = function(spec) { var action_panel = that.get_action_panel(); - var button = $('input[name=consume]', action_panel); - that.consume_button = IPA.action_button({ - label: 'Consume', + var button = $('input[name=register]', action_panel); + that.register_button = IPA.action_button({ + label: 'Register', icon: 'ui-icon-plus', click: function() { - var dialog = that.get_dialog('consume'); + var dialog = that.entity.get_dialog('register'); dialog.open(that.container); } }); + that.register_button.css('display', 'none'); + button.replaceWith(that.register_button); + + button = $('input[name=consume]', action_panel); + that.consume_button = IPA.action_button({ + label: 'Consume', + icon: 'ui-icon-plus', + style: 'display: none;', + click: function() { + var dialog = that.entity.get_dialog('consume'); + dialog.open(that.container); + } + }); + that.consume_button.css('display', 'none'); button.replaceWith(that.consume_button); }; @@ -124,6 +227,9 @@ IPA.entitle.search_facet = function(spec) { function on_success(data, text_status, xhr) { + that.register_button.css('display', 'none'); + that.consume_button.css('display', 'inline'); + that.table.empty(); var result = data.result.result; @@ -132,7 +238,7 @@ IPA.entitle.search_facet = function(spec) { that.table.add_record(record); } - var summary = $('span[name=summary]', that.table.tfoot); + 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); @@ -143,28 +249,50 @@ IPA.entitle.search_facet = function(spec) { } function on_error(xhr, text_status, error_thrown) { + + that.register_button.css('display', 'inline'); + that.consume_button.css('display', 'none'); + var summary = $('span[name=summary]', that.table.tfoot).empty(); - summary.append('

Error: '+error_thrown.name+'

'); - summary.append('

'+error_thrown.title+'

'); - summary.append('

'+error_thrown.message+'

'); + summary.append(error_thrown.message); } - var command = IPA.command({ - entity: 'entitle', - method: 'get', - options: { - all: that.search_all - }, - on_success: on_success, - on_error: on_error - }); - - command.execute(); + that.entity.get_certificates( + on_success, + on_error); }; return that; }; +IPA.entitle.register_dialog = function(spec) { + + spec = spec || {}; + + var that = IPA.dialog(spec); + + that.add_button('Register', function() { + var record = {}; + that.save(record); + + that.entity.register( + record.username, + record.password, + function() { + var facet = that.entity.get_facet('search'); + facet.refresh(); + that.close(); + } + ); + }); + + that.add_button('Cancel', function() { + that.close(); + }); + + return that; +}; + IPA.entitle.consume_dialog = function(spec) { spec = spec || {}; @@ -175,19 +303,14 @@ IPA.entitle.consume_dialog = function(spec) { var record = {}; that.save(record); - var command = IPA.command({ - entity: 'entitle', - method: 'consume', - args: [ record.quantity ], - on_success: function() { - var entity = IPA.get_entity(that.entity_name); - var facet = entity.get_facet('search'); - facet.table.refresh(); + that.entity.consume( + record.quantity, + function() { + var facet = that.entity.get_facet('search'); + facet.refresh(); that.close(); } - }); - - command.execute(); + ); }); that.add_button('Cancel', function() { diff --git a/install/ui/entity.js b/install/ui/entity.js index 4db58465d..23f792d1e 100644 --- a/install/ui/entity.js +++ b/install/ui/entity.js @@ -64,6 +64,9 @@ IPA.facet = function (spec) { }; function init() { + + that.entity = IPA.get_entity(that.entity_name); + for (var i=0; i", + "exclude": null, + "flags": [], + "hint": null, + "include": null, + "label": "", + "length": null, + "maxlength": null, + "minlength": null, + "multivalue": true, + "name": "usercertificate", + "pattern": null, + "pattern_errmsg": null, + "primary_key": false, + "query": false, + "required": false, + "stdin_if_missing": false, + "type": "unicode" + } + ], + "takes_options": [ + { + "alwaysask": false, + "attribute": false, + "autofill": false, + "class": "Str", + "cli_name": "addattr", + "cli_short_name": null, + "default": null, + "doc": "Add an attribute/value pair. Format is attr=value. The attribute must be part of the schema.", + "exclude": [ + "webui" + ], + "flags": [], + "hint": null, + "include": null, + "label": "", + "length": null, + "maxlength": null, + "minlength": null, + "multivalue": true, + "name": "addattr", + "pattern": null, + "pattern_errmsg": null, + "primary_key": false, + "query": false, + "required": false, + "type": "unicode" + }, + { + "alwaysask": false, + "attribute": false, + "autofill": false, + "class": "Str", + "cli_name": "setattr", + "cli_short_name": null, + "default": null, + "doc": "Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.", + "exclude": [ + "webui" + ], + "flags": [], + "hint": null, + "include": null, + "label": "", + "length": null, + "maxlength": null, + "minlength": null, + "multivalue": true, + "name": "setattr", + "pattern": null, + "pattern_errmsg": null, + "primary_key": false, + "query": false, + "required": false, + "type": "unicode" + }, + { + "alwaysask": false, + "attribute": false, + "autofill": true, + "class": "Str", + "cli_name": "uuid", + "cli_short_name": null, + "default": "IMPORTED", + "doc": "Enrollment UUID", + "exclude": null, + "flags": [ + "no_update", + "no_create" + ], + "hint": null, + "include": null, + "label": "UUID", + "length": null, + "maxlength": null, + "minlength": null, + "multivalue": false, + "name": "uuid", + "pattern": null, + "pattern_errmsg": null, + "primary_key": false, + "query": false, + "required": false, + "type": "unicode" + } + ] + }, + "entitle_register": { + "takes_args": [ + { + "alwaysask": false, + "attribute": false, + "autofill": false, + "class": "Str", + "cli_name": "username", + "cli_short_name": null, + "default": null, + "doc": "Username", + "exclude": null, + "flags": [], + "hint": null, + "include": null, + "label": "Username", + "length": null, + "maxlength": null, + "minlength": null, + "multivalue": false, + "name": "username", + "pattern": null, + "pattern_errmsg": null, + "primary_key": false, + "query": false, + "required": true, + "type": "unicode" + } + ], + "takes_options": [ + { + "alwaysask": false, + "attribute": false, + "autofill": false, + "class": "Str", + "cli_name": "addattr", + "cli_short_name": null, + "default": null, + "doc": "Add an attribute/value pair. Format is attr=value. The attribute must be part of the schema.", + "exclude": [ + "webui" + ], + "flags": [], + "hint": null, + "include": null, + "label": "", + "length": null, + "maxlength": null, + "minlength": null, + "multivalue": true, + "name": "addattr", + "pattern": null, + "pattern_errmsg": null, + "primary_key": false, + "query": false, + "required": false, + "type": "unicode" + }, + { + "alwaysask": false, + "attribute": false, + "autofill": false, + "class": "Str", + "cli_name": "setattr", + "cli_short_name": null, + "default": null, + "doc": "Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.", + "exclude": [ + "webui" + ], + "flags": [], + "hint": null, + "include": null, + "label": "", + "length": null, + "maxlength": null, + "minlength": null, + "multivalue": true, + "name": "setattr", + "pattern": null, + "pattern_errmsg": null, + "primary_key": false, + "query": false, + "required": false, + "type": "unicode" + }, + { + "alwaysask": false, + "attribute": false, + "autofill": false, + "class": "Str", + "cli_name": "ipaentitlementid", + "cli_short_name": null, + "default": null, + "doc": "Enrollment UUID", + "exclude": null, + "flags": [ + "no_update", + "no_create" + ], + "hint": null, + "include": null, + "label": "UUID", + "length": null, + "maxlength": null, + "minlength": null, + "multivalue": false, + "name": "ipaentitlementid", + "pattern": null, + "pattern_errmsg": null, + "primary_key": false, + "query": false, + "required": false, + "type": "unicode" + }, + { + "alwaysask": false, + "attribute": false, + "autofill": false, + "class": "Password", + "cli_name": "password", + "cli_short_name": null, + "default": null, + "doc": "Registration password", + "exclude": null, + "flags": [], + "hint": null, + "include": null, + "label": "Password", + "length": null, + "maxlength": null, + "minlength": null, + "multivalue": false, + "name": "password", + "pattern": null, + "pattern_errmsg": null, + "primary_key": false, + "query": false, + "required": true, + "type": "unicode" + } + ] + }, + "entitle_sync": { + "takes_args": [], + "takes_options": [ + { + "alwaysask": false, + "attribute": false, + "autofill": true, + "class": "Int", + "cli_name": "hidden", + "cli_short_name": null, + "default": 1, + "doc": "Quantity", + "exclude": null, + "flags": [ + "no_option", + "no_output" + ], + "hint": null, + "include": null, + "label": "Quantity", + "maxvalue": 2147483647, + "minvalue": 1, + "multivalue": false, + "name": "hidden", + "primary_key": false, + "query": false, + "required": true, + "type": "int" + } + ] + }, "group_add": { "takes_options": [ { diff --git a/install/ui/widget.js b/install/ui/widget.js index fa102737c..744e6ed4a 100644 --- a/install/ui/widget.js +++ b/install/ui/widget.js @@ -282,6 +282,7 @@ IPA.text_widget = function(spec) { var that = IPA.widget(spec); that.size = spec.size || 30; + that.type = spec.type || 'text'; that.create = function(container) { @@ -291,7 +292,7 @@ IPA.text_widget = function(spec) { }).appendTo(container); $('', { - type: 'text', + type: that.type, name: that.name, disabled: that.disabled, size: that.size, diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py index 0dcb89039..7090acc69 100644 --- a/ipalib/plugins/baseldap.py +++ b/ipalib/plugins/baseldap.py @@ -633,7 +633,7 @@ class LDAPCreate(CallbackInterface, crud.Create): # list of attributes we want exported to JSON json_friendly_attributes = ( - 'takes_options', + 'takes_args', 'takes_options', ) def __json__(self): @@ -655,6 +655,16 @@ class LDAPQuery(CallbackInterface, crud.PKQuery): for arg in super(crud.PKQuery, self).get_args(): yield arg + # list of attributes we want exported to JSON + json_friendly_attributes = ( + 'takes_args', 'takes_options', + ) + + def __json__(self): + json_dict = dict( + (a, getattr(self, a)) for a in self.json_friendly_attributes + ) + return json_dict class LDAPMultiQuery(LDAPQuery): """ @@ -1445,6 +1455,16 @@ class LDAPSearch(CallbackInterface, crud.Search): def exc_callback(self, args, options, exc, call_func, *call_args, **call_kwargs): raise exc + # list of attributes we want exported to JSON + json_friendly_attributes = ( + 'takes_options', + ) + + def __json__(self): + json_dict = dict( + (a, getattr(self, a)) for a in self.json_friendly_attributes + ) + return json_dict class LDAPModReverseMember(LDAPQuery): """