From 10d378faf09ec71147994ba0c47033f1745272b3 Mon Sep 17 00:00:00 2001 From: Gislene Pereira Date: Tue, 1 Dec 2015 12:29:33 -0200 Subject: Issue #411 - Display user email in user settings popup [w/ @jeffhsta] --- web-ui/app/js/page/user_settings_box.js | 27 ++++++++++++++++++++++--- web-ui/app/templates/page/user_settings_box.hbs | 2 +- 2 files changed, 25 insertions(+), 4 deletions(-) (limited to 'web-ui') diff --git a/web-ui/app/js/page/user_settings_box.js b/web-ui/app/js/page/user_settings_box.js index 32a06ed3..299f6237 100644 --- a/web-ui/app/js/page/user_settings_box.js +++ b/web-ui/app/js/page/user_settings_box.js @@ -14,7 +14,15 @@ * You should have received a copy of the GNU Affero General Public License * along with Pixelated. If not, see . */ -define(['flight/lib/component', 'features', 'views/templates', 'page/events'], function (defineComponent, features, templates, events) { +define( + [ + 'flight/lib/component', + 'features', + 'views/templates', + 'page/events', + 'helpers/monitored_ajax' + ], function (defineComponent, features, templates, events, monitoredAjax) { + 'use strict'; return defineComponent(function () { @@ -23,10 +31,24 @@ define(['flight/lib/component', 'features', 'views/templates', 'page/events'], f }); this.render = function () { - this.$node.html(templates.page.userSettingsBox()); if (features.isLogoutEnabled()) { this.$node.addClass('extra-bottom-space'); } + + var success = function (userSettings) { + this.$node.html(templates.page.userSettingsBox(userSettings)); + this.on(this.attr.close, 'click', this.toggleHidden); + }; + + var failure = function (resp) { + var msg = i18n('Could not get mail address'); + this.trigger(document, events.ui.userAlerts.displayMessage, { message: msg }); + }; + + monitoredAjax(this, '/user-settings', { + type: 'GET', + contentType: 'application/json; charset=utf-8' + }).done(success.bind(this)).fail(failure.bind(this)); }; this.toggleHidden = function() { @@ -40,7 +62,6 @@ define(['flight/lib/component', 'features', 'views/templates', 'page/events'], f this.after('initialize', function () { this.render(); this.on(document, events.ui.userSettingsBox.toggle, this.toggleHidden); - this.on(this.attr.close, 'click', this.toggleHidden); }); }); }); diff --git a/web-ui/app/templates/page/user_settings_box.hbs b/web-ui/app/templates/page/user_settings_box.hbs index 187d603b..eb227dcf 100644 --- a/web-ui/app/templates/page/user_settings_box.hbs +++ b/web-ui/app/templates/page/user_settings_box.hbs @@ -4,4 +4,4 @@

User Settings

-

$account_email

+

{{ account_email }}

-- cgit v1.2.3