Skip to content

Commit

Permalink
Merge pull request #2 from lcx960324/master
Browse files Browse the repository at this point in the history
basic functions finished
  • Loading branch information
Lawrence Lee authored Sep 14, 2016
2 parents 755aa72 + 366960a commit 416b0d4
Show file tree
Hide file tree
Showing 18 changed files with 351 additions and 125 deletions.
29 changes: 28 additions & 1 deletion app/app.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,29 @@ angular.module('Macaron_WebClient').
when('/status', {template: '<status></status>'}).
when('/list', {template: '<list></list>'}).
when('/logs', {template: '<logs></logs>'}).
when('/live', {template: '<live></live>'}).
otherwise('/basic-info');
}
])
.controller('loginCheckController', function loginCheckController($http, $scope, $location) {
$scope.username = 'Guest';
$http({
method: 'POST',
url: 'http://192.168.50.197:8082/user/getUsername.do',
withCredentials: true
})
.success(function(data) {
if(data.error == '0') {
console.log('username: ' + data.username);
$scope.username = data.username;
} else {
console.log(data);
window.location.href = 'login.html';
}
});
})
.controller('navController', function navController($scope, $location) {

$scope.navItems = [
{
name: 'basic-info',
Expand Down Expand Up @@ -43,7 +62,15 @@ angular.module('Macaron_WebClient').
href: '#!/logs',
location: '/logs',
icon: 'uk-icon-tasks uk-icon-justify'
}
},
{
name: 'live',
title: '实时监控',
href: '#!/live',
location: '/live',
icon: 'uk-icon-video-camera uk-icon-justify'
},

];
$scope.selectedItem = "basic-info";
$scope.navClick = function (itemName) {
Expand Down
3 changes: 2 additions & 1 deletion app/app.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ angular.module('Macaron_WebClient', [
'basicInfo',
'status',
'list',
'logs'
'logs',
'live'
]);
Binary file added app/assets/img/favicon.ico
Binary file not shown.
Binary file added app/assets/movie.ogg
Binary file not shown.
24 changes: 20 additions & 4 deletions app/basic-info/basic-info.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,24 @@
angular.
module('basicInfo').
component('basicInfo', {
templateUrl: 'basic-info/basic-info.template.html',
controller: function basicInfoController() {

}
templateUrl: 'basic-info/basic-info.template.html',
controller: function basicInfoController($http) {
var self = this;
self.basicInfo = {
total: '0',
online: '0',
offline: '0',
unread: '0'
};
$http({
method: 'POST',
url: 'http://192.168.50.197:8082/user/getBasicInfo.do',
withCredentials: true
})
.success(function (data) {
if(data) {
self.basicInfo = data;
}
});
}
});
9 changes: 4 additions & 5 deletions app/basic-info/basic-info.template.html
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
<div class="uk-container uk-container-center">
<script src="http://cdn.bootcss.com/Chart.js/2.1.4/Chart.min.js"></script>
<div class="uk-grid uk-grid-small" data-uk-grid-match>
<div class="uk-width-1-2">
<div class="uk-panel uk-panel-box">
<h4 class="uk-text-center"><i class="uk-icon-list uk-icon-justify"></i> 设备数量</h4>
<div class="uk-text-center" style="font-size: 200%;">5</div>
<div class="uk-text-center" style="font-size: 200%;">{{$ctrl.basicInfo.total}}</div>
</div>
</div>
<div class="uk-width-1-2">
<div class="uk-panel uk-panel-box">
<h4 class="uk-text-center"><i class="uk-icon-list uk-icon-justify"></i> 在线设备</h4>
<div class="uk-text-center" style="font-size: 200%;">5</div>
<div class="uk-text-center" style="font-size: 200%;">{{$ctrl.basicInfo.online}}</div>
</div>
</div>
</div>
<div class="uk-grid uk-grid-small" data-uk-grid-match>
<div class="uk-width-1-2">
<div class="uk-panel uk-panel-box">
<h4 class="uk-text-center"><i class="uk-icon-list uk-icon-justify"></i> 离线设备</h4>
<div class="uk-text-center" style="font-size: 200%;">0</div>
<div class="uk-text-center" style="font-size: 200%;">{{$ctrl.basicInfo.offline}}</div>
</div>
</div>
<div class="uk-width-1-2">
<div class="uk-panel uk-panel-box">
<h4 class="uk-text-center"><i class="uk-icon-list uk-icon-justify"></i> 未读日志</h4>
<div class="uk-text-center" style="font-size: 250%"><a href="#logs" class="uk-link uk-link-muted">3</a></div>
<div class="uk-text-center" style="font-size: 200%">{{$ctrl.basicInfo.unread}}</div>
</div>
</div>
</div>
Expand Down
13 changes: 8 additions & 5 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<title>Macaron · 控制面板</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="assets/img/favicon.ico">
<link rel="stylesheet" href="bower_components/html5-boilerplate/dist/css/normalize.css">
<link rel="stylesheet" href="bower_components/html5-boilerplate/dist/css/main.css">
<link rel="stylesheet" href="bower_components/uikit/css/uikit.gradient.min.css">
Expand All @@ -29,21 +30,23 @@
<script src="list/list.component.js"></script>
<script src="logs/logs.module.js"></script>
<script src="logs/logs.component.js"></script>
<script src="live/live.module.js"></script>
<script src="live/live.component.js"></script>
<script src="../node_modules/angular-chart.js/node_modules/chart.js/dist/Chart.min.js"></script>
<script src="../node_modules/angular-chart.js/dist/angular-chart.min.js"></script>

<nav class="uk-navbar uk-navbar-attached">
<a href="#" class="uk-navbar-brand"><img src="assets/img/dessert.png" height="25" width="110" /></a>
<a class="uk-navbar-brand"><img src="assets/img/dessert.png" height="25" width="110" /></a>
<ul class="uk-navbar-nav">
</ul>
<div class="uk-navbar-flip">
<div class="uk-navbar-flip" ng-controller="loginCheckController">
<ul class="uk-navbar-nav">
<li data-uk-dropdown="{mode:'click'}">
<a href="#"><i class="uk-icon-user"></i> Lawrence</a>
<a href="#"><i class="uk-icon-user"></i> {{username}}</a>
<div class="uk-dropdown uk-dropdown-navbar uk-dropdown-small">
<ul class="uk-nav uk-nav-navbar">
<li><a href=""><i class="uk-icon-users uk-icon-justify" style="margin-right: 5px;"></i> 个人信息</a></li>
<li><a href=""><i class="uk-icon-sign-out uk-icon-justify" style="margin-right: 5px;"></i> 退出登录</a></li>
<!--<li><a href=""><i class="uk-icon-users uk-icon-justify" style="margin-right: 5px;"></i> 个人信息</a></li>-->
<li><a href="login.html"><i class="uk-icon-sign-out uk-icon-justify" style="margin-right: 5px;"></i> 退出登录</a></li>
</ul>
</div>
</li>
Expand Down
22 changes: 19 additions & 3 deletions app/list/list.component.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
/**
* Created by Lawrence on 16/9/10.
*/
'use strict'
'use strict';

angular.
module('list').
component('list', {
templateUrl: 'list/list.template.html',
controller: function basicInfoController() {

controller: function listController($http) {
var self = this;
self.devices = [
// {
// deviceName: 'Test1',
// registerTime: '2016.1.1',
// deviceLocate: 'B623'
// }
];
$http({
method: 'POST',
url: 'http://192.168.50.197:8082/user/getDevices.do',
withCredentials: true
}).success(function(data) {
if(data) {
self.devices = data;
}
});
}
});
14 changes: 4 additions & 10 deletions app/list/list.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,10 @@
</tr>
</thead>
<tbody>
<tr>
<td>Test1</td>
<td>2016-06-01 12:01</td>
<td>B623</td>
<td><button class="uk-button uk-button-small uk-button-danger" type="button">注销</button></td>
</tr>
<tr>
<td>Test2</td>
<td>2016-06-01 12:01</td>
<td>B658</td>
<tr ng-repeat="device in $ctrl.devices">
<td>{{device.deviceName}}</td>
<td>{{device.registerTime}}</td>
<td>{{device.deviceLocate}}</td>
<td><button class="uk-button uk-button-small uk-button-danger" type="button">注销</button></td>
</tr>
</tbody>
Expand Down
24 changes: 24 additions & 0 deletions app/live/live.component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Created by Lawrence on 16/9/11.
*/
'use strict';

angular.
module('live').
component('live', {
templateUrl: 'live/live.template.html',
controller: function liveController() {
var self = this;
self.deviceList = [
{
deviceName: 'Test1',
videoUrl: 'assets/movie.ogg'
},
{
deviceName: 'Test2',
videoUrl: 'assets/movie.ogg'
}
];
self.selected = self.deviceList[0];
}
});
6 changes: 6 additions & 0 deletions app/live/live.module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* Created by Lawrence on 16/9/11.
*/
'use strict';

angular.module('live', []);
16 changes: 16 additions & 0 deletions app/live/live.template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

<div class="uk-container uk-container-center">
<div class="uk-button-dropdown" data-uk-dropdown="{mode:'click'}">
<button class="uk-button" style="margin: 10px 0;">{{$ctrl.selected.deviceName}} <i class="uk-icon-caret-down"></i></button>
<div class="uk-dropdown uk-dropdown-close">
<ul class="uk-nav uk-nav-navbar">
<li ng-repeat="device in $ctrl.deviceList">
<a ng-click="$ctrl.selected = device">{{device.deviceName}}</a>
</li>
</ul>
</div>
</div>
<div class="uk-grid uk-grid-small" data-uk-grid-match>
<video src="{{$ctrl.selected.videoUrl}}" controls="controls"></video>
</div>
</div>
33 changes: 27 additions & 6 deletions app/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<title>Dessert · 登录</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="assets/img/favicon.ico">
<link rel="stylesheet" href="bower_components/html5-boilerplate/dist/css/normalize.css">
<link rel="stylesheet" href="bower_components/html5-boilerplate/dist/css/main.css">
<link rel="stylesheet" href="app.css">
<link rel="stylesheet" href="bower_components/uikit/css/uikit.gradient.min.css">
<script src="bower_components/html5-boilerplate/dist/js/vendor/modernizr-2.8.3.min.js"></script>
<script src="bower_components/jquery/dist/jquery.min.js"></script>
Expand All @@ -20,8 +20,28 @@
<script src="bower_components/uikit/js/uikit.min.js"></script>
<script>
var loginPage = angular.module('loginPage', [])
.controller(loginController, function loginController($scope, $http) {

.controller('loginController', function loginController($scope, $http, $location) {
$scope.login = function (username, password) {
$scope.userInfo = {
username: username,
password: password
};
$http({
method: 'POST',
url: 'http://192.168.50.197:8082/user/login.do',
data: $.param($scope.userInfo),
withCredentials: true,
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
})
.success(function(data) {
if(data.error != '0') {
alert("用户名或密码错误!");
window.location.reload();
} else {
window.location.href = 'index.html';
}
});
}
});
</script>
</head>
Expand All @@ -30,24 +50,25 @@
<div class="uk-text-center uk-height-1-1">
<div class="uk-align-center" style="width: 300px;">
<img class="uk-margin-bottom" src="assets/img/logo.png" width="200" height="200" />
<form class="uk-panel uk-panel-box uk-form" ng-app ng-form="loginForm" ng-controller="loginController" ng-submit="login()">
<form class="uk-panel uk-panel-box uk-form" ng-controller="loginController" ng-submit="login(username, password)">
<div class="uk-form-row">
<input ng-model="username" name="username" type="text" placeholder="用户名" class="uk-width-1-1">
</div>
<div class="uk-form-row">
<input ng-model="password" name="password" type="password" placeholder="密码" class="uk-width-1-1">
</div>
<div class="uk-form-row">
<a href="#" class="uk-width-1-1 uk-button uk-button-primary uk-button-large">登陆</a>
<button class="uk-width-1-1 uk-button uk-button-primary uk-button-large" type="submit">登陆</button>
</div>

<div class="uk-form-row">
<label class="uk-float-left">
<input type="checkbox"> 记住我
</label>
<a class="uk-float-right uk-link uk-link-muted" href="#">忘记密码</a>
</div>
<div class="uk-form-row">
<a ng-href="register.html" class="uk-float-right uk-link uk-link-reset" href="#">还未加入? <u>点此注册</u></a>
<a ng-href="register.html" class="uk-float-right uk-link uk-link-reset" href="register.html">还未加入? <u>点此注册</u></a>
</div>
</form>
</div>
Expand Down
52 changes: 50 additions & 2 deletions app/logs/logs.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,56 @@ angular.
templateUrl: 'logs/logs.template.html',
controller: function logsController($http) {
var self = this;
$http.get('url').then(function(response) {
self.logs = response.data;
self.logs = [
// {
// alertId: '1',
// occurTime: '2016-01-01 12:01',
// deviceName: 'Test1',
// deviceLocate: 'B623',
// message: '燃气数据异常',
// isChecked: '1'
// },
// {
// alertId: '2',
// occurTime: '2016-01-01 12:01',
// deviceName: 'Test1',
// deviceLocate: 'B623',
// message: '燃气数据异常',
// isChecked: '2'
// }
];
$http({
method: 'POST',
url: 'http://192.168.50.197:8082/user/getLogs.do',
withCredentials: true
}).then(function(response) {
if(response.data) {
self.logs = response.data;
}
});
self.solve = function(log) {
$http({
method: 'GET',
url: 'http://192.168.50.197:8082/user/logOperation.do?alertId=' + log.alertId + '&method=' + '1',
withCredentials: true
})
.success(function(data) {
if(data.error == '0') {
log.isChecked = '1';
}
});
};
self.ignore = function(log) {
$http({
method: 'GET',
url: 'http://192.168.50.197:8082/user/logOperation.do?alertId=' + log.alertId + '&method=' + '2',
withCredentials: true
})
.success(function(data) {
if(data.error == '0') {
log.isChecked = '2';
}
});
};
}
});
Loading

0 comments on commit 416b0d4

Please sign in to comment.