aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBastien Wirtz <bastien.wirtz@gmail.com>2021-09-14 13:38:23 -0700
committerGitHub <noreply@github.com>2021-09-14 13:38:23 -0700
commita6b72c97d03d644b4fc2f4ddfdaceb426718e6b7 (patch)
treefda0d18bf2946bbd6aab8eb1a81c19cf000f6662
parentf11b1c9dcff418a2995a1089fa91fd9e44d6fe8b (diff)
parentb2062fb60ad2845bcba8a517220ca3637e1a885b (diff)
downloadhomer-a6b72c97d03d644b4fc2f4ddfdaceb426718e6b7.tar.gz
homer-a6b72c97d03d644b4fc2f4ddfdaceb426718e6b7.tar.zst
homer-a6b72c97d03d644b4fc2f4ddfdaceb426718e6b7.zip
Merge pull request #246 from waschinski/mealie-service
Adding Mealie service
-rw-r--r--docs/configuration.md17
-rw-r--r--src/components/services/Mealie.vue97
2 files changed, 114 insertions, 0 deletions
diff --git a/docs/configuration.md b/docs/configuration.md
index a76ecb3..68711ec 100644
--- a/docs/configuration.md
+++ b/docs/configuration.md
@@ -170,3 +170,20 @@ In order to easily generate all required icon preset for the PWA to work, a tool
170```bash 170```bash
171npx vue-pwa-asset-generator -a {your_512x512_source_png} -o {your_output_folder} 171npx vue-pwa-asset-generator -a {your_512x512_source_png} -o {your_output_folder}
172``` 172```
173
174### Supported services
175
176Currently the following services are supported for showing quick infos on the card. They can be used by setting the type to one of the following values at the item.
177
178- PiHole
179- AdGuardHome
180- PaperlessNG
181- Mealie
182
183### Additional configuration
184
185#### Paperless
186For Paperless you need an API-Key which you have to store at the item in the field `apikey`.
187
188#### Mealie
189First off make sure to remove an existing `subtitle` as it will take precedence if set. Setting `type: "Mealie"` will then show the number of recipes Mealie is keeping organized or the planned meal for today if one is planned. You will have to set an API key in the field `apikey` which can be created in your Mealie installation.
diff --git a/src/components/services/Mealie.vue b/src/components/services/Mealie.vue
new file mode 100644
index 0000000..acff1fb
--- /dev/null
+++ b/src/components/services/Mealie.vue
@@ -0,0 +1,97 @@
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="meal">
24 Today: {{ meal.name }}
25 </template>
26 <template v-else-if="stats">
27 happily keeping {{ stats.totalRecipes }} recipes organized
28 </template>
29 </p>
30 </div>
31 </div>
32 <div class="tag" :class="item.tagstyle" v-if="item.tag">
33 <strong class="tag-text">#{{ item.tag }}</strong>
34 </div>
35 </div>
36 </a>
37 </div>
38 </div>
39</template>
40
41<script>
42export default {
43 name: "Mealie",
44 props: {
45 item: Object,
46 },
47 data: () => ({
48 stats: null,
49 meal: null,
50 }),
51 created() {
52 this.fetchStatus();
53 },
54 methods: {
55 fetchStatus: async function () {
56 if (this.item.subtitle != null) return; // omitting unnecessary ajax call as the subtitle is showing
57 var apikey = this.item.apikey;
58 this.meal = await fetch(`${this.item.url}/api/meal-plans/today/`, {
59 headers: {
60 "Authorization": "Bearer " + this.item.apikey,
61 "Accept": "application/json"
62 }
63 })
64 .then(function(response) {
65 if (!response.ok) {
66 throw new Error("Not 2xx response")
67 } else {
68 if (response != null) {
69 return response.json();
70 }
71 }
72 })
73 .catch((e) => console.log(e));
74 this.stats = await fetch(`${this.item.url}/api/debug/statistics/`, {
75 headers: {
76 "Authorization": "Bearer " + this.item.apikey,
77 "Accept": "application/json"
78 }
79 })
80 .then(function(response) {
81 if (!response.ok) {
82 throw new Error("Not 2xx response")
83 } else {
84 return response.json();
85 }
86 })
87 .catch((e) => console.log(e));
88 },
89 },
90};
91</script>
92
93<style scoped lang="scss">
94.media-left img {
95 max-height: 100%;
96}
97</style>