<template>
  <CMyPage img="" title="Import Data" keywords="" description="">
    <div class="q-ma-sm">
      <q-toggle v-model="caricaDatiToggle" @click="caricadati()" label="Carica Dati"></q-toggle>
      <br>
      <q-toggle v-model="importasulserver" label="Importa sul Server"></q-toggle>
      <q-toggle v-model="skipfirstrow" label="Salta la prima riga"></q-toggle>
      <q-toggle v-model="checkAggiornaQta" label="Aggiorna Quantità in Magazzino"></q-toggle>
      <q-select :behavior="$q.platform.is.ios === true ? 'dialog' : 'menu'" rounded outlined v-model="cosafare"
        :options="ListaCmd" label="Operazione" emit-value map-options>
      </q-select>
      <label class="text-reader">
        <input type="file" @change="loadTextFromFile" />
      </label>
      <br>

      <br>
      <q-btn v-if="cosafare === shared_consts.Cmd.PRODUCTS" label="Importa Prodotti" @click="eseguiCmdProduct"></q-btn>
      <q-btn v-else-if="cosafare === shared_consts.Cmd.PRODUCTS_V2" label="Importa Prodotti Versione 2" @click="eseguiCmdProduct"></q-btn>
      <q-btn v-else-if="cosafare === shared_consts.Cmd.INVENTARIO" label="Importa Inventario" @click="eseguiCmdInventario"></q-btn>
      <q-btn v-else-if="cosafare === shared_consts.Cmd.MACRO_DESCRELINKSITOWEB" label="1) Importa Descrizione e Link (GruppoMacro)" @click="eseguiCmdCatalogoJson"></q-btn>
      <q-btn v-else-if="cosafare === shared_consts.Cmd.MACRO_RANKING" label="2) Importa Ranking JSON" @click="eseguiCmdCatalogoJson"></q-btn>
      <q-btn v-else-if="cosafare === shared_consts.Cmd.MACRO_CATALOGO_JSON" label="3) Importa Catalogo JSON" @click="eseguiCmdCatalogoJson"></q-btn>
      <q-btn v-else label="Esegui" @click="eseguiCmd"></q-btn>
      <br>
      <q-btn label="Genera HTML Province Territoriali" @click="createProvLink"></q-btn>


      <br><br>

      <div>{{ risraw }}</div>

      <div v-if="risultato" v-html="risultato.substring(0, 1000)"></div>
      <br>
      <br>
    </div>
  </CMyPage>
</template>
<script lang="ts" src="./importdata.ts">
</script>

<style lang="scss" scoped>
@import './importdata.scss';
</style>
