]>
Commit | Line | Data |
---|---|---|
1 | <template> | |
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> | |
15 | </template> | |
16 | ||
17 | <script> | |
18 | import service from "@/mixins/service.js"; | |
19 | import Generic from "./Generic.vue"; | |
20 | ||
21 | export default { | |
22 | name: "Paperless", | |
23 | mixins: [service], | |
24 | props: { | |
25 | item: Object, | |
26 | }, | |
27 | components: { | |
28 | Generic, | |
29 | }, | |
30 | data: () => ({ | |
31 | api: null, | |
32 | }), | |
33 | created() { | |
34 | this.fetchStatus(); | |
35 | }, | |
36 | methods: { | |
37 | fetchStatus: async function () { | |
38 | if (this.item.subtitle != null) return; | |
39 | ||
40 | const apikey = this.item.apikey; | |
41 | if (!apikey) { | |
42 | console.error( | |
43 | "apikey is not present in config.yml for the paperless entry!" | |
44 | ); | |
45 | return; | |
46 | } | |
47 | this.api = await this.fetch("/api/documents/", { | |
48 | headers: { | |
49 | Authorization: "Token " + this.item.apikey, | |
50 | }, | |
51 | }).catch((e) => console.log(e)); | |
52 | }, | |
53 | }, | |
54 | }; | |
55 | </script> |