From 65ce52a28e217bd9c0a564813ecd55caee54f30c Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Thu, 20 Aug 2020 11:43:01 -0700 Subject: [PATCH] Boosted mobile app rendering speed when 1000's of devices. --- public/scripts/amt-wsman-0.2.0-min.js | 2 +- translate/translate.json | 20 ++--- views/default-mobile.handlebars | 120 ++++++++++++++------------ 3 files changed, 75 insertions(+), 67 deletions(-) diff --git a/public/scripts/amt-wsman-0.2.0-min.js b/public/scripts/amt-wsman-0.2.0-min.js index 293387e7..389c6296 100644 --- a/public/scripts/amt-wsman-0.2.0-min.js +++ b/public/scripts/amt-wsman-0.2.0-min.js @@ -1 +1 @@ -var WsmanStackCreateService=function(e,s,r,a,o,t){var p={};function l(e){if(!e)return"";var s=" ";for(var r in e)e.hasOwnProperty(r)&&0===r.indexOf("@")&&(s+=r.substring(1)+'="'+e[r]+'" ');return s}function w(e){if(!e)return"";if("string"==typeof e)return e;if(e.InstanceID)return''+e.InstanceID+"";var s="";for(var r in e)if(e.hasOwnProperty(r)){if(s+='',e[r].ReferenceParameters){s+="",s+=""+e[r].Address+""+e[r].ReferenceParameters.ResourceURI+"";var a=e[r].ReferenceParameters.SelectorSet.Selector;if(Array.isArray(a))for(var o=0;o"+a[o].Value+"";else s+=""+a.Value+"";s+=""}else s+=e[r];s+=""}return s+=""}return p.NextMessageId=1,p.Address="/wsman",p.comm=CreateWsmanComm(e,s,r,a,o,t),p.PerformAjax=function(e,o,s,r,a){null==a&&(a=""),p.comm.PerformAjax('
"+e,function(e,s,r){if(200==s){var a=p.ParseWsman(e);a&&null!=a?o(p,a.Header.ResourceURI,a,200,r):o(p,null,{Header:{HttpError:s}},601,r)}else o(p,null,{Header:{HttpError:s}},s,r)},s,r)},p.CancelAllQueries=function(e){p.comm.CancelAllQueries(e)},p.GetNameFromUrl=function(e){var s=e.lastIndexOf("/");return-1==s?e:e.substring(s+1)},p.ExecSubscribe=function(e,s,r,a,o,t,n,l,d,c){var m="",i="";null!=d&&null!=c&&(m="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#UsernameToken"+d+''+c+"",i=''),l=null!=l&&null!=l?""+l+"":"";var u="http://schemas.xmlsoap.org/ws/2004/08/eventing/Subscribe"+p.Address+""+e+""+p.NextMessageId+++"http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous"+w(n)+m+'
'+r+""+i+"PT0.000000S";p.PerformAjax(u+"
",a,o,t,'xmlns:e="http://schemas.xmlsoap.org/ws/2004/08/eventing" xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust" xmlns:se="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:m="http://x.com"')},p.ExecUnSubscribe=function(e,s,r,a,o){var t="http://schemas.xmlsoap.org/ws/2004/08/eventing/Unsubscribe"+p.Address+""+e+""+p.NextMessageId+++"http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous"+w(o)+"";p.PerformAjax(t+"",s,r,a,'xmlns:e="http://schemas.xmlsoap.org/ws/2004/08/eventing"')},p.ExecPut=function(e,s,r,a,o,t){var n="http://schemas.xmlsoap.org/ws/2004/09/transfer/Put"+p.Address+""+e+""+p.NextMessageId+++"http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymousPT60.000S"+w(t)+""+function(e,s){if(!e||null==s)return"";var r=p.GetNameFromUrl(e),a="';for(var o in s)if(s.hasOwnProperty(o)&&0!==o.indexOf("__")&&0!==o.indexOf("@")&&void 0!==s[o]&&null!==s[o]&&"function"!=typeof s[o])if("object"==typeof s[o]&&s[o].ReferenceParameters){a+=""+s[o].Address+""+s[o].ReferenceParameters.ResourceURI+"";var t=s[o].ReferenceParameters.SelectorSet.Selector;if(Array.isArray(t))for(var n=0;n"+t[n].Value+"";else a+=""+t.Value+"";a+=""}else if(Array.isArray(s[o]))for(n=0;n"+s[o][n].toString()+"";else a+=""+s[o].toString()+"";return a+=""}(e,s);p.PerformAjax(n+"",r,a,o)},p.ExecCreate=function(e,s,r,a,o,t){var n=p.GetNameFromUrl(e),l="http://schemas.xmlsoap.org/ws/2004/09/transfer/Create"+p.Address+""+e+""+p.NextMessageId+++"http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymousPT60S"+w(t)+"';for(var d in s)l+=""+s[d]+"";p.PerformAjax(l+"",r,a,o)},p.ExecCreateXml=function(e,s,r,a,o){var t=p.GetNameFromUrl(e);p.PerformAjax("http://schemas.xmlsoap.org/ws/2004/09/transfer/Create"+p.Address+""+e+""+p.NextMessageId+++"http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymousPT60.000S'+s+"",r,a,o)},p.ExecDelete=function(e,s,r,a,o){var t="http://schemas.xmlsoap.org/ws/2004/09/transfer/Delete"+p.Address+""+e+""+p.NextMessageId+++"http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymousPT60S"+w(s)+"";p.PerformAjax(t,r,a,o)},p.ExecGet=function(e,s,r,a){p.PerformAjax("http://schemas.xmlsoap.org/ws/2004/09/transfer/Get"+p.Address+""+e+""+p.NextMessageId+++"http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymousPT60S",s,r,a)},p.ExecMethod=function(e,s,r,a,o,t,n){var l="";for(var d in r)if(null!=r[d])if(Array.isArray(r[d]))for(var c in r[d])l+=""+r[d][c]+"";else l+=""+r[d]+"";p.ExecMethodXml(e,s,l,a,o,t,n)},p.ExecMethodXml=function(e,s,r,a,o,t,n){p.PerformAjax(e+"/"+s+""+p.Address+""+e+""+p.NextMessageId+++"http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymousPT60S"+w(n)+"'+r+"",a,o,t)},p.ExecEnum=function(e,s,r,a){p.PerformAjax("http://schemas.xmlsoap.org/ws/2004/09/enumeration/Enumerate"+p.Address+""+e+""+p.NextMessageId+++'http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymousPT60S',s,r,a)},p.ExecPull=function(e,s,r,a,o){p.PerformAjax("http://schemas.xmlsoap.org/ws/2004/09/enumeration/Pull"+p.Address+""+e+""+p.NextMessageId+++'http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymousPT60S'+s+"99999999",r,a,o)},p.ParseWsman=function(s){try{s.childNodes||(s=function(e){{if(window.DOMParser)return(new DOMParser).parseFromString(e,"text/xml");var s=new ActiveXObject("Microsoft.XMLDOM");return s.async=!1,s.loadXML(e),s}}(s));var e,r={Header:{}},a=s.getElementsByTagName("Header")[0];if(!(a=a||s.getElementsByTagName("a:Header")[0]))return null;for(var o=0;o'+e.InstanceID+"";var s="";for(var r in e)if(e.hasOwnProperty(r)){if(s+='',e[r].ReferenceParameters){s+="",s+=""+e[r].Address+""+e[r].ReferenceParameters.ResourceURI+"";var a=e[r].ReferenceParameters.SelectorSet.Selector;if(Array.isArray(a))for(var o=0;o"+a[o].Value+"";else s+=""+a.Value+"";s+=""}else s+=e[r];s+=""}return s+=""}return p.NextMessageId=1,p.Address="/wsman",p.comm=CreateWsmanComm(e,s,r,a,o,t),p.PerformAjax=function(e,o,s,r,a){null==a&&(a=""),p.comm.PerformAjax('
"+e,function(e,s,r){if(200==s){var a=p.ParseWsman(e);a&&null!=a?o(p,a.Header.ResourceURI,a,200,r):o(p,null,{Header:{HttpError:s}},601,r)}else o(p,null,{Header:{HttpError:s}},s,r)},s,r)},p.CancelAllQueries=function(e){p.comm.CancelAllQueries(e)},p.GetNameFromUrl=function(e){var s=e.lastIndexOf("/");return-1==s?e:e.substring(s+1)},p.ExecSubscribe=function(e,s,r,a,o,t,n,l,c,d){var m="",i="";null!=c&&null!=d&&(m="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#UsernameToken"+c+''+d+"",i=''),l=null!=l&&null!=l?""+l+"":"";var u="http://schemas.xmlsoap.org/ws/2004/08/eventing/Subscribe"+p.Address+""+e+""+p.NextMessageId+++"http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous"+w(n)+m+'
'+r+""+i+"PT0.000000S";p.PerformAjax(u+"
",a,o,t,'xmlns:e="http://schemas.xmlsoap.org/ws/2004/08/eventing" xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust" xmlns:se="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:m="http://x.com"')},p.ExecUnSubscribe=function(e,s,r,a,o){var t="http://schemas.xmlsoap.org/ws/2004/08/eventing/Unsubscribe"+p.Address+""+e+""+p.NextMessageId+++"http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous"+w(o)+"";p.PerformAjax(t+"",s,r,a,'xmlns:e="http://schemas.xmlsoap.org/ws/2004/08/eventing"')},p.ExecPut=function(e,s,r,a,o,t){var n="http://schemas.xmlsoap.org/ws/2004/09/transfer/Put"+p.Address+""+e+""+p.NextMessageId+++"http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymousPT60.000S"+w(t)+""+function(e,s){if(!e||null==s)return"";var r=p.GetNameFromUrl(e),a="';for(var o in s)if(s.hasOwnProperty(o)&&0!==o.indexOf("__")&&0!==o.indexOf("@")&&void 0!==s[o]&&null!==s[o]&&"function"!=typeof s[o])if("object"==typeof s[o]&&s[o].ReferenceParameters){a+=""+s[o].Address+""+s[o].ReferenceParameters.ResourceURI+"";var t=s[o].ReferenceParameters.SelectorSet.Selector;if(Array.isArray(t))for(var n=0;n"+t[n].Value+"";else a+=""+t.Value+"";a+=""}else if(Array.isArray(s[o]))for(n=0;n"+s[o][n].toString()+"";else a+=""+s[o].toString()+"";return a+=""}(e,s);p.PerformAjax(n+"",r,a,o)},p.ExecCreate=function(e,s,r,a,o,t){var n=p.GetNameFromUrl(e),l="http://schemas.xmlsoap.org/ws/2004/09/transfer/Create"+p.Address+""+e+""+p.NextMessageId+++"http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymousPT60S"+w(t)+"';for(var c in s)l+=""+s[c]+"";p.PerformAjax(l+"",r,a,o)},p.ExecCreateXml=function(e,s,r,a,o){var t=p.GetNameFromUrl(e);p.PerformAjax("http://schemas.xmlsoap.org/ws/2004/09/transfer/Create"+p.Address+""+e+""+p.NextMessageId+++"http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymousPT60.000S'+s+"",r,a,o)},p.ExecDelete=function(e,s,r,a,o){var t="http://schemas.xmlsoap.org/ws/2004/09/transfer/Delete"+p.Address+""+e+""+p.NextMessageId+++"http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymousPT60S"+w(s)+"";p.PerformAjax(t,r,a,o)},p.ExecGet=function(e,s,r,a){p.PerformAjax("http://schemas.xmlsoap.org/ws/2004/09/transfer/Get"+p.Address+""+e+""+p.NextMessageId+++"http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymousPT60S",s,r,a)},p.ExecMethod=function(e,s,r,a,o,t,n){var l="";for(var c in r)if(null!=r[c])if(Array.isArray(r[c]))for(var d in r[c])l+=""+r[c][d]+"";else l+=""+r[c]+"";p.ExecMethodXml(e,s,l,a,o,t,n)},p.ExecMethodXml=function(e,s,r,a,o,t,n){p.PerformAjax(e+"/"+s+""+p.Address+""+e+""+p.NextMessageId+++"http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymousPT60S"+w(n)+"'+r+"",a,o,t)},p.ExecEnum=function(e,s,r,a){p.PerformAjax("http://schemas.xmlsoap.org/ws/2004/09/enumeration/Enumerate"+p.Address+""+e+""+p.NextMessageId+++'http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymousPT60S',s,r,a)},p.ExecPull=function(e,s,r,a,o){p.PerformAjax("http://schemas.xmlsoap.org/ws/2004/09/enumeration/Pull"+p.Address+""+e+""+p.NextMessageId+++'http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymousPT60S'+s+"99999999",r,a,o)},p.ParseWsman=function(s){try{s.childNodes||(s=function(e){{if(window.DOMParser)return(new DOMParser).parseFromString(e,"text/xml");var s=new ActiveXObject("Microsoft.XMLDOM");return s.async=!1,s.loadXML(e),s}}(s));var e,r={Header:{}},a=s.getElementsByTagName("Header")[0];if(!(a=a||s.getElementsByTagName("a:Header")[0]))return null;for(var o=0;o9->152", + "default-mobile.handlebars->9->157", "default-mobile.handlebars->9->212", "default.handlebars->27->204", "default.handlebars->27->534" @@ -9344,7 +9344,7 @@ "fr": "L'appareil est branché sur secteur", "fi": "Laite on kytketty", "xloc": [ - "default-mobile.handlebars->9->151", + "default-mobile.handlebars->9->156", "default-mobile.handlebars->9->211", "default.handlebars->27->203", "default.handlebars->27->533" @@ -19682,7 +19682,7 @@ "zh-chs": "該組中沒有英特爾®AMT設備", "fi": "Tässä ryhmässä ei ole Intel® AMT-laitteita", "xloc": [ - "default-mobile.handlebars->9->154" + "default-mobile.handlebars->9->150" ] }, { @@ -19929,7 +19929,7 @@ "zh-chs": "沒有裝置", "fi": "Ei laitteita", "xloc": [ - "default-mobile.handlebars->9->156" + "default-mobile.handlebars->9->152" ] }, { @@ -20027,7 +20027,7 @@ "zh-chs": "該組中沒有設備", "fi": "Ei laitteita tässä ryhmässä", "xloc": [ - "default-mobile.handlebars->9->155", + "default-mobile.handlebars->9->151", "default.handlebars->27->220" ] }, @@ -20046,7 +20046,7 @@ "zh-chs": "沒有與此搜索匹配的設備。", "fi": "Ei hakua vastaavia laitteita.", "xloc": [ - "default-mobile.handlebars->9->153", + "default-mobile.handlebars->9->149", "default.handlebars->27->217" ] }, @@ -20305,8 +20305,8 @@ "fi": "Ei mitään", "xloc": [ "default-mobile.handlebars->9->116", - "default-mobile.handlebars->9->149", - "default-mobile.handlebars->9->150", + "default-mobile.handlebars->9->154", + "default-mobile.handlebars->9->155", "default-mobile.handlebars->9->213", "default-mobile.handlebars->9->218", "default-mobile.handlebars->9->220", @@ -29899,7 +29899,7 @@ "zh-chs": "使用此網站的桌面版本添加設備。", "fi": "Lisää laitteita tämän sivuston työpöytäversion avulla.", "xloc": [ - "default-mobile.handlebars->9->157" + "default-mobile.handlebars->9->153" ] }, { @@ -34099,4 +34099,4 @@ ] } ] -} +} \ No newline at end of file diff --git a/views/default-mobile.handlebars b/views/default-mobile.handlebars index 4b5ae7df..0f93c850 100644 --- a/views/default-mobile.handlebars +++ b/views/default-mobile.handlebars @@ -2205,61 +2205,7 @@ } count++; - var title = EscapeHtml(nodes[i].name); - if (title.length == 0) { title = '' + "None" + ''; } - if ((nodes[i].rname != null) && (nodes[i].rname.length > 0)) { title += ' / ' + EscapeHtml(nodes[i].rname); } - var name = EscapeHtml(nodes[i].name); - if (showRealNames == true && nodes[i].rname != null) name = EscapeHtml(nodes[i].rname); - if (name.length == 0) { name = '' + "None" + ''; } - - // Add device notification icons - var devNotify = '', devNotifySub = ''; - - // This device is "starred" - if (stars[nodes[i]._id] == 1) { - devNotifySub += ''; - } - - // This device has session information - if (nodes[i].sessions != null) { - // Display any agent messages - if (nodes[i].sessions.msg != null) { - devNotifySub += '
' + Object.keys(nodes[i].sessions.msg).length + '
'; - } - - // Sessions are active - if ((nodes[i].sessions.kvm != null) || (nodes[i].sessions.terminal != null) || (nodes[i].sessions.files != null) || (nodes[i].sessions.tcp != null) || (nodes[i].sessions.udp != null)) { - devNotifySub += ''; - } - - // Battery state - if (nodes[i].sessions.battery != null) { - var bat = nodes[i].sessions.battery; - var statestr = ''; - if (bat.state == 'ac') { statestr = "Device is plugged-in"; } - else 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 != '') { devNotify += '
' + devNotifySub + '
'; } - - // Node - var icon = nodes[i].icon, nodestate = NodeStateStr(nodes[i]); - if ((!nodes[i].conn) || (nodes[i].conn == 0)) { icon += ' gray'; } - r += '
' + devNotify + '
' + name + '
' + nodestate + '
'; + r += '
'; // This is a standin for the device, it gets rendered only if visible. // If we are displaying devices by group, put the device in the right group. /* @@ -2333,7 +2279,69 @@ onDevicesScrollnagleTimer = null; var visibleTop = Q('xdevices').scrollTop - 250, visibleBottom = Q('xdevices').scrollTop + Q('xdevices').clientHeight + 250, devdivs = document.getElementsByName('xxdevice'); for (var i = 0; i < devdivs.length; i++) { - devdivs[i].childNodes[0].style.display = ((devdivs[i].offsetTop >= visibleTop) && (devdivs[i].offsetTop < visibleBottom)) ? null : 'none'; + if ((devdivs[i].offsetTop >= visibleTop) && (devdivs[i].offsetTop < visibleBottom)) { + // Show + var node = getNodeFromId(devdivs[i].id) + if (node == null) break; + + 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) { + devNotifySub += ''; + } + + // This device has session information + if (node.sessions != null) { + // Display any agent messages + if (node.sessions.msg != null) { + 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)) { + devNotifySub += ''; + } + + // Battery state + if (node.sessions.battery != null) { + var bat = node.sessions.battery; + var statestr = ''; + if (bat.state == 'ac') { statestr = "Device is plugged-in"; } + else 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 != '') { devNotify += '
' + devNotifySub + '
'; } + + // Node + var icon = node.icon, nodestate = NodeStateStr(node); + if ((!node.conn) || (node.conn == 0)) { icon += ' gray'; } + devdivs[i].innerHTML = '
' + devNotify + '
' + name + '
' + nodestate + '
'; + } else { + devdivs[i].innerHTML = ''; // Hide + } } }