/
index.html
85 lines (81 loc) · 2.74 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Units</title>
<meta name="description" content="" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<style>
html, body, div{
padding: 0;
margin: 0;
line-height: 1;
}
html, body {
height: 100%;
}
.wialon-units {
overflow-y: auto;
height: 100%;
}
.item {
position:relative;
height: 35px;
}
.item .content {
position: absolute;
left: 35px;
top: 0;
bottom: 0;
}
</style>
<div class="wialon-units" ng-app="unitsApp" ng-controller="unitsCtrl">
<div ng-repeat="model in units track by $index">
<div class="item" data-item="{{ $index }}">
<img src="https://hst-api.wialon.com{{model.uri}}?b=32" />
<div class="content">
<div>{{ model.nm }}</div>
<div>{{ model.pos.y }} {{ model.pos.x }}</div>
</div>
</div>
</div>
</div>
<script src="./../../../dist/wialon-src.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/angular.js"></script>
<script>
// patch native window.W
window.name = 'NG_DEFER_BOOTSTRAP!';
// init Wialon session
var session = new W.Session('https://hst-api.wialon.com', {
eventsTimeout: 5
}),
oldEventsCallback = W.Session.prototype._getEventsCallback;
// patch session
session._getEventsCallback = function (data) {
oldEventsCallback.call(this, data);
this.fire('sessionUpdated');
};
var app = angular.module('unitsApp', []);
app.controller('unitsCtrl', function($scope) {
$scope.units = session.getItems('avl_unit');
session.on('sessionUpdated', function() {
$scope.$apply();
});
});
// change 'user' and 'password' to your demo account
session.execute('core/login', {user: 'wialon_test', password: 'test'}, function (data) {
console.log('login callback', data);
// load all unit in session
var params = {spec:[{'type':'type', 'data':'avl_unit', 'flags':0x411, 'mode':0}]};
session.execute('core/update_data_flags', params, function (data) {
angular.element().ready(function() {
angular.resumeBootstrap(['unitsApp']);
});
});
});
</script>
</body>
</html>