neighbour.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta name="mobile-web-app-capable" content="yes">
  5. <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1"/>
  6. <meta charset="UTF-8">
  7. <link rel="stylesheet" href="../../script/semantic/semantic.min.css">
  8. <script src="../../script/jquery.min.js"></script>
  9. <script src="../../script/semantic/semantic.min.js"></script>
  10. <script src="../arsm/js/moment.min.js"></script>
  11. <style>
  12. .hidden{
  13. display:none;
  14. }
  15. </style>
  16. </head>
  17. <body>
  18. <div class="ui container">
  19. <div class="ui basic segment">
  20. <div class="ui header">
  21. <i class="server icon"></i>
  22. <div class="content">
  23. Cluster Neightbourhood
  24. <div class="sub header">Automatic Cluster Discovery Services</div>
  25. </div>
  26. </div>
  27. </div>
  28. <div class="ui divider"></div>
  29. <div class="ui red message" id="errbox" style="display:none;">
  30. <div class="header">
  31. Cluster Scan Error
  32. </div>
  33. <p id="errormsg">An unknown error has occurred. Please try again later.</p>
  34. </div>
  35. <h4 class="ui header">
  36. This Host
  37. <div class="sub header">The broadcasting information sent out by this host server.</div>
  38. </h4>
  39. <div class="ui basic segment" id="thisHost">
  40. </div>
  41. <div class="ui divider"></div>
  42. <h4 class="ui header">
  43. Nearby Hosts
  44. <div class="sub header">The ArozOS broadcast receiver from the Local Area Network.</div>
  45. </h4>
  46. <div class="ui basic segment" id="nearybylist">
  47. </div>
  48. <div class="ui divider"></div>
  49. <h4 class="ui header">
  50. Offline Hosts
  51. <div class="sub header">Host that goes offline for less than 30 days</div>
  52. </h4>
  53. <div class="ui basic segment" id="offlineList">
  54. </div>
  55. <small>All hosts that offline for more than 30 days will be automatically removed from the system record</small>
  56. <div class="ui divider"></div>
  57. <p>Last Updates: <span id="lastUpdateTime"></span> seconds ago</p>
  58. <br><br><br>
  59. </div>
  60. <script>
  61. initClusterScannerList();
  62. function initClusterScannerList(){
  63. $.get("../../system/cluster/scan", function(data){
  64. if (data.error !== undefined){
  65. $("#errormsg").text(data.error);
  66. $("#errbox").show();
  67. }else{
  68. //Render this Host info
  69. if (data.ThisHost != null){
  70. var host = data.ThisHost
  71. $("#thisHost").append(`<div class="ui icon green message">
  72. <i class="server icon"></i>
  73. <div class="content">
  74. <div class="header">
  75. <a href="//${host.HostName}:${host.Port}" target="_blank">${host.HostName}</a>
  76. </div>
  77. <div class="ui list">
  78. <div class="item">
  79. <i class="disk icon"></i>
  80. <div class="content">
  81. <b>MODEL:</b> ${host.Model} (${host.Vendor})
  82. </div>
  83. </div>
  84. <div class="item">
  85. <i class="paperclip icon"></i>
  86. <div class="content">
  87. <b>VER:</b> ${host.MinorVersion} (${host.BuildVersion})
  88. </div>
  89. </div>
  90. <div class="item">
  91. <i class="marker icon"></i>
  92. <div class="content">
  93. <b>IP:</b> ${host.IPv4.join(" / ")}
  94. </div>
  95. </div>
  96. <div class="item">
  97. <i class="tag icon"></i>
  98. <div class="content">
  99. <b>UUID:</b> ${host.UUID}
  100. </div>
  101. </div>
  102. <div class="item">
  103. <i class="server icon"></i>
  104. <div class="content">
  105. <b>MAC:</b> ${host.MacAddr.join(" / ")}
  106. </div>
  107. </div>
  108. </div>
  109. </div>
  110. </div>`);
  111. }
  112. //Render remote host info
  113. $("#nearybylist").html("");
  114. if (data.NearbyHosts == null){
  115. $("#nearybylist").append(`<div class="ui icon teal message">
  116. <i class="question icon"></i>
  117. <div class="content">
  118. No nearby hosts discovered
  119. </div>
  120. `);
  121. }else{
  122. data.NearbyHosts.forEach(host => {
  123. var iplinks = [];
  124. host.IPv4.forEach(ip => {
  125. iplinks.push(`<a href="//${ip}:${host.Port}" target="_blank">${ip}</a>`);
  126. })
  127. var ipDOM = iplinks.join(" / ");
  128. var macDOM = host.MacAddr.join(" / ");
  129. if (host.MacAddr.length == 0){
  130. //Old version of ArozOS, do not support MAC addr broadcast
  131. macDOM = "Version Not Supported";
  132. }
  133. $("#nearybylist").append(`<div class="ui icon teal message">
  134. <i class="server icon"></i>
  135. <div class="content">
  136. <div class="header">
  137. <a href="//${host.HostName}:${host.Port}" target="_blank">${host.HostName}</a>
  138. </div>
  139. <div class="ui list">
  140. <div class="item">
  141. <i class="disk icon"></i>
  142. <div class="content">
  143. <b>MODEL:</b> ${host.Model} (${host.Vendor})
  144. </div>
  145. </div>
  146. <div class="item">
  147. <i class="paperclip icon"></i>
  148. <div class="content">
  149. <b>VER:</b> ${host.MinorVersion} (${host.BuildVersion})
  150. </div>
  151. </div>
  152. <div class="item">
  153. <i class="marker icon"></i>
  154. <div class="content">
  155. <b>IP:</b> ${ipDOM}
  156. </div>
  157. </div>
  158. <div class="item">
  159. <i class="tag icon"></i>
  160. <div class="content">
  161. <b>UUID:</b> ${host.UUID}
  162. </div>
  163. </div>
  164. <div class="item">
  165. <i class="server icon"></i>
  166. <div class="content">
  167. <b>MAC:</b> ${macDOM}
  168. </div>
  169. </div>
  170. </div>
  171. </div>
  172. </div>`);
  173. });
  174. }
  175. //Update the update time
  176. $("#lastUpdateTime").text(Math.floor(Date.now() / 1000) - data.LastUpdate);
  177. }
  178. });
  179. $.get("../../system/cluster/record", function(data){
  180. $("#offlineList").html("");
  181. if (data != null){
  182. data.forEach(function(host){
  183. let ipDOM = "No Record";
  184. if (host.LastSeenIP != null && host.LastSeenIP.length > 0){
  185. ipDOM = host.LastSeenIP.join(" / ");
  186. }
  187. let macDOM = "No Record";
  188. let wakeOnLanButton = "";
  189. if (host.MacAddr != null && host.MacAddr.length > 0){
  190. macDOM = host.MacAddr.join(" / ");
  191. wakeOnLanButton = `<button class="ui right floated basic button" mac="${encodeURIComponent(JSON.stringify(host.MacAddr))}" onclick="wakeonlan(this);"><i class="power icon"></i> Wake On LAN</button>`;
  192. }
  193. $("#offlineList").append(`<div class="ui icon message">
  194. <i class="server icon"></i>
  195. <div class="content">
  196. ${wakeOnLanButton}
  197. <div class="header">
  198. <span>${host.Name}</a>
  199. </div>
  200. <div class="ui list">
  201. <div class="item">
  202. <i class="disk icon"></i>
  203. <div class="content">
  204. <b>MODEL:</b> ${host.Model}
  205. </div>
  206. </div>
  207. <div class="item">
  208. <i class="paperclip icon"></i>
  209. <div class="content">
  210. <b>VER:</b> ${host.Version}
  211. </div>
  212. </div>
  213. <div class="item">
  214. <i class="marker icon"></i>
  215. <div class="content">
  216. <b>IP:</b> ${ipDOM}
  217. </div>
  218. </div>
  219. <div class="item">
  220. <i class="tag icon"></i>
  221. <div class="content">
  222. <b>UUID:</b> ${host.UUID}
  223. </div>
  224. </div>
  225. <div class="item">
  226. <i class="server icon"></i>
  227. <div class="content">
  228. <b>MAC:</b> ${macDOM}
  229. </div>
  230. </div>
  231. </div>
  232. </div>
  233. </div>`);
  234. });
  235. }
  236. if (data == null || data.length == 0){
  237. $("#offlineList").append(`<div class="ui message">
  238. <div class="content">
  239. <i class="checkmark icon"></i> No Offline Network Host
  240. </div>
  241. `);
  242. }
  243. });
  244. }
  245. function wakeonlan(object){
  246. $(object).addClass("disabled");
  247. let macAddr = $(object).attr("mac");
  248. macAddr = JSON.parse(decodeURIComponent(macAddr));
  249. let counter = macAddr.length;
  250. macAddr.forEach(function(thisMac){
  251. $.get("../../system/cluster/wol?mac=" + thisMac, function(data){
  252. console.log("Wake On Lan packet sent to " + thisMac + " with results: "+ data);
  253. counter--;
  254. if (counter == 0){
  255. //All WOL packet has been sent
  256. let currentButtonText = $(object).html();
  257. $(object).addClass("green").addClass("icon");;
  258. $(object).html(`<i class="green checkmark icon"></i>`);
  259. setTimeout(function(){
  260. $(object).removeClass("green").removeClass("remove");
  261. $(object).html(currentButtonText);
  262. $(object).removeClass("disabled");
  263. }, 5000)
  264. }
  265. });
  266. });
  267. }
  268. </script>
  269. </body>
  270. </html>