{{define "header_additions"}}
 <link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css"
   integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A=="
   crossorigin=""/>
 <script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"
   integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="
   crossorigin=""></script>
<style>
#map {
  position: absolute;
  top: 0px;
  left: 0px;
  width: 100%;
  height: 100%;
}
</style>
{{end}}
{{define "body_content"}}
{{ if ne .UserName "" }}
<div id="modal" class="modal">
  <div class="modal-background"></div>
  <div class="modal-card">
    <header class="modal-card-head">
      <p class="modal-card-title">Einstellungen</p>
    </header>
    <div class="modal-card-body">
      <!-- Content ... -->
      <div class="field"> <label id="label" class="label">Bezeichnung</label>
        <div class="control has-icons-right">
          <input id="alias" class="input" type="text" maxlength="25">
          <span id="alias_exclamation" class="icon is-small is-right">
            <i class="fas fa-exclamation-triangle"></i>
          </span>
        </div>
        <p id="alias_errormsg" class="help is-danger"></p>
      </div>

      <div class="field">
        <div class="control checkboxes">
          <label for="smscheckbox" class="checkbox"><input id="smscheckbox" type="checkbox" /><span> SMS Alarmierung aktiv</span></label>
        </div>
      </div>

      <div class="field">
        <label class="label">Alarmnummer (SMS)</label>
        <div class="control has-icons-right">
          <input id="smsnumber" class="input" type="text" maxlength="16"> <span id="smsnumber_exclamation" class="icon is-small is-right">
            <i class="fas fa-exclamation-triangle"></i>
          </span>
        </div>
        <p id="smsnumber_errormsg" class="help is-danger"></p>
      </div>

      <div class="field">
        <div class="control checkboxes">
          <label for="emailcheckbox" class="checkbox"><input id="emailcheckbox" type="checkbox" /><span> E-Mail Alarmierung aktiv</span></label>
        </div>
      </div>

      <div class="field">
        <label class="label">Alarm E-Mail(s) (mehrere durch Komma getrennt)</label>
        <div class="control has-icons-right">
          <input id="email" class="input" type="text" maxlength="100"> <span id="email_exclamation" class="icon is-small is-right">
            <i class="fas fa-exclamation-triangle"></i>
          </span>
        </div>
        <p id="email_errormsg" class="help is-danger"></p>
      </div>

      <div class="field">
        <label class="label">Koordination Gr&uuml;ne Zone (Optional)</label>
        <div class="is-size-7 mb-4">
Bei Verlassen der gr&uuml;nen Zone wird ein Alarm ausgel&ouml;st. Die gr&uuml;ne Zone wird am einfachsten definiert, indem der gew&uuml;nschte Bereich in der Kartenansicht bei gedr&uuml;ckter Ctrl-Taste markiert wird.
        </div>
        <div class="control has-icons-right">
          <input id="greenzone" class="input" type="text" maxlength="50"> <span id="greenzone_exclamation" class="icon is-small is-right">
            <i class="fas fa-exclamation-triangle"></i>
          </span>
        </div>
        <p id="greenzone_errormsg" class="help is-danger"></p>
      </div>

      <div class="is-size-7">
Device ID: <span id="deveui"></span>
      </div>
    </div>
    <footer class="modal-card-foot">
      <button id="modal-save" class="button is-success">OK</button>
      <button id="modal-close" class="button">Cancel</button>
    </footer>
  </div>
</div>

<div id="cart" class="modal">
  <div class="modal-background"></div>
  <div class="modal-card">
    <header class="modal-card-head">
      <p class="modal-card-title">Abo verl&auml;ngern</p>
    </header>
    <p id="charge_data" hidden>0</p>
    <div class="modal-card-body">
      <div id="abos_verlaengern">

      </div>
      <div>
        <div class="mt-4" id="card-element">

        </div>

        
        <div class="message is-danger mt-4" id="card-errors-article" role="alert">
          <div class="message-body" id="card-errors">
          </div>
        </div>
      </div>
    </div>
    <footer class="modal-card-foot">

      <button id="cart-pay" class="button is-success">Bezahlen</button>
      <button id="cart-close" class="button">Cancel</button>
    </footer>
  </div>
</div>

<div id="payment_notifier" class="modal">
  <div class="modal-background"></div>
  <div class="modal-card">
    <header class="modal-card-head">
      <p class="modal-card-title">Info: Bezahlung durchgef&uuml;hrt</p>
    </header>
    <div class="modal-card-body">
      <div class="message is-info">
        <div class="message-body">
Sie haben eine Abo Verl&auml;ngerung bezahlt, besten Dank!

Sie erhalten eine E-Mail, sobald die Zahlung erfolgreich abgeschlossen ist.
        </div>
      </div>
    </div>
    <footer class="modal-card-foot">

      <button id="payment_notifier_close" class="button is-success">Schliessen</button>
    </footer>
  </div>
</div>

{{range .LastMetrics}}
<div class="column tracker is-full notification is-light">
  <p class="is-size-2 is-size-5-mobile has-text-centered has-text-weight-bold" ><span class="alias" id="alias_{{.Deveui}}">{{.Alias}}</span>{{ if not .Readonly }}<a class="show-modal" class="block-link"><span style="float:right;" class="icon is-size-4 is-size-5-mobile"><i class="fa fa-cog"></i></span></a>{{ end }}</p>
  <p id="smsalarmactive_{{.Deveui}}" hidden>{{.Smsalarmactive}}</p>
  <p id="smsnumber_{{.Deveui}}" hidden>{{.Smsnumber}}</p>
  <p id="emailalarmactive_{{.Deveui}}" hidden>{{.Emailalarmactive}}</p>
  <p id="email_{{.Deveui}}" hidden>{{.Email}}</p>
  <p id="greenzone_{{.Deveui}}" hidden>{{.Greenzone}}</p>
  <p id="lastmeasurement_{{.Deveui}}" class="has-text-centered">letzte Position: {{.Timestamp}}</p>
  <p id="batpercent_{{.Deveui}}" class="has-text-centered">{{.BatteryPercentHTML}}</p>
  <div id="{{.Deveui}}" class="columns mt-3">
    <p id="lat" hidden>{{.Lat}}</p>
    <p id="lon" hidden>{{.Lon}}</p>
    <div class="column is-one-quarter"></div>
    <div class="column is-half">
      <a class="block-link" href="/map.html?deveui={{.Deveui}}&alias={{.Alias}}{{ if ne .Greenzone "" }}&greenzone={{.Greenzone}}{{end}}">
        <div id="map_{{.Deveui}}" class="map"></div>
      </a>
    </div>
    <div class="column is-one-quarter"></div>
  </div>

  <div class="has-text-centered">
    <span class="is-size-6 has-text-centered">Abo aktiv bis</span>
    <span class="paid_until is-size-6 has-text-centered">{{.ActiveUntil}}</span>
  </div>
{{ if (lt .DaysUntilDeactivated 1095) }}
  <div class="has-text-centered is-size-7">
    <p class="abo_add_years_text" id="abo_add_years_text_{.Deveui}}">&nbsp;</p>
  </div>
  <div class="has-text-centered">
    <p class="abo_add_years" id="abo_add_years_{{.Deveui}}" hidden>0</p>
    <a class="block-link abo_plus is-unselectable" id="abo_plus_{{.Deveui}}">
      <span class="icon is-medium">
        <i class="fa fa-lg fa-plus"></i>
      </span>
    </a>
    <a class="block-link abo_pay is-unselectable" id="abo_{{.Deveui}}">
      <span class="icon is-medium">
        <i class="fa fa-2x fa-shopping-cart"></i>
      </span>
    </a>
    <a class="block-link abo_minus is-unselectable" id="abo_minus_{{.Deveui}}">
      <span class="icon is-medium">
        <i class="fa fa-lg fa-minus"></i>
      </span>
    </a>
  </div>
{{ end }}
</div>
{{end}}

<script src="https://cdn.jsdelivr.net/momentjs/latest/moment-with-locales.min.js"></script>
<script src="static/js/tracker.js"></script>
{{ else }}
<h4>Bitte zuerst <a href="login.html">einloggen</a></h4>
{{end}}
{{end}}
