deviceManage.esp
19.4 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link href="../../css/frame.css" rel="stylesheet" />
<link href="../../scripts/easyui/themes/default/easyui.css" rel="stylesheet" />
<link href="../../scripts/easyui/themes/icon.css" rel="stylesheet" />
<link href="../../css/reboot.css" rel="stylesheet" />
<style type="text/css">
.tdTitle {
width: 120px;
}
.tdContent {
width: 450px;
}
table.settingsContainer .settimer{
width: 160px!important;
}
.settingBtn {
float: left;
}
.settingBtn.right {
float: right;
}
.ntpServerContainer {
visibility: hidden;
}
</style>
</head>
<body style="position: relative;">
<form id="timingForm">
<table class="settingsContainer">
<tr>
<td class="tdTitle">设备时间</td>
<td class="tdContent">
<span id="serverTime"></span>
</td>
</tr>
<tr>
<td class="tdTitle">校时模式</td>
<td class="tdContent">
<select name="31" id="timingMode" class="settingParameter">
<option value="0">私有协议校时</option>
<option value="1">NTP校时</option>
<option value="2">GPS校时</option>
<option value="5">不自动校时</option>
<!--<option value="2" disabled="disabled">GPS校时</option>-->
</select>
<a class="settingBtn right" id="btnSave">保存</a>
</td>
</tr>
<tr>
<td class="tdTitle">
<span class="ntpServerContainer">NTP服务器地址</span>
</td>
<td class="tdContent">
<span class="ntpServerContainer">
<input id="ntpServer" name="32" class="settingParameter" type="text" />
</span>
</td>
</tr>
</table>
<% inputSecurityToken(); %>
</form>
<table class="settingsContainer">
<tr>
<td class="tdTitle">设备校时</td>
<td class="tdContent">
<a class="settingBtn" id="btnTiming">校时</a>
</td>
</tr>
<tr>
<td class="tdTitle">设备重启</td>
<td class="tdContent">
<a class="settingBtn" id="btnReboot">重启</a>
</td>
</tr>
<tr>
<td class="tdTitle">设备升级</td>
<td class="tdContent">
<form id="formUpgrade" action="/do/trafficController/update" method="POST" enctype="multipart/form-data">
<input class="fileInput" name="file" type="file" />
<a class="settingBtn right" id="btnUpgrade">升级</a>
<% inputSecurityToken(); %>
</form>
</td>
</tr>
<tr>
<td class="tdTitle">设备授权</td>
<td class="tdContent">
<form id="formAuthorise" action="/do/trafficController/authorization" method="POST">
<input id="licenceFile" class="fake_input" name="file" type="text" style="width:173px;background-color:#F0F0F0" ondblclick="selectLicenceFile()"
/>
<a id="selectFile" style="margin-left:-2px;cursor:pointer;background:url(../../images/save.png) no-repeat;padding-top:1px;padding-bottom:2px;padding-left:20px;padding-right:55px;"
onclick="selectLicenceFile()"></a>
<a class="settingBtn right" id="btnAuthorise">授权</a>
<% inputSecurityToken(); %>
<input name="LicenseFileData" type="hidden" />
</form>
</td>
</tr>
<tr>
<td class="tdTitle">参数导入</td>
<td class="tdContent">
<form id="formImport" action="/do/trafficController/importParameter" method="POST" enctype="multipart/form-data">
<input class="fileInput" name="file" type="file" value="" />
<a class="settingBtn right" id="btnImport">导入</a>
<% inputSecurityToken(); %>
</form>
</td>
</tr>
<tr>
<td class="tdTitle">参数导出</td>
<td class="tdContent">
<a class="settingBtn" id="btnExport">导出</a>
</td>
</tr>
<tr>
<td class="tdTitle">存储配置文件导入</td>
<td class="tdContent">
<form id="formStorageImport" action="/do/trafficController/importStorageCfg" method="POST" enctype="multipart/form-data">
<input class="fileInput" name="file" type="file" value="" />
<a class="settingBtn right" id="btnStorageImport">导入</a>
<% inputSecurityToken(); %>
</form>
</td>
</tr>
<tr>
<td class="tdTitle">存储配置文件导出</td>
<td class="tdContent">
<a class="settingBtn" id="btnStorageExport">导出</a>
</td>
</tr>
<tr>
<td class="tdTitle">恢复出厂参数</td>
<td class="tdContent">
<a class="settingBtn" id="btnResetDefault">恢复出厂参数</a>
</td>
</tr>
<tr>
<td class="tdTitle">开机时间设置</td>
<td class="tdContent">
<select class="settimer" id="starttimer" placeholder="开始时间">
</select>
~
<select class="settimer" id="endtimer" placeholder="结束时间">
</select>
</td>
</tr>
<tr>
<td class="tdTitle">关机时间设置</td>
<td class="tdContent">
<select class="settimer" id="starttimer1" placeholder="开始时间">
</select> ~
<select class="settimer" id="endtimer1" placeholder="结束时间">
</select>
</td>
<td class="tdContent">
<a class="settingBtn" id="savetimer">保存</a>
<% inputSecurityToken(); %>
</td>
</tr>
<!-- <tr>
<td class="tdTitle">恢复出厂</td>
<td class="tdContent">
<a class="settingBtn" id="btnFactoryReset">恢复出厂设置</a>
</td>
</tr> -->
</table>
<script src="../../scripts/easyui/jquery.min.js"></script>
<script src="../../scripts/easyui/jquery.easyui.min.js"></script>
<script src="../../scripts/easyui/locale/easyui-lang-zh_CN.js"></script>
<script src="../../scripts/utilities.js"></script>
<script src="../../scripts/jquery.form.js"></script>
<script src="../../scripts/dateTimeExtension.js"></script>
<script type="text/javascript">
//参数适配器
var parameterAdaptor = new ParameterAdaptor();
var uploadFileType = null;
var rebootManager = new RebootManager();
$().ready(function () {
//刷新相机的时间
showDeviceTime();
//加载校时相关参数
loadTimingInfo();
//加载时间段
gettimer();
//校时模式联动
$("#timingMode").change(onTimingModeChanged);
$("#btnSave").click(saveParametersToServer);//保存校时模式及NTP服务器参数
$("#btnTiming").click(setDeviceTimeByLocalTime);//校时
$("#btnReboot").click(sendCmdReboot);//重启相机
$("#btnUpgrade").click(upgradeDevice);//升级
$("#btnAuthorise").click(authoriseDevice);//设备授权
$("#btnImport").click(importSettings);//导入参数
$("#btnExport").click(exportSettings);//导出参数
$("#btnStorageImport").click(importStorageSettings);
$("#btnStorageExport").click(exportStorageSettings);
$("#btnResetDefault").click(resetDefault);//恢复默认参数
$("#btnFactoryReset").click(factoryReset);//恢复出厂设置
$("#savetimer").click(savetimer) //时间设置
var html = '<option value=""></option>';
for(var i = 1; i < 25; i++){
html += "<option value="+i+">"+i+"</option>"
}
$('.settimer').html(html);
});
//保存参数到服务器
function saveParametersToServer() {
var timingForm = $("#timingForm");
//保存参数到服务器
parameterAdaptor.saveParameters(timingForm);
}
//校时模式变更回调
function onTimingModeChanged(event) {
//选择的校时模式
var timingMode = $("#timingMode").val();
if (timingMode == "1") {
$(".ntpServerContainer").css("visibility", "visible");
} else {
$(".ntpServerContainer").css("visibility", "hidden");
}
}
//显示相机设备的时间
function showDeviceTime() {
getServerTime(showTimeString);
}
//开启时间设置
function savetimer(val) {
var timer = {};
var s1 = $("#starttimer").val();
var e1 = $("#endtimer").val();
var s2 = $("#starttimer1").val();
var e2 = $("#endtimer1").val();
var parms = {
open1:s1,
close1:e1,
open2:s2,
close2:e2
}
var security = document.getElementsByName("-xsrf-");
parms["-xsrf-"] = security[0].value;
var url = "/do/trafficController/setExtraDataOpenTime";
$.post(url, parms, function (data) {
if (data.error) {
} else {
}
}, "json");
}
function gettimer(){
var url = "/do/trafficController/getExtraDataOpenTime";
$.get(url, null,function (data) {
$("#starttimer").val(data.feedback.open1);
$("#endtimer").val(data.feedback.close1);
$("#starttimer1").val(data.feedback.open2);
$("#endtimer1").val(data.feedback.close2);
}, "json");
}
//负责显示时间字符串
function showTimeString(time) {
var dateString = time.format("yyyy-MM-dd hh:mm:ss");
$("#serverTime").text(dateString);
//1秒种调一次获取时间的方法
setTimeout(showDeviceTime, 1000);
}
//加载NTP校时的信息
function loadTimingInfo() {
var refererInfo = "deviceManage";
parameterAdaptor.getParameters(refererInfo, showTimingInfo);
//显示校时信息
function showTimingInfo(data) {
var values = data.feedback;
$("#timingMode").val(values["31"]);
$("#ntpServer").val(values["32"]);
//更新校时显示
onTimingModeChanged();
};
}
//手动校时,使用本地的时间
function setDeviceTimeByLocalTime() {
var url = "/do/trafficController/setTime";
var date = new Date();
var params = {
Year: date.getFullYear(),
Month: date.getMonth() + 1,
Day: date.getDate(),
Hour: date.getHours(),
Minute: date.getMinutes(),
Second: date.getSeconds()
};
$.get(url, params, function (data) {
if (data.error) {
$.messager.alert("结果", "校时成功!", "info");
} else {
$.messager.alert("结果", "校时失败!" + data.feedback.Msg, "error");
}
}, "json");
}
//重启设备
function sendCmdReboot() {
rebootManager.sendRebootCmd("确认要重启相机?");
}
//导出设置参数
function exportSettings() {
var url = "/do/trafficController/exportParameter";
window.open(url);
}
//存储配置文件导出
function exportStorageSettings() {
var url = "/do/trafficController/exportStorageCfg";
//显示假的进度条
$.messager.progress({
title: "导出",
msg: "存储配置文件导出中,请稍候...",
text: "",
interval: 1000
});
$.ajax({
type: "GET",
url: url,
data: null,
dataType: "json",
error: function (jqXHR, textStatus, error) {
$.messager.progress("close");
$.messager.alert("出错", "请求出错,信息: " + error, "error");
},
success: function (data, textStatus, jqXHR) {
$.messager.progress("close");
//下载日志文件
if (data.error) {
//aalert(data.feedback.FilePath);
var fileUrl = "/do/trafficController/downloadFile?FilePath=" + data.feedback.FilePath;
downloadByIframe(fileUrl);
} else {
$.messager.alert("出错", data.feedback.Msg, "info");
}
}
});
}
//参数恢复为默认值
function resetDefault() {
var url = "/do/trafficController/default";
$.get(url, null, function (data) {
if (data.error) {
rebootManager.sendRebootCmd("恢复出厂参数成功!需重启相机生效!");
} else {
$.messager.alert("结果", "重置失败!" + data.feedback.Msg, "error");
}
}, "json");
}
//恢复出厂设置
function factoryReset() {
var url = "/do/trafficController/recovery";
$.get(url, null, function (data) {
if (data.error) {
$.messager.alert("结果", "恢复出厂设置成功!", "info");
} else {
$.messager.alert("结果", "恢复出厂设置失败!" + data.feedback.Msg, "error");
}
}, "json");
}
//升级设备
function upgradeDevice() {
uploadFileType = "system";
var options = {
target: "#importResultDiv",
dataType: "json",
beforeSubmit: validateFileName,
success: showUploadResult,
error: onUploadError
};
$("#formUpgrade").ajaxSubmit(options);
}
//设备授权
function authoriseDevice() {
uploadFileType = "license";
var options = {
dataType: "json",
beforeSubmit: validateFileName,
success: showUploadResult,
error: onUploadError
};
$("#formAuthorise").ajaxSubmit(options);
}
//导入设置
function importSettings() {
uploadFileType = "parameter";
var options = {
dataType: "json",
beforeSubmit: validateFileName,
success: showUploadResult,
error: onUploadError
};
$("#formImport").ajaxSubmit(options);
}
//存储参数配置文件导入
function importStorageSettings() {
uploadFileType = "storageSettings";
var options = {
dataType: "json",
beforeSubmit: validateFileName,
success: showUploadResult,
error: onUploadError
};
$("#formStorageImport").ajaxSubmit(options);
}
//检测上传文件是否正确
function validateFileName(formData, jqForm, options) {
var fileName;
if (!formData || formData.length < 1 || formData[0].value == "") {
$.messager.alert("提示", "请选择文件!", "error");
return false;
}
//验证文件格式
if (typeof (formData[0].value) == "object" && formData[0].value.name) {
fileName = formData[0].value.name;
} else {
fileName = formData[0].value;
}
if (uploadFileType == "system") {
if (!isFileNameEndWith(fileName, "tar.gz.ais") && !isFileNameEndWith(fileName, ".bin")) {
$.messager.alert("提示", "必须为 .tar.gz.ais 或者 .bin 后辍名的文件!", "error");
return false;
}
} else if (uploadFileType == "license") {
if (!isFileNameEndWith(fileName, ".lic")) {
$.messager.alert("提示", "必须为 .lic 后辍名的文件!", "error");
return false;
}
} else if (uploadFileType == "parameter") {
if (!isFileNameEndWith(fileName, ".tar.gz")) {
$.messager.alert("提示", "必须为 .tar.gz 后辍名的文件!", "error");
return false;
}
} else if (uploadFileType == "storageSettings") {
if (!isFileNameEndWith(fileName, ".tar.gz") && !isFileNameEndWith(fileName, ".zip")) {
$.messager.alert("提示", "必须为 .tar.gz 或 .zip 后辍名的文件!", "error");
return false;
}
}
//验证通过,显示进度条
$.messager.progress({
title: "",
text: "上传中,请稍侯...",
interval: 1000
});
return true;
}
function isFileNameEndWith(fileName, extenName) {
return fileName.substring(fileName.length - extenName.length) == extenName;
}
//显示上传结果
function showUploadResult(response, statusText, xhr, $form) {
if (response.error) {
//提示是否要重启设备
rebootManager.sendRebootCmd("导入成功!需重启后生效,现在是否要重启?");
} else {
$.messager.alert("提示", "失败!原因:" + response.feedback.Msg, "error");
}
$.messager.progress("close");
}
//当上传失败时显示出错信息
function onUploadError() {
$.messager.alert("提示", "上传失败!", "error");
try {
$.messager.progress("close");
} catch (e) {
}
}
function selectLicenceFile() {
var infoOcxObj = window.parent.frames.getInfoOcx();
var RefererInfo = "deviceInfo";
parameterAdaptor.getParameters(RefererInfo, function (data) {
var result = infoOcxObj.SelectedLicenseFile(data.feedback["7"]);
$("#licenceFile").val(result);
$("input[name='LicenseFileData']").val(infoOcxObj.GetFileData(result));
});
}
</script>
</body>
</html>