bootstrap: fix edit node and duplicate lastbootuptime
Signed-off-by: si458 <simonsmith5521@gmail.com>
si458 committed
Nov 10, 2024 at 20:23 UTC
9a8f4e8ebe2932dd8e26f024ab788f572e98ba50
2 files changed
+49
-50
public/styles/style-bootstrap.css
-4
@@ -1305,10 +1305,6 @@ NoMeshesPanel img {
1305
font-size: small;
1306
}
1307
1308
-#dp10devicevalue {
1309
- width: 230px;
1310
-}
1311
-
1308
.fulldesk #p11 {
1309
height: 100%;
1310
}
views/default3.handlebars
+49
-46
@@ -10036,12 +10036,11 @@
10036
var showEditNodeValueDialog_modes4 = [64, 64, 64, 4096];
10037
function showEditNodeValueDialog(mode) {
10038
if (xxdialogMode) return;
10039
- var x = '<select id=dp10devicevalue multiple class="form-control" maxlength=' + showEditNodeValueDialog_modes4[mode] + ' class=form-control>';
10039
+ var x = '';
10040
var y = '';
10041
- var v = currentNode[showEditNodeValueDialog_modes2[mode]];
10042
- if (v == null) v = '';
10041
if (mode == 3) {
10042
// Get a list of all possible device tags
10043
+ x = '<select id=dp10devicevalue multiple class="form-control" maxlength=' + showEditNodeValueDialog_modes4[mode] + ' class=form-control>';
10044
var allTags = [];
10045
for (var i in nodes) { if (nodes[i].tags) { for (var j in nodes[i].tags) { if (allTags.indexOf(nodes[i].tags[j]) == -1) { allTags.push(nodes[i].tags[j]); } } } }
10046
if (allTags.length > 0) {
@@ -10051,18 +10050,29 @@
10050
y += Array.isArray(v) && v.indexOf(allTags[i]) !== -1 ? '<option selected=selected>' + EscapeHtml(allTags[i]) + '</option>' : '<option>' + EscapeHtml(allTags[i]) + '</option>';
10051
}
10052
}
10053
+ x += y + '</select>'
10054
+ setModalContent('xxAddAgent', "Edit Tags", x);
10055
+ $('#dp10devicevalue').select2({
10056
+ theme: "bootstrap-5",
10057
+ width: $( this ).data( 'width' ) ? $( this ).data( 'width' ) : $( this ).hasClass( 'w-100' ) ? '100%' : 'style',
10058
+ placeholder: showEditNodeValueDialog_modes3[mode],
10059
+ closeOnSelect: false,
10060
+ allowClear: true,
10061
+ tokenSeparators: [','],
10062
+ tags: true
10063
+ });
10064
+ } else {
10065
+ x = addHtmlFormFloating(showEditNodeValueDialog_modes[mode], '<input id=dp10devicevalue class="form-control" maxlength=' + showEditNodeValueDialog_modes4[mode] + ' placeholder="' + showEditNodeValueDialog_modes3[mode] + '" onchange=p10editdevicevalueValidate(' + mode + ',event) onkeyup=p10editdevicevalueValidate(' + mode + ',event) class=form-control/>');
10066
+ setModalContent('xxAddAgent', 'Edit Device', x);
10067
+ showModal('xxAddAgentModal', 'idx_dlgOkButton', function () {
10068
+ showEditNodeValueDialogEx(3, mode);
10069
+ });
10070
}
10055
- x += y + '</select>'
10056
- setModalContent('xxAddAgent', "Edit Tags", x);
10057
- $('#dp10devicevalue').select2({
10058
- theme: "bootstrap-5",
10059
- width: $( this ).data( 'width' ) ? $( this ).data( 'width' ) : $( this ).hasClass( 'w-100' ) ? '100%' : 'style',
10060
- placeholder: showEditNodeValueDialog_modes3[mode],
10061
- closeOnSelect: false,
10062
- allowClear: true,
10063
- tokenSeparators: [','],
10064
- tags: true
10065
- });
10071
+ var v = currentNode[showEditNodeValueDialog_modes2[mode]];
10072
+ if (v == null) v = '';
10073
+ if (Array.isArray(v)) { v = v.join(', '); }
10074
+ Q('dp10devicevalue').value = v;
10075
+ p10editdevicevalueValidate();
10076
showModal('xxAddAgentModal', 'idx_dlgOkButton', function () { showEditNodeValueDialogEx(3, mode); });
10077
Q('dp10devicevalue').focus();
10078
}
@@ -10077,10 +10087,15 @@
10087
}
10088
10089
function showEditNodeValueDialogEx(button, mode) {
10080
- var tt = $('#dp10devicevalue').select2('data'), tags = "";
10081
- for (var i in tt) { tags += tt[i]['text'].trim() + ', '; }
10090
+ var tags = '';
10091
var x = { action: 'changedevice', nodeid: currentNode._id };
10083
- x[showEditNodeValueDialog_modes2[mode]] = decodeURIComponent(tags.slice(0,-2));
10092
+ if (mode == 3) {
10093
+ var tt = $('#dp10devicevalue').select2('data');
10094
+ for (var i in tt) { tags += tt[i]['text'].trim() + ', '; }
10095
+ x[showEditNodeValueDialog_modes2[mode]] = decodeURIComponent(tags.slice(0,-2));
10096
+ } else {
10097
+ x[showEditNodeValueDialog_modes2[mode]] = Q('dp10devicevalue').value;
10098
+ }
10099
meshserver.send(x);
10100
}
10101
@@ -13152,35 +13167,23 @@
13167
var x = '';
13168
if (node.rname) { x += addDetailItem("Name", EscapeHtml(node.rname), s); }
13169
if (node.osdesc) { x += addDetailItem("Version", EscapeHtml(node.osdesc), s); }
13155
- if ((hardware.windows && hardware.windows.osinfo) || node.osdesc) {
13156
- if (hardware.windows && hardware.windows.osinfo) {
13157
- var m = hardware.windows.osinfo;
13158
- if (m.OSArchitecture) {
13159
- if (m.OSArchitecture.startsWith('32')) { x += addDetailItem("Architecture", "32-bit", s); }
13160
- else if (m.OSArchitecture.startsWith('64')) { x += addDetailItem("Architecture", "64-bit", s); }
13161
- else { x += addDetailItem("Architecture", EscapeHtml(m.OSArchitecture), s); }
13162
- }
13163
- if (m.LastBootUpTime) {
13164
- var thedate = {
13165
- year: parseInt(m.LastBootUpTime.substring(0, 4)),
13166
- month: parseInt(m.LastBootUpTime.substring(4, 6)) - 1, // Months are 0-based in JavaScript (0 - January, 11 - December)
13167
- day: parseInt(m.LastBootUpTime.substring(6, 8)),
13168
- hours: parseInt(m.LastBootUpTime.substring(8, 10)),
13169
- minutes: parseInt(m.LastBootUpTime.substring(10, 12)),
13170
- seconds: parseInt(m.LastBootUpTime.substring(12, 14)),
13171
- };
13172
- const date = printDateTime(new Date(thedate.year, thedate.month, thedate.day, thedate.hours, thedate.minutes, thedate.seconds));
13173
- x += addDetailItem("Last Boot Up Time", date);
13174
- }
13175
- }
13176
- if (hardware.linux && hardware.linux.LastBootUpTime) {
13177
- var lastBootUpTime = new Date(hardware.linux.LastBootUpTime);
13178
- const date = printDateTime(lastBootUpTime);
13179
- x += addDetailItem("Last Boot Up Time", date);
13180
- }
13181
- if (hardware.darwin && hardware.darwin.LastBootUpTime) {
13182
- var lastBootUpTime = new Date(hardware.darwin.LastBootUpTime * 1000); // must times by 1000 even tho timestamp is correct?
13183
- const date = printDateTime(lastBootUpTime);
13170
+ if (hardware.windows && hardware.windows.osinfo) {
13171
+ var m = hardware.windows.osinfo;
13172
+ if (m.OSArchitecture) {
13173
+ if (m.OSArchitecture.startsWith('32')) { x += addDetailItem("Architecture", "32-bit", s); }
13174
+ else if (m.OSArchitecture.startsWith('64')) { x += addDetailItem("Architecture", "64-bit", s); }
13175
+ else { x += addDetailItem("Architecture", EscapeHtml(m.OSArchitecture), s); }
13176
+ }
13177
+ if (m.LastBootUpTime) {
13178
+ var thedate = {
13179
+ year: parseInt(m.LastBootUpTime.substring(0, 4)),
13180
+ month: parseInt(m.LastBootUpTime.substring(4, 6)) - 1, // Months are 0-based in JavaScript (0 - January, 11 - December)
13181
+ day: parseInt(m.LastBootUpTime.substring(6, 8)),
13182
+ hours: parseInt(m.LastBootUpTime.substring(8, 10)),
13183
+ minutes: parseInt(m.LastBootUpTime.substring(10, 12)),
13184
+ seconds: parseInt(m.LastBootUpTime.substring(12, 14)),
13185
+ };
13186
+ const date = printDateTime(new Date(thedate.year, thedate.month, thedate.day, thedate.hours, thedate.minutes, thedate.seconds));
13187
x += addDetailItem("Last Boot Up Time", date);
13188
}
13189
}