<div class="ancBacAdminRecherche">
  <div>
    <div class="row" ng-if="!xgos.portal.parameters.inElastic">
      <div class="col-xs-12">
        <div class="alert alert-warning">
          La recherche rapide n'est pas activée pour ce portail.
        </div>
      </div>
    </div>

    <div ng-if="xgos.portal.parameters.inElastic">
      <div ng-if="xgos.isroot">
        <div
          class="ancBacIndexation alert"
          ng-init="showButtonsIndexation=!dossierFTI.inElasticSearch"
        >
          <div
            class="pull-right btn btn-default btn-sm"
            ng-click="showButtonsIndexation=!showButtonsIndexation"
          >
            <span ng-show="!showButtonsIndexation">
              <i class="fa fa-eye"></i> Afficher les boutons d'indexation</span
            >
            <span ng-show="showButtonsIndexation">
              <i class="fa fa-eye-slash"></i> Cacher les boutons
              d'indexation</span
            >
          </div>
          @n'apparait que pour root.
          <br />

          <div ng-show="showButtonsIndexation" style="padding-top: 15px;">
            <div></div>

            <div class="ancBacIndexationProgress">
              <div class="text-center">
                <div
                  class="btn btn-primary launchIndexation"
                  ng-click="lancerIndexationAnc()"
                  ng-disabled="indexationEncours || dossierFTI.inElasticSearch"
                >
                  Lancer l'indexation de l'application ANC
                  <small ng-if="noEfIndexing"
                    >(<i class="fa fa-warning"></i> sauf elements de
                    filiere)</small
                  >
                </div>
                <div
                  class="btn btn-primary launchRapport"
                  ng-if="dossierFTI.inElasticSearch"
                  ng-click="getEtatAllIndexByType()"
                >
                  Rapport d'indexation
                </div>

                <!-- <div class="btn btn-danger" ng-if="displayBtnIndexControlesOnly" 
                                ng-click="lancerIndexationCtrlOnly()">
                                    Index Controles Only
                                </div> -->
              </div>

              <div class="detail">
                <div class="indexationEncours" ng-if="indexationEncours">
                  <div>
                    <i class="fa fa-spinner fa-spin"></i> Indexation en cours
                  </div>
                  <div>
                    <span style="color: red">
                      Laisser cet écran ouvert pendant l'indexation.
                    </span>
                  </div>
                </div>

                <div class="sub">
                  <label>Dossiers</label>
                  <div
                    class="indexMProgress"
                    ng-if="!dossierFTI.inElasticSearch"
                  >
                    <div
                      class="indexMBar"
                      ng-class="{'indexed': indexProgress.dossiers==100 }"
                      ng-style="{'width':indexProgress.dossiers+'%'}"
                    ></div>
                  </div>
                  <div
                    class="qteIndexee"
                    ng-if="indexProgressQuantites.dossiers>=0"
                  >
                    {{ indexProgressQuantites.dossiers | number}}
                  </div>
                  <div
                    class="alreadyIndexed"
                    ng-if="dossierFTI.inElasticSearch"
                  >
                    <i class="fa fa-check"></i> Indexé
                  </div>
                  <div class="qteBrut" title="En base">
                    {{ etatIndexationGeneral.nbreDossiers}}
                  </div>
                  <div class="qteBrutIndexee" title="Indexé">
                    {{ etatIndexationGeneral.nbreDossiersIndexes}}
                  </div>
                </div>

                <div class="sub">
                  <label>Contrôles</label>
                  <div
                    class="indexMProgress"
                    ng-if="!controleFTI.inElasticSearch"
                  >
                    <div
                      class="indexMBar"
                      ng-class="{'indexed': indexProgress.controles==100 }"
                      ng-style="{'width':indexProgress.controles+'%'}"
                    ></div>
                  </div>
                  <div
                    class="qteIndexee"
                    ng-if="indexProgressQuantites.controles>=0"
                  >
                    {{ indexProgressQuantites.controles | number}}
                  </div>
                  <div
                    class="alreadyIndexed"
                    ng-if="controleFTI.inElasticSearch"
                  >
                    <i class="fa fa-check"></i> Indexé
                  </div>
                  <div class="qteBrut" title="En base">
                    {{ etatIndexationGeneral.nbreControles}}
                  </div>
                  <div class="qteBrutIndexee" title="Indexé">
                    {{ etatIndexationGeneral.nbreControlesIndexes}}
                  </div>
                </div>
                <div class="sub">
                  <label>Filières</label>
                  <div
                    class="indexMProgress"
                    ng-if="!filiereFTI.inElasticSearch"
                  >
                    <div
                      class="indexMBar"
                      ng-class="{'indexed': indexProgress.filieres==100 }"
                      ng-style="{'width':indexProgress.filieres+'%'}"
                    ></div>
                  </div>
                  <div
                    class="qteIndexee"
                    ng-if="indexProgressQuantites.filieres>=0"
                  >
                    {{ indexProgressQuantites.filieres | number}}
                  </div>
                  <div
                    class="alreadyIndexed"
                    ng-if="filiereFTI.inElasticSearch"
                  >
                    <i class="fa fa-check"></i> Indexé
                  </div>
                  <div class="qteBrut" title="En base">
                    {{ etatIndexationGeneral.nbreFilieres}}
                  </div>
                  <div class="qteBrutIndexee" title="Indexé">
                    {{ etatIndexationGeneral.nbreFilieresIndexes}}
                  </div>
                </div>
                <div class="sub">
                  <label>Association filières - dossiers</label>
                  <div
                    class="indexMProgress"
                    ng-if="!filiereElementFTI.inElasticSearch"
                  >
                    <div
                      class="indexMBar"
                      ng-class="{'indexed': indexProgress.elemsfiliere==100 }"
                      ng-style="{'width':indexProgress.elemsfiliere+'%'}"
                    ></div>
                  </div>
                  <div
                    class="qteIndexee"
                    ng-if="indexProgressQuantites.elemsfiliere>=0"
                  >
                    {{ indexProgressQuantites.elemsfiliere | number}}
                  </div>
                  <div
                    class="alreadyIndexed"
                    ng-if="filiereElementFTI.inElasticSearch"
                  >
                    <i class="fa fa-check"></i> Indexé
                  </div>
                  <div class="qteBrut" title="En base">
                    {{ etatIndexationGeneral.nbreAssociationFilDos}}
                  </div>
                  <div class="qteBrutIndexee" title="Indexé">
                    {{ etatIndexationGeneral.nbreAssociationFilDosIndexes}}
                  </div>
                </div>
                <div class="sub">
                  <label>Vidanges</label>
                  <div
                    class="indexMProgress"
                    ng-if="!vidangeFormulaireFTI.inElasticSearch"
                  >
                    <div
                      class="indexMBar"
                      ng-class="{'indexed': indexProgress.vidanges==100 }"
                      ng-style="{'width':indexProgress.vidanges+'%'}"
                    ></div>
                  </div>
                  <div
                    class="qteIndexee"
                    ng-if="indexProgressQuantites.vidanges>=0"
                  >
                    {{ indexProgressQuantites.vidanges | number}}
                  </div>
                  <div
                    class="alreadyIndexed"
                    ng-if="vidangeFormulaireFTI.inElasticSearch"
                  >
                    <i class="fa fa-check"></i> Indexé
                  </div>
                  <div class="qteBrut" title="En base">
                    {{ etatIndexationGeneral.nbreVidanges}}
                  </div>
                  <div class="qteBrutIndexee" title="Indexé">
                    {{ etatIndexationGeneral.nbreVidangesIndexes}}
                  </div>
                </div>

                <div class="sub">
                  <label>Éléments de filière </label>
                  <div
                    class="indexMProgress"
                    ng-if="!indexationEfData.toutIndexe"
                  >
                    <div
                      class="indexMBar"
                      ng-class="{'indexed': indexProgress.ef==100 }"
                      ng-style="{'width':indexProgress.ef+'%'}"
                    ></div>
                  </div>
                  <div class="qteIndexee" ng-if="indexProgressQuantites.ef>=0">
                    {{ indexProgressQuantites.ef | number}}
                  </div>
                  <div
                    class="alreadyIndexed"
                    ng-if="indexationEfData.toutIndexe"
                  >
                    <i class="fa fa-check"></i> Indexé
                  </div>
                  <div class="qteBrut" title="En base">
                    {{ etatIndexationGeneral.nbreElementsFilieres}}
                  </div>
                  <div class="qteBrutIndexee" title="Indexé">
                    {{ etatIndexationGeneral.nbreElementsFilieresIndexes}}
                  </div>
                </div>

                <div class="sub">
                  <label>Contenu des contrôles</label>
                  <div
                    class="indexMProgress"
                    ng-if="!indexationEfData.toutIndexe"
                  >
                    <div
                      class="indexMBar"
                      ng-class="{'indexed': indexProgress.json==100}"
                      ng-style="{'width':indexProgress.json+'%'}"
                    ></div>
                  </div>
                  <div
                    class="qteIndexee"
                    ng-if="indexProgressQuantites.json>=0"
                  >
                    {{ indexProgressQuantites.json | number}}
                  </div>
                  <div
                    class="alreadyIndexed"
                    ng-if="indexationEfData.toutIndexe"
                  >
                    <i class="fa fa-check"></i> Indexé
                  </div>
                  <div class="qteBrut" title="En base">
                    {{ etatIndexationGeneral.nbreContenuControles}}
                  </div>
                  <div class="qteBrutIndexee" title="Indexé">
                    {{ etatIndexationGeneral.nbreContenuControlesIndexes}}
                  </div>
                </div>
              </div>

              <!-- <div>Éléments de filière</div>
                        <div>Vidanges</div>
                        <div>Données des contrôles</div> -->
              <!-- <div>Données des contrôles {{indexProgress.ef}}</div> -->
            </div>

            <!-- <div class="btn btn-default" ng-click=pre_indexcontroles()>
                       Dossiers <span ng-if="dossierFTI.inElasticSearch"> <i class="fa fa-check"></i></span>
                    </div>


                    <div class="btn btn-default " ng-click=indexControle()>
                        Contrôles  <span ng-if="controleFTI.inElasticSearch"> <i class="fa fa-check"></i></span>
                    </div>


                    <div class="btn btn-default" ng-click="indexFiliere()">
                        Filières <span ng-if="filiereFTI.inElasticSearch"> <i class="fa fa-check"></i></span>
                    </div>



                    <div class="btn btn-default" ng-click=indexFiliereEle()>
                        Éléments de filière <span ng-if="filiereElementFTI.inElasticSearch"> <i class="fa fa-check"></i></span>
                    </div>

                    <div class="btn btn-default" ng-click=indexVidangesFormulaires()>
                        Vidanges  <span ng-if="vidangeFormulaireFTI.inElasticSearch"> <i class="fa fa-check"></i></span>
                    </div>


                    <div class="btn btn-default" ng-click=doIndexControles()>
                        <small>Contrôles/Vidanges json + éléments de filière </small><span ng-if="fosseToutesEauxFti.inElasticSearch"> <i class="fa fa-check"></i></span>
                    </div> -->

            <hr />

            <div class="btn btn-danger" ng-click="supprimeIndexationPortail()">
              Supprimer l'indexation de ce portail
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>

  <div ng-if="dossierFTI.inElasticSearch && controleFTI.inElasticSearch">
    <!-- <select ng-model="foo" ng-options="x.name for x in items" 
    options-class="{ 'is-eligible' : eligible, 'not-eligible': !eligible }"></select> -->

    <div class="row spbrow">
      <div class="col-xs-12">
        <div class="alert alert-success">
          <span>La recherche est correctement configurée</span>
          <button
            style="float:right;margin-top:-6px"
            type="button"
            class="btn btn-default"
            ng-click="visibleSearch()"
            title="{{ !showSearch ? 'Requêteur' : 'Résultat'}}"
          >
            <i
              class="fa"
              ng-class="{ 'fa-search': !showSearch , 'fa-list': showSearch  }"
            ></i>
          </button>
        </div>
      </div>
    </div>

    <h4 ng-if="nomRequeteEnCours">Requête : {{nomRequeteEnCours}}</h4>

    <div ng-show="showSearch">
      <div
        map="map"
        res="resultatElastic"
        elastic-filter
        allow-fields-configuration="true"
        place="'widget'"
        ftid="resftuid"
        fti="resfti"
        addspecial="true"
      ></div>
    </div>

    <div ng-if="!showSearch">
      <div
        fti="searchquerydb.fti"
        no-default-action="true"
        res="resultdatatable"
        map="map"
        attributes="searchquerydb.fti.attributes"
        actions="[]"
        where="false"
        sensitive="config.case"
        fullfilter="config.fullfilter"
        geojsondata="resultatElastic"
        geoj="resultatElastic"
        height="{{datatableHeight}}"
        update-in-db="false"
        table-fill-page="true"
        rendu-title-colonne="false"
        export-csv="recherche_anc.csv"
        date-format="'dd-MM-yyyy'"
        reset-filter-on-toggle="true"
        display-total-number="true"
        gcdata-datatable
      ></div>
    </div>
  </div>
</div>
