Mobile app speed up.
Ylian Saint-Hilaire committed
Feb 17, 2021 at 14:23 UTC
2c72c6b7c19aacfc33ee427611c101e0e5e9bd4d
1 file changed
+73
-64
views/default-mobile.handlebars
+73
-64
@@ -1794,8 +1794,7 @@
1794
//onSortSelectChange(true);
1795
//drawNotifications();
1796
refreshDevice(node._id);
1797
- //updateMapMarkers();
1798
- mainUpdate(4);
1797
+ updateDeviceViewDevice(node);
1798
if (currentNode == node) { updateDeviceDetails(); }
1799
1800
//if ((currentNode == node) && (xxdialogMode != null) && (xxdialogTag == '@xxmap')) { p10showNodeLocationDialog(); }
@@ -1853,9 +1852,8 @@
1852
// Clear sesssion information if needed
1853
if ((node.conn & 1) == 0) { delete node.sessions; }
1854
1856
- mainUpdate(4);
1855
refreshDevice(node._id);
1858
- //updateMapMarkers();
1856
+ updateDeviceViewDevice(node);
1857
}
1858
break;
1859
}
@@ -1893,7 +1891,7 @@
1891
}
1892
1893
refreshDevice(message.event.nodeid);
1896
- mainUpdate(4);
1894
+ updateDeviceViewDevice(node);
1895
//if ((currentNode != null) && (currentNode._id == message.event.nodeid)) { gotoDevice(currentNode._id, xxcurrentView, true); }
1896
1897
// If we are looking at the sessions dialog box for this device now, update it
@@ -2774,77 +2772,88 @@
2772
}
2773
2774
function onDevicesScrollEx() {
2775
+ var devdivs = document.getElementsByName('xxdevice');
2776
onDevicesScrollnagleTimer = null;
2778
- var visibleTop = Q('xdevices').scrollTop - 250, visibleBottom = Q('xdevices').scrollTop + Q('xdevices').clientHeight + 250, devdivs = document.getElementsByName('xxdevice');
2777
for (var i = 0; i < devdivs.length; i++) {
2780
- if ((devdivs[i].offsetTop >= visibleTop) && (devdivs[i].offsetTop < visibleBottom)) {
2781
- // Show
2782
- var node = getNodeFromId(devdivs[i].id)
2783
- if (node == null) break;
2784
-
2785
- var title = EscapeHtml(node.name);
2786
- if (title.length == 0) { title = '<i>' + "None" + '</i>'; }
2787
- if ((node.rname != null) && (node.rname.length > 0)) { title += ' / ' + EscapeHtml(node.rname); }
2788
- var name = EscapeHtml(node.name);
2789
- if (showRealNames == true && node.rname != null) name = EscapeHtml(node.rname);
2790
- if (name.length == 0) { name = '<i>' + "None" + '</i>'; }
2791
-
2792
- // Add device notification icons
2793
- var devNotify = '', devNotifySub = '';
2794
-
2795
- // This device is "starred"
2796
- if (stars[node._id] == 1) {
2797
- devNotifySub += '<img class=deviceNotifyDotSub src=images/icon-star-notify-16.png width=16 height=16>';
2778
+ // Show
2779
+ var node = getNodeFromId(devdivs[i].id)
2780
+ if (node == null) break;
2781
+ updateDeviceViewHtml(devdivs[i], node);
2782
+ }
2783
+ }
2784
+
2785
+ // Update a single device in the current view
2786
+ function updateDeviceViewDevice(node) {
2787
+ if (node == null) return;
2788
+ var devdiv = Q(node._id);
2789
+ if ((devdiv != null) && (devdiv.innerHTML != '')) { updateDeviceViewHtml(devdiv, node); } // Only update if the device is visible
2790
+ }
2791
+
2792
+ function updateDeviceViewHtml(div, node) {
2793
+ var visibleTop = Q('xdevices').scrollTop - 250, visibleBottom = Q('xdevices').scrollTop + Q('xdevices').clientHeight + 250;
2794
+ if ((div.offsetTop >= visibleTop) && (div.offsetTop < visibleBottom)) {
2795
+ var title = EscapeHtml(node.name);
2796
+ if (title.length == 0) { title = '<i>' + "None" + '</i>'; }
2797
+ if ((node.rname != null) && (node.rname.length > 0)) { title += ' / ' + EscapeHtml(node.rname); }
2798
+ var name = EscapeHtml(node.name);
2799
+ if (showRealNames == true && node.rname != null) name = EscapeHtml(node.rname);
2800
+ if (name.length == 0) { name = '<i>' + "None" + '</i>'; }
2801
+
2802
+ // Add device notification icons
2803
+ var devNotify = '', devNotifySub = '';
2804
+
2805
+ // This device is "starred"
2806
+ if (stars[node._id] == 1) {
2807
+ devNotifySub += '<img class=deviceNotifyDotSub src=images/icon-star-notify-16.png width=16 height=16>';
2808
+ }
2809
+
2810
+ // This device has session information
2811
+ if (node.sessions != null) {
2812
+ // Display any agent messages
2813
+ if (node.sessions.msg != null) {
2814
+ devNotifySub += '<div style="width:16;height:16" class=deviceNotifyDotSub>' + Object.keys(node.sessions.msg).length + '</div>';
2815
}
2816
2800
- // This device has session information
2801
- if (node.sessions != null) {
2802
- // Display any agent messages
2803
- if (node.sessions.msg != null) {
2804
- devNotifySub += '<div style="width:16;height:16" class=deviceNotifyDotSub>' + Object.keys(node.sessions.msg).length + '</div>';
2805
- }
2817
+ // Sessions are active
2818
+ if ((node.sessions.kvm != null) || (node.sessions.terminal != null) || (node.sessions.files != null) || (node.sessions.tcp != null) || (node.sessions.udp != null)) {
2819
+ devNotifySub += '<img class=deviceNotifyDotSub src=images/icon-relay-notify.png width=16 height=16>';
2820
+ }
2821
2807
- // Sessions are active
2808
- if ((node.sessions.kvm != null) || (node.sessions.terminal != null) || (node.sessions.files != null) || (node.sessions.tcp != null) || (node.sessions.udp != null)) {
2809
- devNotifySub += '<img class=deviceNotifyDotSub src=images/icon-relay-notify.png width=16 height=16>';
2810
- }
2822
+ // Help is required
2823
+ if (node.sessions.help != null) {
2824
+ devNotifySub += '<img class=deviceNotifyDotSub src=images/icon-help-notify-16.png width=16 height=16>';
2825
+ }
2826
2812
- // Help is required
2813
- if (node.sessions.help != null) {
2814
- devNotifySub += '<img class=deviceNotifyDotSub src=images/icon-help-notify-16.png width=16 height=16>';
2827
+ // Battery state
2828
+ if (node.sessions.battery != null) {
2829
+ var bat = node.sessions.battery;
2830
+ var statestr = '';
2831
+ if (bat.state == 'ac') { statestr = "Device is plugged-in"; }
2832
+ else if (bat.state == 'dc') { statestr = "Device is battery powered"; }
2833
+
2834
+ var levelstr = '', levelnum = -1;
2835
+ if ((typeof bat.level == 'number') && (bat.level >= 0) && (bat.level <= 100)) {
2836
+ levelstr = bat.level + '%';
2837
+ levelnum = (Math.floor((bat.level + 10) / 25) + 1);
2838
+ if (levelnum > 5) { lvl = 5; }
2839
+ if (bat.state == 'ac') { if (bat.level == 100) { levelnum = 11; } else { levelnum += 5; } }
2840
}
2841
2817
- // Battery state
2818
- if (node.sessions.battery != null) {
2819
- var bat = node.sessions.battery;
2820
- var statestr = '';
2821
- if (bat.state == 'ac') { statestr = "Device is plugged-in"; }
2822
- else if (bat.state == 'dc') { statestr = "Device is battery powered"; }
2823
-
2824
- var levelstr = '', levelnum = -1;
2825
- if ((typeof bat.level == 'number') && (bat.level >= 0) && (bat.level <= 100)) {
2826
- levelstr = bat.level + '%';
2827
- levelnum = (Math.floor((bat.level + 10) / 25) + 1);
2828
- if (levelnum > 5) { lvl = 5; }
2829
- if (bat.state == 'ac') { if (bat.level == 100) { levelnum = 11; } else { levelnum += 5; } }
2830
- }
2831
-
2832
- if (levelnum > 0) {
2833
- devNotify += '<div class="deviceBatterySmall deviceBatterySmall' + levelnum + '" title="' + ((statestr != null) ? (statestr + ', ' + levelstr) : levelstr) + '"></div>';
2834
- }
2842
+ if (levelnum > 0) {
2843
+ devNotify += '<div class="deviceBatterySmall deviceBatterySmall' + levelnum + '" title="' + ((statestr != null) ? (statestr + ', ' + levelstr) : levelstr) + '"></div>';
2844
}
2845
}
2846
+ }
2847
2838
- // Add any device icons
2839
- if (devNotifySub != '') { devNotify += '<div class=deviceNotifyDot>' + devNotifySub + '</div>'; }
2848
+ // Add any device icons
2849
+ if (devNotifySub != '') { devNotify += '<div class=deviceNotifyDot>' + devNotifySub + '</div>'; }
2850
2841
- // Node
2842
- var icon = node.icon, nodestate = NodeStateStr(node);
2843
- if ((!node.conn) || (node.conn == 0)) { icon += ' gray'; }
2844
- devdivs[i].innerHTML = '<div>' + devNotify + '<div class="i' + icon + ' devList2"></div><div class=devList3><div class=devList4><b>' + name + '</b></div><div class=devList5>' + nodestate + '</div></div></div>';
2845
- } else {
2846
- devdivs[i].innerHTML = ''; // Hide
2847
- }
2851
+ // Node
2852
+ var icon = node.icon, nodestate = NodeStateStr(node);
2853
+ if ((!node.conn) || (node.conn == 0)) { icon += ' gray'; }
2854
+ div.innerHTML = '<div>' + devNotify + '<div class="i' + icon + ' devList2"></div><div class=devList3><div class=devList4><b>' + name + '</b></div><div class=devList5>' + nodestate + '</div></div></div>';
2855
+ } else {
2856
+ div.innerHTML = ''; // Hide
2857
}
2858
}
2859