{% extends "base.html" %} {% from "macros.jinja" import window_vars with context
%} {% block scripts %} {{ window_vars(user) }}
<script>
  {% if bleskomat_vars %}
  window.bleskomat_vars = {{ bleskomat_vars | tojson | safe }}
  {% endif %}
</script>
<script src="/bleskomat/static/js/index.js"></script>
{% endblock %} {% block page %}
<div class="row q-col-gutter-md">
  <div class="col-12 col-md-7 q-gutter-y-md">
    <q-card>
      <q-card-section>
        <q-btn unelevated color="primary" @click="formDialog.show = true"
          >Add Bleskomat</q-btn
        >
      </q-card-section>
    </q-card>

    <q-card>
      <q-card-section>
        <div class="row items-center no-wrap q-mb-md">
          <div class="col">
            <h5 class="text-subtitle1 q-my-none">Bleskomats</h5>
          </div>
        </div>
        <q-table
          dense
          flat
          :data="sortedBleskomats"
          row-key="id"
          :columns="bleskomatsTable.columns"
          :pagination.sync="bleskomatsTable.pagination"
        >
          {% raw %}
          <template v-slot:header="props">
            <q-tr :props="props">
              <q-th auto-width></q-th>
              <q-th v-for="col in props.cols" :key="col.name" :props="props">
                {{ col.label }}
              </q-th>
              <q-th auto-width></q-th>
            </q-tr>
          </template>
          <template v-slot:body="props">
            <q-tr :props="props">
              <q-td auto-width>
                <q-btn
                  flat
                  dense
                  size="xs"
                  icon="file_download"
                  color="orange"
                  @click="exportConfigFile(props.row.id)"
                >
                  <q-tooltip content-class="bg-accent"
                    >Export Configuration</q-tooltip
                  >
                </q-btn>
              </q-td>
              <q-td v-for="col in props.cols" :key="col.name" :props="props">
                {{ col.value }}
              </q-td>
              <q-td auto-width>
                <q-btn
                  flat
                  dense
                  size="xs"
                  @click="openUpdateDialog(props.row.id)"
                  icon="edit"
                  color="light-blue"
                >
                  <q-tooltip content-class="bg-accent">Edit</q-tooltip>
                </q-btn>
                <q-btn
                  flat
                  dense
                  size="xs"
                  @click="deleteBleskomat(props.row.id)"
                  icon="cancel"
                  color="pink"
                >
                  <q-tooltip content-class="bg-accent">Delete</q-tooltip>
                </q-btn>
              </q-td>
            </q-tr>
          </template>
          {% endraw %}
        </q-table>
      </q-card-section>
    </q-card>
  </div>

  <div class="col-12 col-md-5 q-gutter-y-md">
    <q-card>
      <q-card-section>
        <h6 class="text-subtitle1 q-my-none">
          {{SITE_TITLE}} Bleskomat extension
        </h6>
      </q-card-section>
      <q-card-section class="q-pa-none">
        <q-separator></q-separator>
        <q-list> {% include "bleskomat/_api_docs.html" %} </q-list>
      </q-card-section>
    </q-card>
  </div>

  <q-dialog v-model="formDialog.show" position="top" @hide="closeFormDialog">
    <q-card class="q-pa-lg q-pt-xl lnbits__dialog-card">
      <q-form @submit="sendFormData" class="q-gutter-md">
        <q-select
          filled
          dense
          emit-value
          v-model="formDialog.data.wallet"
          :options="g.user.walletOptions"
          label="Wallet *"
        >
        </q-select>
        <q-input
          filled
          dense
          v-model.trim="formDialog.data.name"
          type="text"
          label="Name *"
        ></q-input>
        <q-select
          filled
          dense
          v-model="formDialog.data.fiat_currency"
          :options="formDialog.fiatCurrencies"
          label="Fiat Currency *"
        >
        </q-select>
        <q-select
          filled
          dense
          v-model="formDialog.data.exchange_rate_provider"
          :options="formDialog.exchangeRateProviders"
          label="Exchange Rate Provider *"
        >
        </q-select>
        <q-input
          filled
          dense
          v-model.number="formDialog.data.fee"
          type="string"
          :default="0.00"
          label="Fee (%) *"
        ></q-input>
        <div class="row q-mt-lg">
          <q-btn
            v-if="formDialog.data.id"
            unelevated
            color="primary"
            type="submit"
            >Update Bleskomat</q-btn
          >
          <q-btn
            v-else
            unelevated
            color="primary"
            :disable="
                formDialog.data.wallet == null ||
                formDialog.data.name == null ||
                formDialog.data.fiat_currency == null ||
                formDialog.data.exchange_rate_provider == null ||
                formDialog.data.fee == null"
            type="submit"
            >Add Bleskomat</q-btn
          >
          <q-btn v-close-popup flat color="grey" class="q-ml-auto"
            >Cancel</q-btn
          >
        </div>
      </q-form>
    </q-card>
  </q-dialog>
</div>
{% endblock %}
