aceberg/WatchYourPorts

View on GitHub
internal/web/templates/scan.html

Summary

Maintainability
Test Coverage
{{ define "scan.html" }}
</head>
<script src="/fs/public/js/scan.js"></script>
<script src="/fs/public/js/sort.js"></script>
<link rel="stylesheet" type="text/css" href="/fs/public/css/index.css" />
<body>
<!-- Add Edit Modal -->
<div class="modal" id="mEdit">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title">Edit</h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close">
          <span aria-hidden="true"></span>
        </button>
      </div>
      <div class="modal-body">
        <form action="/addr_save/" method="post" class="form">
          <table class="table table-borderless">
            <tr>
              <td>Name</td>
              <td>
                <input name="name" type="text" class="form-control" value="{{ .OneAddr.Name }}">
              </td>
            </tr>
            <tr>
              <td>Address</td>
              <td>
                <input type="text" class="form-control" value="{{ .OneAddr.Addr }}" disabled>
                <input name="addr" type="hidden" class="form-control" value="{{ .OneAddr.Addr }}">
              </td>
            </tr>
            <tr>
              <td>
                <button type="submit" class="btn btn-primary">Save</button>
        </form>
              </td>
              <td>
                <form action="/addr_del/" method="post" class="form">
                  <input name="addr" type="hidden" class="form-control" value="{{ .OneAddr.Addr }}">
                  <button type="submit" class="btn btn-danger" style="float: right;">Delete this Address</button>
                </form>
              </td>
            </tr>
          </table>
      </div>
    </div>
  </div>
</div>
<!-- End Modal -->
<div class="container-lg">
  <div class="row">
    <div class="col-md mt-4">
      <h3>{{ .OneAddr.Name }}: {{ .OneAddr.Addr }}
        <button class="btn my-button" title="Edit" data-bs-toggle="modal" data-bs-target="#mEdit">
          <i class="bi bi-pencil-fill"></i>
        </button>
      </h3>
    </div>
    <div class="col-md mt-4">
      <form class="input-group">
        <input id="begin" type="text" class="form-control" placeholder="1">
        <input id="end" type="text" class="form-control" placeholder="65535">
        <!-- To get from JS -->
        <input type="hidden" id="pageAddr" value="{{ .OneAddr.Addr }}"> 
        <button onclick="scanAddr()" type="button" class="btn btn-primary">Scan</button>
      </form>
      <div style="display: flex; justify-content: space-between; visibility: hidden;" id="stopBtn">
        <button onclick="stopScan()" type="button" class="btn btn-warning">Stop</button>
        <div id="curPort"></div>
      </div>
    </div>
  </div>
  <br>
  <div class="row">
    <div class="card border-primary">
      <div class="card-body">
        <form action="/scan_save/" method="post" class="form">
          <input name="addr" type="hidden" value="{{ .OneAddr.Addr }}">
          <div class="row">
            <div class="col-lg-11 table-responsive mb-4">
              <table class="table table-striped">
                <thead>
                  <th style="width: 3em;"></th>
                  <th style="white-space: nowrap;">Name <i class="bi bi-sort-down-alt" onclick="sortBy('Name')"></i></th>
                  <th style="white-space: nowrap;">Port <i class="bi bi-sort-down-alt" onclick="sortBy('Port')"></i></th>
                  <th style="white-space: nowrap;">State <i class="bi bi-sort-down-alt" onclick="sortBy('State')"></i></th>
                  <th style="white-space: nowrap;">Watch <i class="bi bi-sort-down-alt" onclick="sortBy('Watch')"></i></th>
                  <th>Del</th>
                </thead>
                <tbody id="tBody"></tbody>
              </table>
            </div>
            <div class="col-sm mb-4">
              <button type="submit" class="btn btn-outline-primary" style="height: 100%;">Save</button>
            </div>
          </div>
        </form>
      </div>
    </div>
  </div>
</div>

{{ template "footer.html" }}
{{ end }}