]> git.immae.eu Git - github/bastienwirtz/homer.git/blame - src/components/services/Tautulli.vue
Linting update
[github/bastienwirtz/homer.git] / src / components / services / Tautulli.vue
CommitLineData
e6c106eb
ES
1<template>
2 <Generic :item="item">
3 <template #indicator>
4 <div class="notifs">
5 <strong
6 v-if="streams > 0"
7 class="notif playing"
8 :title="`${streams} active stream${streams > 1 ? 's' : ''}`"
9 >
10 {{ streams }}
11 </strong>
12 <i
13 v-if="error"
14 class="notif error fa-solid fa-triangle-exclamation"
15 title="Unable to fetch current status"
16 ></i>
17 </div>
18 </template>
19 </Generic>
20</template>
21
22<script>
23import service from "@/mixins/service.js";
24import Generic from "./Generic.vue";
25
26export default {
27 name: "Tautulli",
28 mixins: [service],
29 props: {
30 item: Object,
31 },
32 components: {
33 Generic,
34 },
35 data: () => ({
36 stats: null,
37 error: false,
38 }),
39 computed: {
40 streams: function () {
41 if (!this.stats) {
42 return "";
43 }
44 return this.stats.stream_count;
45 },
46 },
47 created() {
48 this.fetchStatus();
49 },
50 methods: {
51 fetchStatus: async function () {
52 try {
95d73348 53 const response = await this.fetch(
de4b7e61 54 `/api/v2?apikey=${this.item.apikey}&cmd=get_activity`,
95d73348 55 );
e6c106eb
ES
56 this.error = false;
57 this.stats = response.response.data;
58 } catch (e) {
59 this.error = true;
60 console.error(e);
61 }
95d73348 62 },
e6c106eb
ES
63 },
64};
65</script>
66
67<style scoped lang="scss">
68.notifs {
69 position: absolute;
70 color: white;
71 font-family: sans-serif;
72 top: 0.3em;
73 right: 0.5em;
74
75 .notif {
76 display: inline-block;
77 padding: 0.2em 0.35em;
78 border-radius: 0.25em;
79 position: relative;
80 margin-left: 0.3em;
81 font-size: 0.8em;
82
83 &.playing {
84 background-color: #28a9a3;
85 }
86
87 &.error {
88 border-radius: 50%;
89 aspect-ratio: 1;
90 background-color: #e51111;
91 }
92 }
93}
94</style>