status.html 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735
  1. <div class="ui stackable grid">
  2. <div class="ten wide column serverstatusWrapper">
  3. <div id="serverstatus" class="ui statustab inverted segment">
  4. <h1 class="ui header" style="margin-top: 1em; margin-left: 0.4em; padding-bottom: 1em;">
  5. <i id="rpStatusIcon" class="loading spinner icon"></i>
  6. <div class="content">
  7. <span id="statusTitle">Loading</span>
  8. <div class="sub header" id="statusText">Checking server status</div>
  9. </div>
  10. </h1>
  11. <div class="dot-container">
  12. <div class="dot"></div>
  13. <div class="dot"></div>
  14. <div class="dot"></div>
  15. <div class="dot"></div>
  16. </div>
  17. </div>
  18. </div>
  19. <div class="six wide column statisticWrapper">
  20. <div class="ui statustab segment">
  21. <h5 class="ui header">
  22. <i class="exchange icon"></i>
  23. <div class="content">
  24. <span id="summaryTotalCount"></span> <small>Req. Today</small>
  25. <div class="sub header" style="margin-top: 0.4em;">
  26. <i class="green circle check icon"></i> <span id="summarySuccCount"></span>
  27. / <i class="red red exclamation circle icon"></i> <span id="summaryErrCount"></span>
  28. </div>
  29. </div>
  30. </h5>
  31. <div class="ui divider"></div>
  32. <h5 class="ui header" style="margin-top: 0px;">
  33. <i class="arrows alternate horizontal icon"></i>
  34. <div class="content">
  35. <span id="forwardtype"></span>
  36. <div class="sub header" id="forwardtypeList">
  37. </div>
  38. </div>
  39. </h5>
  40. <div class="ui divider"></div>
  41. <h5 class="ui header" style="margin-top: 0px;">
  42. <i class="map marker alternate icon"></i>
  43. <div class="content">
  44. <span id="country"></span>
  45. <div class="sub header" id="countryList">
  46. <i class="ui loading circle notch icon"></i> Resolving GeoIP
  47. </div>
  48. </div>
  49. </h5>
  50. </div>
  51. </div>
  52. </div>
  53. <div class="standardContainer" style="padding-bottom: 0 !important;">
  54. <!-- Power Buttons-->
  55. <button id="startbtn" class="ui basic button" onclick="startService();"><i class="ui green arrow alternate circle up icon"></i> Start Service</button>
  56. <button id="stopbtn" class="ui basic notloopbackOnly disabled button" onclick="stopService();"><i class="ui red minus circle icon"></i> Stop Service</button>
  57. <div class="ui divider"></div>
  58. <h4>Network Status</h4>
  59. <p>Overall Network I/O in Current Host Server</p>
  60. </div>
  61. <div id="networkActWrapper" class="standardContainer" style="position: relative;">
  62. <canvas id="networkActivity"></canvas>
  63. </div>
  64. <div id="networkActivityPlaceHolder">
  65. <p style="opacity: 0.5;"> Graph Render Paused</p>
  66. </div>
  67. <div class="standardContainer">
  68. <div class="ui divider"></div>
  69. <h4>Global Settings</h4>
  70. <p>Inbound Port (Reverse Proxy Listening Port)</p>
  71. <div class="ui action fluid notloopbackOnly input">
  72. <small id="applyButtonReminder">Click "Apply" button to confirm listening port changes</small>
  73. <input type="text" id="incomingPort" placeholder="Incoming Port" value="80">
  74. <button class="ui green notloopbackOnly button" style="background: linear-gradient(60deg, #27e7ff, #00ca52);" onclick="handlePortChange();"><i class="ui checkmark icon"></i> Apply</button>
  75. </div>
  76. <br><br>
  77. <div id="tls" class="ui toggle notloopbackOnly checkbox">
  78. <input type="checkbox">
  79. <label>Use TLS to serve proxy request</label>
  80. </div>
  81. <br>
  82. <div id="listenP80" class="ui toggle notloopbackOnly tlsEnabledOnly checkbox" style="margin-top: 0.6em;" >
  83. <input type="checkbox">
  84. <label>Enable HTTP server on port 80<br>
  85. <small>(Only apply when TLS enabled and not using port 80)</small></label>
  86. </div>
  87. <br>
  88. <div id="redirect" class="ui toggle notloopbackOnly tlsEnabledOnly checkbox" style="margin-top: 0.6em; padding-left: 2em;">
  89. <input type="checkbox">
  90. <label>Force redirect HTTP request to HTTPS</label>
  91. </div>
  92. <div class="ui basic segment" style="background-color: #f7f7f7; border-radius: 1em;">
  93. <div class="ui accordion advanceSettings">
  94. <div class="title">
  95. <i class="dropdown icon"></i>
  96. Advance Settings
  97. </div>
  98. <div class="content">
  99. <div id="tlsMinVer" class="ui toggle notloopbackOnly tlsEnabledOnly checkbox" style="margin-top: 0.6em;">
  100. <input type="checkbox">
  101. <label>Force TLS v1.2 or above<br>
  102. <small>(Enhance security, but not compatible with legacy browsers)</small></label>
  103. </div>
  104. <br>
  105. <div id="developmentMode" class="ui toggle checkbox" style="margin-top: 0.6em;">
  106. <input type="checkbox">
  107. <label>Development Mode<br>
  108. <small>(Set Cache-Control to no-store so browser will always fetch new contents from your sites)</small></label>
  109. </div>
  110. <br>
  111. </div>
  112. </div>
  113. </div>
  114. <div id="rploopbackWarning" class="ui segment" style="display:none;">
  115. <b><i class="yellow warning icon"></i> Loopback Routing Warning</b><br>
  116. <small>This management interface is a loopback proxied service. <br>If you want to shutdown the reverse proxy server, please remove the proxy rule for the management interface and refresh.</small>
  117. </div>
  118. <div class="ui divider"></div>
  119. <div class="">
  120. <h4>Statistic Overview</h4>
  121. <div class="ui two column stackable grid">
  122. <div class="column">
  123. <p>Visitor Counts</p>
  124. <table class="ui unstackable very basic celled table">
  125. <thead>
  126. <tr>
  127. <th>Country ISO Code</th>
  128. <th>Unique Visitors</th>
  129. </tr>
  130. </thead>
  131. <tbody id="countryCodetable">
  132. <tr>
  133. <td colspan="2">No Data</td>
  134. </tr>
  135. </tbody>
  136. </table>
  137. </div>
  138. <div class="column">
  139. <p>Proxy Request Types</p>
  140. <table class="ui unstackable very basic celled table">
  141. <thead>
  142. <tr>
  143. <th>Proxy Type</th>
  144. <th>Count</th>
  145. </tr>
  146. </thead>
  147. <tbody id="forwardTypeTable">
  148. <tr>
  149. <td colspan="2">No Data</td>
  150. </tr>
  151. </tbody>
  152. </table>
  153. </div>
  154. </div>
  155. </div>
  156. <br>
  157. <button class="ui right floated basic button" onclick="getDailySummaryDetails();"><i class="green refresh icon"></i> Refresh</button>
  158. <br><br>
  159. </div>
  160. <script>
  161. let loopbackProxiedInterface = false;
  162. let currentListeningPort = 80;
  163. $(".advanceSettings").accordion();
  164. //Initial the start stop button if this is reverse proxied
  165. $.get("/api/proxy/requestIsProxied", function(data){
  166. if (data == true){
  167. //This management interface is reverse proxied by itself
  168. //do not allow turning off the proxy
  169. $(".notloopbackOnly").addClass("disabled");
  170. loopbackProxiedInterface = true;
  171. $("#rploopbackWarning").show();
  172. }
  173. });
  174. //Get the latest server status from proxy server
  175. function initRPStaste(){
  176. $.get("/api/proxy/status", function(data){
  177. $("#incomingPort").off("change");
  178. if (data.Running == true){
  179. $("#startbtn").addClass("disabled");
  180. if (!loopbackProxiedInterface){
  181. $("#stopbtn").removeClass("disabled");
  182. }
  183. $("#serverstatus").addClass("green");
  184. $("#statusTitle").text("Online");
  185. $("#rpStatusIcon").attr("class", "white circle check icon");
  186. $("#statusText").text("Serving request on port: " + data.Option.Port);
  187. }else{
  188. $("#startbtn").removeClass("disabled");
  189. $("#stopbtn").addClass("disabled");
  190. $("#statusTitle").text("Offline");
  191. $("#rpStatusIcon").attr("class", "yellow moon icon")
  192. $("#statusText").text("Reverse proxy server is offline");
  193. $("#serverstatus").removeClass("green");
  194. }
  195. $("#incomingPort").val(data.Option.Port);
  196. currentListeningPort = data.Option.Port;
  197. $("#incomingPort").on("change", function(){
  198. let newPortValue = $("#incomingPort").val().trim();
  199. if (currentListeningPort != newPortValue){
  200. $("#applyButtonReminder").show();
  201. }else{
  202. $("#applyButtonReminder").hide();
  203. }
  204. });
  205. });
  206. }
  207. function getDailySummaryDetails(){
  208. function sortObjectByValue(obj) {
  209. // Convert object to array of [key, value] pairs
  210. const entries = Object.entries(obj);
  211. // Sort array based on value of each pair
  212. entries.sort((a, b) => {
  213. return b[1] - a[1];
  214. });
  215. // Convert sorted array back to object
  216. const sortedObj = {};
  217. for (const [key, value] of entries) {
  218. sortedObj[key] = value;
  219. }
  220. return sortedObj;
  221. }
  222. $.get("/api/stats/countries", function(data){
  223. data = sortObjectByValue(data);
  224. $("#country").html((Object.keys(data)[0])?Object.keys(data)[0]:"No Data");
  225. $("#countryList").html(`
  226. <div>
  227. ${(Object.keys(data)[1])?Object.keys(data)[1]:"-"}<br>
  228. ${(Object.keys(data)[2])?Object.keys(data)[2]:"-"}
  229. </div>
  230. `);
  231. //populate the table
  232. $("#countryCodetable").html("");
  233. for (const [key, value] of Object.entries(data)) {
  234. var countryName = getCountryName(key);
  235. if (countryName == ""){
  236. countryName = "LAN"
  237. }
  238. $("#countryCodetable").append(`<tr>
  239. <td>${key} (${countryName})</td>
  240. <td>${value}</td>
  241. </tr>`);
  242. }
  243. if (Object.keys(data).length == 0){
  244. $("#countryCodetable").append(`<tr>
  245. <td colspan="2"><i class="ui green circle check icon"></i> No Data</td>
  246. </tr>`);
  247. }
  248. });
  249. //Filter forward type
  250. function fft(ft){
  251. if (ft.indexOf("-") >= 0){
  252. ft = ft.replace("-", " (");
  253. ft = ft + ")";
  254. }
  255. ft = ft.charAt(0).toUpperCase() + ft.slice(1);
  256. return ft;
  257. }
  258. $.get("/api/stats/summary", function(data){
  259. data = sortObjectByValue(data.ForwardTypes);
  260. $("#forwardtype").html((Object.keys(data)[0])?fft(Object.keys(data)[0]) + ": " + abbreviateNumber(data[Object.keys(data)[0]]):"No Data");
  261. $("#forwardtypeList").html(`
  262. <div>
  263. ${(Object.keys(data)[1])?fft(Object.keys(data)[1]) + ": " + abbreviateNumber(data[Object.keys(data)[1]]):"-"}<br>
  264. ${(Object.keys(data)[2])?fft(Object.keys(data)[2]) + ": " + abbreviateNumber(data[Object.keys(data)[2]]):"-"}
  265. </div>
  266. `);
  267. $("#forwardTypeTable").html("");
  268. for (const [key, value] of Object.entries(data)) {
  269. $("#forwardTypeTable").append(`<tr>
  270. <td>${key}</td>
  271. <td>${value}</td>
  272. </tr>`);
  273. }
  274. if (Object.keys(data).length == 0){
  275. $("#forwardTypeTable").append(`<tr>
  276. <td colspan="2"><i class="ui green circle check icon"></i> No Data</td>
  277. </tr>`);
  278. }
  279. });
  280. }
  281. getDailySummaryDetails();
  282. function getDailySummary(){
  283. $.get("/api/stats/summary?fast=true", function(data){
  284. $("#summaryTotalCount").text(abbreviateNumber(data.TotalRequest));
  285. $("#summarySuccCount").text(abbreviateNumber(data.ValidRequest));
  286. $("#summaryErrCount").text(abbreviateNumber(data.ErrorRequest));
  287. });
  288. }
  289. setInterval(function(){
  290. getDailySummary();
  291. }, 10000);
  292. getDailySummary();
  293. //Start and stop service button
  294. function startService(){
  295. $.post("/api/proxy/enable", {enable: true}, function(data){
  296. if (data.error != undefined){
  297. msgbox(data.error, false, 5000);
  298. }
  299. initRPStaste();
  300. });
  301. }
  302. function stopService(){
  303. $.post("/api/proxy/enable", {enable: false}, function(data){
  304. if (data.error != undefined){
  305. msgbox(data.error, false, 5000);
  306. }
  307. initRPStaste();
  308. });
  309. }
  310. function handleP80ListenerStateChange(enabled){
  311. $.ajax({
  312. url: "/api/proxy/listenPort80",
  313. data: {"enable": enabled},
  314. success: function(data){
  315. if (data.error != undefined){
  316. console.log(data.error);
  317. return;
  318. }
  319. if (enabled){
  320. $("#redirect").show();
  321. msgbox("Port 80 listener enabled");
  322. }else{
  323. $("#redirect").hide();
  324. msgbox("Port 80 listener disabled");
  325. }
  326. }
  327. });
  328. }
  329. function handlePortChange(){
  330. var newPortValue = $("#incomingPort").val();
  331. if (isNaN(newPortValue - 1) || newPortValue < 1 || newPortValue > 65535){
  332. msgbox("Invalid incoming port value", false, 5000);
  333. return;
  334. }
  335. $.post("/api/proxy/setIncoming", {incoming: newPortValue}, function(data){
  336. if (data.error != undefined){
  337. msgbox(data.error, false, 5000);
  338. return;
  339. }
  340. msgbox("Listening Port Updated");
  341. initRPStaste();
  342. //Hide the reminder text
  343. $("#applyButtonReminder").hide();
  344. });
  345. }
  346. function initPort80ListenerSetting(){
  347. $.get("/api/proxy/listenPort80", function(data){
  348. if (data){
  349. $("#listenP80").checkbox("set checked");
  350. $("#redirect").show();
  351. }else{
  352. $("#listenP80").checkbox("set unchecked");
  353. $("#redirect").hide();
  354. }
  355. $("#listenP80").find("input").on("change", function(){
  356. let enabled = $(this)[0].checked;
  357. handleP80ListenerStateChange(enabled);
  358. })
  359. });
  360. }
  361. initPort80ListenerSetting();
  362. function initHTTPtoHTTPSRedirectSetting(){
  363. $.get("/api/proxy/useHttpsRedirect", function(data){
  364. if (data == true){
  365. $("#redirect").checkbox("set checked");
  366. }
  367. //Initiate the input listener on the checkbox
  368. $("#redirect").find("input").on("change", function(){
  369. let thisValue = $("#redirect").checkbox("is checked");
  370. $.ajax({
  371. url: "/api/proxy/useHttpsRedirect",
  372. data: {set: thisValue},
  373. success: function(data){
  374. if (data.error != undefined){
  375. msgbox(data.error, false, 8000);
  376. //Restore backend value to make sure the UI is always in sync
  377. $.get("/api/proxy/useHttpsRedirect", function(data){
  378. if (data == true){
  379. $("#redirect").checkbox("set checked");
  380. }else{
  381. $("#redirect").checkbox("set unchecked");
  382. }
  383. });
  384. }else{
  385. //Updated
  386. msgbox("Setting Updated");
  387. initRPStaste();
  388. }
  389. }
  390. })
  391. });
  392. });
  393. }
  394. initHTTPtoHTTPSRedirectSetting();
  395. function initTlsVersionSetting(){
  396. $.get("/api/cert/tlsRequireLatest", function(data){
  397. if (data == true){
  398. $("#tlsMinVer").checkbox("set checked");
  399. }else{
  400. $("#tlsMinVer").checkbox("set unchecked");
  401. }
  402. //Bind events to the checkbox
  403. $("#tlsMinVer").find("input").on("change", function(){
  404. let thisValue = $("#tlsMinVer").checkbox("is checked");
  405. $.ajax({
  406. url: "/api/cert/tlsRequireLatest",
  407. data: {"set": thisValue},
  408. success: function(data){
  409. if (data.error != undefined){
  410. msgbox(data.error, false, 5000);
  411. }else{
  412. msgbox("TLS Version Setting Updated");
  413. }
  414. }
  415. })
  416. });
  417. });
  418. }
  419. initTlsVersionSetting();
  420. function initDevelopmentMode(){
  421. $.get("/api/proxy/developmentMode", function(data){
  422. if (data === true){
  423. $("#developmentMode").checkbox("set checked")
  424. }else{
  425. $("#developmentMode").checkbox("set unchecked")
  426. }
  427. //Bind change events
  428. $("#developmentMode").off("change").on("change", function(data){
  429. let enableDevMode = ($(this).find("input[type='checkbox']")[0].checked);
  430. $.get("/api/proxy/developmentMode?enable=" + enableDevMode, function(data){
  431. if (enableDevMode){
  432. msgbox("Development mode enabled");
  433. }else{
  434. msgbox("Development mode disabled");
  435. }
  436. });
  437. });
  438. });
  439. }
  440. initDevelopmentMode();
  441. function initTlsSetting(){
  442. $.get("/api/cert/tls", function(data){
  443. if (data == true){
  444. $("#tls").checkbox("set checked");
  445. }else{
  446. $(".tlsEnabledOnly").addClass('disabled');
  447. $(".tlsEnabledOnly").addClass('disabled');
  448. }
  449. //Initiate the input listener on the checkbox
  450. $("#tls").find("input").on("change", function(){
  451. let thisValue = $("#tls").checkbox("is checked");
  452. if (thisValue){
  453. $(".tlsEnabledOnly").removeClass('disabled');
  454. }else{
  455. $(".tlsEnabledOnly").addClass('disabled');
  456. }
  457. $.ajax({
  458. url: "/api/cert/tls",
  459. data: {set: thisValue},
  460. success: function(data){
  461. if (data.error != undefined){
  462. alert(data.error);
  463. }else{
  464. //Updated
  465. //Check for case if the port is invalid default ports
  466. if ($("#incomingPort").val() == "80" && thisValue == true){
  467. confirmBox("Change listen port to :443?", function(choice){
  468. if (choice == true){
  469. $("#incomingPort").val("443");
  470. handlePortChange();
  471. }
  472. });
  473. }else if ($("#incomingPort").val() == "443" && thisValue == false){
  474. confirmBox("Change listen port to :80?", function(choice){
  475. if (choice == true){
  476. $("#incomingPort").val("80");
  477. handlePortChange();
  478. }
  479. });
  480. }else{
  481. msgbox("Setting Updated");
  482. }
  483. initRPStaste();
  484. }
  485. }
  486. })
  487. });
  488. })
  489. }
  490. initTlsSetting();
  491. </script>
  492. <script>
  493. /*
  494. Render Network Activity Graph
  495. */
  496. /*
  497. Setup Graph
  498. */
  499. let rxValues = [];
  500. let txValues = [];
  501. let dataCount = 300;
  502. let timestamps = [];
  503. for(var i = 0; i < dataCount; i++){
  504. timestamps.push(parseInt(Date.now() / 1000) + i);
  505. }
  506. function fetchData() {
  507. $.ajax({
  508. url: '/api/stats/netstatgraph?array=true',
  509. success: function(data){
  510. if (rxValues.length == 0){
  511. rxValues = JSON.parse(JSON.stringify(data.Rx));
  512. }else{
  513. rxValues.push(data.Rx[dataCount-1]);
  514. rxValues.shift();
  515. }
  516. if (txValues.length == 0){
  517. txValues = JSON.parse(JSON.stringify(data.Tx));
  518. }else{
  519. txValues.push(data.Tx[dataCount-1]);
  520. txValues.shift();
  521. }
  522. timestamps.push(parseInt(Date.now() / 1000));
  523. timestamps.shift();
  524. updateChart();
  525. }
  526. })
  527. }
  528. function formatBandwidth(bps) {
  529. const KBPS = 1000;
  530. const MBPS = 1000 * KBPS;
  531. const GBPS = 1000 * MBPS;
  532. if (bps >= GBPS) {
  533. return (bps / GBPS).toFixed(2) + " Gbps";
  534. } else if (bps >= MBPS) {
  535. return (bps / MBPS).toFixed(2) + " Mbps";
  536. } else if (bps >= KBPS) {
  537. return (bps / KBPS).toFixed(2) + " Kbps";
  538. } else {
  539. return bps.toFixed(2) + " bps";
  540. }
  541. }
  542. var networkStatisticChart;
  543. function initChart(){
  544. $.get("/api/stats/netstat", function(data){
  545. networkStatisticChart = new Chart(
  546. document.getElementById('networkActivity'),
  547. {
  548. type: 'line',
  549. responsive: true,
  550. resizeDelay: 300,
  551. options: {
  552. animation: false,
  553. maintainAspectRatio: false,
  554. bezierCurve: true,
  555. tooltips: {enabled: false},
  556. hover: {mode: null},
  557. //stepped: 'middle',
  558. plugins: {
  559. legend: {
  560. display: true,
  561. position: "right",
  562. },
  563. title: {
  564. display: false,
  565. text: 'Network Statistic'
  566. },
  567. },
  568. scales: {
  569. x: {
  570. display: false,
  571. },
  572. y: {
  573. display: true,
  574. scaleLabel: {
  575. display: true,
  576. labelString: 'Value'
  577. },
  578. ticks: {
  579. stepSize: 10000000,
  580. callback: function(label, index, labels) {
  581. return formatBandwidth(parseInt(label));
  582. }
  583. },
  584. gridLines: {
  585. display: true
  586. }
  587. }
  588. }
  589. },
  590. data: {
  591. labels: timestamps,
  592. datasets: [
  593. {
  594. label: 'Inbound',
  595. data: rxValues,
  596. borderColor: "#484bb8",
  597. borderWidth: 1,
  598. backgroundColor: 'rgba(72, 75, 184, 0.2)',
  599. fill: true,
  600. pointStyle: false,
  601. },
  602. {
  603. label: 'Outbound',
  604. data: txValues,
  605. borderColor: '#02a9c1',
  606. borderWidth: 1,
  607. backgroundColor: 'rgba(2, 169, 193, 0.2)',
  608. fill: true,
  609. pointStyle: false,
  610. }
  611. ]
  612. }
  613. }
  614. );
  615. });
  616. }
  617. function updateChart() {
  618. //networkStatisticChart.data.datasets[0].data = rxValues;
  619. //networkStatisticChart.data.datasets[1].data = txValues;
  620. if (networkStatisticChart != undefined){
  621. networkStatisticChart.update();
  622. }
  623. }
  624. function updateChartSize(){
  625. let newSize = $("#networkActWrapper").width() - 300;
  626. if (window.innerWidth > 750){
  627. newSize = window.innerWidth - $(".toolbar").width() - 500;
  628. }else{
  629. newSize = $("#networkActWrapper").width() - 500;
  630. }
  631. if (networkStatisticChart != undefined){
  632. networkStatisticChart.resize(newSize, 200);
  633. }
  634. }
  635. function handleChartAccumulateResize(){
  636. $("#networkActivity").hide();
  637. $("#networkActivityPlaceHolder").show();
  638. if (chartResizeTimeout != undefined){
  639. clearTimeout(chartResizeTimeout);
  640. }
  641. chartResizeTimeout = setTimeout(function(){
  642. chartResizeTimeout = undefined;
  643. $("#networkActivityPlaceHolder").hide();
  644. $("#networkActivity").show();
  645. updateChartSize();
  646. }, 300);
  647. }
  648. var chartResizeTimeout;
  649. window.addEventListener('resize', () => {
  650. handleChartAccumulateResize();
  651. });
  652. //Bind event to tab switch
  653. tabSwitchEventBind["status"] = function(){
  654. //On switch over to this page, resize the chart
  655. handleChartAccumulateResize();
  656. }
  657. window.addEventListener("focus", function(event){
  658. handleChartAccumulateResize();
  659. });
  660. //Initialize chart data
  661. initChart();
  662. fetchData();
  663. setInterval(fetchData, 1000);
  664. </script>