BatchList.vue 2.39 KB
Newer Older
1
<template>
Bat's avatar
Bat committed
2
  <div v-title="'Import Batches'">
3
    <div class="ui vertical stripe segment">
4
5
6
7
8
9
10
11
12
13
14
      <div v-if="isLoading" :class="['ui', 'centered', 'active', 'inline', 'loader']"></div>
      <button
        class="ui left floated labeled icon button"
        @click="fetchData(previousLink)"
        :disabled="!previousLink"><i class="left arrow icon"></i> Previous</button>
      <button
        class="ui right floated right labeled icon button"
        @click="fetchData(nextLink)"
        :disabled="!nextLink">Next <i class="right arrow icon"></i></button>
      <div class="ui hidden clearing divider"></div>
      <div class="ui hidden clearing divider"></div>
15
      <table v-if="results.length > 0" class="ui unstackable table">
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
        <thead>
          <tr>
            <th>ID</th>
            <th>Launch date</th>
            <th>Jobs</th>
            <th>Status</th>
          </tr>
        </thead>
        <tbody>
          <tr v-for="result in results">
            <td>{{ result.id }}</th>
            <td>
              <router-link :to="{name: 'library.import.batches.detail', params: {id: result.id }}">
                {{ result.creation_date }}
              </router-link>
            </td>
            <td>{{ result.jobs.length }}</td>
            <td>
              <span
Eliot Berriot's avatar
Eliot Berriot committed
35
                :class="['ui', {'yellow': result.status === 'pending'}, {'red': result.status === 'errored'}, {'green': result.status === 'finished'}, 'label']">{{ result.status }}</span>
36
37
38
39
40
41
42
43
44
              </td>
            </tr>
          </tbody>
        </table>
      </div>
  </div>
</template>

<script>
Eliot Berriot's avatar
Eliot Berriot committed
45
import axios from 'axios'
46
47
import logger from '@/logging'

Eliot Berriot's avatar
Eliot Berriot committed
48
const BATCHES_URL = 'import-batches/'
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67

export default {
  components: {},
  data () {
    return {
      results: [],
      isLoading: false,
      nextLink: null,
      previousLink: null
    }
  },
  created () {
    this.fetchData(BATCHES_URL)
  },
  methods: {
    fetchData (url) {
      var self = this
      this.isLoading = true
      logger.default.time('Loading import batches')
Eliot Berriot's avatar
Eliot Berriot committed
68
      axios.get(url, {}).then((response) => {
69
70
71
72
73
74
75
76
77
78
79
80
81
82
        self.results = response.data.results
        self.nextLink = response.data.next
        self.previousLink = response.data.previous
        logger.default.timeEnd('Loading import batches')
        self.isLoading = false
      })
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
</style>