aboutsummaryrefslogtreecommitdiff
path: root/viewer/src/views/SplashScreen.vue
blob: dcb845d92a97e33f3c4c1b228b755637a90d6982 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<template>
  <b-loading v-if="isLoading" active />
  <div v-else-if="markdown" :class="$style.splashscreen" class="scrollbar">
    <Markdown :style="config.style" class="flex-grow-1" :markdown="markdown" />
    <b-button size="is-large" :label="buttonAcknowledgeLabel" @click="validation" />
  </div>
</template>

<script lang="ts">
import { SplashScreenConfig } from "@/@types/splashscreen";
import { Markdown } from "@/components/async";
import FetchWithCheck from "@/services/fetchWithCheck";
import { TranslateResult } from "vue-i18n";
import { Component, Emit, Vue } from "vue-property-decorator";

@Component({
  components: {
    Markdown,
  },
})
export default class SplashScreen extends Vue {
  isLoading: boolean = true;
  markdown: string | null = null;

  get config(): SplashScreenConfig {
    return this.$uiStore.splashScreenConfig!;
  }

  created() {
    this.fetchMarkdown();
  }

  fetchMarkdown() {
    FetchWithCheck.get(`${process.env.VUE_APP_DATA_URL}${this.config.resource}?${this.config.acknowledgmentKey ?? ""}`)
      .then(response => response.text())
      .then(text => (this.markdown = text))
      .finally(() => (this.isLoading = false))
      .catch(this.displayError);
  }

  displayError(reason: any) {
    this.$buefy.snackbar.open({
      message: `${reason}`,
      actionText: this.$t("snack.retry"),
      position: "is-top",
      type: "is-danger",
      indefinite: true,
      onAction: this.fetchMarkdown,
    });
  }

  get buttonAcknowledgeLabel(): TranslateResult {
    return this.config.buttonAcknowledgeLabel ?? this.$t("splashScreen.button.acknowledge");
  }

  @Emit()
  validation() {}
}
</script>

<style lang="scss" module>
.splashscreen {
  display: flex;
  flex-flow: column;
  align-items: center;
  padding: 32px;
}
</style>