istio.io/istio@v0.0.0-20240520182934-d79c90f27776/pkg/ctrlz/assets/templates/home.html (about)

     1  {{ define "title" }}Istio ControlZ{{ end }}
     2  {{ define "content" }}
     3  
     4  <p>
     5      Make a selection in the left sidebar to inspect & control aspects of this process.
     6  </p>
     7  
     8  <table>
     9      <tbody>
    10      <tr>
    11          <td>Process Name</td>
    12          <td>{{.ProcessName}}</td>
    13      </tr>
    14  
    15      <tr>
    16          <td>Heap Size</td>
    17          <td id="HeapSize">{{.HeapSize}} bytes</td>
    18      </tr>
    19  
    20      <tr>
    21          <td>Num Garbage Collections</td>
    22          <td id="NumGC">{{.NumGC}}</td>
    23      </tr>
    24  
    25      <tr>
    26          <td>Current Time</td>
    27          <td id="CurrentTime"></td>
    28      </tr>
    29  
    30      <script>
    31          // we do this so there's a useful date in the table, which avoids things shifting around during initial paint
    32          var d = new Date().toLocaleString();
    33          document.getElementById("CurrentTime").innerText = d;
    34      </script>
    35  
    36      <tr>
    37          <td>Hostname</td>
    38          <td>{{.Hostname}}</td>
    39      </tr>
    40  
    41      <tr>
    42          <td>IP Address</td>
    43          <td>{{.IP}}</td>
    44      </tr>
    45  
    46      </tbody>
    47  </table>
    48  
    49  <br/>
    50  <button id="terminate" class="btn btn-istio" onclick="terminateProcess()">Terminate Process</button>
    51  <p id="terminated" style="display:none">Process Terminated</p>
    52  
    53  {{ template "last-refresh" .}}
    54  
    55  <script>
    56      "use strict"
    57  
    58      function refreshHomeInfo() {
    59          var url = window.location.protocol + "//" + window.location.host + "/homej/";
    60  
    61          var ajax = new XMLHttpRequest();
    62          ajax.onload = onload;
    63          ajax.onerror = onerror;
    64          ajax.open("GET", url, true);
    65          ajax.send();
    66  
    67          function onload() {
    68              if (this.status == 200) { // request succeeded
    69                  var hi = JSON.parse(this.responseText);
    70                  document.getElementById("HeapSize").innerText = hi.HeapSize.toLocaleString() + " bytes";
    71                  document.getElementById("NumGC").innerText = hi.NumGC.toLocaleString();
    72  
    73                  var d = new Date(hi.CurrentTime / 1000000).toLocaleString();
    74                  document.getElementById("CurrentTime").innerText = d;
    75  
    76                  updateRefreshTime();
    77              }
    78          }
    79  
    80          function onerror(e) {
    81              console.error(e);
    82          }
    83      }
    84  
    85      function terminateProcess() {
    86          document.getElementById("terminate").style.display = "none";
    87          document.getElementById("terminated").style.display = "block";
    88  
    89          var url = window.location.protocol + "//" + window.location.host + "/homej/exit";
    90  
    91          var ajax = new XMLHttpRequest();
    92          ajax.onload = onload;
    93          ajax.onerror = onerror;
    94          ajax.open("PUT", url, true);
    95          ajax.send();
    96  
    97          function onload() {
    98              if (this.status == 200) { // request succeeded
    99              }
   100          }
   101  
   102          function onerror(e) {
   103              console.error(e);
   104          }
   105      }
   106  
   107      refreshHomeInfo();
   108      window.setInterval(refreshHomeInfo, 1000);
   109  </script>
   110  
   111  {{ end }}