{% extends "app/templates/base.tmpl" %}

{% block title %}
Debug Main Page
{% endblock %}

{% block content %}
<nav>
  <div class="title">
    <h1>ADMIN DEBUG INTERFACE</h1>
  </div>
</nav>
<main class="dashboard">
  <section class="widget">
    <fieldset>
      <legend>Error reports</legend>
      <desc><a href="/dbg/error">CLICK HERE TO SEE THE ERROR REPORTS</a> </desc>
    </fieldset>

    <fieldset>
      <legend>Download file data:</legend>
      <desc>Given an FILE-ID, downloads the file data as file. The file data is encoded using transit.</desc>
      <form method="get" action="/dbg/file/data">
        <div class="row">
          <input type="text" style="width:300px" name="file-id" placeholder="file-id" />
        </div>
        <div class="row">
          <input type="submit" name="download" value="Download" />
          <input type="submit" name="clone" value="Clone" />
        </div>
      </form>
    </fieldset>

    <fieldset>
      <legend>Upload File Data:</legend>
      <desc>Create a new file on your draft projects using the file downloaded from the previous section.</desc>
      <form method="post" enctype="multipart/form-data" action="/dbg/file/data">
        <div class="row">
          <input type="file" name="file" value="" />
        </div>
        <div class="row">
          <label>Import with same id?</label>
          <input type="checkbox" name="reuseid" />
        </div>

        <div class="row">
          <input type="submit" value="Upload" />
        </div>
      </form>
    </fieldset>

    <fieldset>
      <legend>Profile Management</legend>
      <form method="post" action="/dbg/actions/resend-email-verification">
        <div class="row">
          <input type="email" name="email" placeholder="example@example.com" value="" />
        </div>

        <div class="row">
          <label for="force-verify">Are you sure?</label>
          <input id="force-verify" type="checkbox" name="force" />
          <br />
          <small>
            This is a just a security double check for prevent non intentional submits.
          </small>
        </div>

        <div class="row">
          <input type="submit" name="resend" value="Resend Verification" />
          <input type="submit" name="verify" value="Verify" />
        </div>

        <div class="row">
          <input type="submit" class="danger" name="block" value="Block" />
          <input type="submit" class="danger" name="unblock" value="Unblock" />
        </div>
      </form>
    </fieldset>



  </section>

  <section class="widget">
    <fieldset>
      <legend>Export binfile:</legend>
      <desc>Given an FILE-ID, downloads the file and optionally all
      the related libraries in a single custom formatted binary
      file.</desc>

      <form method="get" action="/dbg/file/export">
        <div class="row set-of-inputs">
          <input type="text" style="width:300px" name="file-ids" placeholder="file-id" />
          <input type="text" style="width:300px" name="file-ids" placeholder="file-id" />
          <input type="text" style="width:300px" name="file-ids" placeholder="file-id" />
          <input type="text" style="width:300px" name="file-ids" placeholder="file-id" />
        </div>

        <div class="row">
          <label>Include libraries?</label>
          <input type="checkbox" name="includelibs" />
        </div>

        <div class="row">
          <label>Embed assets?</label>
          <input type="checkbox" name="embedassets" checked/>
        </div>

        <div class="row">
          <input type="submit" name="download" value="Download" />
          <input type="submit" name="clone" value="Clone" />
        </div>
      </form>
    </fieldset>
    <fieldset>
      <legend>Import binfile:</legend>
      <desc>Import penpot file in binary
      format. If <strong>overwrite</strong> is checked, all files will
      be overwritten using the same ids found in the file instead of
      generating a new ones.</desc>

      <form method="post" enctype="multipart/form-data" action="/dbg/file/import">
        <div class="row">
          <input type="file" name="file" value="" />
        </div>

        <div class="row">
          <label>Overwrite?</label>
          <input type="checkbox" name="overwrite" />
          <br />
          <small>
            Instead of creating a new file with all relations remapped,
            reuses all ids and updates/overwrites the objects that are
            already exists on the database.
            <strong>Warning, this operation should be used with caution.</strong>
          </small>
        </div>

        <div class="row">
          <label>Migrate?</label>
          <input type="checkbox" name="migrate" />
          <br />
          <small>
            Applies the file migrations on the importation process.
          </small>
        </div>

        <div class="row">
          <input type="submit" name="upload" value="Upload" />
        </div>
      </form>
    </fieldset>
  </section>

  <section class="widget">
    <fieldset>
      <legend>Reset file version</legend>
      <desc>Allows reset file data version to a specific number/</desc>

      <form method="post" action="/dbg/actions/reset-file-version">
        <div class="row">
          <input type="text" style="width:300px" name="file-id" placeholder="file-id" />
        </div>
        <div class="row">
          <input type="number" style="width:100px" name="version" placeholder="version" value="32" />
        </div>

        <div class="row">
          <label for="force-version">Are you sure?</label>
          <input id="force-version" type="checkbox" name="force" />
          <br />
          <small>
            This is a just a security double check for prevent non intentional submits.
          </small>
        </div>


        <div class="row">
          <input type="submit" value="Submit" />
        </div>
      </form>
    </fieldset>
  </section>
</main>
{% endblock %}
