This is an automated email from the ASF dual-hosted git repository.
atkach pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/trunk by this push:
new 8a1f8e4 AMBARI-23342 Admin View: Users and Groups style tweaks
8a1f8e4 is described below
commit 8a1f8e41098a692f52e71e2509c6a425c2516a3f
Author: Andrii Tkach <[email protected]>
AuthorDate: Fri Mar 23 14:53:37 2018 +0200
AMBARI-23342 Admin View: Users and Groups style tweaks
---
.../stackVersions/StackVersionsCreateCtrl.js | 4 +-
.../controllers/userManagement/GroupEditCtrl.js | 46 ------------
.../controllers/userManagement/GroupsListCtrl.js | 5 +-
.../controllers/userManagement/UserEditCtrl.js | 45 ------------
.../controllers/userManagement/UsersListCtrl.js | 5 +-
.../app/scripts/directives/editableList.js | 82 ++++++++++++++--------
.../app/scripts/services/ConfirmationModal.js | 5 +-
.../admin-web/app/styles/bootstrap-overrides.css | 21 ++++++
.../resources/ui/admin-web/app/styles/main.css | 6 ++
.../app/views/directives/editableList.html | 11 ++-
.../app/views/modals/ConfirmationModal.html | 2 +-
.../app/views/userManagement/groupEdit.html | 13 ----
.../app/views/userManagement/userEdit.html | 6 --
13 files changed, 104 insertions(+), 147 deletions(-)
diff --git
a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsCreateCtrl.js
b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsCreateCtrl.js
index c3353f7..a2c21c3 100644
---
a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsCreateCtrl.js
+++
b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsCreateCtrl.js
@@ -346,7 +346,7 @@ angular.module('ambariAdminConsole')
$t('versions.register.error.body'),
null,
null,
- true
+ {hideCancelButton: true}
)
});
}
@@ -419,7 +419,7 @@ angular.module('ambariAdminConsole')
},
$t('common.controls.ok'),
$t('common.controls.cancel'),
- true
+ {hideCancelButton: true}
)
};
diff --git
a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/userManagement/GroupEditCtrl.js
b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/userManagement/GroupEditCtrl.js
index 0d978eb..f963992 100644
---
a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/userManagement/GroupEditCtrl.js
+++
b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/userManagement/GroupEditCtrl.js
@@ -71,52 +71,6 @@ function($scope, $rootScope, Group, $routeParams, Cluster,
View, Alert, Confirma
$scope.isMembersEditing = false;
};
- $scope.deleteGroup = function(group) {
- ConfirmationModal.show(
- $t('common.delete', {
- term: $t('common.group')
- }),
- $t('common.deleteConfirmation', {
- instanceType: $t('common.group').toLowerCase(),
- instanceName: '"' + group.group_name + '"'
- })
- ).then(function() {
- Cluster.getPrivilegesForResource({
- nameFilter : group.group_name,
- typeFilter : {value: 'GROUP'}
- }).then(function(data) {
- var clusterPrivilegesIds = [];
- var viewsPrivileges = [];
- if (data.items && data.items.length) {
- angular.forEach(data.items[0].privileges, function(privilege) {
- if (privilege.PrivilegeInfo.principal_type === 'GROUP') {
- if (privilege.PrivilegeInfo.type === 'VIEW') {
- viewsPrivileges.push({
- id: privilege.PrivilegeInfo.privilege_id,
- view_name: privilege.PrivilegeInfo.view_name,
- version: privilege.PrivilegeInfo.version,
- instance_name: privilege.PrivilegeInfo.instance_name
- });
- } else {
-
clusterPrivilegesIds.push(privilege.PrivilegeInfo.privilege_id);
- }
- }
- });
- }
- group.destroy().then(function() {
- $location.url('/userManagement?tab=groups');
- if (clusterPrivilegesIds.length) {
-
Cluster.deleteMultiplePrivileges($rootScope.cluster.Clusters.cluster_name,
clusterPrivilegesIds);
- }
- angular.forEach(viewsPrivileges, function(privilege) {
- View.deletePrivilege(privilege);
- });
- });
- });
- });
- };
-
-
$scope.removeViewPrivilege = function(name, privilege) {
var privilegeObject = {
id: privilege.privilege_id,
diff --git
a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/userManagement/GroupsListCtrl.js
b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/userManagement/GroupsListCtrl.js
index a28f827..32b0ade 100644
---
a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/userManagement/GroupsListCtrl.js
+++
b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/userManagement/GroupsListCtrl.js
@@ -107,7 +107,10 @@ function($scope, Group, $modal, ConfirmationModal,
$rootScope, $translate, Setti
$t('common.deleteConfirmation', {
instanceType: $t('common.group').toLowerCase(),
instanceName: '"' + group.group_name + '"'
- })
+ }),
+ null,
+ null,
+ {primaryClass: 'btn-danger'}
).then(function() {
Cluster.getPrivilegesForResource({
nameFilter : group.group_name,
diff --git
a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/userManagement/UserEditCtrl.js
b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/userManagement/UserEditCtrl.js
index 2ecf8a2..f8633ce 100644
---
a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/userManagement/UserEditCtrl.js
+++
b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/userManagement/UserEditCtrl.js
@@ -218,51 +218,6 @@ function($scope, $rootScope, $routeParams, Cluster, User,
View, $modal, $locatio
});
};
- $scope.deleteUser = function () {
- ConfirmationModal.show(
- $t('common.delete', {
- term: $t('common.user')
- }),
- $t('common.deleteConfirmation', {
- instanceType: $t('common.user').toLowerCase(),
- instanceName: '"' + $scope.user.user_name + '"'
- })
- ).then(function () {
- Cluster.getPrivilegesForResource({
- nameFilter: $scope.user.user_name,
- typeFilter: {value: 'USER'}
- }).then(function (data) {
- var clusterPrivilegesIds = [];
- var viewsPrivileges = [];
- if (data.items && data.items.length) {
- angular.forEach(data.items[0].privileges, function (privilege) {
- if (privilege.PrivilegeInfo.principal_type === 'USER') {
- if (privilege.PrivilegeInfo.type === 'VIEW') {
- viewsPrivileges.push({
- id: privilege.PrivilegeInfo.privilege_id,
- view_name: privilege.PrivilegeInfo.view_name,
- version: privilege.PrivilegeInfo.version,
- instance_name: privilege.PrivilegeInfo.instance_name
- });
- } else {
-
clusterPrivilegesIds.push(privilege.PrivilegeInfo.privilege_id);
- }
- }
- });
- }
- User.delete($scope.user.user_name).then(function () {
- $location.url('/userManagement?tab=users');
- if (clusterPrivilegesIds.length) {
-
Cluster.deleteMultiplePrivileges($rootScope.cluster.Clusters.cluster_name,
clusterPrivilegesIds);
- }
- angular.forEach(viewsPrivileges, function (privilege) {
- View.deletePrivilege(privilege);
- });
- });
- });
- });
- };
-
function deleteUserRoles(clusterName, user, ignoreAlert) {
return Cluster.deleteMultiplePrivileges(
clusterName,
diff --git
a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/userManagement/UsersListCtrl.js
b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/userManagement/UsersListCtrl.js
index 609ef03..012a1cc 100644
---
a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/userManagement/UsersListCtrl.js
+++
b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/userManagement/UsersListCtrl.js
@@ -148,7 +148,10 @@ function($scope, User, $modal, $rootScope, UserConstants,
$translate, Cluster, V
$t('common.deleteConfirmation', {
instanceType: $t('common.user').toLowerCase(),
instanceName: '"' + user.user_name + '"'
- })
+ }),
+ null,
+ null,
+ {primaryClass: 'btn-danger'}
).then(function () {
Cluster.getPrivilegesForResource({
nameFilter: user.user_name,
diff --git
a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/directives/editableList.js
b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/directives/editableList.js
index 6b6cf5c..4a2ec44 100644
---
a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/directives/editableList.js
+++
b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/directives/editableList.js
@@ -98,8 +98,9 @@ angular.module('ambariAdminConsole')
break;
case 13: // Enter
$scope.$apply(function() {
- $scope.addItem();
- $scope.focusOnInput();
+ if ($scope.addItem()) {
+ $scope.focusOnInput();
+ }
});
return false;
break;
@@ -129,6 +130,10 @@ angular.module('ambariAdminConsole')
$scope.input = '';
$scope.typeahead = [];
$scope.selectedTypeahed = 0;
+ $scope.resources = [];
+ $scope.invalidInput = false;
+
+ preloadResources();
// Watch source of items
$scope.$watch(function() {
@@ -141,37 +146,33 @@ angular.module('ambariAdminConsole')
$scope.$watch(function() {
return $scope.input;
}, function(newValue) {
+ $scope.invalidInput = false;
if(newValue){
var newValue = newValue.split(',').filter(function(i){
i = i.replace(' ', ''); // Sanitize from spaces
return !!i.trim();
}).map(function(i) { return i.trim(); });
if( newValue.length > 1){
+ var validInput = true;
// If someone paste coma separated string, then just add all items
to list
angular.forEach(newValue, function(item) {
- $scope.addItem(item);
+ if (validInput) {
+ validInput = $scope.addItem(item);
+ }
});
- $scope.clearInput();
- $scope.focusOnInput();
-
+ if (validInput) {
+ $scope.clearInput();
+ $scope.focusOnInput();
+ }
} else {
- // Load typeahed items based on current input
-
$resource.listByName(encodeURIComponent(newValue)).then(function(data) {
- var items = [];
- angular.forEach(data.data.items, function(item) {
- var name;
- if($scope.resourceType === 'User'){
- name = item.Users.user_name;
- } else if($scope.resourceType === 'Group'){
- name = item.Groups.group_name;
- }
- if($scope.items.indexOf(name) < 0){ // Only if item not in list
- items.push(name);
- }
- });
- $scope.typeahead = items.slice(0, 5);
- $scope.selectedTypeahed = 0;
+ var items = [];
+ angular.forEach($scope.resources, function (name) {
+ if (name.indexOf(newValue) !== -1 && $scope.items.indexOf(name)
=== -1) {
+ items.push(name);
+ }
});
+ $scope.typeahead = items.slice(0, 5);
+ $scope.selectedTypeahed = 0;
}
} else {
$scope.typeahead = [];
@@ -180,6 +181,20 @@ angular.module('ambariAdminConsole')
}
});
+ function preloadResources() {
+ $resource.listByName('').then(function(data) {
+ if (data && data.data.items) {
+ $scope.resources = data.data.items.map(function(item) {
+ if ($scope.resourceType === 'User') {
+ return item.Users.user_name;
+ } else if ($scope.resourceType === 'Group') {
+ return item.Groups.group_name;
+ }
+ });
+ }
+ });
+ }
+
$scope.enableEditMode = function(event) {
if( $scope.editable && !$scope.editMode){
//only one editable-list could be in edit mode at once
@@ -197,12 +212,15 @@ angular.module('ambariAdminConsole')
event.stopPropagation();
};
$scope.save = function(event) {
+ var validInput = true;
if( $scope.input ){
- $scope.addItem($scope.input);
+ validInput = $scope.addItem($scope.input);
+ }
+ if (validInput) {
+ $scope.itemsSource = $scope.items;
+ $scope.editMode = false;
+ $scope.input = '';
}
- $scope.itemsSource = $scope.items;
- $scope.editMode = false;
- $scope.input = '';
if(event){
event.stopPropagation();
}
@@ -224,10 +242,16 @@ angular.module('ambariAdminConsole')
$scope.addItem = function(item) {
item = item ? item : $scope.typeahead.length ?
$scope.typeahead[$scope.selectedTypeahed] : $scope.input;
- if(item && $scope.items.indexOf(item) < 0){
- $scope.items.push(item);
- $scope.input = '';
+ if (item && $scope.items.indexOf(item) === -1){
+ if ($scope.resources.indexOf(item) !== -1) {
+ $scope.items.push(item);
+ $scope.input = '';
+ } else {
+ $scope.invalidInput = true;
+ return false;
+ }
}
+ return true;
};
$scope.removeFromItems = function(item) {
diff --git
a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/ConfirmationModal.js
b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/ConfirmationModal.js
index 2e65e0f..dd3e320 100644
---
a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/ConfirmationModal.js
+++
b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/ConfirmationModal.js
@@ -23,7 +23,7 @@ angular.module('ambariAdminConsole')
var $t = $translate.instant;
return {
- show: function(header, body, confirmText, cancelText,
hideCancelButton) {
+ show: function(header, body, confirmText, cancelText, options) {
var deferred = $q.defer();
var modalInstance = $modal.open({
@@ -35,7 +35,8 @@ angular.module('ambariAdminConsole')
$scope.innerScope = body.scope;
$scope.confirmText = confirmText || $t('common.controls.ok');
$scope.cancelText = cancelText || $t('common.controls.cancel');
- $scope.showCancelButton =
!hideCancelButton;
+ $scope.primaryClass = options.primaryClass || 'btn-primary',
+ $scope.showCancelButton =
!options.hideCancelButton;
$scope.ok = function() {
$modalInstance.close();
diff --git
a/ambari-admin/src/main/resources/ui/admin-web/app/styles/bootstrap-overrides.css
b/ambari-admin/src/main/resources/ui/admin-web/app/styles/bootstrap-overrides.css
new file mode 100644
index 0000000..8f30045
--- /dev/null
+++
b/ambari-admin/src/main/resources/ui/admin-web/app/styles/bootstrap-overrides.css
@@ -0,0 +1,21 @@
+/**
+ * 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.
+ */
+
+.modal-body .form-group label {
+ font-weight: normal;
+}
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 17c6beb..3b7de26 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
@@ -139,6 +139,12 @@
position: relative;
cursor: pointer;
}
+
+.has-error.add-item-input {
+ color: #666;
+ border: 1px solid #EF6162 !important;
+}
+
.add-item-input span:focus{
cursor: default;
}
diff --git
a/ambari-admin/src/main/resources/ui/admin-web/app/views/directives/editableList.html
b/ambari-admin/src/main/resources/ui/admin-web/app/views/directives/editableList.html
index 7b4413f..fdf9fce 100644
---
a/ambari-admin/src/main/resources/ui/admin-web/app/views/directives/editableList.html
+++
b/ambari-admin/src/main/resources/ui/admin-web/app/views/directives/editableList.html
@@ -19,7 +19,16 @@
<div class="editable-list-container well" ng-class="{'edit-mode' : editMode,
'disabled' : !editable}" ng-click="enableEditMode($event)">
<div class="items-box">
<ul class="items-list">
- <li class="item" ng-repeat="item in items | orderBy:identity"><span><a
href>{{item}}</a><button ng-click="removeFromItems(item)" type="button"
class="close"><span aria-hidden="true">×</span><span
class="sr-only">{{'common.controls.close' |
translate}}</span></button></span></li><li class="item add-item-input"
ng-show="editMode">
+ <li class="item" ng-repeat="item in items | orderBy:identity">
+ <span>
+ <a href>{{item}}</a>
+ <button ng-click="removeFromItems(item)" type="button" class="close">
+ <span aria-hidden="true">×</span>
+ <span class="sr-only">{{'common.controls.close' |
translate}}</span>
+ </button>
+ </span>
+ </li>
+ <li class="item add-item-input" ng-class="{'has-error': invalidInput}"
ng-show="editMode">
<span contenteditable></span>
<div class="typeahead-box" ng-show="typeahead.length != 0">
<ul>
diff --git
a/ambari-admin/src/main/resources/ui/admin-web/app/views/modals/ConfirmationModal.html
b/ambari-admin/src/main/resources/ui/admin-web/app/views/modals/ConfirmationModal.html
index 95a68b3..308d9f2 100644
---
a/ambari-admin/src/main/resources/ui/admin-web/app/views/modals/ConfirmationModal.html
+++
b/ambari-admin/src/main/resources/ui/admin-web/app/views/modals/ConfirmationModal.html
@@ -24,5 +24,5 @@
</div>
<div class="modal-footer">
<button class="btn btn-default" ng-if="showCancelButton"
ng-click="cancel()">{{cancelText}}</button>
- <button class="btn btn-primary" ng-click="ok()">{{confirmText}}</button>
+ <button class="btn" ng-class="primaryClass"
ng-click="ok()">{{confirmText}}</button>
</div>
\ No newline at end of file
diff --git
a/ambari-admin/src/main/resources/ui/admin-web/app/views/userManagement/groupEdit.html
b/ambari-admin/src/main/resources/ui/admin-web/app/views/userManagement/groupEdit.html
index 4688eb5..fbab9de 100644
---
a/ambari-admin/src/main/resources/ui/admin-web/app/views/userManagement/groupEdit.html
+++
b/ambari-admin/src/main/resources/ui/admin-web/app/views/userManagement/groupEdit.html
@@ -22,19 +22,6 @@
<li><a href="#/userManagement?tab=groups">{{'common.groups' |
translate}}</a></li>
<li class="active">{{group.group_name}}</li>
</ol>
- <div class="pull-right">
- <div ng-switch="group.group_type != 'LOCAL'">
- <button
- ng-switch-when="true"
- class="btn disabled deletegroup-btn"
- tooltip="{{'common.cannotDelete' | translate:{term: constants.group}
}}">
- {{'common.delete' | translate:{term: constants.group} }}
- </button>
- <button ng-switch-when="false" class="btn btn-danger deletegroup-btn"
ng-click="deleteGroup(group)">
- {{'common.delete' | translate:{term: constants.group} }}
- </button>
- </div>
- </div>
</div>
<form class="form-horizontal" role="form" novalidate name="form" >
diff --git
a/ambari-admin/src/main/resources/ui/admin-web/app/views/userManagement/userEdit.html
b/ambari-admin/src/main/resources/ui/admin-web/app/views/userManagement/userEdit.html
index 2e54bd8..9c15041 100644
---
a/ambari-admin/src/main/resources/ui/admin-web/app/views/userManagement/userEdit.html
+++
b/ambari-admin/src/main/resources/ui/admin-web/app/views/userManagement/userEdit.html
@@ -22,12 +22,6 @@
<li><a href="#/userManagement?tab=users">{{'common.users' |
translate}}</a></li>
<li class="active">{{user.user_name}}</li>
</ol>
- <div class="pull-right">
- <div ng-switch="isCurrentUser || user.user_type != 'LOCAL'">
- <button class="btn deleteuser-btn disabled btn-default"
ng-switch-when="true" tooltip="{{'common.cannotDelete' | translate:{term:
constants.user} }}">{{'common.delete' | translate:{term: constants.user}
}}</button>
- <button class="btn deleteuser-btn btn-danger" ng-switch-when="false"
ng-click="deleteUser()">{{'common.delete' | translate:{term: constants.user}
}}</button>
- </div>
- </div>
</div>
<hr>
<form class="form-horizontal" role="form" >
--
To stop receiving notification emails like this one, please contact
[email protected].