@include(snippets/header)
<div class="settings">
  <h1>Settings</h1>
  <h2>Site settings</h2>
    <div class="themes">
      <h3>Themes</h3>
        @each(themes as t)
          <a href="/theme/{{ t }}">{{ t }}</a>
        @endeach
    </div>
    <div class="modes">
      <h3>Modes</h3>
      <span>Current: {{ modes[session.mode] ?? 'sfw' }}</span>
      @for(let i = 0; i < modes.length; i++)
        <a class="dropdown-item" href="/mode/{{ i }}">{{ modes[i] }}</a>
      @endfor
    </div>
  <h2>Account</h2>
  <table class="table">
    <tbody>
      <tr>
        <td>UserID</td>
        <td>{{ session.id }}</td>
      </tr>
      <tr>
        <td>admin</td>
        <td>{{ !!session.admin }}</td>
      </tr>
      <tr>
        <td>username</td>
        <td>{!! session.user !!}</td>
      </tr>
      <tr>
        <td>@if(session.avatar)<a href="/{{ session.avatar }}"><img id="img_avatar" src="/t/{{ session.avatar }}.webp"></a>@endif</td>
        <td><input type="text" class="input" name="i_avatar" value="{{ session.avatar }}"></td>
      </tr>
      <tr>
        <td>mail</td>
        <td><input type="text" class="input" name="i_mail" placeholder="hashed" disabled></td>
      </tr>
      <tr>
        <td colspan="2"><input type="submit" id="s_avatar" value="save"></td>
      </tr>
    </tbody>
  </table>
  <h2>Sessions</h2>
  <table class="table">
    <thead>
      <tr>
        <th>&nbsp;</th>
        <th>id</th>
        <th>&nbsp;</th>
        <th>last action</th>
      </tr>
    </thead>
    <tbody>
      @each(sessions as sess)
      <tr@if(sess.id === session.sess_id) style="background-color: rgb(0, 89, 0)"@endif>
        <td>{{ sess.kmsi ? '&#9875;' : '' }}</td>
        <td tooltip="{{ sess.browser }}" flow="right">
          <p>{{ sess.id }}</p>
          <p><a href="#" onclick="alert('not yet implemented!');">logout</a></p>
        </td>
        <td>
          <p>last_used: {{ new Date(sess.last_used * 1e3).toLocaleString("de-DE") }}</p>
          <p>created_at: {{ new Date(sess.created_at * 1e3).toLocaleString("de-DE") }}</p>
        </td>
        <td><a href="{{ sess.last_action }}" target="_blank">{{ sess.last_action }}</a></td>
      </tr>
      @endeach
    </tbody>
  </table>
</div>
@include(snippets/footer)
