feature #4210: Add user groups dialog

This commit is contained in:
Daniel Molina committed 2016-01-19 13:22:08 +01:00
1 parent 132290530d
commit 49b883f4c9
10 files changed
+240 -7

No files matched your search

@@ -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
@@ -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
@@ -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
+2 -1
View File
@@ -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 = [
@@ -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",
@@ -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"),
@@ -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;
}
});
@@ -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';
});
@@ -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. }}
{{! -------------------------------------------------------------------------- }}
<div id="{{dialogId}}" class="reveal-modal large max-height" role="dialog" data-reveal>
<div class="row">
<h3 class="subheader">{{tr "User Groups"}}</h3>
</div>
<form data-abide="ajax" id="{{dialogId}}Form">
<div class="row">
<div class="large-12 columns">
</div>
</div>
<div class="form_buttons row">
<button type="submit" class="button radius right">
{{tr "Apply changes"}}
</button>
</div>
<a class="close-reveal-modal">&#215;</a>
</form>
</div>
@@ -39,6 +39,7 @@ define(function(require) {
CommonActions.prototype.create = _create;
CommonActions.prototype.showCreate = _showCreate;
CommonActions.prototype.showUpdate = _showUpdate;
CommonActions.prototype.checkAndShow = _checkAndShow;
CommonActions.prototype.checkAndShowUpdate = _checkAndShowUpdate;
CommonActions.prototype.update = _update;
CommonActions.prototype.updateTemplate = _updateTemplate;
@@ -186,18 +187,23 @@ define(function(require) {
}
function _checkAndShowUpdate() {
var that = this;
return _checkAndShow("show_to_update");
}
function _checkAndShow(action) {
var that = this;
return {
type: "single",
type: 'single',
call: function() {
var selected_nodes = Sunstone.getDataTable(that.tabId).elements();
if (selected_nodes.length != 1) {
Notifier.notifyMessage("Please select one (and just one) resource to update.");
var selectedNodes = Sunstone.getDataTable(that.tabId).elements();
if (selectedNodes.length != 1) {
Notifier.notifyMessage('Please select one (and just one) resource to update.');
return false;
}
var resource_id = "" + selected_nodes[0];
Sunstone.runAction(that.resourceStr + ".show_to_update", resource_id);
var resourceId = '' + selectedNodes[0];
Sunstone.runAction(that.resourceStr + '.' + action, resourceId);
}
}
}