';
if ((view == 1) || (view == 2) || (view == 3)) {
var collapsed = CollapsedGroups['pwr:' + pwr];
@@ -3512,115 +3514,101 @@
}
count++;
- var title = EscapeHtml(node.name);
- if (title.length == 0) { title = '
' + "None" + ''; }
- if ((node.rname != null) && (node.rname.length > 0)) { title += ' / ' + EscapeHtml(node.rname); }
- var name = EscapeHtml(node.name);
- if (showRealNames == true && node.rname != null) name = EscapeHtml(node.rname);
- if (name.length == 0) { name = '
' + "None" + ''; }
-
- // Add device notification icons
- var devNotify = '', devNotifySub = '';
-
- // This device is "starred"
- if (stars[node._id] == 1) {
- if (view == 2) {
- devNotifySub += '
![](images/icon-star-notify-10.png)
';
- } else {
- devNotifySub += '
![](images/icon-star-notify-16.png)
';
- }
- }
-
- // This device has session information
- if (node.sessions != null) {
- // Display any agent messages
- if (node.sessions.msg != null) {
- if (view == 2) {
- devNotifySub += '
';
- } else {
- devNotifySub += '
' + Object.keys(node.sessions.msg).length + '
';
- }
- }
-
- // Sessions are active
- if ((node.sessions.kvm != null) || (node.sessions.terminal != null) || (node.sessions.files != null) || (node.sessions.tcp != null) || (node.sessions.udp != null)) {
- if (view == 2) {
- devNotifySub += '
![](images/icon-relay-notify10.png)
';
- } else {
- devNotifySub += '
![](images/icon-relay-notify.png)
';
- }
- }
-
- // Help is required
- if (node.sessions.help != null) {
- if (view == 2) {
- devNotifySub += '
![](images/icon-help-notify-10.png)
';
- } else {
- devNotifySub += '
![](images/icon-help-notify-16.png)
';
- }
- }
-
- // Battery state
- if ((node.sessions.battery != null) && (view == 1)) {
- var bat = node.sessions.battery;
- var statestr = '';
- if (bat.state == 'ac') { statestr = "Device is plugged-in"; }
- if (bat.state == 'dc') { statestr = "Device is battery powered"; }
-
- var levelstr = '', levelnum = -1;
- if ((typeof bat.level == 'number') && (bat.level >= 0) && (bat.level <= 100)) {
- levelstr = bat.level + '%';
- levelnum = (Math.floor((bat.level + 10) / 25) + 1);
- if (levelnum > 5) { lvl = 5; }
- if (bat.state == 'ac') { if (bat.level == 100) { levelnum = 11; } else { levelnum += 5; } }
- }
-
- if (levelnum > 0) {
- devNotify += '
';
- }
- }
- }
-
- // Add any device icons
- if (devNotifySub != '') {
- if (view == 2) {
- devNotify += '
' + devNotifySub + '
';
- } else {
- devNotify += '
' + devNotifySub + '
';
- }
- }
-
- // Node
- var icon = node.icon;
- if ((!node.conn) || (node.conn == 0)) { icon += ' gray'; }
if (view == 1) {
- r += '
' + name + '
' + NodeStateStr(node) + '
' + devNotify + '
';
+ // Draw the device standin
+ r += '
';
} else if (view == 2) {
- var states = [];
- if (node.conn) {
- if ((node.conn & 1) != 0) { states.push('
' + "Agent" + ''); }
- if ((node.conn & 2) != 0) { states.push('
' + "CIRA" + ''); }
- else if ((node.conn & 4) != 0) { states.push('
' + "AMT" + ''); }
- if ((node.conn & 8) != 0) { states.push('
' + "Relay" + ''); }
- if ((node.conn & 16) != 0) { states.push('
' + "MQTT" + ''); }
- }
-
+ // Draw the device standin
var collapseName = node.meshid;
if (sort == 1) { collapseName = ('pwr:' + (node.pwr?node.pwr:0)); }
else if ((sort == 3) || (sort == 4)) { collapseName = 'tag:**xx**xx*TaG*xx**xx**'; }
var collapsed = (sort != 3) & (sort != 4) & CollapsedGroups[collapseName];
- r += '
';
- r += ' ';
- r += ' ';
- r += ' ';
- r += ' ' + name + ' ' + devNotify + ' | ';
- r += '' + getUserShortStr(node);
- r += ' | ' + (node.ip != null ? node.ip : '');
- r += ' | ' + states.join(' + ');
- //r += ' | ' + (node.pwr != null ? powerStateStrings[node.pwr] : '');
- r += ' |
';
+ r += '
|
';
} else if ((view == 3) && (node.conn & 1) && (((meshrights & 8) || (meshrights & 256)) != 0) && ((node.agent.caps & 1) != 0)) { // Check if we have rights and agent is capable of KVM.
if ((multiDesktopFilter) && ((multiDesktopFilter.length == 0) || (multiDesktopFilter.indexOf('devid_' + node._id) >= 0))) {
+ var title = EscapeHtml(node.name);
+ if (title.length == 0) { title = '
' + "None" + ''; }
+ if ((node.rname != null) && (node.rname.length > 0)) { title += ' / ' + EscapeHtml(node.rname); }
+ var name = EscapeHtml(node.name);
+ if (showRealNames == true && node.rname != null) name = EscapeHtml(node.rname);
+ if (name.length == 0) { name = '
' + "None" + ''; }
+
+ // Add device notification icons
+ var devNotify = '', devNotifySub = '';
+
+ // This device is "starred"
+ if (stars[node._id] == 1) {
+ if (view == 2) {
+ devNotifySub += '
![](images/icon-star-notify-10.png)
';
+ } else {
+ devNotifySub += '
![](images/icon-star-notify-16.png)
';
+ }
+ }
+
+ // This device has session information
+ if (node.sessions != null) {
+ // Display any agent messages
+ if (node.sessions.msg != null) {
+ if (view == 2) {
+ devNotifySub += '
';
+ } else {
+ devNotifySub += '
' + Object.keys(node.sessions.msg).length + '
';
+ }
+ }
+
+ // Sessions are active
+ if ((node.sessions.kvm != null) || (node.sessions.terminal != null) || (node.sessions.files != null) || (node.sessions.tcp != null) || (node.sessions.udp != null)) {
+ if (view == 2) {
+ devNotifySub += '
![](images/icon-relay-notify10.png)
';
+ } else {
+ devNotifySub += '
![](images/icon-relay-notify.png)
';
+ }
+ }
+
+ // Help is required
+ if (node.sessions.help != null) {
+ if (view == 2) {
+ devNotifySub += '
![](images/icon-help-notify-10.png)
';
+ } else {
+ devNotifySub += '
![](images/icon-help-notify-16.png)
';
+ }
+ }
+
+ // Battery state
+ if ((node.sessions.battery != null) && (view == 1)) {
+ var bat = node.sessions.battery;
+ var statestr = '';
+ if (bat.state == 'ac') { statestr = "Device is plugged-in"; }
+ if (bat.state == 'dc') { statestr = "Device is battery powered"; }
+
+ var levelstr = '', levelnum = -1;
+ if ((typeof bat.level == 'number') && (bat.level >= 0) && (bat.level <= 100)) {
+ levelstr = bat.level + '%';
+ levelnum = (Math.floor((bat.level + 10) / 25) + 1);
+ if (levelnum > 5) { lvl = 5; }
+ if (bat.state == 'ac') { if (bat.level == 100) { levelnum = 11; } else { levelnum += 5; } }
+ }
+
+ if (levelnum > 0) {
+ devNotify += '
';
+ }
+ }
+ }
+
+ // Add any device icons
+ if (devNotifySub != '') {
+ if (view == 2) {
+ devNotify += '
' + devNotifySub + '
';
+ } else {
+ devNotify += '
' + devNotifySub + '
';
+ }
+ }
+
+ // Node
+ var icon = node.icon;
+ if ((!node.conn) || (node.conn == 0)) { icon += ' gray'; }
+
+ // Draw the device and canvas
r += '
' + devNotify;
//r += '
';
r += '
' + name + '
';
@@ -3829,6 +3817,161 @@
}
}
oldviewmode = view;
+ onDevicesScrollEx();
+ }
+
+
+ var onDevicesTouchActive = false;
+ var onDevicesScrollnagleTimer = null;
+ function onDevicesScroll() {
+ if ((onDevicesScrollnagleTimer != null) || (onDevicesTouchActive)) return;
+ onDevicesScrollnagleTimer = setTimeout(onDevicesScrollEx, 250);
+ }
+
+ function onDeviceTouch(x) {
+ if (onDevicesTouchActive == x) return;
+ onDevicesTouchActive = x;
+ if (x == false) onDevicesScrollEx();
+ }
+
+ function onDevicesScrollEx() {
+ onDevicesScrollnagleTimer = null;
+ var visibleTop = Q('xdevices').scrollTop - 200, visibleBottom = Q('xdevices').scrollTop + Q('xdevices').clientHeight + 200;
+ var view = Q('viewselect').value, devdivs = document.getElementsByName('xxdevice' + view);
+ for (var i = 0; i < devdivs.length; i++) {
+ if ((devdivs[i].offsetTop >= visibleTop) && (devdivs[i].offsetTop < visibleBottom)) {
+ var node = getNodeFromId(devdivs[i].id.substring(3));
+ if (node != null) { updateDeviceViewHtml(view, devdivs[i], node); } else { devdivs[i].innerHTML = ''; }
+ } else {
+ devdivs[i].innerHTML = '';
+ }
+ }
+ }
+
+ // Update a single device in the current view
+ function updateDeviceViewDevice(node) {
+ var view = Q('viewselect').value;
+ if ((view != 1) && (view != 2)) { mainUpdate(4); return; }
+ if (typeof node == 'string') { node = getNodeFromId(node); }
+ if (node == null) return;
+ var devdiv = Q('xv' + view + node._id);
+ if (devdiv.innerHTML != '') { updateDeviceViewHtml(view, devdiv, node); } // Only update if the device is visible
+ }
+
+ function updateDeviceViewHtml(view, div, node) {
+ var deviceBoxWidth = div.clientWidth;
+
+ var title = EscapeHtml(node.name);
+ if (title.length == 0) { title = '
' + "None" + ''; }
+ if ((node.rname != null) && (node.rname.length > 0)) { title += ' / ' + EscapeHtml(node.rname); }
+ var name = EscapeHtml(node.name);
+ if (showRealNames == true && node.rname != null) name = EscapeHtml(node.rname);
+ if (name.length == 0) { name = '
' + "None" + ''; }
+
+ // Add device notification icons
+ var devNotify = '', devNotifySub = '';
+
+ // This device is "starred"
+ if (stars[node._id] == 1) {
+ if (view == 2) {
+ devNotifySub += '
![](images/icon-star-notify-10.png)
';
+ } else {
+ devNotifySub += '
![](images/icon-star-notify-16.png)
';
+ }
+ }
+
+ // This device has session information
+ if (node.sessions != null) {
+ // Display any agent messages
+ if (node.sessions.msg != null) {
+ if (view == 2) {
+ devNotifySub += '
';
+ } else {
+ devNotifySub += '
' + Object.keys(node.sessions.msg).length + '
';
+ }
+ }
+
+ // Sessions are active
+ if ((node.sessions.kvm != null) || (node.sessions.terminal != null) || (node.sessions.files != null) || (node.sessions.tcp != null) || (node.sessions.udp != null)) {
+ if (view == 2) {
+ devNotifySub += '
![](images/icon-relay-notify10.png)
';
+ } else {
+ devNotifySub += '
![](images/icon-relay-notify.png)
';
+ }
+ }
+
+ // Help is required
+ if (node.sessions.help != null) {
+ if (view == 2) {
+ devNotifySub += '
![](images/icon-help-notify-10.png)
';
+ } else {
+ devNotifySub += '
![](images/icon-help-notify-16.png)
';
+ }
+ }
+
+ // Battery state
+ if ((node.sessions.battery != null) && (view == 1)) {
+ var bat = node.sessions.battery;
+ var statestr = '';
+ if (bat.state == 'ac') { statestr = "Device is plugged-in"; }
+ if (bat.state == 'dc') { statestr = "Device is battery powered"; }
+
+ var levelstr = '', levelnum = -1;
+ if ((typeof bat.level == 'number') && (bat.level >= 0) && (bat.level <= 100)) {
+ levelstr = bat.level + '%';
+ levelnum = (Math.floor((bat.level + 10) / 25) + 1);
+ if (levelnum > 5) { lvl = 5; }
+ if (bat.state == 'ac') { if (bat.level == 100) { levelnum = 11; } else { levelnum += 5; } }
+ }
+
+ if (levelnum > 0) {
+ devNotify += '
';
+ }
+ }
+ }
+
+ // Add any device icons
+ if (devNotifySub != '') {
+ if (view == 2) {
+ devNotify += '
' + devNotifySub + '
';
+ } else {
+ devNotify += '
' + devNotifySub + '
';
+ }
+ }
+
+ // Node
+ var icon = node.icon;
+ if ((!node.conn) || (node.conn == 0)) { icon += ' gray'; }
+
+ if (view == 1) {
+ div.innerHTML = '
' + name + '
' + NodeStateStr(node) + '
' + devNotify + '
';
+ } else {
+ var states = [];
+ if (node.conn) {
+ if ((node.conn & 1) != 0) { states.push('
' + "Agent" + ''); }
+ if ((node.conn & 2) != 0) { states.push('
' + "CIRA" + ''); }
+ else if ((node.conn & 4) != 0) { states.push('
' + "AMT" + ''); }
+ if ((node.conn & 8) != 0) { states.push('
' + "Relay" + ''); }
+ if ((node.conn & 16) != 0) { states.push('
' + "MQTT" + ''); }
+ }
+
+ var collapseName = node.meshid;
+ if (sort == 1) { collapseName = ('pwr:' + (node.pwr?node.pwr:0)); }
+ else if ((sort == 3) || (sort == 4)) { collapseName = 'tag:**xx**xx*TaG*xx**xx**'; }
+ var collapsed = (sort != 3) & (sort != 4) & CollapsedGroups[collapseName];
+ //r += '
';
+ var r = ' ';
+ r += ' ';
+ r += ' ';
+ r += ' ';
+ r += ' ' + name + ' ' + devNotify + ' | ';
+ r += ' ' + getUserShortStr(node);
+ r += ' | ' + (node.ip != null ? node.ip : '');
+ r += ' | ' + states.join(' + ');
+ //r += ' | ' + (node.pwr != null ? powerStateStrings[node.pwr] : '');
+ //r += ' | |
';
+ div.innerHTML = r;
+ }
}
// Show device help requests
@@ -3904,9 +4047,11 @@
var x;
if (type == 2) {
// Table rows collapse
- var rows = document.getElementsByName('DevxCol' + id2);
- if (rows.length == 0) return;
- x = (rows[0].style['display'] == 'none');
+ var xrows = document.getElementsByName('xxdevice2');
+ if (xrows.length == 0) return;
+ var rows = [];
+ for (var i = 0; i < xrows.length; i++) { if (xrows[i].attributes.colname.value.substring(7) == id2) { rows.push(xrows[i]); } }
+ var x = (rows[0].style['display'] == 'none');
if (x) { delete CollapsedGroups[id2]; } else { CollapsedGroups[id2] = true; }
for (var i = 0; i < rows.length; i++) { rows[i].style['display'] = (x ? '' : 'none'); }
} else {
@@ -4847,7 +4992,8 @@
var starcount = Object.keys(stars).length;
for (var i in selectedDevices) { if ((starcount < 20) && (stars[selectedDevices[i]] == null)) { stars[selectedDevices[i]] = 1; starcount++; } }
putstore('stars', JSON.stringify(stars));
- if (Q('DevFilterSelect').value == 3) { mainUpdate(5); } else { mainUpdate(4); }
+ updateDeviceViewDevice(nodeid);
+ if (Q('DevFilterSelect').value == 3) { mainUpdate(1); }
}
}