base.html
6.8 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
<span style="font-size:18px;"><!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<title>{{ _('智能料架系统') }}</title>
<!-- <link rel="icon" href="/static/favicon.ico"> -->
<!-- <link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}"> -->
<link rel="icon" href="/static/favicon.ico">
<link href="/static/css/bootstrap.min.css" rel="stylesheet">
<script src="/static/js/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</head>
<body>
{% set index=1 %}
{% import 'head.html' as head with context%}
{{ head }}
<div class="container-fluid">
<div class="row">
<div class="col-md-6">
<h2>{{ _('料架系统') }}</h2>
<hr class="divider">
<!-- 料架启动关闭 -->
<div class="panel panel-info">
<div class="panel-heading">
<h3 class="panel-title">{{ _('开关') }}</h3>
</div>
<div class="panel-body">
<input type="button" value={{ _('启动') }} class="btn btn-info" onclick="startpost()"/>
<input type="button" value={{ _('停止') }} class="btn btn-warning" onclick="stoppost()"/>
</div>
</div>
<div id="panel-group">
<!-- 1 -->
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">{{ _('提醒消息') }}</h3>
</div>
<div class="panel-body">
<div class="alert alert-info" role="alert">
<p>
{{ _('运行状态') }}:<span id="shelfstate"></span>
</p>
</div>
<div class="alert alert-info" role="alert">
<p>
{{ _('配置文件加载状态') }}:<span id="testinfo">{{ _('加载成功') if config_state else _('加载失败,请在配置页面上传配置文件') }}</span>
</p>
</div>
<div class="alert alert-info" role="alert">
<p>
{{ _('服务器地址') }}:<span id="ipconfig"></span>
</p>
</div>
<div class="alert alert-info" role="alert">
<p>
{{ _('料架编号') }}:<span id="ccid"></span>
</p>
</div>
<div class="alert alert-info" role="alert">
<p>
{{ _('服务器连接状态') }}:<span id="poststate"></span>
</p>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<h2>{{ _('运行日志&状态信息') }}</h2>
<hr class="divider">
<!-- 日志下载 -->
<div class="panel panel-info">
<div class="panel-heading">
<h3 class="panel-title">{{ _('日志下载') }}</h3>
</div>
<div class="panel-body">
<a type="button" class="btn btn-warning" href="{{ url_for('download') }}">{{ _('下载日志') }}</a>
</div>
</div>
<!-- 日志显示 -->
<div class="panel panel-info">
<div class="panel-heading">
<h3 class="panel-title">{{ _('日志') }}</h3>
</div>
<div class="panel-body">
<div id="logmsg" style="overflow:auto;height: 400px;background:#000; color:green"></div>
</div>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function () {
getstate();
taillog();
console.log('success');
});
function startpost(){
$.ajax({
url:"/startpost",
type:"post",
// data:form,
dataType: 'json',
processData:false,
contentType:false,
success:function(data){
if (data[0].state == 'on') {$("#shelfstate").html("{{ _('运行中') }}");}
else if (data[0].state == 'off') {$("#shelfstate").html("{{ _('已关闭') }}");}
else {$("#shelfstate").html("{{ _('未初始化') }}");}
// console.log(data)
alert (data[0].msg)
},
error:function(e){
alert("{{ _('启动失败') }}");
}
})
}
function stoppost(){
// var form= new FormData(document.getElementById("test_form"));
var shelfstate = document.getElementById("shelfstate").value
console.log(shelfstate)
$.ajax({
url:"/stoppost",
type:"post",
// data:form,
dataType: 'json',
processData:false,
contentType:false,
success:function(data){
if (data[0].state == 'on') {$("#shelfstate").html("{{ _('运行中') }}");}
else if (data[0].state == 'off') {$("#shelfstate").html("{{ _('已关闭') }}");}
else {$("#shelfstate").html("{{ _('未初始化') }}");}
console.log(data)
alert (data[0].msg)
},
error:function(e){
alert("{{ _('停止失败') }}");
}
})
}
// 获取开机关机状态
function getstate(){
// var form= new FormData(document.getElementById("test_form"));
$.ajax({
url:"/getstate",
type:"post",
// data:form,
dataType: 'json',
processData:false,
contentType:false,
success:function(data){
console.log(data)
if (data[0].state == 'on') {$("#shelfstate").html("{{ _('运行中') }}");}
else if (data[0].state == 'off') {$("#shelfstate").html("{{ _('已关闭') }}");}
else {$("#shelfstate").html("{{ _('未初始化') }}");}
// $("#gpioconfig").html(data[0].gpio)
$("#ipconfig").html(data[0].ipconfig['ip'])
$("#ccid").html(data[0].ipconfig['cid'])
},
error:function(e){
alert("{{ _('未获取到状态信息') }}");
}
})
}
// 获取开机关机状态
function taillog(){
// var form= new FormData(document.getElementById("test_form"));
$.ajax({
url:"/taillog",
type:"post",
// data:form,
dataType: 'json',
processData:false,
contentType:false,
success:function(data){
$("#logmsg").html(data.msg)
$("#poststate").html(data.poststate)
},
error:function(e){
}
})
}
setInterval(function(){
taillog();
}, 3000);
</script>
<script src="/static/js/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</body>
</html>