diff --git a/src/sunstone/public/app/tabs/users-tab.js b/src/sunstone/public/app/tabs/users-tab.js
index ec759c392b..bb27393049 100644
--- a/src/sunstone/public/app/tabs/users-tab.js
+++ b/src/sunstone/public/app/tabs/users-tab.js
@@ -8,6 +8,8 @@ define(function(require) {
var DATATABLE_ID = "dataTableUsers";
var _dialogs = [
+ require('./users-tab/dialogs/password'),
+ require('./users-tab/dialogs/auth-driver')
];
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 b540de9b5a..cd28c04e78 100644
--- a/src/sunstone/public/app/tabs/users-tab/actions.js
+++ b/src/sunstone/public/app/tabs/users-tab/actions.js
@@ -8,6 +8,8 @@ define(function(require) {
var RESOURCE = "User";
var TAB_ID = require('./tabId');
var CREATE_DIALOG_ID = require('./form-panels/create/formPanelId');
+ var PASSWORD_DIALOG_ID = require('./dialogs/password/dialogId');
+ var AUTH_DRIVER_DIALOG_ID = require('./dialogs/auth-driver/dialogId');
var _actions = {
"User.create" : {
@@ -55,19 +57,19 @@ define(function(require) {
error: Notifier.onError
},
- /* TODO
"User.update_password" : {
type: "custom",
- call: popUpUpdatePasswordDialog
+ call: function(){
+ Sunstone.getDialog(PASSWORD_DIALOG_ID).show();
+ }
},
"User.passwd" : {
type: "multiple",
call: OpenNebulaResource.passwd,
- elements: userElements,
- error: onError
+ error: Notifier.onError
},
- */
+
"User.chgrp" : {
type: "multiple",
call: OpenNebulaResource.chgrp,
@@ -98,20 +100,20 @@ define(function(require) {
elements : userElements,
error: onError
},
+ */
"User.change_authentication" : {
type: "custom",
- call: popUpChangeAuthenticationDialog
+ call: function(){
+ Sunstone.getDialog(AUTH_DRIVER_DIALOG_ID).show();
+ }
},
+
"User.chauth" : {
type: "multiple",
call: OpenNebulaResource.chauth,
- callback : function(req){
- Sunstone.runAction(RESOURCE+".show",req.request.data[0][0]);
- },
- elements: userElements,
- error: onError
+ error: Notifier.onError,
},
- */
+
"User.show" : {
type: "single",
call: OpenNebulaResource.show,
diff --git a/src/sunstone/public/app/tabs/users-tab/dialogs/auth-driver.js b/src/sunstone/public/app/tabs/users-tab/dialogs/auth-driver.js
new file mode 100644
index 0000000000..7d5e3c5eae
--- /dev/null
+++ b/src/sunstone/public/app/tabs/users-tab/dialogs/auth-driver.js
@@ -0,0 +1,89 @@
+define(function(require) {
+ /*
+ DEPENDENCIES
+ */
+
+ var BaseDialog = require('utils/dialogs/dialog');
+ var TemplateHTML = require('hbs!./auth-driver/html');
+ var Sunstone = require('sunstone');
+ var Notifier = require('utils/notifier');
+ var Locale = require('utils/locale');
+ var UserCreation = require('tabs/users-tab/utils/user-creation');
+
+ /*
+ CONSTANTS
+ */
+
+ var DIALOG_ID = require('./auth-driver/dialogId');
+ var TAB_ID = require('../tabId');
+
+ /*
+ CONSTRUCTOR
+ */
+
+ function Dialog() {
+ this.dialogId = DIALOG_ID;
+
+ 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;
+
+ return Dialog;
+
+ /*
+ FUNCTION DEFINITIONS
+ */
+
+ function _html() {
+ return TemplateHTML({
+ 'dialogId': this.dialogId,
+ 'userCreationHTML': UserCreation.html()
+ });
+ }
+
+ function _setup(context) {
+ var that = this;
+
+ UserCreation.setup(context, {name: false, password: false});
+
+ context.off('invalid.fndtn.abide', '#' + DIALOG_ID + 'Form');
+ context.off('valid.fndtn.abide', '#' + DIALOG_ID + 'Form');
+
+ context.on('invalid.fndtn.abide', '#' + DIALOG_ID + 'Form', function(e) {
+ // Fix for valid event firing twice
+ if (e.namespace != 'abide.fndtn') { return; }
+
+ Notifier.notifyError(Locale.tr("One or more required fields are missing or malformed."));
+ }).on('valid.fndtn.abide', '#' + DIALOG_ID + 'Form', function(e) {
+ // Fix for valid event firing twice
+ if (e.namespace != 'abide.fndtn') { return; }
+
+ var inputs = UserCreation.retrieve(context);
+
+ var selElems = Sunstone.getDataTable(TAB_ID).elements();
+
+ Sunstone.runAction('User.chauth', selElems, inputs.auth_driver);
+
+ Sunstone.getDialog(DIALOG_ID).hide();
+ Sunstone.getDialog(DIALOG_ID).reset();
+ Sunstone.runAction('User.refresh');
+
+ return false;
+ });
+
+ context.foundation('reflow', 'abide');
+
+ return false;
+ }
+
+ function _onShow(context) {
+
+ return false;
+ }
+});
diff --git a/src/sunstone/public/app/tabs/users-tab/dialogs/auth-driver/dialogId.js b/src/sunstone/public/app/tabs/users-tab/dialogs/auth-driver/dialogId.js
new file mode 100644
index 0000000000..2bb01a67d7
--- /dev/null
+++ b/src/sunstone/public/app/tabs/users-tab/dialogs/auth-driver/dialogId.js
@@ -0,0 +1,3 @@
+define(function(require){
+ return 'userAuthDriverDialog';
+});
\ No newline at end of file
diff --git a/src/sunstone/public/app/tabs/users-tab/dialogs/auth-driver/html.hbs b/src/sunstone/public/app/tabs/users-tab/dialogs/auth-driver/html.hbs
new file mode 100644
index 0000000000..68f958384a
--- /dev/null
+++ b/src/sunstone/public/app/tabs/users-tab/dialogs/auth-driver/html.hbs
@@ -0,0 +1,18 @@
+
\ No newline at end of file
diff --git a/src/sunstone/public/app/tabs/users-tab/dialogs/password.js b/src/sunstone/public/app/tabs/users-tab/dialogs/password.js
new file mode 100644
index 0000000000..44219bb8d5
--- /dev/null
+++ b/src/sunstone/public/app/tabs/users-tab/dialogs/password.js
@@ -0,0 +1,89 @@
+define(function(require) {
+ /*
+ DEPENDENCIES
+ */
+
+ var BaseDialog = require('utils/dialogs/dialog');
+ var TemplateHTML = require('hbs!./password/html');
+ var Sunstone = require('sunstone');
+ var Notifier = require('utils/notifier');
+ var Locale = require('utils/locale');
+ var UserCreation = require('tabs/users-tab/utils/user-creation');
+
+ /*
+ CONSTANTS
+ */
+
+ var DIALOG_ID = require('./password/dialogId');
+ var TAB_ID = require('../tabId');
+
+ /*
+ CONSTRUCTOR
+ */
+
+ function Dialog() {
+ this.dialogId = DIALOG_ID;
+
+ 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;
+
+ return Dialog;
+
+ /*
+ FUNCTION DEFINITIONS
+ */
+
+ function _html() {
+ return TemplateHTML({
+ 'dialogId': this.dialogId,
+ 'userCreationHTML': UserCreation.html()
+ });
+ }
+
+ function _setup(context) {
+ var that = this;
+
+ UserCreation.setup(context, {name: false, auth_driver: false});
+
+ context.off('invalid.fndtn.abide', '#' + DIALOG_ID + 'Form');
+ context.off('valid.fndtn.abide', '#' + DIALOG_ID + 'Form');
+
+ context.on('invalid.fndtn.abide', '#' + DIALOG_ID + 'Form', function(e) {
+ // Fix for valid event firing twice
+ if (e.namespace != 'abide.fndtn') { return; }
+
+ Notifier.notifyError(Locale.tr("One or more required fields are missing or malformed."));
+ }).on('valid.fndtn.abide', '#' + DIALOG_ID + 'Form', function(e) {
+ // Fix for valid event firing twice
+ if (e.namespace != 'abide.fndtn') { return; }
+
+ var inputs = UserCreation.retrieve(context);
+
+ var selElems = Sunstone.getDataTable(TAB_ID).elements();
+
+ Sunstone.runAction('User.passwd', selElems, inputs.password);
+
+ Sunstone.getDialog(DIALOG_ID).hide();
+ Sunstone.getDialog(DIALOG_ID).reset();
+ Sunstone.runAction('User.refresh');
+
+ return false;
+ });
+
+ context.foundation('reflow', 'abide');
+
+ return false;
+ }
+
+ function _onShow(context) {
+
+ return false;
+ }
+});
diff --git a/src/sunstone/public/app/tabs/users-tab/dialogs/password/dialogId.js b/src/sunstone/public/app/tabs/users-tab/dialogs/password/dialogId.js
new file mode 100644
index 0000000000..fb8aa25a92
--- /dev/null
+++ b/src/sunstone/public/app/tabs/users-tab/dialogs/password/dialogId.js
@@ -0,0 +1,3 @@
+define(function(require){
+ return 'userPasswordDialog';
+});
\ No newline at end of file
diff --git a/src/sunstone/public/app/tabs/users-tab/dialogs/password/html.hbs b/src/sunstone/public/app/tabs/users-tab/dialogs/password/html.hbs
new file mode 100644
index 0000000000..81ad03565e
--- /dev/null
+++ b/src/sunstone/public/app/tabs/users-tab/dialogs/password/html.hbs
@@ -0,0 +1,18 @@
+
\ No newline at end of file
diff --git a/src/sunstone/public/app/tabs/users-tab/utils/user-creation.js b/src/sunstone/public/app/tabs/users-tab/utils/user-creation.js
index f74a8f2beb..353009b32d 100644
--- a/src/sunstone/public/app/tabs/users-tab/utils/user-creation.js
+++ b/src/sunstone/public/app/tabs/users-tab/utils/user-creation.js
@@ -14,14 +14,44 @@ define(function(require) {
return TemplateHTML();
}
- function _setup(context){
+ /**
+ * Setups the html
+ * @param {object} context jquery selector
+ * @param {object} [options] Options to hide/show each field. Each field is
+ * enabled by default.
+ * - name: true, false
+ * - password: true, false
+ * - auth_driver: true, false
+ */
+ function _setup(context, options){
+
+ var passwordEnabled = true;
+
+ if (options != undefined){
+ if (options.name != undefined && options.name == false){
+ $('#username',context).removeAttr('required');
+ $('.name_row', context).hide();
+ }
+
+ if (options.password != undefined && options.password == false){
+ passwordEnabled = false;
+
+ $('#pass',context).removeAttr('required');
+ $('.password_row', context).hide();
+ }
+
+ if (options.auth_driver != undefined && options.auth_driver == false){
+ $('.auth_driver_row', context).hide();
+ }
+ }
+
$('#driver', context).change(function(){
if ($(this).val() == "ldap"){
- $('#pass',context).hide().removeAttr('required');
- $('label[for="pass"]',context).hide();
- } else {
- $('#pass',context).show().attr('required', '');
- $('label[for="pass"]',context).show();
+ $('#pass',context).removeAttr('required');
+ $('.password_row', context).hide();
+ } else if (passwordEnabled) {
+ $('#pass',context).attr('required', '');
+ $('.password_row', context).show();
}
});
diff --git a/src/sunstone/public/app/tabs/users-tab/utils/user-creation/html.hbs b/src/sunstone/public/app/tabs/users-tab/utils/user-creation/html.hbs
index ef33c4cb95..09d39b6617 100644
--- a/src/sunstone/public/app/tabs/users-tab/utils/user-creation/html.hbs
+++ b/src/sunstone/public/app/tabs/users-tab/utils/user-creation/html.hbs
@@ -1,16 +1,16 @@
-