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