diff --git a/src/sunstone/etc/sunstone-views/admin.yaml b/src/sunstone/etc/sunstone-views/admin.yaml index 5c20f87e53..27e4623f0b 100644 --- a/src/sunstone/etc/sunstone-views/admin.yaml +++ b/src/sunstone/etc/sunstone-views/admin.yaml @@ -69,6 +69,7 @@ tabs: User.create_dialog: true User.update_password: true User.quotas_dialog: true + User.groups_dialog: true User.chgrp: true User.addgroup: true User.delgroup: true diff --git a/src/sunstone/etc/sunstone-views/admin_vcenter.yaml b/src/sunstone/etc/sunstone-views/admin_vcenter.yaml index 9bb7a8b8b4..af83c08207 100644 --- a/src/sunstone/etc/sunstone-views/admin_vcenter.yaml +++ b/src/sunstone/etc/sunstone-views/admin_vcenter.yaml @@ -69,6 +69,7 @@ tabs: User.create_dialog: true User.update_password: true User.quotas_dialog: true + User.groups_dialog: true User.chgrp: true User.addgroup: true User.delgroup: true diff --git a/src/sunstone/etc/sunstone-views/user.yaml b/src/sunstone/etc/sunstone-views/user.yaml index 34b99b8da4..39d1ab84e4 100644 --- a/src/sunstone/etc/sunstone-views/user.yaml +++ b/src/sunstone/etc/sunstone-views/user.yaml @@ -70,6 +70,7 @@ tabs: User.create_dialog: true User.update_password: true User.quotas_dialog: true + User.groups_dialog: true User.chgrp: true User.addgroup: true User.delgroup: true diff --git a/src/sunstone/public/app/tabs/users-tab.js b/src/sunstone/public/app/tabs/users-tab.js index f00f2f4bec..ff846dca59 100644 --- a/src/sunstone/public/app/tabs/users-tab.js +++ b/src/sunstone/public/app/tabs/users-tab.js @@ -26,7 +26,8 @@ define(function(require) { var _dialogs = [ require('./users-tab/dialogs/password'), require('./users-tab/dialogs/auth-driver'), - require('./users-tab/dialogs/quotas') + require('./users-tab/dialogs/quotas'), + require('./users-tab/dialogs/groups') ]; var _panels = [ diff --git a/src/sunstone/public/app/tabs/users-tab/actions.js b/src/sunstone/public/app/tabs/users-tab/actions.js index 8b97d98c81..0e1a60eb44 100644 --- a/src/sunstone/public/app/tabs/users-tab/actions.js +++ b/src/sunstone/public/app/tabs/users-tab/actions.js @@ -27,6 +27,7 @@ define(function(require) { var PASSWORD_DIALOG_ID = require('./dialogs/password/dialogId'); var AUTH_DRIVER_DIALOG_ID = require('./dialogs/auth-driver/dialogId'); var QUOTAS_DIALOG_ID = require('./dialogs/quotas/dialogId'); + var GROUPS_DIALOG_ID = require('./dialogs/groups/dialogId'); var RESOURCE = "User"; var XML_ROOT = "USER"; @@ -43,6 +44,18 @@ define(function(require) { "User.chgrp": _commonActions.multipleAction('chgrp'), "User.addgroup": _commonActions.multipleAction('addgroup'), "User.delgroup": _commonActions.multipleAction('delgroup'), + "User.groups_dialog" : _commonActions.checkAndShow("groups"), + + "User.groups" : { + type: "single", + call: OpenNebulaResource.show, + callback: function(request, response) { + Sunstone.getDialog(GROUPS_DIALOG_ID).setParams({element: response[XML_ROOT]}); + Sunstone.getDialog(GROUPS_DIALOG_ID).reset(); + Sunstone.getDialog(GROUPS_DIALOG_ID).show(); + }, + error: Notifier.onError + }, "User.update_password" : { type: "custom", diff --git a/src/sunstone/public/app/tabs/users-tab/buttons.js b/src/sunstone/public/app/tabs/users-tab/buttons.js index bf1c4de331..5aa209ff41 100644 --- a/src/sunstone/public/app/tabs/users-tab/buttons.js +++ b/src/sunstone/public/app/tabs/users-tab/buttons.js @@ -42,6 +42,11 @@ define(function(require) { layout: "main_buttons", text : Locale.tr("Quotas") }, + "User.groups_dialog" : { + type : "action", + layout: "main_buttons", + text : Locale.tr("Groups") + }, "User.chgrp" : { type: "confirm_with_select", text: Locale.tr("Change group"), diff --git a/src/sunstone/public/app/tabs/users-tab/dialogs/groups.js b/src/sunstone/public/app/tabs/users-tab/dialogs/groups.js new file mode 100644 index 0000000000..9e04db1c19 --- /dev/null +++ b/src/sunstone/public/app/tabs/users-tab/dialogs/groups.js @@ -0,0 +1,153 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2015, OpenNebula Project, OpenNebula Systems */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); you may */ +/* not use this file except in compliance with the License. You may obtain */ +/* a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ +/* See the License for the specific language governing permissions and */ +/* limitations under the License. */ +/* -------------------------------------------------------------------------- */ + +define(function(require) { + /* + DEPENDENCIES + */ + + var BaseDialog = require('utils/dialogs/dialog'); + var TemplateHTML = require('hbs!./groups/html'); + //var Sunstone = require('sunstone'); + //var DatastoreTable = require('tabs/datastores-tab/datatable') + //var Notifier = require('utils/notifier'); + //var OpenNebulaImage = require('opennebula/image'); + //var OpenNebulaDatastore = require('opennebula/datastore'); + + /* + CONSTANTS + */ + + var DIALOG_ID = require('./groups/dialogId'); + //var IMAGES_TAB_ID = require('tabs/images-tab/tabId') + + /* + CONSTRUCTOR + */ + + function Dialog() { + this.dialogId = DIALOG_ID; + + //this.datastoreTable = new DatastoreTable('image_clone', { + // 'select': true, + // 'selectOptions': { + // 'filter_fn': function(ds) { + // return ds.TYPE == OpenNebulaDatastore.TYPES.IMAGE_DS; + // } + // } + //}); + + BaseDialog.call(this); + }; + + Dialog.DIALOG_ID = DIALOG_ID; + Dialog.prototype = Object.create(BaseDialog.prototype); + Dialog.prototype.constructor = Dialog; + Dialog.prototype.html = _html; + Dialog.prototype.onShow = _onShow; + Dialog.prototype.setup = _setup; + Dialog.prototype.setParams = _setParams; + + return Dialog; + + /* + FUNCTION DEFINITIONS + */ + + function _html() { + return TemplateHTML({ + 'dialogId': this.dialogId, + //'datastoreTableSelectHTML': this.datastoreTable.dataTableHTML + }); + } + + function _setup(dialog) { + var that = this; + // TODO: Show DS with the same ds mad only +// that.datastoreTable.initialize(); +// +// $('#image_clone_advanced_toggle', dialog).click(function() { +// $('#image_clone_advanced', dialog).toggle(); +// return false; +// }); +// +// $('#' + DIALOG_ID + 'Form', dialog).submit(function() { +// var name = $('input[name="image_clone_name"]', this).val(); +// var sel_elems = Sunstone.getDataTable(IMAGES_TAB_ID).elements(); +// +// if (!name || !sel_elems.length) +// Notifier.notifyError('A name or prefix is needed!'); +// +// var extra_info = {}; +// +// var targeDS = that.datastoreTable.retrieveResourceTableSelect(); +// if (targeDS) { +// extra_info['target_ds'] = targeDS; +// } +// +// if (sel_elems.length > 1) { +// for (var i = 0; i < sel_elems.length; i++) { +// //If we are cloning several images we +// //use the name as prefix +// extra_info['name'] = name + OpenNebulaImage.getName(sel_elems[i]); +// Sunstone.runAction('Image.clone', sel_elems[i], extra_info); +// } +// } else { +// extra_info['name'] = name; +// Sunstone.runAction('Image.clone', sel_elems[0], extra_info) +// } +// +// Sunstone.getDialog(DIALOG_ID).hide(); +// Sunstone.getDialog(DIALOG_ID).reset(); +// setTimeout(function() { +// Sunstone.runAction('Image.refresh'); +// }, 1500); +// return false; +// }); + + return false; + } + + + /** + * @param {object} params + * - params.element : user object, or empty object {} + */ + function _setParams(params) { + this.element = params.element; + } + + function _onShow(dialog) { +// var sel_elems = Sunstone.getDataTable(IMAGES_TAB_ID).elements(); +// //show different text depending on how many elements are selected +// if (sel_elems.length > 1) { +// $('.clone_one', dialog).hide(); +// $('.clone_several', dialog).show(); +// $('input[name="image_clone_name"]', dialog).val('Copy of '); +// } else { +// $('.clone_one', dialog).show(); +// $('.clone_several', dialog).hide(); +// $('input[name="image_clone_name"]', dialog).val('Copy of ' + OpenNebulaImage.getName(sel_elems[0])); +// }; +// +// $('#image_clone_advanced', dialog).hide(); +// this.datastoreTable.resetResourceTableSelect(); +// +// $("input[name='image_clone_name']", dialog).focus(); + + return false; + } +}); diff --git a/src/sunstone/public/app/tabs/users-tab/dialogs/groups/dialogId.js b/src/sunstone/public/app/tabs/users-tab/dialogs/groups/dialogId.js new file mode 100644 index 0000000000..ec6cee554d --- /dev/null +++ b/src/sunstone/public/app/tabs/users-tab/dialogs/groups/dialogId.js @@ -0,0 +1,19 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2015, OpenNebula Project, OpenNebula Systems */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); you may */ +/* not use this file except in compliance with the License. You may obtain */ +/* a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ +/* See the License for the specific language governing permissions and */ +/* limitations under the License. */ +/* -------------------------------------------------------------------------- */ + +define(function(require){ + return 'userGroupsDialog'; +}); diff --git a/src/sunstone/public/app/tabs/users-tab/dialogs/groups/html.hbs b/src/sunstone/public/app/tabs/users-tab/dialogs/groups/html.hbs new file mode 100644 index 0000000000..11cc9b12d8 --- /dev/null +++ b/src/sunstone/public/app/tabs/users-tab/dialogs/groups/html.hbs @@ -0,0 +1,33 @@ +{{! -------------------------------------------------------------------------- }} +{{! Copyright 2002-2015, OpenNebula Project, OpenNebula Systems }} +{{! }} +{{! Licensed under the Apache License, Version 2.0 (the "License"); you may }} +{{! not use this file except in compliance with the License. You may obtain }} +{{! a copy of the License at }} +{{! }} +{{! http://www.apache.org/licenses/LICENSE-2.0 }} +{{! }} +{{! Unless required by applicable law or agreed to in writing, software }} +{{! distributed under the License is distributed on an "AS IS" BASIS, }} +{{! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. }} +{{! See the License for the specific language governing permissions and }} +{{! limitations under the License. }} +{{! -------------------------------------------------------------------------- }} + +