Skip to content
This repository was archived by the owner on Sep 17, 2019. It is now read-only.

Commit 0bc4194

Browse files
committed
modals
1 parent 4416d11 commit 0bc4194

6 files changed

Lines changed: 111 additions & 9 deletions

File tree

‎app/ModuleABApp.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
angular.module('ModuleAB' ,[
1515
'ngRoute',
16+
'ui.bootstrap',
1617
'ModuleAB.appsets',
1718
'ModuleAB.records',
1819
'ModuleAB.policies',
@@ -31,7 +32,7 @@ controller("topNavBar", function($scope, $http){
3132
method: "GET",
3233
url: "/api/v1/auth/check"
3334
}).then(function(response){
34-
// do nothing.
35+
$scope.showName = response.data.show_name;
3536
}, function(response){
3637
window.location.href = "/login";
3738
});

‎app/app.css‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,4 @@
6060
content: "";
6161
padding: 0;
6262
}
63+

‎app/index.html‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@
4242
<!-- Basic JavaScript lib -->
4343
<!-- Angular.js -->
4444
<script src="/bower_components/angular/angular.js"></script>
45-
<script src="bower_components/angular-route/angular-route.js"></script>
45+
<script src="/bower_components/angular-route/angular-route.min.js"></script>
46+
<script src="/bower_components/angular-animate/angular-animate.min.js"></script>
47+
<script src="/bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js"></script>
4648

4749
<!-- jQuery -->
4850
<script src="/bower_components/jquery/dist/jquery.min.js"></script>
@@ -76,8 +78,8 @@
7678

7779
<ul class="nav navbar-top-links navbar-right" ng-controller="topNavBar">
7880
<li class="dropdown">
79-
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
80-
<i class="fa fa-user fa-fw"></i> <i class="fa fa-caret-down"></i>
81+
<a class="dropdown-toggle" data-toggle="dropdown" href="javascript:void(0);">
82+
<i class="fa fa-user fa-fw"></i> {{showName}} <i class="fa fa-caret-down"></i>
8183
</a>
8284
<ul class="dropdown-menu dropdown-user">
8385
<li><a href="#"><i class="fa fa-user fa-fw"></i> 用户设定</a>

‎app/users/users.html‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,54 @@ <h1 class="page-header">用户管理</h1>
55
<!-- /.col-lg-12 -->
66
</div>
77
<!-- /.row -->
8+
9+
<!-- Modal -->
10+
<script type="text/ng-template" id="userModal.html">
11+
<div class="modal-header">
12+
<h3 class="modal-title">{{type}}用户</h3>
13+
</div>
14+
<div class="modal-body"></div>
15+
<div class="modal-footer">
16+
<button class="btn btn-primary" ng-click="doJob()">
17+
<i class="fa fa-fw" ng-class="jobType"></i> {{job}}
18+
</button>
19+
<button class="btn btn-default" ng-click="cancel()">
20+
<i class="fa fa-remove fa-fw"></i> 取消
21+
</button>
22+
</div>
23+
</script>
24+
25+
<div class="row">
26+
<button type="button" class="btn btn-primary" ng-click="userEdit('new')">
27+
<i class="fa fa-plus fa-fw"></i> 新增
28+
</button>
29+
<table class="col-lg-12 table table-striped">
30+
<thead>
31+
<th>登录名</th>
32+
<th>显示名</th>
33+
<th>角色</th>
34+
<th></th>
35+
</thead>
36+
<tbody>
37+
<tr ng-repeat="user in users">
38+
<td>{{user.loginname}}</td>
39+
<td>{{user.name}}</td>
40+
<td>
41+
<span ng-repeat="role in user.Roles">
42+
{{role.name}},
43+
</span>
44+
</td>
45+
<td style="text-align:right">
46+
<button type="button" class="btn btn-default" ng-click="userEdit('modify', user)">
47+
<i class="fa fa-pencil fa-fw"></i> 修改
48+
</button>
49+
<button type="button" class="btn btn-danger" ng-disable="!user.removable" ng-click="delete(user)">
50+
<i class="fa fa-trash fa-fw"></i> 删除
51+
</button>
52+
</td>
53+
</tr>
54+
</tbody>
55+
</table>
56+
</div>
57+
58+

‎app/users/users.js‎

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,59 @@
11
'use strict';
22

3-
angular.module('ModuleAB.users', ['ngRoute'])
3+
var app = angular.module('ModuleAB.users', ['ngRoute']);
44

5-
.config(['$routeProvider', function($routeProvider) {
5+
app.config(['$routeProvider', function($routeProvider) {
66
$routeProvider.when('/users', {
77
templateUrl: 'users/users.html',
88
controller: 'users'
99
});
10-
}])
10+
}]);
1111

12-
.controller('users', [function() {
12+
app.controller('users', function($scope, $http, $uibModal) {
13+
$http({
14+
method: "GET",
15+
url: "/api/v1/users"
16+
}).then(function(response){
17+
$scope.users = response.data;
18+
}, function(response){
19+
});
1320

14-
}]);
21+
$scope.userEdit = function(type, user){
22+
var modal = $uibModal.open({
23+
templateUrl: 'userModal.html',
24+
controller: 'userModal',
25+
resolve: {
26+
type: function(){return type;},
27+
user: function(){return user;}
28+
}
29+
});
30+
};
31+
32+
});
33+
34+
app.controller('userModal', function($scope, $http, $uibModalInstance, type, user){
35+
switch(type){
36+
case 'new':
37+
$scope.type = "新增";
38+
$scope.jobType = "fa-plus";
39+
$scope.job = "新增"
40+
break;
41+
case 'modify':
42+
$scope.type = "修改";
43+
$scope.jobType = "fa-pencil";
44+
$scope.job = "修改";
45+
break;
46+
}
47+
if (user === undefined) {
48+
user = {
49+
loginname: "",
50+
password: "",
51+
name: "",
52+
Roles: []
53+
};
54+
}
55+
$scope.user = user
56+
$scope.cancel = function(){
57+
$uibModalInstance.dismiss('cancel');
58+
}
59+
});

‎bower.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
"dependencies": {
99
"angular": "~1.4.0",
1010
"angular-route": "~1.4.0",
11+
"angular-animate": "~1.4.0",
12+
"angular-bootstrap": "~1.3.0",
1113
"angular-loader": "~1.4.0",
1214
"angular-mocks": "~1.4.0",
1315
"html5-boilerplate": "~5.2.0",

0 commit comments

Comments
 (0)