Skip to content
Snippets Groups Projects
ImportTask.vue 4.31 KiB
Newer Older
Timothee P's avatar
Timothee P committed
    <div class="imports-header">
      <div class="file-column">
        Fichiers importés
      </div>

      <div class="status-column">
Timothee P's avatar
Timothee P committed
      </div>
    </div>
    
    <div
      v-for="importFile in importsForFeatureType"
      :key="importFile.created_on"
      class="filerow"
Florent Lavelle's avatar
Florent Lavelle committed
    >
Timothee P's avatar
Timothee P committed
      <div class="file-column">
        <h4 class="ui header align-right">
          <div :data-tooltip="importFile.geojson_file_name" class="ellipsis">
            {{ importFile.geojson_file_name }}
Timothee P's avatar
Timothee P committed
          </div>
        </h4>
        <div class="sub header">
          ajouté le {{ importFile.created_on | formatDate }}
        </div>
Timothee P's avatar
Timothee P committed
      </div>
      
      <div class="status-column">
        <span
          v-if="importFile.infos"
          :data-tooltip="importFile.infos"
          class="ui icon margin-left"
Timothee P's avatar
Timothee P committed
          <i
            v-if="importFile.status === 'processing'"
            class="orange hourglass half icon"
            aria-hidden="true"
          />
          <i
            v-else-if="importFile.status === 'finished'"
            class="green check circle outline icon"
            aria-hidden="true"
          />
          <i
            v-else-if="importFile.status === 'failed'"
            class="red x icon"
            aria-hidden="true"
          />
          <i
            v-else
            class="red ban icon"
            aria-hidden="true"
          />
        </span>
        <span
          v-if="importFile.status === 'pending'"
          data-tooltip="Statut en attente. Clickez pour rafraichir."
        >
          <i
            :class="['orange icon', ready && !reloading ? 'sync' : 'hourglass half rotate']"
            aria-hidden="true"
            @click="fetchImports()"
          />
        </span>
Timothee P's avatar
Timothee P committed
      </div>
    </div>
import { mapState } from 'vuex';
leandro's avatar
leandro committed

Timothee P's avatar
Timothee P committed
    formatDate: function (value) {
Florent Lavelle's avatar
Florent Lavelle committed
      const date = new Date(value);
Florent Lavelle's avatar
Florent Lavelle committed
      return date.toLocaleDateString('fr', {
        year: 'numeric',
        month: 'long',
        day: 'numeric',
      return value.substring(0, 27) + '..';
Timothee P's avatar
Timothee P committed
  props: {
    data: {
      type: Array,
      default: null,
Timothee P's avatar
Timothee P committed
    },
    reloading: {
      type: Boolean,
      default: false,
Timothee P's avatar
Timothee P committed
    }
  },

  data() {
    return {
      open: false,
      ready: true,
    };
  },

Timothee P's avatar
Timothee P committed
  computed: {
    ...mapState('feature', ['features']),
Timothee P's avatar
Timothee P committed

    importsForFeatureType() {
      return this.data.filter((el) => el.feature_type_title === this.$route.params.feature_type_slug);
    }
Timothee P's avatar
Timothee P committed
  },

Timothee P's avatar
Timothee P committed
        console.log(newValue);
        this.ready = true;
      }
    },
  },

  methods: {
    fetchImports() {
      this.$store.dispatch(
Florent Lavelle's avatar
Florent Lavelle committed
        'feature-type/GET_IMPORTS', {
          project_slug:  this.$route.params.slug,
          feature_type: this.$route.params.feature_type_slug
        });
leandro's avatar
leandro committed
      this.$store.dispatch('feature/GET_PROJECT_FEATURES', {
        project_slug:  this.$route.params.slug,
        feature_type__slug:  this.$route.params.feature_type_slug
      }).catch((err) => {
        console.error(err);
      //* show that the action was triggered, could be improved with animation (doesn't work)
      this.ready = false;
    },
  },
};
</script>

Florent Lavelle's avatar
Florent Lavelle committed
<style scoped lang="less">
Timothee P's avatar
Timothee P committed
  border: 1px solid lightgrey;
  margin-top: 1rem;
  .imports-header {
    border-bottom: 1px solid lightgrey;
    font-weight: bold;
Timothee P's avatar
Timothee P committed
  > div {
    padding: .5em 1em;
  }
  .filerow {
    background-color: #fff;
  }
  .imports-header, .filerow {
    display: flex;

    .file-column {
      width: 80%;
Timothee P's avatar
Timothee P committed
    }
    .status-column {
      width: 20%;
Timothee P's avatar
Timothee P committed
    }
  }
}

.sync {
  cursor: pointer;
Timothee P's avatar
Timothee P committed
i.icon {
  width: 20px !important;
  height: 20px !important;
Timothee P's avatar
Timothee P committed
.rotate {
  -webkit-animation:spin 1.5s cubic-bezier(0.7, 0.3, 0, 0) infinite;
  -moz-animation:spin 1.5s cubic-bezier(0.7, 0.3, 0, 0) infinite;
  animation:spin 1.5s cubic-bezier(0.7, 0.3, 0, 0) infinite;
@-moz-keyframes spin { 100% { -moz-transform: rotate(180deg); } }
@-webkit-keyframes spin { 100% { -webkit-transform: rotate(180deg); } }
@keyframes spin { 100% { -webkit-transform: rotate(180deg); transform:rotate(180deg); } }
Florent Lavelle's avatar
Florent Lavelle committed
</style>