Letters.vue 2.52 KB
Newer Older
Markus Opolka's avatar
Markus Opolka committed
1
2
3
4
<template>
 <v-container grid-list-md>
    <v-layout row wrap>
      <v-flex xs12>
5
6
7
8
9
10
        <h3>{{header}}
          <v-btn flat icon color="green" @click="reload">
            <v-progress-circular v-if="reloading" indeterminate color="grey" v-bind:size="20"></v-progress-circular>
            <v-icon v-else>cached</v-icon>
          </v-btn>
        </h3>
Markus Opolka's avatar
Markus Opolka committed
11
12
      </v-flex>

Markus Opolka's avatar
Markus Opolka committed
13
      <!-- List of all Letters -->
14
      <v-flex xs12 v-if="letters">
Markus Opolka's avatar
Markus Opolka committed
15
16
        <v-list>
          <template v-for="letter in letters">
Markus Opolka's avatar
Markus Opolka committed
17
            <v-list-tile avatar v-if="letter.valid" v-bind:key="letter.url" :to="letter.link">
Markus Opolka's avatar
Markus Opolka committed
18
              <v-list-tile-avatar>
Markus Opolka's avatar
Markus Opolka committed
19
                <v-icon grey lighten-1>mail</v-icon>
Markus Opolka's avatar
Markus Opolka committed
20
21
22
23
24
              </v-list-tile-avatar>
              <v-list-tile-content>
                <v-list-tile-title v-html="letter.name"></v-list-tile-title>
              </v-list-tile-content>
            </v-list-tile>
Markus Opolka's avatar
Markus Opolka committed
25
26
27
28
29
30
31
32
33
            <v-list-tile avatar v-else v-bind:key="letter.name" class="red darken-4">
              <v-list-tile-avatar>
                <v-icon grey lighten-1 dark>error</v-icon>
              </v-list-tile-avatar>
              <v-list-tile-content>
                <v-list-tile-title v-html="letter.name" class="white--text"></v-list-tile-title>
                <span class="white--text caption">Error while loading file</span>
              </v-list-tile-content>
            </v-list-tile>
Markus Opolka's avatar
Markus Opolka committed
34
35
36
37
            <v-divider></v-divider>
          </template>
        </v-list>
      </v-flex>
38

39
      <!-- Progress Bar -->
40
      <v-flex xs12 v-else>
41
        <v-progress-linear indeterminate color="primary"></v-progress-linear>
42
43
      </v-flex>

44
45
46
47
48
      <!-- Caching Info -->
      <v-snackbar :timeout="timeout" :top="true" :left="true" v-model="snackbar">
        Reloaded Document Cache
      </v-snackbar>

Markus Opolka's avatar
Markus Opolka committed
49
50
51
52
53
54
55
56
57
58
    </v-layout>
 </v-container>

</template>

<script>
export default {
  name: 'Letters',
  data () {
    return {
Markus Opolka's avatar
Markus Opolka committed
59
      header: 'Lettres',
60
      letters: null,
61
62
63
      reloading: false,
      timeout: 1000,
      snackbar: false
64
65
66
67
68
69
70
    }
  },
  methods: {
    reload () {
      // Trigger Backend to reload cache
      this.reloading = true
      this.$http.get('http://localhost:3000/api/metadata/reload').then(function (data) {
71
        this.load(true)
72
73
      })
    },
74
    load (snack) {
75
76
77
78
      // Initial load of metadata
      this.$http.get('http://localhost:3000/api/metadata/table').then(function (data) {
        this.letters = data.body
        this.reloading = false
79
        this.snackbar = snack
80
      })
Markus Opolka's avatar
Markus Opolka committed
81
82
83
    }
  },
  created () {
84
    this.load(false)
Markus Opolka's avatar
Markus Opolka committed
85
86
87
  }
}
</script>