diff options
Diffstat (limited to 'src/components/services/Medusa.vue')
-rw-r--r-- | src/components/services/Medusa.vue | 142 |
1 files changed, 58 insertions, 84 deletions
diff --git a/src/components/services/Medusa.vue b/src/components/services/Medusa.vue index 5720649..43b5651 100644 --- a/src/components/services/Medusa.vue +++ b/src/components/services/Medusa.vue | |||
@@ -1,65 +1,49 @@ | |||
1 | <template> | 1 | <template> |
2 | <div> | 2 | <Generic :item="item"> |
3 | <div class="card" :class="item.class"> | 3 | <template #indicator> |
4 | <a :href="item.url" :target="item.target" rel="noreferrer"> | 4 | <div class="notifs"> |
5 | <div class="card-content"> | 5 | <strong |
6 | <div class="media"> | 6 | v-if="config !== null && config.system.news.unread > 0" |
7 | <div v-if="item.logo" class="media-left"> | 7 | class="notif news" |
8 | <figure class="image is-48x48"> | 8 | title="News" |
9 | <img :src="item.logo" :alt="`${item.name} logo`" /> | 9 | >{{ config.system.news.unread }}</strong |
10 | </figure> | 10 | > |
11 | </div> | 11 | <strong |
12 | <div v-if="item.icon" class="media-left"> | 12 | v-if="config !== null && config.main.logs.numWarnings > 0" |
13 | <figure class="image is-48x48"> | 13 | class="notif warnings" |
14 | <i style="font-size: 35px" :class="['fa-fw', item.icon]"></i> | 14 | title="Warning" |
15 | </figure> | 15 | >{{ config.main.logs.numWarnings }}</strong |
16 | </div> | 16 | > |
17 | <div class="media-content"> | 17 | <strong |
18 | <p class="title is-4">{{ item.name }}</p> | 18 | v-if="config !== null && config.main.logs.numErrors > 0" |
19 | <p class="subtitle is-6">{{ item.subtitle }}</p> | 19 | class="notif errors" |
20 | </div> | 20 | title="Error" |
21 | <div class="notifs"> | 21 | >{{ config.main.logs.numErrors }}</strong |
22 | <strong | 22 | > |
23 | v-if="config !== null && config.system.news.unread > 0" | 23 | <strong |
24 | class="notif news" | 24 | v-if="serverError" |
25 | title="News" | 25 | class="notif errors" |
26 | >{{ config.system.news.unread }}</strong | 26 | title="Connection error to Medusa API, check url and apikey in config.yml" |
27 | > | 27 | >?</strong |
28 | <strong | 28 | > |
29 | v-if="config !== null && config.main.logs.numWarnings > 0" | 29 | </div> |
30 | class="notif warnings" | 30 | </template> |
31 | title="Warning" | 31 | </Generic> |
32 | >{{ config.main.logs.numWarnings }}</strong | ||
33 | > | ||
34 | <strong | ||
35 | v-if="config !== null && config.main.logs.numErrors > 0" | ||
36 | class="notif errors" | ||
37 | title="Error" | ||
38 | >{{ config.main.logs.numErrors }}</strong | ||
39 | > | ||
40 | <strong | ||
41 | v-if="serverError" | ||
42 | class="notif errors" | ||
43 | title="Connection error to Medusa API, check url and apikey in config.yml" | ||
44 | >?</strong | ||
45 | > | ||
46 | </div> | ||
47 | </div> | ||
48 | <div class="tag" :class="item.tagstyle" v-if="item.tag"> | ||
49 | <strong class="tag-text">#{{ item.tag }}</strong> | ||
50 | </div> | ||
51 | </div> | ||
52 | </a> | ||
53 | </div> | ||
54 | </div> | ||
55 | </template> | 32 | </template> |
56 | 33 | ||
57 | <script> | 34 | <script> |
35 | import service from "@/mixins/service.js"; | ||
36 | import Generic from "./Generic.vue"; | ||
37 | |||
58 | export default { | 38 | export default { |
59 | name: "Medusa", | 39 | name: "Medusa", |
40 | mixins: [service], | ||
60 | props: { | 41 | props: { |
61 | item: Object, | 42 | item: Object, |
62 | }, | 43 | }, |
44 | components: { | ||
45 | Generic, | ||
46 | }, | ||
63 | data: () => { | 47 | data: () => { |
64 | return { | 48 | return { |
65 | config: null, | 49 | config: null, |
@@ -71,16 +55,9 @@ export default { | |||
71 | }, | 55 | }, |
72 | methods: { | 56 | methods: { |
73 | fetchConfig: function () { | 57 | fetchConfig: function () { |
74 | fetch(`${this.item.url}/api/v2/config`, { | 58 | this.fetch("/api/v2/config", { |
75 | credentials: "include", | 59 | headers: { "X-Api-Key": this.item.apikey }, |
76 | headers: { "X-Api-Key": `${this.item.apikey}` }, | ||
77 | }) | 60 | }) |
78 | .then((response) => { | ||
79 | if (response.status != 200) { | ||
80 | throw new Error(response.statusText); | ||
81 | } | ||
82 | return response.json(); | ||
83 | }) | ||
84 | .then((conf) => { | 61 | .then((conf) => { |
85 | this.config = conf; | 62 | this.config = conf; |
86 | }) | 63 | }) |
@@ -94,35 +71,32 @@ export default { | |||
94 | </script> | 71 | </script> |
95 | 72 | ||
96 | <style scoped lang="scss"> | 73 | <style scoped lang="scss"> |
97 | .media-left img { | ||
98 | max-height: 100%; | ||
99 | } | ||
100 | .notifs { | 74 | .notifs { |
101 | position: absolute; | 75 | position: absolute; |
102 | color: white; | 76 | color: white; |
103 | font-family: sans-serif; | 77 | font-family: sans-serif; |
104 | top: 0.3em; | 78 | top: 0.3em; |
105 | right: 0.5em; | 79 | right: 0.5em; |
106 | } | 80 | .notif { |
107 | .notif { | 81 | padding-right: 0.35em; |
108 | padding-right: 0.35em; | 82 | padding-left: 0.35em; |
109 | padding-left: 0.35em; | 83 | padding-top: 0.2em; |
110 | padding-top: 0.2em; | 84 | padding-bottom: 0.2em; |
111 | padding-bottom: 0.2em; | 85 | border-radius: 0.25em; |
112 | border-radius: 0.25em; | 86 | position: relative; |
113 | position: relative; | 87 | margin-left: 0.3em; |
114 | margin-left: 0.3em; | 88 | font-size: 0.8em; |
115 | font-size: 0.8em; | 89 | &.news { |
116 | } | 90 | background-color: #777777; |
117 | .news { | 91 | } |
118 | background-color: #777777; | ||
119 | } | ||
120 | 92 | ||
121 | .warnings { | 93 | &.warnings { |
122 | background-color: #d08d2e; | 94 | background-color: #d08d2e; |
123 | } | 95 | } |
124 | 96 | ||
125 | .errors { | 97 | &.errors { |
126 | background-color: #e51111; | 98 | background-color: #e51111; |
99 | } | ||
100 | } | ||
127 | } | 101 | } |
128 | </style> | 102 | </style> |