\ No newline at end of file
diff --git a/src/sunstone/public/app/tabs/users-tab.js b/src/sunstone/public/app/tabs/users-tab.js
index 8daaa42b7e..45d2691a2b 100644
--- a/src/sunstone/public/app/tabs/users-tab.js
+++ b/src/sunstone/public/app/tabs/users-tab.js
@@ -27,7 +27,8 @@ define(function(require) {
require('./users-tab/dialogs/password'),
require('./users-tab/dialogs/auth-driver'),
require('./users-tab/dialogs/quotas'),
- require('./users-tab/dialogs/groups')
+ require('./users-tab/dialogs/groups'),
+ require('./users-tab/dialogs/login-token')
];
var _panels = [
diff --git a/src/sunstone/public/app/tabs/users-tab/dialogs/login-token.js b/src/sunstone/public/app/tabs/users-tab/dialogs/login-token.js
new file mode 100644
index 0000000000..5d810f66f6
--- /dev/null
+++ b/src/sunstone/public/app/tabs/users-tab/dialogs/login-token.js
@@ -0,0 +1,129 @@
+/* -------------------------------------------------------------------------- */
+/* Copyright 2002-2016, 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!./login-token/html');
+ var Sunstone = require('sunstone');
+ var Notifier = require('utils/notifier');
+ var Locale = require('utils/locale');
+ var OpenNebula = require('opennebula');
+ //var Config = require('sunstone-config');
+
+ /*
+ CONSTANTS
+ */
+
+ var DIALOG_ID = require('./login-token/dialogId');
+ var USERS_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;
+ Dialog.prototype.setParams = _setParams;
+
+ return Dialog;
+
+ /*
+ FUNCTION DEFINITIONS
+ */
+
+ /**
+ * @param {object} params
+ * - params.element : user element
+ */
+ function _setParams(params) {
+ this.element = params.element;
+ }
+
+ function _html() {
+ return TemplateHTML({
+ 'dialogId': this.dialogId,
+ 'element': this.element
+ });
+ }
+
+ function _setup(context) {
+ var that = this;
+
+ $("#token_btn", context).click(function(){
+
+ $("#token_btn", context).html('')
+
+ OpenNebula.User.login({
+ data : {
+ id: "-1",
+ 'username': that.element.NAME,
+ //token
+ //expire
+ },
+ success: function(req, response){
+ OpenNebula.User.show({
+ data : {
+ id: that.element.ID
+ },
+ success: function(request, user_json){
+ Sunstone.getDialog(DIALOG_ID).hide();
+ Sunstone.getDialog(DIALOG_ID).setParams({element: user_json.USER});
+ Sunstone.getDialog(DIALOG_ID).reset();
+ Sunstone.getDialog(DIALOG_ID).show();
+
+ if (Sunstone.getTab() == USERS_TAB_ID){
+ Sunstone.runAction('User.refresh');
+ } else {
+ Sunstone.runAction('Settings.refresh');
+ }
+ },
+ error: function(request, error_json){
+ Sunstone.getDialog(DIALOG_ID).hide();
+ Notifier.onError(request, error_json);
+ }
+ });
+ },
+ error: Notifier.onError
+ });
+ });
+
+ return false;
+ }
+
+ function _onShow(context) {
+ var tabId = Sunstone.getTab();
+
+ if (tabId == USERS_TAB_ID){
+ this.setNames( Sunstone.getDataTable(USERS_TAB_ID).elements({names: true}) );
+ }
+
+ return false;
+ }
+});
diff --git a/src/sunstone/public/app/tabs/users-tab/dialogs/login-token/dialogId.js b/src/sunstone/public/app/tabs/users-tab/dialogs/login-token/dialogId.js
new file mode 100644
index 0000000000..7781472b32
--- /dev/null
+++ b/src/sunstone/public/app/tabs/users-tab/dialogs/login-token/dialogId.js
@@ -0,0 +1,19 @@
+/* -------------------------------------------------------------------------- */
+/* Copyright 2002-2016, 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 'userLoginTokenDialog';
+});
diff --git a/src/sunstone/public/app/tabs/users-tab/dialogs/login-token/html.hbs b/src/sunstone/public/app/tabs/users-tab/dialogs/login-token/html.hbs
new file mode 100644
index 0000000000..f03d4731af
--- /dev/null
+++ b/src/sunstone/public/app/tabs/users-tab/dialogs/login-token/html.hbs
@@ -0,0 +1,62 @@
+{{! -------------------------------------------------------------------------- }}
+{{! Copyright 2002-2016, 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. }}
+{{! -------------------------------------------------------------------------- }}
+
+
+
+
+
{{tr "Login Token"}}
+
+
+
+
+
+
+
+
+ {{tr "A login token acts as a password and can be used to authenticate with OpenNebula through Sunstone, the CLI, or the API"}}
+
- {{#if element.TEMPLATE.SSH_PUBLIC_KEY}}
- {{element.TEMPLATE.SSH_PUBLIC_KEY}}
- {{else}}
- {{tr "You can provide a SSH Key for this User clicking on the edit button"}}
- {{/if}}
-
+ {{#if element.TEMPLATE.SSH_PUBLIC_KEY}}
+ {{element.TEMPLATE.SSH_PUBLIC_KEY}}
+ {{else}}
+ {{tr "You can provide a SSH Key for this User clicking on the edit button"}}
+ {{/if}}
+
+
+
+
diff --git a/src/sunstone/public/app/templates/helpers/humanizeTime.js b/src/sunstone/public/app/templates/helpers/humanizeTime.js
new file mode 100644
index 0000000000..4d7e9c39c0
--- /dev/null
+++ b/src/sunstone/public/app/templates/helpers/humanizeTime.js
@@ -0,0 +1,35 @@
+/* -------------------------------------------------------------------------- */
+/* Copyright 2002-2016, 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) {
+ var Handlebars = require('hbs/handlebars');
+ var Humanize = require('utils/humanize');
+
+ /**
+ * Turns a Unix-formatted time into a human readable string
+ */
+ var humanizeTime = function(seconds) {
+ if (seconds == undefined || seconds == ""){
+ return "-";
+ }
+
+ return Humanize.prettyTime(seconds);
+ };
+
+ Handlebars.registerHelper('humanizeTime', humanizeTime);
+
+ return humanizeTime;
+});