ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexantone...@apache.org
Subject ambari git commit: AMBARI-14843. Admin View: add page "Login Message" with full functionality (alexantonenko)
Date Fri, 29 Jan 2016 23:06:36 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 44c98665a -> 5facf9a5e


AMBARI-14843. Admin View: add page "Login Message" with full functionality (alexantonenko)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/5facf9a5
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/5facf9a5
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/5facf9a5

Branch: refs/heads/trunk
Commit: 5facf9a5e7fecfbf433a8af274911b527f737fcb
Parents: 44c9866
Author: Alex Antonenko <hiveww@gmail.com>
Authored: Fri Jan 29 18:19:36 2016 +0200
Committer: Alex Antonenko <hiveww@gmail.com>
Committed: Sat Jan 30 01:06:32 2016 +0200

----------------------------------------------------------------------
 .../main/resources/ui/admin-web/app/index.html  |  1 +
 .../loginActivities/LoginMessageMainCtrl.js     | 67 ++++++++++++++++++++
 .../ui/admin-web/app/scripts/i18n.config.js     |  5 +-
 .../resources/ui/admin-web/app/styles/main.css  |  6 ++
 .../app/views/loginActivities/loginMessage.html | 50 ++++++++++++++-
 5 files changed, 127 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/5facf9a5/ambari-admin/src/main/resources/ui/admin-web/app/index.html
----------------------------------------------------------------------
diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/index.html b/ambari-admin/src/main/resources/ui/admin-web/app/index.html
index 268e92f..fd2c6b8 100644
--- a/ambari-admin/src/main/resources/ui/admin-web/app/index.html
+++ b/ambari-admin/src/main/resources/ui/admin-web/app/index.html
@@ -129,6 +129,7 @@
     <script src="scripts/controllers/NavbarCtrl.js"></script>
     <script src="scripts/controllers/authentication/AuthenticationMainCtrl.js"></script>
     <script src="scripts/controllers/loginActivities/LoginActivitiesMainCtrl.js"></script>
+    <script src="scripts/controllers/loginActivities/LoginMessageMainCtrl.js"></script>
     <script src="scripts/controllers/users/UsersCreateCtrl.js"></script>
     <script src="scripts/controllers/users/UsersListCtrl.js"></script>
     <script src="scripts/controllers/users/UsersShowCtrl.js"></script>

http://git-wip-us.apache.org/repos/asf/ambari/blob/5facf9a5/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
new file mode 100644
index 0000000..11fcea5
--- /dev/null
+++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/loginActivities/LoginMessageMainCtrl.js
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+'use strict';
+
+angular.module('ambariAdminConsole')
+  .controller('LoginMessageMainCtrl',['$scope', 'Alert', '$timeout', '$http', '$translate',
function($scope, Alert, $timeout, $http, $translate) {
+    var $t = $translate.instant;
+    $scope.status = false;
+    $scope.motdExists = false;
+    $scope.text = "";
+    $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;
+      $scope.motdExists = true;
+    });
+
+    $scope.inputChangeEvent = function(){
+      $scope.submitDisabled = false;
+    };
+    $scope.changeStatus = function(){
+      $scope.status = !$scope.status;
+      $scope.submitDisabled = false;
+    };
+
+    $scope.saveLoginMsg = function(form) {
+      var method = $scope.motdExists ? 'PUT' : 'POST';
+      var data = {
+        'AdminSettings' : {
+          'content' : '{"text":"' + $scope.text + '", "status":"' + $scope.status + '"}',
+          'name' : 'motd',
+          'setting_type' : 'ambari-server'
+        }
+      };
+      form.submitted = true;
+      if (form.$valid){
+        $scope.submitDisabled = true;
+        $http({
+          method: method,
+          url: '/api/v1/admin-settings/' + ($scope.motdExists ? 'motd' : ''),
+          data: data
+        }).then(function successCallback() {
+          $scope.motdExists = true;
+        }, function errorCallback(data) {
+          $scope.submitDisabled = false;
+          Alert.error($t('common.loginActivities.saveError'), data.data.message);
+        });
+      }
+    };
+  }]);

http://git-wip-us.apache.org/repos/asf/ambari/blob/5facf9a5/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 04485c6..b274965 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
@@ -83,7 +83,10 @@ angular.module('ambariAdminConsole')
       'loginActivities': {
         'loginActivities':'Login Activities',
         'loginMessage': 'Login Message',
-        'homeDirectory': 'Home Directory'
+        'loginMessage.placeholder': 'Please enter login message',
+        'homeDirectory': 'Home Directory',
+        'onlySimpleChars': 'Must contain only simple characters.',
+        'saveError': 'Save error'
       },
 
       'controls': {

http://git-wip-us.apache.org/repos/asf/ambari/blob/5facf9a5/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 895a28f..f54d87c 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,6 +682,12 @@ 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 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;}
+
 .views-permissions-panel .panel-body{
   padding-bottom: 0;
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/5facf9a5/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 dfdb3a7..8fb7870 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
@@ -16,4 +16,52 @@
 * limitations under the License.
 -->
 
-Login Message
\ No newline at end of file
+<br/>
+<div class="login-message-pane" ng-controller="LoginMessageMainCtrl">
+
+  <form class="form-horizontal" novalidate name="form" autocomplete="off">
+    <div class="well">
+      <div class="form-group" ng-class="{'has-error' : (form.login_text.$error.pattern)
&& form.submitted}">
+        <i class="fa fa-toggle-on active"
+           ng-if="status == true"
+           ng-click="changeStatus();">
+        </i>
+        <i class="fa fa-toggle-on fa-rotate-180 inactive"
+           ng-if="status == false"
+           ng-click="changeStatus();">
+        </i>
+        <div class="col-sm-11">
+          <input type="text"
+                 ng-disabled="!status"
+                 class="form-control"
+                 name="login_text"
+                 placeholder="{{'common.loginActivities.loginMessage.placeholder' | translate}}"
+                 ng-model="text"
+                 ng-change="inputChangeEvent()"
+                 ng-pattern="/^([a-zA-Z0-9._\s]+)$/"
+                 autocomplete="off">
+
+          <div class="alert alert-danger top-margin" ng-show="form.login_text.$error.pattern
&& form.submitted">
+            {{'common.loginActivities.onlySimpleChars' | translate}}
+          </div>
+        </div>
+      </div>
+    </div>
+    <div class="form-group">
+      <div class="col-sm-offset-2 col-sm-10">
+        <button
+          class="btn btn-primary groupcreate-btn pull-right left-margin"
+          ng-disabled="submitDisabled"
+          ng-click="saveLoginMsg(form)">
+          {{'common.controls.save' | translate}}
+        </button>
+      </div>
+    </div>
+  </form>
+</div>
+
+
+
+
+
+


Mime
View raw message