-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigform.html
256 lines (214 loc) · 11.4 KB
/
configform.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
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="description" content="Описание страницы. Не менее 160 символов. " />
<meta name="keywords" content="Здесь указываем список ключевых слов, разделенные запятой." />
<link rel="stylesheet" href="/public/configform.css">
<script src="http://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous">
</script>
<title>Главная страница</title>
</head>
<body>
<div class="main" ; text-align:rigth;>
<h3>Настройка конфигурации</h3>
<div class="elements">
<div>
<p>
<label>host</label>
<input type="text" size="30" id='host' />
</p>
<p>
<label>port</label>
<input type="text" size="30" id='port' />
</p>
<p>
<label>user name </label>
<input type="text" size="30" id='user' />
</p>
<p>
<label>user password</label>
<input type="text" size="30" id="password" />
</p>
<p>
<label>Период автообновления</label>
<!-- <input type="text" size="30" id="period" /> -->
<input type="text" size="7" id="period"/>
<SELECT name="selectUnitTime" id="selectUnitTime">
<OPTION VALUE="0">Единица времени</OPTION>
<OPTION VALUE="2">мин</OPTION>
<OPTION Selected VALUE="3">ч</OPTION>
</SELECT>
</p>
<p>
<input value="Сохранить настройки" name="buttonSave" type="button" id="buttonSave" />
</p>
<p class="update">
<input value="Обновить базу" name="buttonUpdate" type="button" id="buttonUpdate" />
<input value="Автоматическое обновление" name="buttonAutoUpdate" type="button" id="buttonAutoUpdate" />
<input value="Остановить автообновление" name="buttonStop" type="button" id="buttonStop" />
</p>
<p>
<label>Статус сервиса</label>
<input type="text" size="30" id ='serviceStatus' />
</p>
<p>
<label>Информационный лог обновления остатков</label>
</p>
<p>
<textarea name='log' cols = "80" rows="20" id='log'></textarea>
</p>
<p>
<input value="Экспорт БД" name="Export" type="button" id="buttonExport" />
</p>
<!-- <SELECT name="numbers[]" id="numbers" multiple size="3" style="width:250px;"></SELECT> -->
<p>
<label>Информационный лог добавления заказов</label>
</p>
<p>
<textarea name='logRequest' cols = "80" rows="20" id='logRequest'></textarea>
</p>
</div>
<script>
// function Add_option_to_select(){
// var second = new Array (12, 15, 20, 30, 45);
// var minute = new Array (1, 2, 5, 15, 30);
// var hour = new Array (1, 2, 3, 5, 6);
// var listNumbers = document.getElementById('numbers');
// var listUnitTime = document.getElementById('selectUnitTime');
// var selind = listUnitTime.options.selectedIndex;
// switch (selind){
// case 1:
// listNumbers.options.length = 0;
// var len = second.length;
// for (var i = 0; i < len; n++){
// listNumbers[i] = new Option( second[i],i);
// }
// }
// }
//var serverAddress = 'http://localhost:3000'
var serverAddress = 'http://185.144.30.230:3000'
updateLog(true);
document.getElementById("log").scrollTop=document.getElementById("log").scrollHeight;
$('#buttonExport').click(function(e) {
function downloadURI(uri, name) {
var link = document.createElement("a");
link.download = name;
link.href = uri;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
delete link;
}
// /downloadURI(serverAddress + '/public/products.xml','1.xml');
$.getJSON(serverAddress+'/exportDb', ans => {
console.log(ans);
console.log(ans.commet)
if (ans.status == "OK"){
// downloadURI(serverAddress + '/public/db_export.csv','db_export.csv');
$('#log').val($.trim($('#log').val() + '\n' + 'Выполнен экспорт БД на FTP.'+ "\n"));
document.getElementById("log").scrollTop=document.getElementById("log").scrollHeight;
}else{
prompt('Неудалось экспортировать БД.',JSON.stringify(ans.commet));
// $('#log').val($.trim($('#log').val() + '\n' + 'Неудалось экспортировать БД.' + JSON.stringify(ans.commet) + "\n"));
document.getElementById("log").scrollTop=document.getElementById("log").scrollHeight;
}
})
});
$.getJSON(serverAddress+'/config', data => {
console.log(data);
var host = document.getElementById('host').value = data.config.host;
var port = document.getElementById('port').value = data.config.port;
var user = document.getElementById('user').value = data.config.user;
var password = document.getElementById("password").value = data.config.password;
var period = document.getElementById("period").value = data.config.period;
var unitTime = document.getElementById('selectUnitTime').options.selectedIndex = data.config.unitTime;
})
$('#buttonSave').bind('click', function () {
console.log('Нажата');
var index = document.getElementById("selectUnitTime").options.selectedIndex;
data = {
host: document.getElementById('host').value,
port: document.getElementById('port').value,
user: document.getElementById('user').value,
password: document.getElementById('password').value,
period: document.getElementById('period').value,
unitTime: document.getElementById('selectUnitTime').options[index].value,
};
console.log(data);
if (index == 0){
}
$.post(serverAddress+'/saveConfig', data);
})
$('#buttonUpdate').bind('click', function () {
console.log('Save нажата')
$.post(serverAddress+'/update');
// window.location.reload();
})
$('#buttonAutoUpdate').bind('click', function () {
$.post(serverAddress+'/autoUpdate');
window.location.reload();
$('#buttonAutoUpdate').prop('disabled',true);
})
$('#buttonStop').bind('click', function () {
$.post(serverAddress+'/stop');
$('#buttonAutoUpdate').prop('disabled',false);
window.location.reload();
})
$.getJSON(serverAddress+'/getStatus', data => {
console.log(data)
var serviceStatus = document.getElementById("serviceStatus").value = data.serviceStatus;
})
function setCaretPosition (elem, caretPos) {
if (document.selection) { // ie
elem.focus ();
var range = document.selection.createRange ();
range.moveStart ('character', -elem.value.length);
range.moveStart ('character', caretPos);
range.moveEnd ('character', 0);
range.select ();
} else if (elem.selectionStart || elem.selectionStart == '0') { // Mozilla
elem.selectionStart = caretPos;
elem.selectionEnd = caretPos;
elem.focus ();
}
}
var setIntervalId = setInterval(updateLog,2000);
function updateLog(scroll = false){
$.getJSON(serverAddress+'/getLogfile', data => {
var str ='';
for (i in data.array){
str = str + data.array[i] + '\n';
}
var log = document.getElementById('log').value = str;
if (scroll){
document.getElementById("log").scrollTop=document.getElementById("log").scrollHeight;
}
})
$.getJSON(serverAddress+'/getLogfileRequest', data => {
var str ='';
for (i in data.array){
str = str + data.array[i] + '\n';
}
var log = document.getElementById('logRequest').value = str;
document.getElementById("logRequest").scrollTop=document.getElementById("logRequest").scrollHeight;
})
}
document.getElementById('logRequest').scrollTop =document.getElementById("logRequest").scrollHeight;
</script>
</div>
<div class='status_class'>
</div>
<!-- <div id="main">
<div id="primary">
<div id="content">
Тут содержимое контента
</div>
</div>
<div id="secondary">
Содержимое сайдбара
</div>
</div> -->
</body>
</html>