This repository has been archived by the owner on Feb 7, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdialog_session_filter.html
339 lines (278 loc) · 11.8 KB
/
dialog_session_filter.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
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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Event filter settings</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="./node_modules/@primer/octicons/build/build.css">
<link rel="stylesheet" href="./node_modules/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="./node_modules/animate.css/animate.min.css">
<style>
table.scroll {
width: 100%;
border-collapse: collapse;
border-spacing: 0;
border: 1px solid black;
}
table.scroll tbody,
table.scroll thead {
display: block;
width: 100%;
}
thead tr th {
height: 25px;
line-height: 15px;
text-align: left;
vertical-align: top;
}
table.scroll tbody.allow {
height: 30vh;
background-color: rgb(215, 248, 177);
overflow-y: auto;
overflow-x: hidden;
}
table.scroll tbody.filter {
height: 30vh;
background-color: rgb(241, 185, 185);
overflow-y: auto;
overflow-x: hidden;
}
table.scroll td.ctext,
table.scroll th.ctext {
text-align: center;
vertical-align: middle;
}
tbody {
border-top: 1px solid black;
}
tbody td,
thead th {
overflow: hidden;
height: 22px;
line-height: 15px;
border-right: 1px solid black;
white-space: nowrap;
}
tbody td:last-child,
thead th:last-child {
border-right: none;
}
body {
margin-right: 10px;
}
</style>
</head>
<body class="bg-light" style="padding-top: 20px;">
<div class="container-fluid">
<div class="row">
<div class="col-10">
<table id="tableAllow"
class="table scroll table-sm table-responsive table-hover table-striped"
id="table-allow">
<thead class="thead-light">
<tr class="d-flex">
<th class="col-12 ctext">Event(s) that should be displayed</th>
</tr>
</thead>
<tbody class="allow">
<tr class="d-flex clickable-row" style="cursor: pointer">
<td class="col-6"><strong>class1.measurement</strong>
<span class="text-monospace" style="color:darkgreen;">(0x000a 10)</span></td>
<td class="col-6"><strong>Temperature</strong>
<span class="text-monospace" style="color:darkgreen;">(0x0006 6)</span></td>
</tr>
<tr class="d-flex clickable-row" style="cursor: pointer">
<td class="col-6"><strong>class1.control</strong>
<span class="text-monospace" style="color:darkgreen;">(0x001e 30)</span></td>
<td class="col-6"><strong>All types</strong></td>
</tr>
</tbody>
</table>
</div>
<div class="col-2">
<button id="btnAddAllowEvent" type="button" class="btn btn-sm btn-warning rounded">
<strong>Add allowed event</strong></button>
</div>
</div>
<div class="row ctext">
<div class="col-12">
</div>
</div>
<div class="row">
<div class="col-10">
<table id="tableFilter"
class="table scroll table-sm table-responsive table-hover table-striped"
id="table-filter">
<thead class="thead-light">
<tr class="d-flex">
<th class="col-12 ctext">Event(s) that should NOT be displayed</th>
</tr>
</thead>
<tbody class="filter">
<tr class="d-flex clickable-row" style="cursor: pointer">
<td class="col-6"><strong>class1.measurement</strong>
<span class="text-monospace" style="color:darkgreen;">(0x000a 10)</span></td>
<td class="col-6"><strong>Temperature</strong>
<span class="text-monospace" style="color:darkgreen;">(0x0006 6)</span></td>
</tr>
<tr class="d-flex clickable-row" style="cursor: pointer">
<td class="col-6"><strong>class1.control</strong>
<span class="text-monospace" style="color:darkgreen;">(0x001e 30)</span></td>
<td class="col-6"><strong>All types</strong></td>
</tr>
<!-- <tr class="clickable-row" style="cursor: pointer">
<td>CAN4VSCP</td>
<td>00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00</td>
<td>Type=2 CANAL DRIVER</td>
</tr>
<tr class="clickable-row" style="cursor: pointer">
<td>Ethernet</td>
<td>00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00</td>
<td>Type=2, Level II driver</td>
</tr>
<tr class="clickable-row" style="cursor: pointer">
<td>Dooley</td>
<td>00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00</td>
<td>Type</td>
</tr> -->
</tbody>
</table>
</div>
<div class="col-2">
<button id="btnAddFilterEvent" type="button" class="btn btn-sm btn-warning rounded">
<strong>Add NOT allowed event</strong></button>
</div>
</div>
<div class="row">
<div class="col-12 ctext">
<button id="btnLoad" type="button" class="btn btn-sm btn-warning rounded">
<strong>Load</strong></button>
<button id="btnSave" type="button" class="btn btn-sm btn-warning rounded">
<strong>Save</strong></button>
</div>
</div>
<div class="row">
<div class="col-sm-12 text-center">
<div>
<hr />
</div>
<div class="row">
<div class="col-sm-12" text-center">
<button id="btnCancel" class="btn-sm btn-default">Cancel</button>
<button id="btnSubmit" type="submit" class="btn-sm btn-default">OK</button>
</div>
</div>
</div>
</div>
</div>
<!-- Bootstrap Optional JavaScript -->
<!-- jQuery first, then popper.js, then Bootstrap JS -->
<script>let $ = jQuery = require('./node_modules/jquery/dist/jquery.min.js');</script>
<script>require('./node_modules/@popperjs/core/dist/cjs/popper.js');</script>
<script>require('./node_modules/bootstrap/dist/js/bootstrap.min.js');</script>
</body>
<script>
const { remote, ipcRenderer } = require('electron');
const { app, dialog } = remote;
const sprintf = require('sprintf-js').sprintf;
const win = remote.getCurrentWindow();
const vscp = require('node-vscp'); // TODO: use module
const vscp_tcp_Client = require('./src/vscptcp'); // TODO: use module
let guid = '';
let testProgress = '';
let vscpif = [];
///////////////////////////////////////////////////////////////////////////
// addFilterRow
//
var addInterfaceRow = function (vscpclass, vscptype) {
// Ask for symbolic names
let vscpclasstxt = '';
let vscptypetxt = '';
let tbl = document.getElementById("tableFilter");
let tableRef = tbl.getElementsByTagName('tbody')[0];
let row = tableRef.insertRow(-1);
row.classList.add("clickable-row");
row.classList.add("d-flex");
row.style.cursor = "pointer";
// VSCP Class
let cellClass = row.insertCell(0);
cellClass.innerHTML = '<strong>' + vscpclasstxt +
'</strong> <span class="text-monospace" style="color:darkgreen;">'+
sprintf('(0x%04x %d)', vscpclass, vscpclass ) + '</span>';
cellClass.classList.add("col-6");
// VSCP Type
let cellType = row.insertCell(0);
cellType.innerHTML = '<strong>' + vscptypetxt +
'</strong> <span class="text-monospace" style="color:darkgreen;">'+
sprintf('(0x%04x %d)', vscptype, vscptype ) + '</span>';
cellType.classList.add("col-6");
}
///////////////////////////////////////////////////////////////////////////
// Document ready
//
$(document).ready(function ($) {
var options = ipcRenderer.sendSync("dialog-open", "");
var params = JSON.parse(options);
console.log(params);
$("#hostname").html("<kbd>Host:</kbd> " + params.host);
///////////////////////////////////////////////////////////////////////////
// Cancel
//
$("#btnCancel").on('click', function (e) {
ipcRenderer.send("dialog-close", '');
remote.getCurrentWindow().close();
});
///////////////////////////////////////////////////////////////////////////
// Save selected interface
//
$("#btnSubmit").on('click', function (e) {
//e.preventDefault();
console.log('submit')
ipcRenderer.send("dialog-close", guid);
remote.getCurrentWindow().close();
});
// Select table row
$('#interface-table-id').on('click', '.clickable-row', function (event) {
$(this).addClass('bg-info').siblings().removeClass('bg-info');
guid = event.currentTarget.cells[1].innerHTML;
});
// double click table row
$('#interface-table-id').on('dblclick', '.clickable-row', function (event) {
guid = event.currentTarget.cells[1].innerHTML;
$(this).addClass('bg-info').siblings().removeClass('bg-info');
ipcRenderer.send("dialog-close", guid);
remote.getCurrentWindow().close();
});
///////////////////////////////////////////////////////////////////////////////
// getInterfaces
//
getInterfaces({
host: params.host,
username: params.username,
password: params.password
})
.then(res => {
console.log(vscpif);
vscpif.forEach((item) => {
addInterfaceRow(item.name, item.guid, item.type);
});
})
.catch(err => {
let options = {
type: 'error',
buttons: ['OK'],
title: 'Interface failure',
message: 'Failed to get interfaces from remote host/device',
detail: 'Error: ' + err.message + ' \n' + testProgress
}
dialog.showMessageBox(remote.getCurrentWindow(), options);
console.log("Failed to get interfaces");
console.log(err);
$(this).removeClass('active').addClass('connerr ');
$("#errorHost").addClass("d-block");
$("#errorHost").html(err.message);
});
});
</script>
</html>