diff options
author | Andreas Waschinski <25221082+waschinski@users.noreply.github.com> | 2021-08-08 11:18:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-08 11:18:46 +0200 |
commit | a74fa3830232f761bb66c7509e088f7468d5b619 (patch) | |
tree | 3d74723467a10a194b481a2d7cf6c1b84bf921c1 /src/components/services/PaperlessNG.vue | |
parent | bebb6953cb1e5b61be000b3f2d76a27256bff3d9 (diff) | |
parent | 35926e1e6e4669e881b8f69003f97752172eb922 (diff) | |
download | homer-a74fa3830232f761bb66c7509e088f7468d5b619.tar.gz homer-a74fa3830232f761bb66c7509e088f7468d5b619.tar.zst homer-a74fa3830232f761bb66c7509e088f7468d5b619.zip |
Merge branch 'main' into patch-1
Diffstat (limited to 'src/components/services/PaperlessNG.vue')
-rw-r--r-- | src/components/services/PaperlessNG.vue | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/src/components/services/PaperlessNG.vue b/src/components/services/PaperlessNG.vue new file mode 100644 index 0000000..4fb31f8 --- /dev/null +++ b/src/components/services/PaperlessNG.vue | |||
@@ -0,0 +1,83 @@ | |||
1 | <template> | ||
2 | <div> | ||
3 | <div class="card" :class="item.class"> | ||
4 | <a :href="item.url" :target="item.target" rel="noreferrer"> | ||
5 | <div class="card-content"> | ||
6 | <div class="media"> | ||
7 | <div v-if="item.logo" class="media-left"> | ||
8 | <figure class="image is-48x48"> | ||
9 | <img :src="item.logo" :alt="`${item.name} logo`" /> | ||
10 | </figure> | ||
11 | </div> | ||
12 | <div v-if="item.icon" class="media-left"> | ||
13 | <figure class="image is-48x48"> | ||
14 | <i style="font-size: 35px" :class="['fa-fw', item.icon]"></i> | ||
15 | </figure> | ||
16 | </div> | ||
17 | <div class="media-content"> | ||
18 | <p class="title is-4">{{ item.name }}</p> | ||
19 | <p class="subtitle is-6"> | ||
20 | <template v-if="item.subtitle"> | ||
21 | {{ item.subtitle }} | ||
22 | </template> | ||
23 | <template v-else-if="api"> | ||
24 | happily storing {{ api.count }} documents | ||
25 | </template> | ||
26 | </p> | ||
27 | </div> | ||
28 | </div> | ||
29 | <div class="tag" :class="item.tagstyle" v-if="item.tag"> | ||
30 | <strong class="tag-text">#{{ item.tag }}</strong> | ||
31 | </div> | ||
32 | </div> | ||
33 | </a> | ||
34 | </div> | ||
35 | </div> | ||
36 | </template> | ||
37 | |||
38 | <script> | ||
39 | export default { | ||
40 | name: "Paperless", | ||
41 | props: { | ||
42 | item: Object, | ||
43 | }, | ||
44 | data: () => ({ | ||
45 | api: null, | ||
46 | }), | ||
47 | created() { | ||
48 | this.fetchStatus(); | ||
49 | }, | ||
50 | methods: { | ||
51 | fetchStatus: async function () { | ||
52 | if (this.item.subtitle != null) return; // omitting unnecessary ajax call as the subtitle is showing | ||
53 | var apikey = this.item.apikey; | ||
54 | if (!apikey) { | ||
55 | console.error( | ||
56 | "apikey is not present in config.yml for the paperless entry!" | ||
57 | ); | ||
58 | return; | ||
59 | } | ||
60 | const url = `${this.item.url}/api/documents/`; | ||
61 | this.api = await fetch(url, { | ||
62 | headers: { | ||
63 | Authorization: "Token " + this.item.apikey, | ||
64 | }, | ||
65 | }) | ||
66 | .then(function (response) { | ||
67 | if (!response.ok) { | ||
68 | throw new Error("Not 2xx response"); | ||
69 | } else { | ||
70 | return response.json(); | ||
71 | } | ||
72 | }) | ||
73 | .catch((e) => console.log(e)); | ||
74 | }, | ||
75 | }, | ||
76 | }; | ||
77 | </script> | ||
78 | |||
79 | <style scoped lang="scss"> | ||
80 | .media-left img { | ||
81 | max-height: 100%; | ||
82 | } | ||
83 | </style> | ||