aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRobin Schneider <45321827+robinschneider@users.noreply.github.com>2021-10-07 00:15:26 +0200
committerGitHub <noreply@github.com>2021-10-07 00:15:26 +0200
commit270e522e0ee2bb9bef795251796abbfc74efbef3 (patch)
treec8a22126b6393b48b6c3bd0365befd6fd695faaf /src
parent584f2b4b32e69865d9561f1537142791710f676d (diff)
parent220c60cba04e86e782e9610aa8ef0d77e221072c (diff)
downloadhomer-270e522e0ee2bb9bef795251796abbfc74efbef3.tar.gz
homer-270e522e0ee2bb9bef795251796abbfc74efbef3.tar.zst
homer-270e522e0ee2bb9bef795251796abbfc74efbef3.zip
Merge branch 'bastienwirtz:main' into hotkey
Diffstat (limited to 'src')
-rw-r--r--src/assets/app.scss10
-rw-r--r--src/components/Service.vue5
-rw-r--r--src/components/services/AdGuardHome.vue98
-rw-r--r--src/components/services/Generic.vue33
-rw-r--r--src/components/services/Mealie.vue94
-rw-r--r--src/components/services/OpenWeather.vue135
-rw-r--r--src/components/services/PaperlessNG.vue1
-rw-r--r--src/components/services/PiHole.vue4
-rw-r--r--src/components/services/Ping.vue55
-rw-r--r--src/components/services/Radarr.vue8
-rw-r--r--src/components/services/Sonarr.vue8
11 files changed, 349 insertions, 102 deletions
diff --git a/src/assets/app.scss b/src/assets/app.scss
index 6bb5068..f2dfb37 100644
--- a/src/assets/app.scss
+++ b/src/assets/app.scss
@@ -106,7 +106,7 @@ body {
106 } 106 }
107 107
108 .first-line { 108 .first-line {
109 height: 100px; 109 min-height: 100px;
110 vertical-align: center; 110 vertical-align: center;
111 background-color: var(--highlight-primary); 111 background-color: var(--highlight-primary);
112 112
@@ -121,7 +121,7 @@ body {
121 } 121 }
122 122
123 .container { 123 .container {
124 height: 80px; 124 min-height: 80px;
125 padding: 10px 0; 125 padding: 10px 0;
126 } 126 }
127 127
@@ -140,8 +140,7 @@ body {
140 } 140 }
141 } 141 }
142 } 142 }
143 .navbar, 143 .navbar {
144 .navbar-menu {
145 background-color: var(--highlight-secondary); 144 background-color: var(--highlight-secondary);
146 145
147 a { 146 a {
@@ -153,6 +152,9 @@ body {
153 background-color: var(--highlight-hover); 152 background-color: var(--highlight-hover);
154 } 153 }
155 } 154 }
155 .navbar-menu {
156 background-color: inherit;
157 }
156 } 158 }
157 .navbar-end { 159 .navbar-end {
158 text-align: right; 160 text-align: right;
diff --git a/src/components/Service.vue b/src/components/Service.vue
index 8686759..39a9ac4 100644
--- a/src/components/Service.vue
+++ b/src/components/Service.vue
@@ -7,16 +7,13 @@ import Generic from "./services/Generic.vue";
7 7
8export default { 8export default {
9 name: "Service", 9 name: "Service",
10 components: {
11 Generic,
12 },
13 props: { 10 props: {
14 item: Object, 11 item: Object,
15 }, 12 },
16 computed: { 13 computed: {
17 component() { 14 component() {
18 const type = this.item.type || "Generic"; 15 const type = this.item.type || "Generic";
19 if (type == "Generic") { 16 if (type === "Generic") {
20 return Generic; 17 return Generic;
21 } 18 }
22 return () => import(`./services/${type}.vue`); 19 return () => import(`./services/${type}.vue`);
diff --git a/src/components/services/AdGuardHome.vue b/src/components/services/AdGuardHome.vue
index d4a2b89..16881fa 100644
--- a/src/components/services/AdGuardHome.vue
+++ b/src/components/services/AdGuardHome.vue
@@ -1,59 +1,77 @@
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="stats">
10 </figure> 10 {{ percentage }}&percnt; blocked
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 <template #indicator>
15 </figure> 15 <div class="status" :class="protection">
16 </div> 16 {{ protection }}
17 <div class="media-content"> 17 </div>
18 <p class="title is-4">{{ item.name }}</p> 18 </template>
19 <p class="subtitle is-6">{{ item.subtitle }}</p> 19 </Generic>
20 </div>
21 <div
22 v-if="status"
23 class="status"
24 v-bind:class="status.protection_enabled ? 'enabled' : 'disabled'"
25 >
26 {{ status.protection_enabled }}
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> 20</template>
37 21
38<script> 22<script>
23import Generic from "./Generic.vue";
24
39export default { 25export default {
40 name: "AdGuardHome", 26 name: "AdGuardHome",
41 props: { 27 props: {
42 item: Object, 28 item: Object,
43 }, 29 },
30 components: {
31 Generic,
32 },
44 data: () => { 33 data: () => {
45 return { 34 return {
46 status: null, 35 status: null,
36 stats: null,
47 }; 37 };
48 }, 38 },
39 computed: {
40 percentage: function () {
41 if (this.stats) {
42 return (
43 (this.stats.num_blocked_filtering * 100) /
44 this.stats.num_dns_queries
45 ).toFixed(2);
46 }
47 return "";
48 },
49 protection: function () {
50 if (this.status) {
51 return this.status.protection_enabled ? "enabled" : "disabled";
52 } else return "unknown";
53 },
54 },
49 created: function () { 55 created: function () {
50 this.fetchStatus(); 56 this.fetchStatus();
57 if (!this.item.subtitle) {
58 this.fetchStats();
59 }
51 }, 60 },
52 methods: { 61 methods: {
53 fetchStatus: async function () { 62 fetchStatus: async function () {
54 this.status = await fetch(`${this.item.url}/control/status`).then( 63 this.status = await fetch(`${this.item.url}/control/status`, {
55 (response) => response.json() 64 credentials: "include",
56 ); 65 })
66 .then((response) => response.json())
67 .catch((e) => console.log(e));
68 },
69 fetchStats: async function () {
70 this.stats = await fetch(`${this.item.url}/control/stats`, {
71 credentials: "include",
72 })
73 .then((response) => response.json())
74 .catch((e) => console.log(e));
57 }, 75 },
58 }, 76 },
59}; 77};
@@ -79,6 +97,12 @@ export default {
79 box-shadow: 0px 0px 4px 1px #c9404d; 97 box-shadow: 0px 0px 4px 1px #c9404d;
80 } 98 }
81 99
100 &.unknown:before {
101 background-color: #c9c740;
102 border-color: #ccc935;
103 box-shadow: 0px 0px 4px 1px #c9c740;
104 }
105
82 &:before { 106 &:before {
83 content: " "; 107 content: " ";
84 display: inline-block; 108 display: inline-block;
diff --git a/src/components/services/Generic.vue b/src/components/services/Generic.vue
index 08bd3f6..af65a8c 100644
--- a/src/components/services/Generic.vue
+++ b/src/components/services/Generic.vue
@@ -8,22 +8,27 @@
8 <a :href="item.url" :target="item.target" rel="noreferrer"> 8 <a :href="item.url" :target="item.target" rel="noreferrer">
9 <div class="card-content"> 9 <div class="card-content">
10 <div :class="mediaClass"> 10 <div :class="mediaClass">
11 <div v-if="item.logo" class="media-left"> 11 <slot name="icon">
12 <figure class="image is-48x48"> 12 <div v-if="item.logo" class="media-left">
13 <img :src="item.logo" :alt="`${item.name} logo`" /> 13 <figure class="image is-48x48">
14 </figure> 14 <img :src="item.logo" :alt="`${item.name} logo`" />
15 </div> 15 </figure>
16 <div v-if="item.icon" class="media-left"> 16 </div>
17 <figure class="image is-48x48"> 17 <div v-if="item.icon" class="media-left">
18 <i style="font-size: 35px" :class="['fa-fw', item.icon]"></i> 18 <figure class="image is-48x48">
19 </figure> 19 <i style="font-size: 35px" :class="['fa-fw', item.icon]"></i>
20 </div> 20 </figure>
21 </div>
22 </slot>
21 <div class="media-content"> 23 <div class="media-content">
22 <p class="title is-4">{{ item.name }}</p> 24 <slot name="content">
23 <p class="subtitle is-6" v-if="item.subtitle"> 25 <p class="title is-4">{{ item.name }}</p>
24 {{ item.subtitle }} 26 <p class="subtitle is-6" v-if="item.subtitle">
25 </p> 27 {{ item.subtitle }}
28 </p>
29 </slot>
26 </div> 30 </div>
31 <slot name="indicator" class="indicator"></slot>
27 </div> 32 </div>
28 <div class="tag" :class="item.tagstyle" v-if="item.tag"> 33 <div class="tag" :class="item.tagstyle" v-if="item.tag">
29 <strong class="tag-text">#{{ item.tag }}</strong> 34 <strong class="tag-text">#{{ item.tag }}</strong>
diff --git a/src/components/services/Mealie.vue b/src/components/services/Mealie.vue
new file mode 100644
index 0000000..790a9b1
--- /dev/null
+++ b/src/components/services/Mealie.vue
@@ -0,0 +1,94 @@
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"> Today: {{ meal.name }} </template>
24 <template v-else-if="stats">
25 happily keeping {{ stats.totalRecipes }} recipes organized
26 </template>
27 </p>
28 </div>
29 </div>
30 <div class="tag" :class="item.tagstyle" v-if="item.tag">
31 <strong class="tag-text">#{{ item.tag }}</strong>
32 </div>
33 </div>
34 </a>
35 </div>
36 </div>
37</template>
38
39<script>
40export default {
41 name: "Mealie",
42 props: {
43 item: Object,
44 },
45 data: () => ({
46 stats: null,
47 meal: null,
48 }),
49 created() {
50 this.fetchStatus();
51 },
52 methods: {
53 fetchStatus: async function () {
54 if (this.item.subtitle != null) return; // omitting unnecessary ajax call as the subtitle is showing
55 this.meal = await fetch(`${this.item.url}/api/meal-plans/today/`, {
56 headers: {
57 Authorization: "Bearer " + this.item.apikey,
58 Accept: "application/json",
59 },
60 })
61 .then(function (response) {
62 if (!response.ok) {
63 throw new Error("Not 2xx response");
64 } else {
65 if (response != null) {
66 return response.json();
67 }
68 }
69 })
70 .catch((e) => console.log(e));
71 this.stats = await fetch(`${this.item.url}/api/debug/statistics/`, {
72 headers: {
73 Authorization: "Bearer " + this.item.apikey,
74 Accept: "application/json",
75 },
76 })
77 .then(function (response) {
78 if (!response.ok) {
79 throw new Error("Not 2xx response");
80 } else {
81 return response.json();
82 }
83 })
84 .catch((e) => console.log(e));
85 },
86 },
87};
88</script>
89
90<style scoped lang="scss">
91.media-left img {
92 max-height: 100%;
93}
94</style>
diff --git a/src/components/services/OpenWeather.vue b/src/components/services/OpenWeather.vue
new file mode 100644
index 0000000..09ff76a
--- /dev/null
+++ b/src/components/services/OpenWeather.vue
@@ -0,0 +1,135 @@
1<template>
2 <div>
3 <div class="card" :class="item.class">
4 <a
5 :href="`https://openweathermap.org/city/${id}`"
6 :target="item.target"
7 rel="noreferrer"
8 >
9 <div class="card-content">
10 <div class="media">
11 <div v-if="icon" class="media-left" :class="item.background">
12 <figure class="image is-48x48">
13 <img
14 :src="`https://openweathermap.org/img/wn/${icon}@2x.png`"
15 :alt="conditions"
16 :title="conditions"
17 />
18 </figure>
19 </div>
20 <div class="media-content">
21 <p v-if="error" class="error">Data could not be retrieved</p>
22 <div v-else>
23 <p class="title is-4">{{ name }}</p>
24 <p class="subtitle is-6">
25 {{ temp | tempSuffix(this.item.units) }}
26 </p>
27 </div>
28 </div>
29 </div>
30 <div class="tag" :class="item.tagstyle" v-if="item.tag">
31 <strong class="tag-text">#{{ item.tag }}</strong>
32 </div>
33 </div>
34 </a>
35 </div>
36 </div>
37</template>
38
39<script>
40export default {
41 name: "OpenWeather",
42 props: {
43 item: Object,
44 },
45 data: () => ({
46 id: null,
47 icon: null,
48 name: null,
49 temp: null,
50 conditions: null,
51 error: false,
52 }),
53 created() {
54 this.fetchWeather();
55 },
56 methods: {
57 fetchWeather: async function () {
58 let locationQuery;
59
60 // Use location ID if specified, otherwise retrieve value from location (name).
61 if (this.item.locationId) {
62 locationQuery = `id=${this.item.locationId}`;
63 } else {
64 locationQuery = `q=${this.item.location}`;
65 }
66
67 const url = `https://api.openweathermap.org/data/2.5/weather?${locationQuery}&appid=${this.item.apiKey}&units=${this.item.units}`;
68 fetch(url)
69 .then((response) => {
70 if (!response.ok) {
71 throw Error(response.statusText);
72 }
73 return response.json();
74 })
75 .then((weather) => {
76 this.id = weather.id;
77 this.name = weather.name;
78 this.temp = parseInt(weather.main.temp).toFixed(1);
79 this.icon = weather.weather[0].icon;
80 this.conditions = weather.weather[0].description;
81 })
82 .catch((e) => {
83 console.log(e);
84 this.error = true;
85 });
86 },
87 },
88 filters: {
89 tempSuffix: function (value, type) {
90 if (!value) return "";
91
92 let unit = "K";
93 if (type === "metric") {
94 unit = "°C";
95 } else if (type === "imperial") {
96 unit = "°F";
97 }
98 return `${value} ${unit}`;
99 },
100 },
101};
102</script>
103
104<style scoped lang="scss">
105// Add a border around the weather image.
106// Otherwise the image is not always distinguishable.
107.media-left {
108 &.circle,
109 &.square {
110 background-color: #e4e4e4;
111 }
112
113 &.circle {
114 border-radius: 90%;
115 }
116
117 img {
118 max-height: 100%;
119 }
120}
121
122.error {
123 color: #de0000;
124}
125
126// Change background color in dark mode.
127.is-dark {
128 .media-left {
129 &.circle,
130 &.square {
131 background-color: #909090;
132 }
133 }
134}
135</style>
diff --git a/src/components/services/PaperlessNG.vue b/src/components/services/PaperlessNG.vue
index 4fb31f8..af13317 100644
--- a/src/components/services/PaperlessNG.vue
+++ b/src/components/services/PaperlessNG.vue
@@ -59,6 +59,7 @@ export default {
59 } 59 }
60 const url = `${this.item.url}/api/documents/`; 60 const url = `${this.item.url}/api/documents/`;
61 this.api = await fetch(url, { 61 this.api = await fetch(url, {
62 credentials: "include",
62 headers: { 63 headers: {
63 Authorization: "Token " + this.item.apikey, 64 Authorization: "Token " + this.item.apikey,
64 }, 65 },
diff --git a/src/components/services/PiHole.vue b/src/components/services/PiHole.vue
index 7042a7b..87f7090 100644
--- a/src/components/services/PiHole.vue
+++ b/src/components/services/PiHole.vue
@@ -64,7 +64,9 @@ export default {
64 methods: { 64 methods: {
65 fetchStatus: async function () { 65 fetchStatus: async function () {
66 const url = `${this.item.url}/api.php`; 66 const url = `${this.item.url}/api.php`;
67 this.api = await fetch(url) 67 this.api = await fetch(url, {
68 credentials: "include",
69 })
68 .then((response) => response.json()) 70 .then((response) => response.json())
69 .catch((e) => console.log(e)); 71 .catch((e) => console.log(e));
70 }, 72 },
diff --git a/src/components/services/Ping.vue b/src/components/services/Ping.vue
index 8a9b7a4..6fd3ec5 100644
--- a/src/components/services/Ping.vue
+++ b/src/components/services/Ping.vue
@@ -1,46 +1,24 @@
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 v-if="status" class="status" :class="status">
5 <div class="card-content"> 5 {{ status }}
6 <div class="media"> 6 </div>
7 <div v-if="item.logo" class="media-left"> 7 </template>
8 <figure class="image is-48x48"> 8 </Generic>
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 </p>
24 </div>
25 <div v-if="status" class="status" :class="status">
26 {{ status }}
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> 9</template>
37 10
38<script> 11<script>
12import Generic from "./Generic.vue";
13
39export default { 14export default {
40 name: "Ping", 15 name: "Ping",
41 props: { 16 props: {
42 item: Object, 17 item: Object,
43 }, 18 },
19 components: {
20 Generic,
21 },
44 data: () => ({ 22 data: () => ({
45 status: null, 23 status: null,
46 }), 24 }),
@@ -50,7 +28,11 @@ export default {
50 methods: { 28 methods: {
51 fetchStatus: async function () { 29 fetchStatus: async function () {
52 const url = `${this.item.url}`; 30 const url = `${this.item.url}`;
53 fetch(url, { method: "HEAD", cache: "no-cache" }) 31 fetch(url, {
32 method: "HEAD",
33 cache: "no-cache",
34 credentials: "include",
35 })
54 .then((response) => { 36 .then((response) => {
55 if (!response.ok) { 37 if (!response.ok) {
56 throw Error(response.statusText); 38 throw Error(response.statusText);
@@ -66,9 +48,6 @@ export default {
66</script> 48</script>
67 49
68<style scoped lang="scss"> 50<style scoped lang="scss">
69.media-left img {
70 max-height: 100%;
71}
72.status { 51.status {
73 font-size: 0.8rem; 52 font-size: 0.8rem;
74 color: var(--text-title); 53 color: var(--text-title);
diff --git a/src/components/services/Radarr.vue b/src/components/services/Radarr.vue
index 9d38292..a9cdedf 100644
--- a/src/components/services/Radarr.vue
+++ b/src/components/services/Radarr.vue
@@ -70,7 +70,9 @@ export default {
70 }, 70 },
71 methods: { 71 methods: {
72 fetchConfig: function () { 72 fetchConfig: function () {
73 fetch(`${this.item.url}/api/health?apikey=${this.item.apikey}`) 73 fetch(`${this.item.url}/api/health?apikey=${this.item.apikey}`, {
74 credentials: "include",
75 })
74 .then((response) => { 76 .then((response) => {
75 if (response.status != 200) { 77 if (response.status != 200) {
76 throw new Error(response.statusText); 78 throw new Error(response.statusText);
@@ -92,7 +94,9 @@ export default {
92 console.error(e); 94 console.error(e);
93 this.serverError = true; 95 this.serverError = true;
94 }); 96 });
95 fetch(`${this.item.url}/api/queue?apikey=${this.item.apikey}`) 97 fetch(`${this.item.url}/api/queue?apikey=${this.item.apikey}`, {
98 credentials: "include",
99 })
96 .then((response) => { 100 .then((response) => {
97 if (response.status != 200) { 101 if (response.status != 200) {
98 throw new Error(response.statusText); 102 throw new Error(response.statusText);
diff --git a/src/components/services/Sonarr.vue b/src/components/services/Sonarr.vue
index 7851b6b..0270255 100644
--- a/src/components/services/Sonarr.vue
+++ b/src/components/services/Sonarr.vue
@@ -70,7 +70,9 @@ export default {
70 }, 70 },
71 methods: { 71 methods: {
72 fetchConfig: function () { 72 fetchConfig: function () {
73 fetch(`${this.item.url}/api/health?apikey=${this.item.apikey}`) 73 fetch(`${this.item.url}/api/health?apikey=${this.item.apikey}`, {
74 credentials: "include",
75 })
74 .then((response) => { 76 .then((response) => {
75 if (response.status != 200) { 77 if (response.status != 200) {
76 throw new Error(response.statusText); 78 throw new Error(response.statusText);
@@ -92,7 +94,9 @@ export default {
92 console.error(e); 94 console.error(e);
93 this.serverError = true; 95 this.serverError = true;
94 }); 96 });
95 fetch(`${this.item.url}/api/queue?apikey=${this.item.apikey}`) 97 fetch(`${this.item.url}/api/queue?apikey=${this.item.apikey}`, {
98 credentials: "include",
99 })
96 .then((response) => { 100 .then((response) => {
97 if (response.status != 200) { 101 if (response.status != 200) {
98 throw new Error(response.statusText); 102 throw new Error(response.statusText);