4 <p class="title is-4">{{ item.name }}</p>
5 <p class="subtitle is-6">
6 <template v-if="item.subtitle">
15 <div v-if="status" class="status" :class="status">
23 import service from "@/mixins/service.js";
24 import Generic from "./Generic.vue";
46 headers: function () {
47 const basicAuth = `${this.item.apikey}:`;
50 Authorization: `Basic ${btoa(basicAuth)}`,
53 details: function () {
56 if (this.item.things) {
58 `${this.things.count} things (${this.things.online} Online)`,
62 if (this.item.items) {
63 details.push(`${this.items.count} items`);
66 return details.join(", ");
70 this.fetchServerStatus();
72 if (!this.item.subtitle && this.status !== "dead") {
73 this.fetchServerStats();
77 fetchServerStatus: async function () {
78 const headers = this.headers;
79 this.fetch("/rest/systeminfo", { headers })
81 if (response && response.systemInfo) this.status = "running";
82 else throw new Error();
89 fetchServerStats: async function () {
90 const headers = this.headers;
92 if (this.item.things) {
93 const data = await this.fetch("/rest/things?summary=true", {
99 this.things.count = data.length;
100 this.things.online = data.filter(
101 (e) => e.statusInfo.status === "ONLINE",
105 if (this.item.items) {
106 const data = await this.fetch("/rest/items", { headers }).catch((e) => {
110 this.items.count = data.length;
117 <style scoped lang="scss">
120 color: var(--text-title);
123 background-color: #94e185;
124 border-color: #78d965;
125 box-shadow: 0 0 5px 1px #94e185;
129 background-color: #c9404d;
130 border-color: #c42c3b;
131 box-shadow: 0 0 5px 1px #c9404d;
136 display: inline-block;
140 border: 1px solid #000;