summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Vobornik <pvoborni@redhat.com>2014-09-03 14:45:05 +0200
committerPetr Vobornik <pvoborni@redhat.com>2014-09-15 09:39:04 +0200
commit663a9e8809760cb8fc9b9ec4f1e11d0073199d8b (patch)
tree7bf39b51ef5ad59952bd09727b6f1d7e495b4f21
parenta7b19720f53a429e3fa73565f5256b8468d19ca9 (diff)
downloadfreeipa-views_ui.tar.gz
freeipa-views_ui.tar.xz
freeipa-views_ui.zip
idviews uiviews_ui
-rw-r--r--install/ui/src/freeipa/app.js3
-rw-r--r--install/ui/src/freeipa/association.js3
-rw-r--r--install/ui/src/freeipa/idviews.js434
-rw-r--r--install/ui/src/freeipa/navigation/menu_spec.js1
4 files changed, 439 insertions, 2 deletions
diff --git a/install/ui/src/freeipa/app.js b/install/ui/src/freeipa/app.js
index 2297b866d..46752fa09 100644
--- a/install/ui/src/freeipa/app.js
+++ b/install/ui/src/freeipa/app.js
@@ -35,6 +35,7 @@ define([
'./hostgroup',
'./host',
'./idrange',
+ './idviews',
'./netgroup',
'./otptoken',
'./policy',
@@ -50,4 +51,4 @@ define([
'dojo/domReady!'
],function(app_container) {
return app_container;
-}); \ No newline at end of file
+});
diff --git a/install/ui/src/freeipa/association.js b/install/ui/src/freeipa/association.js
index b78903ad7..87a0570e6 100644
--- a/install/ui/src/freeipa/association.js
+++ b/install/ui/src/freeipa/association.js
@@ -133,6 +133,7 @@ IPA.bulk_associator = function(spec) {
spec = spec || {};
var that = IPA.associator(spec);
+ that.options = spec.options || { 'all': true };
that.execute = function() {
@@ -145,7 +146,7 @@ IPA.bulk_associator = function(spec) {
entity: that.entity.name,
method: that.method,
args: [that.pkey],
- options: { 'all': true },
+ options: that.options,
on_success: that.on_success,
on_error: that.on_error
});
diff --git a/install/ui/src/freeipa/idviews.js b/install/ui/src/freeipa/idviews.js
new file mode 100644
index 000000000..5434fd72b
--- /dev/null
+++ b/install/ui/src/freeipa/idviews.js
@@ -0,0 +1,434 @@
+/* Authors:
+ * Petr Vobornik <pvoborni@redhat.com>
+ *
+ * Copyright (C) 2014 Red Hat
+ * see file 'COPYING' for use and warranty information
+ *
+ * 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.
+ *
+ * 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+define([
+ './ipa',
+ './jquery',
+ './menu',
+ './phases',
+ './reg',
+ './rpc',
+ './text',
+ './details',
+ './facet',
+ './search',
+ './entity'],
+ function(IPA, $, menu, phases, reg, rpc, text, mod_details, mod_facet) {
+/**
+ * ID Views module
+ * @class
+ * @singleton
+ */
+var idviews = IPA.idviews = {};
+
+var make_spec = function() {
+return {
+ name: 'idview',
+ enable_test: function() {
+ return true;
+ },
+ facet_groups: ['appliedto', 'overrides', 'settings'],
+ facets: [
+ {
+ $type: 'search',
+ columns: [
+ 'cn',
+ 'description'
+ ]
+ },
+ {
+ $type: 'details',
+ actions: [
+ 'delete'
+ ],
+ header_actions: ['delete'],
+ state: {
+ },
+ sections: [
+ {
+ name: 'details',
+ //label: '@i18n:objects.idviews.details',
+ fields: [
+ 'cn',
+ {
+ $type: 'textarea',
+ name: 'description'
+ },
+ {
+ name: 'useroverrides'
+ },
+ {
+ name: 'groupoverrides'
+ },
+ {
+ name: 'appliedtohosts'
+ }
+ ]
+ }
+ ]
+ },
+ {
+ $type: 'nested_search',
+ //$factory: IPA.automount.key_search_facet,
+ facet_group: 'overrides',
+ nested_entity: 'idoverrideuser',
+ search_all_entries: true,
+ label: 'User overrides',// TODO: translate
+ tab_label: 'User overrides', // TODO: translate
+ name: 'idoverrideuser',
+ columns: [
+ {
+ name: 'ipaanchoruuid',
+ label: 'User to override' //TODO: translate
+ },
+ 'uid',
+ 'uidnumber',
+ 'homedirectory',
+ 'description'
+ ]
+ },
+ {
+ $type: 'nested_search',
+ //$factory: IPA.automount.key_search_facet,
+ facet_group: 'overrides',
+ nested_entity: 'idoverridegroup',
+ search_all_entries: true,
+ label: 'Group overrides',// TODO: translate
+ tab_label: 'Group overrides', // TODO: translate
+ name: 'idoverridegroup',
+ columns: [
+ {
+ name: 'ipaanchoruuid',
+ label: 'Group to override' //TODO: translate
+ },
+ 'cn',
+ 'gidnumber',
+ 'description'
+ ]
+ },
+ {
+ $type: 'attribute',
+ name: 'appliedtohosts',
+ attribute: 'appliedtohosts',
+ tab_label: 'Applied to hosts',
+ facet_group: 'appliedto',
+ actions: [
+ 'idview_apply', //host and hostgroups
+ 'idview_apply_hostgroups',
+ 'idview_unapply_action' //host and hostgroups
+ ],
+ control_buttons: [
+ {
+ name: 'idview_apply',
+ label: 'Apply to hosts',
+ //label: '@i18n:buttons.disable',
+ icon: 'fa-plus'
+ },
+ {
+ name: 'idview_apply_hostgroups',
+ label: 'Apply to host groups',
+ //label: '@i18n:buttons.disable',
+ icon: 'fa-plus'
+ }
+ ],
+ columns: [
+ {
+ name: 'appliedtohosts',
+ label: 'Host' // TODO: translate
+ }
+ ]
+ }
+ ],
+
+ adder_dialog: {
+ fields: [
+ 'cn',
+ 'description'
+ ]
+ }
+};};
+
+var make_idoverrideuser_spec = function() {
+return {
+ name: 'idoverrideuser',
+ enable_test: function() {
+ return true;
+ },
+ containing_entity: 'idview',
+ facets: [
+ {
+ $type: 'details',
+ disable_breadcrumb: false,
+ containing_facet: 'idoverrideuser',
+ actions: [
+ 'delete'
+ ],
+ header_actions: ['delete'],
+ state: {
+ },
+ sections: [
+ {
+ name: 'details',
+ //label: '@i18n:objects.idviews.details',
+ fields: [
+ {
+ $type: 'link',
+ name: 'ipaanchoruuid',
+ label: 'User to override',
+ other_entity: 'user',
+ no_check: true,
+ is_link: true
+ },
+ {
+ $type: 'textarea',
+ name: 'description'
+ },
+ 'uid',
+ 'uidnumber',
+ 'homedirectory'
+ ]
+ }
+ ]
+ }
+ ],
+
+ adder_dialog: {
+ fields: [
+ {
+ $type: 'entity_select',
+ label: 'User to override',
+ name: 'ipaanchoruuid',
+ other_entity: 'user',
+ other_field: 'uid'
+ },
+ 'uid',
+ 'uidnumber',
+ 'homedirectory',
+ {
+ $type: 'textarea',
+ name: 'description'
+ }
+ ]
+ }
+};};
+
+var make_idoverridegroup_spec = function() {
+return {
+ name: 'idoverridegroup',
+ enable_test: function() {
+ return true;
+ },
+ containing_entity: 'idview',
+ facets: [
+ {
+ $type: 'details',
+ disable_breadcrumb: false,
+ containing_facet: 'idoverridegroup',
+ actions: [
+ 'delete'
+ ],
+ header_actions: ['delete'],
+ state: {
+ },
+ sections: [
+ {
+ name: 'details',
+ //label: '@i18n:objects.idviews.details',
+ fields: [
+ {
+ $type: 'link',
+ name: 'ipaanchoruuid',
+ label: 'Group to override',
+ other_entity: 'group',
+ no_check: true,
+ is_link: true
+ },
+ {
+ $type: 'textarea',
+ name: 'description'
+ },
+ 'cn',
+ 'gidnumber'
+ ]
+ }
+ ]
+ }
+ ],
+
+ adder_dialog: {
+ fields: [
+ {
+ $type: 'entity_select',
+ label: 'Group to override',
+ name: 'ipaanchoruuid',
+ other_entity: 'group',
+ other_field: 'cn'
+ },
+ 'cn',
+ 'gidnumber',
+ {
+ $type: 'textarea',
+ name: 'description'
+ }
+ ]
+ }
+};};
+
+
+/**
+ * Apply Id view on hosts on hostgroup action base class
+ *
+ * @class idviews.apply_action
+ * @extends IPA.action
+ */
+idviews.apply_action = function(spec) {
+
+ spec = spec || {};
+ spec.name = spec.name || 'idview_apply';
+ spec.label = spec.label || 'Apply on Hosts';
+
+ var that = IPA.action(spec);
+
+ /**
+ * Entity to apply
+ * @type {[type]}
+ */
+ that.other_entity = spec.other_entity || 'host';
+
+ that.execute_action = function(facet, on_success, on_error) {
+
+ that.show_add_dialog(facet);
+ };
+
+ that.on_success = function(facet, data, text_status, xhr) {
+
+ //IPA.notify_success(data.result.summary);
+ //facet.on_update.notify();
+ //facet.redirect();
+ };
+
+ that.show_add_dialog = function(facet, current_pkeys) {
+
+ var pkey = facet.get_pkey();
+ var other_entity = reg.entity.get(that.other_entity);
+ var other_entity_label = other_entity.metadata.label;
+ var title = "Apply ID view on ${entity}".replace('${entity}', other_entity_label);
+
+ var dialog = IPA.association_adder_dialog({
+ title: title,
+ entity: facet.entity,
+ pkey: pkey,
+ other_entity: other_entity,
+ attribute_member: that.attribute_member,
+ exclude: current_pkeys || []
+ //search_options: that.search_options
+ });
+
+ // var adder_columns = that.adder_columns.values;
+ // if (adder_columns.length) {
+ // dialog.set_columns(adder_columns);
+ // }
+
+ dialog.execute = function() {
+
+ var associator = IPA.bulk_associator({
+ entity: facet.entity,
+ pkey: pkey,
+ other_entity: that.other_entity,
+ values: dialog.get_selected_values(),
+ method: 'apply',
+ options: {},
+ on_success: function(data) {
+ facet.refresh();
+ dialog.close();
+
+ var succeeded = IPA.get_succeeded(data);
+ var msg = text.get('@i18n:association.added').replace('${count}', succeeded);
+ IPA.notify_success(msg);
+ },
+ on_error: function() {
+ facet.refresh();
+ dialog.close();
+ }
+ });
+
+ associator.execute();
+ };
+
+ dialog.open();
+ };
+
+ return that;
+};
+
+
+/**
+ * Apply Id view on hosts on hostgroup action base class
+ *
+ * @class idviews.apply_hostgroup_action
+ * @extends idviews.apply_action
+ */
+idviews.apply_hostgroups_action = function(spec) {
+
+ spec = spec || {};
+ spec.name = spec.name || 'idview_apply_hostgroups';
+ spec.label = spec.label || 'Apply on Hosts Groups';
+ spec.other_entity = spec.other_entity || 'hostgroup';
+
+ var that = idviews.apply_action(spec);
+ return that;
+};
+
+/**
+ * ID View entity specification object
+ * @member idviews
+ */
+idviews.spec = make_spec();
+
+/**
+ * ID user override entity specification object
+ * @member idviews
+ */
+idviews.idoverrideuser_spec = make_idoverrideuser_spec();
+
+/**
+ * ID group override entity specification object
+ * @member idviews
+ */
+idviews.idoverridegroup_spec = make_idoverridegroup_spec();
+
+/**
+ * Register entity
+ * @member idviews
+ */
+idviews.register = function() {
+ var e = reg.entity;
+ var a = reg.action;
+ e.register({type: 'idview', spec: idviews.spec});
+ e.register({type: 'idoverrideuser', spec: idviews.idoverrideuser_spec});
+ e.register({type: 'idoverridegroup', spec: idviews.idoverridegroup_spec});
+ a.register('idview_apply', idviews.apply_action);
+ a.register('idview_apply_hostgroups', idviews.apply_hostgroups_action);
+};
+
+phases.on('registration', idviews.register);
+
+return idviews;
+});
diff --git a/install/ui/src/freeipa/navigation/menu_spec.js b/install/ui/src/freeipa/navigation/menu_spec.js
index 9182d11bf..ed80f4eba 100644
--- a/install/ui/src/freeipa/navigation/menu_spec.js
+++ b/install/ui/src/freeipa/navigation/menu_spec.js
@@ -168,6 +168,7 @@ var nav = {};
{ entity: 'trustconfig' }
]
},
+ { entity: 'idview' },
{ entity: 'config' }
]
}