Commit 219aff4a by lepdou

用户模糊搜索 流程优化

parent 2f620e6f
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
<link rel="stylesheet" type="text/css" href="../vendor/angular/angular-toastr-1.4.1.min.css"> <link rel="stylesheet" type="text/css" href="../vendor/angular/angular-toastr-1.4.1.min.css">
<link rel="stylesheet" type="text/css" media='all' href="../vendor/angular/loading-bar.min.css"> <link rel="stylesheet" type="text/css" media='all' href="../vendor/angular/loading-bar.min.css">
<link rel="stylesheet" type="text/css" href="../styles/common-style.css"> <link rel="stylesheet" type="text/css" href="../styles/common-style.css">
<link rel="stylesheet" type="text/css" href="../vendor/select2/select2.min.css">
<title>权限管理</title> <title>权限管理</title>
</head> </head>
...@@ -37,9 +38,9 @@ ...@@ -37,9 +38,9 @@
<div class="col-sm-8"> <div class="col-sm-8">
<form class="form-inline" ng-submit="assignMasterRoleToUser()"> <form class="form-inline" ng-submit="assignMasterRoleToUser()">
<div class="form-group"> <div class="form-group">
<input type="text" class="form-control" placeholder="域账号" required ng-model="toAssignMasterRoleUser"> <apollouserselector apollo-id="userSelectWidgetId"></apollouserselector>
</div> </div>
<button type="submit" class="btn btn-default">添加</button> <button type="submit" class="btn btn-default" style="margin-left: 20px;">添加</button>
</form> </form>
<!-- Split button --> <!-- Split button -->
<div class="user-container"> <div class="user-container">
...@@ -88,6 +89,7 @@ ...@@ -88,6 +89,7 @@
<!--nicescroll--> <!--nicescroll-->
<script src="../vendor/jquery.nicescroll.min.js"></script> <script src="../vendor/jquery.nicescroll.min.js"></script>
<script src="../vendor/select2/select2.min.js" type="text/javascript"></script>
<!--biz--> <!--biz-->
<!--must import--> <!--must import-->
<script type="application/javascript" src="../scripts/app.js"></script> <script type="application/javascript" src="../scripts/app.js"></script>
......
...@@ -32,15 +32,26 @@ ...@@ -32,15 +32,26 @@
</header> </header>
<div class="panel-body"> <div class="panel-body">
<form class="form-horizontal" ng-show="step == 1" ng-submit="createNamespace()">
<div class="row text-right" style="padding-right: 20px;">
<div class="btn-group btn-group-sm" role="group" aria-label="...">
<button type="button" class="btn btn-default" ng-class="{active:type=='link'}" ng-click="switchType('link')">关联已存在的Namespace</button>
<button type="button" class="btn btn-default" ng-class="{active:type=='create'}" ng-click="switchType('create')">创建新的Namespace</button>
</div>
</div>
<form class="form-horizontal" style="margin-top: 30px;" ng-show="step == 1" ng-submit="createNamespace()">
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">应用ID</label> <label class="col-sm-3 control-label">应用ID</label>
<div class="col-sm-6" ng-bind="appId"> <div class="col-sm-6">
<label ng-bind="appId"></label>
</div> </div>
</div> </div>
<div class="form-horizontal" ng-show="type == 'link'"> <div class="form-horizontal" ng-show="type == 'link'">
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label"><apollorequiredfiled></apollorequiredfiled> 选择集群</label> <label class="col-sm-3 control-label">
<apollorequiredfiled></apollorequiredfiled>
选择集群</label>
<div class="col-sm-6"> <div class="col-sm-6">
<apolloclusterselector apollo-app-id="appId" apollo-default-all-checked="true" <apolloclusterselector apollo-app-id="appId" apollo-default-all-checked="true"
apollo-select="collectSelectedClusters"></apolloclusterselector> apollo-select="collectSelectedClusters"></apolloclusterselector>
...@@ -48,7 +59,9 @@ ...@@ -48,7 +59,9 @@
</div> </div>
</div> </div>
<div class="form-group" ng-show="type == 'create'"> <div class="form-group" ng-show="type == 'create'">
<label class="col-sm-3 control-label"><apollorequiredfiled></apollorequiredfiled> 名称</label> <label class="col-sm-3 control-label">
<apollorequiredfiled></apollorequiredfiled>
名称</label>
<div class="col-sm-4"> <div class="col-sm-4">
<div class="input-group"> <div class="input-group">
<span class="input-group-addon" ng-bind="appBaseInfo.namespacePrefix"></span> <span class="input-group-addon" ng-bind="appBaseInfo.namespacePrefix"></span>
...@@ -65,7 +78,9 @@ ...@@ -65,7 +78,9 @@
</div> </div>
</div> </div>
<div class="form-group" ng-show="type == 'link'"> <div class="form-group" ng-show="type == 'link'">
<label class="col-sm-3 control-label"><apollorequiredfiled></apollorequiredfiled> namespace</label> <label class="col-sm-3 control-label">
<apollorequiredfiled></apollorequiredfiled>
namespace</label>
<div class="col-sm-4"> <div class="col-sm-4">
<select id="namespaces"> <select id="namespaces">
<option></option> <option></option>
...@@ -75,7 +90,7 @@ ...@@ -75,7 +90,7 @@
<div class="form-group"> <div class="form-group">
<div class="col-sm-offset-3 col-sm-10"> <div class="col-sm-offset-3 col-sm-10">
<button type="submit" class="btn btn-default">提交</button> <button type="submit" class="btn btn-primary">提交</button>
</div> </div>
</div> </div>
</form> </form>
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
<link rel="stylesheet" type="text/css" href="../vendor/angular/angular-toastr-1.4.1.min.css"> <link rel="stylesheet" type="text/css" href="../vendor/angular/angular-toastr-1.4.1.min.css">
<link rel="stylesheet" type="text/css" media='all' href="../vendor/angular/loading-bar.min.css"> <link rel="stylesheet" type="text/css" media='all' href="../vendor/angular/loading-bar.min.css">
<link rel="stylesheet" type="text/css" href="../styles/common-style.css"> <link rel="stylesheet" type="text/css" href="../styles/common-style.css">
<link rel="stylesheet" type="text/css" href="../vendor/select2/select2.min.css">
<title>权限管理</title> <title>权限管理</title>
</head> </head>
...@@ -37,9 +38,9 @@ ...@@ -37,9 +38,9 @@
<div class="col-sm-8"> <div class="col-sm-8">
<form class="form-inline" ng-submit="assignRoleToUser('ModifyNamespace')"> <form class="form-inline" ng-submit="assignRoleToUser('ModifyNamespace')">
<div class="form-group"> <div class="form-group">
<input type="text" class="form-control" placeholder="域账号" required ng-model="toAssignModifyNamespaceRoleUser"> <apollouserselector apollo-id="modifyRoleWidgetId"></apollouserselector>
</div> </div>
<button type="submit" class="btn btn-default">添加</button> <button type="submit" class="btn btn-default" style="margin-left: 20px;">添加</button>
</form> </form>
<!-- Split button --> <!-- Split button -->
<div class="user-container"> <div class="user-container">
...@@ -66,9 +67,10 @@ ...@@ -66,9 +67,10 @@
<div class="col-sm-8"> <div class="col-sm-8">
<form class="form-inline" ng-submit="assignRoleToUser('ReleaseNamespace')"> <form class="form-inline" ng-submit="assignRoleToUser('ReleaseNamespace')">
<div class="form-group"> <div class="form-group">
<input type="text" class="form-control" placeholder="域账号" required ng-model="toAssignReleaseNamespaceRoleUser"> <apollouserselector apollo-id="releaseRoleWidgetId"></apollouserselector>
</div> </div>
<button type="submit" class="btn btn-default">添加</button> <button type="submit" class="btn btn-default" style="margin-left: 20px;">添加</button>
</form> </form>
<!-- Split button --> <!-- Split button -->
<div style="margin-top: 15px;"> <div style="margin-top: 15px;">
...@@ -116,6 +118,8 @@ ...@@ -116,6 +118,8 @@
<!--nicescroll--> <!--nicescroll-->
<script src="../vendor/jquery.nicescroll.min.js"></script> <script src="../vendor/jquery.nicescroll.min.js"></script>
<script src="../vendor/select2/select2.min.js" type="text/javascript"></script>
<!--biz--> <!--biz-->
<!--must import--> <!--must import-->
<script type="application/javascript" src="../scripts/app.js"></script> <script type="application/javascript" src="../scripts/app.js"></script>
......
...@@ -7,6 +7,8 @@ role_module.controller('AppRoleController', ...@@ -7,6 +7,8 @@ role_module.controller('AppRoleController',
appId: params.appid appId: params.appid
}; };
$scope.userSelectWidgetId = 'toAssignMasterRoleUser';
PermissionService.has_assign_user_permission($scope.pageContext.appId) PermissionService.has_assign_user_permission($scope.pageContext.appId)
.then(function (result) { .then(function (result) {
$scope.hasAssignUserPermission = result.hasPermission; $scope.hasAssignUserPermission = result.hasPermission;
...@@ -21,14 +23,14 @@ role_module.controller('AppRoleController', ...@@ -21,14 +23,14 @@ role_module.controller('AppRoleController',
}); });
$scope.toAssignMasterRoleUser = '';
$scope.assignMasterRoleToUser = function () { $scope.assignMasterRoleToUser = function () {
var toAssignMasterRoleUser = $('.' + $scope.userSelectWidgetId).select2('data')[0].id;
PermissionService.assign_master_role($scope.pageContext.appId, PermissionService.assign_master_role($scope.pageContext.appId,
$scope.toAssignMasterRoleUser) toAssignMasterRoleUser)
.then(function (result) { .then(function (result) {
toastr.success("添加成功"); toastr.success("添加成功");
$scope.appRoleUsers.masterUsers.push({userId: $scope.toAssignMasterRoleUser}); $scope.appRoleUsers.masterUsers.push({userId: toAssignMasterRoleUser});
}, function (result) { }, function (result) {
toastr.error(AppUtil.errorMsg(result), "添加失败"); toastr.error(AppUtil.errorMsg(result), "添加失败");
}); });
......
role_module.controller('NamespaceRoleController', role_module.controller('NamespaceRoleController',
['$scope', '$location', '$window', 'toastr', 'AppService', 'AppUtil', 'PermissionService', ['$scope', '$location', '$window', 'toastr', 'AppService', 'UserService', 'AppUtil',
function ($scope, $location, $window, toastr, AppService, AppUtil, PermissionService) { 'PermissionService',
function ($scope, $location, $window, toastr, AppService, UserService, AppUtil,
PermissionService) {
var params = AppUtil.parseParams($location.$$url); var params = AppUtil.parseParams($location.$$url);
$scope.pageContext = { $scope.pageContext = {
appId: params.appid, appId: params.appid,
namespaceName: params.namespaceName namespaceName: params.namespaceName
}; };
$scope.releaseRoleWidgetId = 'releaseRoleWidgetId';
$scope.modifyRoleWidgetId = 'modifyRoleWidgetId';
PermissionService.has_assign_user_permission($scope.pageContext.appId) PermissionService.has_assign_user_permission($scope.pageContext.appId)
.then(function (result) { .then(function (result) {
...@@ -24,26 +29,29 @@ role_module.controller('NamespaceRoleController', ...@@ -24,26 +29,29 @@ role_module.controller('NamespaceRoleController',
toastr.error(AppUtil.errorMsg(result), "加载授权用户出错"); toastr.error(AppUtil.errorMsg(result), "加载授权用户出错");
}); });
$scope.toAssignReleaseNamespaceRoleUser = '', $scope.toAssignModifyNamespaceRoleUser = '';
$scope.assignRoleToUser = function (roleType) { $scope.assignRoleToUser = function (roleType) {
if ('ReleaseNamespace' == roleType) { if ('ReleaseNamespace' == roleType) {
var toAssignReleaseNamespaceRoleUser = $('.' + $scope.releaseRoleWidgetId).select2('data')[0].id;
PermissionService.assign_release_namespace_role($scope.pageContext.appId, PermissionService.assign_release_namespace_role($scope.pageContext.appId,
$scope.pageContext.namespaceName, $scope.pageContext.namespaceName,
$scope.toAssignReleaseNamespaceRoleUser) toAssignReleaseNamespaceRoleUser)
.then(function (result) { .then(function (result) {
toastr.success("添加成功"); toastr.success("添加成功");
$scope.rolesAssignedUsers.releaseRoleUsers.push({userId: $scope.toAssignReleaseNamespaceRoleUser}); $scope.rolesAssignedUsers.releaseRoleUsers.push(
{userId: toAssignReleaseNamespaceRoleUser});
}, function (result) { }, function (result) {
toastr.error(AppUtil.errorMsg(result), "添加失败"); toastr.error(AppUtil.errorMsg(result), "添加失败");
}); });
} else { } else {
var toAssignModifyNamespaceRoleUser = $('.' + $scope.modifyRoleWidgetId).select2('data')[0].id;
PermissionService.assign_modify_namespace_role($scope.pageContext.appId, PermissionService.assign_modify_namespace_role($scope.pageContext.appId,
$scope.pageContext.namespaceName, $scope.pageContext.namespaceName,
$scope.toAssignModifyNamespaceRoleUser) toAssignModifyNamespaceRoleUser)
.then(function (result) { .then(function (result) {
toastr.success("添加成功"); toastr.success("添加成功");
$scope.rolesAssignedUsers.modifyRoleUsers.push({userId: $scope.toAssignModifyNamespaceRoleUser}); $scope.rolesAssignedUsers.modifyRoleUsers.push(
{userId: toAssignModifyNamespaceRoleUser});
}, function (result) { }, function (result) {
toastr.error(AppUtil.errorMsg(result), "添加失败"); toastr.error(AppUtil.errorMsg(result), "添加失败");
}); });
...@@ -84,5 +92,8 @@ role_module.controller('NamespaceRoleController', ...@@ -84,5 +92,8 @@ role_module.controller('NamespaceRoleController',
} }
list.splice(index, 1); list.splice(index, 1);
} }
$scope.modifyRoleUsersId = 'J_modify_role_users';
$scope.releaseRoleUsersId = 'J_release_role_users';
}]); }]);
...@@ -258,3 +258,55 @@ directive_module.directive('apolloentrance', function ($compile, $window) { ...@@ -258,3 +258,55 @@ directive_module.directive('apolloentrance', function ($compile, $window) {
}); });
/** entrance */
directive_module.directive('apollouserselector', function ($compile, $window) {
return {
restrict: 'E',
templateUrl: '../views/component/user-selector.html',
transclude: true,
replace: true,
scope: {
id: '=apolloId'
},
link: function (scope, element, attrs) {
scope.$watch("id", initSelect2);
var searchUsersAjax = {
ajax: {
url: '/users',
dataType: 'json',
delay: 250,
data: function (params) {
return {
keyword: params.term ? params.term: '',
limit: 100
}
},
processResults: function (data, params) {
var users = [];
data.forEach(function (user) {
users.push({
id: user.userId,
text: user.userId + " | " + user.name + " | " + user.email
})
});
return {
results: users
}
},
cache: true,
minimumInputLength: 5
}
};
function initSelect2(){
$('.' + scope.id).select2(searchUsersAjax);
}
}
}
});
...@@ -3,6 +3,10 @@ appService.service('UserService', ['$resource', '$q', function ($resource, $q) { ...@@ -3,6 +3,10 @@ appService.service('UserService', ['$resource', '$q', function ($resource, $q) {
load_user:{ load_user:{
method: 'GET', method: 'GET',
url:'/user' url:'/user'
},
find_users: {
method: 'GET',
url: '/users'
} }
}); });
return { return {
...@@ -16,6 +20,18 @@ appService.service('UserService', ['$resource', '$q', function ($resource, $q) { ...@@ -16,6 +20,18 @@ appService.service('UserService', ['$resource', '$q', function ($resource, $q) {
d.reject(result); d.reject(result);
}); });
return d.promise; return d.promise;
},
find_users: function (keyword) {
var d = $q.defer();
user_resource.find_users({
keyword: keyword
},
function (result) {
d.resolve(result);
}, function (result) {
d.reject(result);
});
return d.promise;
} }
} }
}]); }]);
<select class="{{id}}" style="width: 450px;">
</select>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment