Return-Path: X-Original-To: apmail-ambari-commits-archive@www.apache.org Delivered-To: apmail-ambari-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7FF1D187B6 for ; Wed, 3 Feb 2016 19:14:50 +0000 (UTC) Received: (qmail 31438 invoked by uid 500); 3 Feb 2016 19:14:16 -0000 Delivered-To: apmail-ambari-commits-archive@ambari.apache.org Received: (qmail 31327 invoked by uid 500); 3 Feb 2016 19:14:16 -0000 Mailing-List: contact commits-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@ambari.apache.org Delivered-To: mailing list commits@ambari.apache.org Received: (qmail 31263 invoked by uid 99); 3 Feb 2016 19:14:16 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Feb 2016 19:14:16 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id E7D64DFF96; Wed, 3 Feb 2016 19:14:15 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ncole@apache.org To: commits@ambari.apache.org Date: Wed, 03 Feb 2016 19:14:16 -0000 Message-Id: <0a736acbee6a420681c45386b3e0ad11@git.apache.org> In-Reply-To: <75fe46c9de954833bdf764628194ff02@git.apache.org> References: <75fe46c9de954833bdf764628194ff02@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [02/16] ambari git commit: AMBARI-14880. Add popup that will show desired messages upon login (alexantonenko) AMBARI-14880. Add popup that will show desired messages upon login (alexantonenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/aab6d889 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/aab6d889 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/aab6d889 Branch: refs/heads/branch-dev-patch-upgrade Commit: aab6d889895ddf2c02fd6fa2c79ec9901fb9e768 Parents: 9cc01b4 Author: Alex Antonenko Authored: Tue Feb 2 19:14:21 2016 +0200 Committer: Alex Antonenko Committed: Tue Feb 2 19:14:33 2016 +0200 ---------------------------------------------------------------------- .../loginActivities/LoginMessageMainCtrl.js | 53 +++++++++++--- .../ui/admin-web/app/scripts/i18n.config.js | 6 +- .../resources/ui/admin-web/app/styles/main.css | 8 ++- .../app/views/loginActivities/loginMessage.html | 74 +++++++++++++------- ambari-web/app/assets/data/clusters/info.json | 11 --- ambari-web/app/assets/data/settings/motd.json | 10 +++ ambari-web/app/messages.js | 1 + ambari-web/app/router.js | 41 +++++++++++ ambari-web/app/utils/ajax/ajax.js | 4 ++ 9 files changed, 158 insertions(+), 50 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/aab6d889/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/loginActivities/LoginMessageMainCtrl.js ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/loginActivities/LoginMessageMainCtrl.js b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/loginActivities/LoginMessageMainCtrl.js index 11fcea5..88c4d27 100644 --- a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/loginActivities/LoginMessageMainCtrl.js +++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/loginActivities/LoginMessageMainCtrl.js @@ -18,17 +18,21 @@ 'use strict'; angular.module('ambariAdminConsole') - .controller('LoginMessageMainCtrl',['$scope', 'Alert', '$timeout', '$http', '$translate', function($scope, Alert, $timeout, $http, $translate) { - var $t = $translate.instant; + .controller('LoginMessageMainCtrl',['$scope', 'Alert', '$timeout', '$location', '$http', '$translate', 'UnsavedDialog', function($scope, Alert, $timeout, $location, $http, $translate, UnsavedDialog) { + var $t = $translate.instant, + targetUrl = '/loginActivities'; + $scope.status = false; $scope.motdExists = false; $scope.text = ""; + $scope.buttonText = "Ok"; $scope.submitDisabled = true; $http.get('/api/v1/admin-settings/motd').then(function (res) { - var respons = JSON.parse(res.data.AdminSettings.content); - $scope.text = respons.text ? respons.text : ""; - $scope.status = respons.status && respons.status == "true" ? true : false; + var response = JSON.parse(res.data.AdminSettings.content); + $scope.text = response.text ? response.text : ""; + $scope.buttonText = response.button ? response.button : ""; + $scope.status = response.status && response.status == "true" ? true : false; $scope.motdExists = true; }); @@ -40,28 +44,57 @@ angular.module('ambariAdminConsole') $scope.submitDisabled = false; }; - $scope.saveLoginMsg = function(form) { + $scope.$watch(function(scope) { + return scope.submitDisabled; + }, function(submitDisabled) { + $scope.form.$dirty = !submitDisabled + }); + + $scope.saveLoginMsg = function(targetUrl) { var method = $scope.motdExists ? 'PUT' : 'POST'; var data = { 'AdminSettings' : { - 'content' : '{"text":"' + $scope.text + '", "status":"' + $scope.status + '"}', + 'content' : '{"text":"' + $scope.text + '", "button":"' + $scope.buttonText + '", "status":"' + $scope.status + '"}', 'name' : 'motd', 'setting_type' : 'ambari-server' } }; - form.submitted = true; - if (form.$valid){ + $scope.form.submitted = true; + if ($scope.form.$valid){ $scope.submitDisabled = true; - $http({ + return $http({ method: method, url: '/api/v1/admin-settings/' + ($scope.motdExists ? 'motd' : ''), data: data }).then(function successCallback() { $scope.motdExists = true; + targetUrl ? $location.path(targetUrl) : ""; }, function errorCallback(data) { $scope.submitDisabled = false; Alert.error($t('common.loginActivities.saveError'), data.data.message); }); } }; + + $scope.$on('$locationChangeStart', function(event, __targetUrl) { + if( $scope.form.$dirty ){ + UnsavedDialog().then(function(action) { + targetUrl = __targetUrl.split('#').pop(); + switch(action){ + case 'save': + $scope.saveLoginMsg(targetUrl); + break; + case 'discard': + $scope.form.$setPristine(); + $location.path(targetUrl); + break; + case 'cancel': + targetUrl = '/loginActivities'; + break; + } + }); + event.preventDefault(); + } + }); + }]); http://git-wip-us.apache.org/repos/asf/ambari/blob/aab6d889/ambari-admin/src/main/resources/ui/admin-web/app/scripts/i18n.config.js ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/i18n.config.js b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/i18n.config.js index c83d627..c1b9d88 100644 --- a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/i18n.config.js +++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/i18n.config.js @@ -85,9 +85,13 @@ angular.module('ambariAdminConsole') 'loginActivities':'Login Activities', 'loginMessage': 'Login Message', 'loginMessage.placeholder': 'Please enter login message', + 'buttonText.placeholder': 'Please enter text for the "ok" button', 'homeDirectory': 'Home Directory', 'onlySimpleChars': 'Must contain only simple characters.', - 'saveError': 'Save error' + 'saveError': 'Save error', + 'message': 'Message', + 'buttonText': 'Button text', + 'switch': 'On/Off' }, 'controls': { http://git-wip-us.apache.org/repos/asf/ambari/blob/aab6d889/ambari-admin/src/main/resources/ui/admin-web/app/styles/main.css ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/styles/main.css b/ambari-admin/src/main/resources/ui/admin-web/app/styles/main.css index f54d87c..0474e9c 100644 --- a/ambari-admin/src/main/resources/ui/admin-web/app/styles/main.css +++ b/ambari-admin/src/main/resources/ui/admin-web/app/styles/main.css @@ -682,11 +682,13 @@ table.no-border tr td{ min-height: 63px; } -.login-message-pane .active, .inactive {font-size:30px;cursor:pointer;float: left;margin-left: 17px;} +.login-message-pane .active, .inactive {font-size:30px;cursor:pointer;float: left;} .login-message-pane i.active {color: #5cb85c;margin-top: 3px;} .login-message-pane i.inactive {color: #d9534f;margin-top: 2px;} -.login-message-pane .well {height: 74px;} -.login-message-pane input {margin-left: 3px;} +.login-message-pane .on-off-switch-wrap {height:32px;} + +/*.login-message-pane .well {height: 74px;} +.login-message-pane input {margin-left: 3px;}*/ .views-permissions-panel .panel-body{ padding-bottom: 0; http://git-wip-us.apache.org/repos/asf/ambari/blob/aab6d889/ambari-admin/src/main/resources/ui/admin-web/app/views/loginActivities/loginMessage.html ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/views/loginActivities/loginMessage.html b/ambari-admin/src/main/resources/ui/admin-web/app/views/loginActivities/loginMessage.html index 8fb7870..37b6165 100644 --- a/ambari-admin/src/main/resources/ui/admin-web/app/views/loginActivities/loginMessage.html +++ b/ambari-admin/src/main/resources/ui/admin-web/app/views/loginActivities/loginMessage.html @@ -18,44 +18,68 @@