Skip to content

Commit c930472

Browse files
author
javaage
committed
user finish
1 parent 1461012 commit c930472

15 files changed

Lines changed: 1183 additions & 415 deletions

File tree

helloworld-springboot/pom.xml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -146,18 +146,11 @@
146146
<version>1.0.4</version>
147147
</dependency>
148148
<dependency>
149-
<groupId>net.sf.json-lib</groupId>
150-
<artifactId>json-lib</artifactId>
151-
<version>2.4</version>
152-
<classifier>jdk15</classifier>
153-
</dependency>
154-
<!-- <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId>
155-
</dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId>
156-
</dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId>
157-
</dependency> -->
158-
<!-- <version>1.0.0.M1</version> -->
159-
<!-- <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-gcp-starter-sql</artifactId>
160-
<version>1.0.0.BUILD-SNAPSHOT</version> </dependency> -->
149+
<groupId>org.json</groupId>
150+
<artifactId>json</artifactId>
151+
<version>20171018</version>
152+
</dependency>
153+
161154
</dependencies>
162155

163156
<build>

helloworld-springboot/src/main/UI/gulpfile.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var gulp = require('gulp'),
1212

1313
var paths = {
1414
scripts: 'src/js/**/*.*',
15-
styles: 'src/less/**/*.*',
15+
styles: ['src/less/**/*.*','src/css/**/*.*'],
1616
images: 'src/img/**/*.*',
1717
templates: 'src/templates/**/*.html',
1818
index: 'src/index.html',
@@ -25,7 +25,7 @@ var paths = {
2525
gulp.task('usemin', function() {
2626
return gulp.src(paths.index)
2727
.pipe(usemin({
28-
js: [minifyJs(), 'concat'],
28+
//js: [minifyJs(), 'concat'],
2929
css: [minifyCss({keepSpecialComments: 0}), 'concat'],
3030
}))
3131
.pipe(gulp.dest('../webapp'));
@@ -105,4 +105,5 @@ gulp.task('livereload', function() {
105105
* Gulp tasks
106106
*/
107107
gulp.task('build', ['usemin', 'build-assets', 'build-custom']);
108-
gulp.task('default', ['build', 'webserver', 'livereload', 'watch']);
108+
gulp.task('default', ['build', 'webserver', 'livereload', 'watch']);
109+
gulp.task('serve', ['webserver', 'livereload', 'watch']);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.inactive {
2+
background-color: #eeeeee !important;
3+
}
4+
5+
.help-block,
6+
{
7+
color: #a94442;
8+
}
9+
10+
input.ng-invalid {
11+
border: 1px solid #a94442;
12+
}
13+
14+
input.ng-valid{
15+
border: 1px solid green;
16+
}

helloworld-springboot/src/main/UI/src/index.html

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,24 @@
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1">
66

7-
<title>RDash AngularJS</title>
7+
<title>Learning Assistant </title>
88
<!-- STYLES -->
99
<!-- build:css lib/css/main.min.css -->
1010
<link rel="stylesheet" type="text/css" href="components/bootstrap/dist/css/bootstrap.min.css">
1111
<link rel="stylesheet" type="text/css" href="components/font-awesome/css/font-awesome.min.css">
1212
<link rel="stylesheet" type="text/css" href="components/rdash-ui/dist/css/rdash.min.css">
13+
<link rel="stylesheet" type="text/css" href="components/angular-ui-grid/ui-grid.min.css">
14+
<link rel="stylesheet" type="text/css" href="components/ng-table/bundles/ng-table.min.css">
15+
<link rel="stylesheet" type="text/css" href="css/common.css">
1316
<!-- endbuild -->
1417
<!-- SCRIPTS -->
1518
<!-- build:js lib/js/main.min.js -->
1619
<script type="text/javascript" src="components/angular/angular.min.js"></script>
20+
<script type="text/javascript" src="components/angular-bootstrap/ui-bootstrap.min.js"></script>
1721
<script type="text/javascript" src="components/angular-bootstrap/ui-bootstrap-tpls.min.js"></script>
1822
<script type="text/javascript" src="components/angular-cookies/angular-cookies.min.js"></script>
1923
<script type="text/javascript" src="components/angular-ui-router/release/angular-ui-router.min.js"></script>
24+
<script type="text/javascript" src="components/ng-table/bundles/ng-table.min.js"></script>
2025
<!-- endbuild -->
2126
<!-- Custom Scripts -->
2227
<script type="text/javascript" src="js/dashboard.min.js"></script>
@@ -29,7 +34,7 @@
2934
<ul class="sidebar">
3035
<li class="sidebar-main">
3136
<a ng-click="toggleSidebar()">
32-
Dashboard
37+
Console
3338
<span class="menu-icon glyphicon glyphicon-transfer"></span>
3439
</a>
3540
</li>
@@ -44,13 +49,13 @@
4449
</li>
4550
-->
4651
<li class="sidebar-list">
47-
<a href="#/employee">User <span class="menu-icon fa fa-table"></span></a>
52+
<a href="#/employee">User <span class="menu-icon fa fa-users"></span></a>
4853
</li>
4954
<li class="sidebar-list">
50-
<a href="#/role">Role <span class="menu-icon fa fa-table"></span></a>
55+
<a href="#/role">Role <span class="menu-icon fa fa-television"></span></a>
5156
</li>
5257
<li class="sidebar-list">
53-
<a href="#/course">Course <span class="menu-icon fa fa-table"></span></a>
58+
<a href="#/course">Course <span class="menu-icon fa fa-calendar"></span></a>
5459
</li>
5560
<li class="sidebar-list">
5661
<a href="#/sample">Golden Sample<span class="menu-icon fa fa-table"></span></a>

helloworld-springboot/src/main/UI/src/js/common/app.environments.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
getUserList: '/api/user/list',
3434
deleteUser: '/api/user/{0}',
3535
addUser: '/api/user',
36-
updateUser: '/api/user/{0}'
36+
updateUser: '/api/user'
3737
};
3838
function _joinUrl(domain, path) {
3939
return domain.replace(/(^http.*?)\/{0,}$/, '$1/') + path.replace(/^\/{0,}(.*)/, '$1');
@@ -73,7 +73,7 @@
7373
this.config = config;
7474
};
7575
this.$get = function () {
76-
this.setEnvironment(constants.environments.MOCK);
76+
this.setEnvironment(constants.environments.PRO);
7777
return config;
7878
};
7979

helloworld-springboot/src/main/UI/src/js/common/app.services.js

Lines changed: 100 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,70 @@ angular
22
.module('RDash')
33
.service('app.services', ['$http','$q','app.environments',function ($http,$q,environments) {
44
var url = environments.services.customService.url;
5-
var deferred = $q.defer();
5+
6+
this.isEmptyOrNull = function (obj) {
7+
/// <summary>
8+
/// Retrieve true when object is empty, undefined or null.
9+
/// </summary>
10+
/// <param name='obj'>Object to be checked</param>
11+
/// <returns type='boolean'>True when object is empty, undefined or null.</returns>
12+
/// <doc>myPerformance.factory:methods#isEmptyOrNull</doc>
13+
return ((obj === undefined) ||
14+
(obj === null) ||
15+
(angular.isString(obj) && (obj === '')) ||
16+
(angular.isArray(obj) && (obj.length === 0)) // Arrays
17+
);
18+
};
19+
20+
this.urlFormat = function () {
21+
/// <summary>
22+
/// Format url using string.format way to match parameters.
23+
/// </summary>
24+
/// <returns type='string'>String parsed.</returns>
25+
/// <doc>myPerformance.factory:methods#urlFormat</doc>
26+
var args = arguments, url = '', baseUrl = '', qs = '', qsFormatted = '', splitted, vars = [], hash, i;
27+
if (this.isEmptyOrNull(args)) {
28+
return '';
29+
}
30+
if (args.length === 1) {
31+
url = args[0];
32+
}
33+
else {
34+
url = args[0].replace(/\{(\d+)\}/g, function (match, number) {
35+
return args[parseInt(number, 10) + 1] !== undefined ? encodeURIComponent(args[parseInt(number, 10) + 1]) : '';
36+
});
37+
}
38+
// Remove empty qs parameters
39+
if (url.indexOf('?') >= 0) {
40+
splitted = url.split('?');
41+
baseUrl = splitted[0];
42+
if (splitted.length > 1) {
43+
qs = splitted[1].split('&');
44+
for (i = 0; i < qs.length; i++) {
45+
if (qs[i].indexOf('=') >= 0) {
46+
hash = qs[i].split('=');
47+
vars.push({ code: hash[0], value: hash[1] });
48+
}
49+
else {
50+
vars.push({ code: qs[i], value: '' });
51+
}
52+
}
53+
// Fill qsFormatted using vars and removing empty values
54+
for (i = 0; i < vars.length; i++) {
55+
if (vars[i].value && vars[i].value !== '') {
56+
qsFormatted = qsFormatted + ((qsFormatted === '') ? '?' : '&') + vars[i].code + '=' + vars[i].value;
57+
}
58+
}
59+
}
60+
}
61+
else {
62+
baseUrl = url;
63+
}
64+
return baseUrl + qsFormatted;
65+
};
66+
667
this.getUserList = function(){
68+
var deferred = $q.defer();
769
$http.get(url.getUserList,{})
870
.success(function(data){
971
console.log(data);
@@ -19,4 +81,41 @@ angular
1981

2082
return deferred.promise;
2183
};
84+
85+
this.addUser = function(user){
86+
var deferred = $q.defer();
87+
$http.post(url.addUser,user)
88+
.success(function(data){
89+
console.log(data);
90+
if (data.code == 1) {
91+
deferred.resolve(data);
92+
} else {
93+
deferred.reject(data);
94+
}
95+
})
96+
.error(function(error){
97+
deferred.reject(error);
98+
});
99+
100+
return deferred.promise;
101+
};
102+
103+
this.updateUser = function(user){
104+
var deferred = $q.defer();
105+
var urlQuery = this.urlFormat(url.updateUser,user.id);
106+
$http.put(urlQuery,user)
107+
.success(function(data){
108+
console.log(data);
109+
if (data.code == 1) {
110+
deferred.resolve(data);
111+
} else {
112+
deferred.reject(data);
113+
}
114+
})
115+
.error(function(error){
116+
deferred.reject(error);
117+
});
118+
119+
return deferred.promise;
120+
}
22121
}]);
Lines changed: 115 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,123 @@
11
angular
22
.module('RDash')
3-
.controller('EmployeeCtrl', ['$scope','app.environments','app.services', EmployeeCtrl]);
3+
.controller('EmployeeCtrl', ['$rootScope', '$scope','$log','$uibModal','app.services','NgTableParams', EmployeeCtrl])
4+
.controller('OperateUserCtrl', ['$scope','$log','$uibModalInstance','app.services', AddUserCtrl]);
5+
function EmployeeCtrl($rootScope, $scope, $log,$uibModal, services,NgTableParams) {
6+
$scope.users = [];
7+
$scope.isIDLegal = false;
8+
$scope.getUserList = function(){
9+
services.getUserList().then(function(result) {
10+
if (result.code == 1) {
11+
$scope.users = result.data;
12+
$scope.tableParams = new NgTableParams(
13+
{
14+
page: 1, // show first page
15+
count: 10, // count per page
16+
sorting: { id: 'asc'}
17+
},
18+
{
19+
total: 0, // length of data
20+
dataset: result.data
21+
});
22+
}
23+
}, function (error) {
24+
console.log(error);
25+
});
26+
}
427

5-
function EmployeeCtrl($scope,environments,services) {
28+
$scope.addUserModal = function(){
29+
//var scope = $rootScope.$new();
30+
$scope.user = {};
31+
$scope.isModify = false;
32+
var modalInstance = $uibModal.open({
33+
scope: $scope,
34+
animation: true,
35+
templateUrl: 'addUserModal.html',
36+
controller: 'OperateUserCtrl',
37+
});
38+
};
639

7-
services.getUserList().then(function(result) {
8-
9-
if (result.code == 1) {
10-
$scope.users = result.data;
11-
}
12-
}, function (error) {
13-
console.log(error);
14-
});
40+
$scope.inactiveUser = function(user){
41+
user.active = false;
42+
services.updateUser(user).then(function(result) {
43+
if (result.code == 1) {
44+
//alert("success");
45+
}
46+
}, function (error) {
47+
console.log(error);
48+
});
49+
};
50+
51+
$scope.activeUser = function(user){
52+
user.active = true;
53+
services.updateUser(user).then(function(result) {
54+
if (result.code == 1) {
55+
//alert("success");
56+
}
57+
}, function (error) {
58+
console.log(error);
59+
});
60+
};
61+
62+
$scope.updateUserModal = function(user){
63+
//var scope = $rootScope.$new();
64+
$scope.user =user;
65+
$scope.isModify = true;
66+
var modalInstance = $uibModal.open({
67+
scope: $scope,
68+
animation: true,
69+
templateUrl: 'addUserModal.html',
70+
controller: 'OperateUserCtrl',
71+
});
72+
};
73+
74+
$scope.updateUser = function(user){
75+
services.updateUser(user).then(function(result) {
76+
if (result.code == 1) {
77+
alert("success");
78+
}
79+
}, function (error) {
80+
console.log(error);
81+
});
82+
};
83+
84+
$scope.getUserList();
85+
}
86+
87+
function AddUserCtrl($scope, $log,$uibModalInstance, services) {
1588

16-
$scope.submitUser = function(){
1789

90+
$scope.closeUserModal = function(){
91+
$uibModalInstance.dismiss();
1892
};
93+
94+
$scope.checkForm = function(){
95+
96+
return true;
97+
}
98+
99+
$scope.submitUserData = function(){
100+
if($scope.checkForm()){
101+
if($scope.isModify){
102+
services.updateUser($scope.user).then(function(result) {
103+
if (result.code == 1) {
104+
$scope.closeUserModal();
105+
}
106+
}, function (error) {
107+
console.log(error);
108+
});
109+
}else{
110+
services.addUser($scope.user).then(function(result) {
111+
if (result.code == 1) {
112+
$scope.getUserList();
113+
$scope.closeUserModal();
114+
}
115+
}, function (error) {
116+
console.log(error);
117+
});
118+
}
119+
}
120+
};
121+
122+
19123
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
angular.module('RDash', ['ui.bootstrap', 'ui.router', 'ngCookies']);
1+
angular.module('RDash', ['ui.bootstrap', 'ui.router', 'ngCookies', 'ngTable']);

0 commit comments

Comments
 (0)