]> git.immae.eu Git - github/bastienwirtz/homer.git/blame - src/components/services/PaperlessNG.vue
Linting update
[github/bastienwirtz/homer.git] / src / components / services / PaperlessNG.vue
CommitLineData
24229b54 1<template>
b4a2db6e
BW
2 <Generic :item="item">
3 <template #content>
4 <p class="title is-4">{{ item.name }}</p>
5 <p class="subtitle is-6">
6 <template v-if="item.subtitle">
7 {{ item.subtitle }}
8 </template>
9 <template v-else-if="api">
10 happily storing {{ api.count }} documents
11 </template>
12 </p>
13 </template>
14 </Generic>
24229b54 15</template>
16
17<script>
b4a2db6e
BW
18import service from "@/mixins/service.js";
19import Generic from "./Generic.vue";
20
24229b54 21export default {
22 name: "Paperless",
b4a2db6e 23 mixins: [service],
24229b54 24 props: {
25 item: Object,
26 },
b4a2db6e
BW
27 components: {
28 Generic,
29 },
24229b54 30 data: () => ({
31 api: null,
32 }),
33 created() {
34 this.fetchStatus();
35 },
36 methods: {
37 fetchStatus: async function () {
b4a2db6e
BW
38 if (this.item.subtitle != null) return;
39
40 const apikey = this.item.apikey;
24229b54 41 if (!apikey) {
c06c0cdf 42 console.error(
de4b7e61 43 "apikey is not present in config.yml for the paperless entry!",
c06c0cdf 44 );
24229b54 45 return;
46 }
b4a2db6e 47 this.api = await this.fetch("/api/documents/", {
c06c0cdf
BW
48 headers: {
49 Authorization: "Token " + this.item.apikey,
50 },
b4a2db6e 51 }).catch((e) => console.log(e));
24229b54 52 },
53 },
54};
55</script>