From 3fbf5b99f358e55feb1f834ef5469ac9072f5d24 Mon Sep 17 00:00:00 2001 From: hunterlong Date: Sun, 2 Feb 2020 17:03:12 -0800 Subject: [PATCH] vue --- .../src/components/Dashboard/ServiceInfo.vue | 47 +++++++++---------- .../components/Dashboard/ServiceSparkLine.vue | 12 ++++- frontend/src/forms/Integration.vue | 10 ++-- frontend/src/forms/User.vue | 8 ++-- 4 files changed, 41 insertions(+), 36 deletions(-) diff --git a/frontend/src/components/Dashboard/ServiceInfo.vue b/frontend/src/components/Dashboard/ServiceInfo.vue index 52d16256..f7ac4629 100644 --- a/frontend/src/components/Dashboard/ServiceInfo.vue +++ b/frontend/src/components/Dashboard/ServiceInfo.vue @@ -7,17 +7,11 @@
-
- +
+
-
- -
-
- -
-
- +
+
@@ -41,28 +35,31 @@ }, data() { return { - first: [], - second: [], - third: [], - fourth: [] + set1: [], + set2: [] } }, async created() { - this.first = await this.getFailures(7, "hour") - this.second = await this.getFailures(30, "hour") - this.third = await this.getHits(7, "hour") - this.fourth = await this.getHits(30, "hour") + this.set1 = await this.getHits(24, "hour") + this.set2 = await this.getHits(24 * 7, "day") }, methods: { - async getHits(days, group) { - const start = this.ago(3600 * 24) + async getHits(hours, group) { + const start = this.ago(3600 * hours) const data = await Api.service_hits(this.service.id, start, this.now(), group) - return [data] + if (!data) { + return [{name: "None", data: []}] + } + return [{name: "Latency", data: data.data}] }, - async getFailures(days, group) { - const start = this.ago(3600 * 24) - const data = await Api.service_failures(this.service.id, start, this.now()) - return [data] + calc (s) { + let data = s[0].data + let total = 0 + data.forEach((f) => { + total += f.y + }); + total = total / data.length + return total.toFixed(0) + "ms Average" } } } diff --git a/frontend/src/components/Dashboard/ServiceSparkLine.vue b/frontend/src/components/Dashboard/ServiceSparkLine.vue index 681972dc..c4de3ce3 100644 --- a/frontend/src/components/Dashboard/ServiceSparkLine.vue +++ b/frontend/src/components/Dashboard/ServiceSparkLine.vue @@ -17,6 +17,14 @@ export default { type: String, } }, + watch: { + title () { + + }, + subtitle () { + + } + }, data() { return { chartOpts: { @@ -41,7 +49,7 @@ export default { enabled: false }, title: { - text: "title", + text: this.title, offsetX: 0, style: { fontSize: '28px', @@ -49,7 +57,7 @@ export default { } }, subtitle: { - text: "subtitle", + text: this.subtitle, offsetX: 0, style: { fontSize: '14px', diff --git a/frontend/src/forms/Integration.vue b/frontend/src/forms/Integration.vue index 2330bb67..a9059891 100644 --- a/frontend/src/forms/Integration.vue +++ b/frontend/src/forms/Integration.vue @@ -43,14 +43,12 @@ {{service.type}} - +
- {{out}} -
@@ -83,18 +81,18 @@ async addService(s) { const data = {name: s.name, type: s.type, domain: s.domain, port: s.port, check_interval: s.check_interval, timeout: s.timeout} const out = await Api.service_create(data) - window.console.log(out) + const services = await Api.services() + this.$store.commit('setServices', services) s.added = true }, async updateIntegration() { const i = this.integration const data = {name: i.name, enabled: i.enabled, fields: i.fields} this.out = data - const out = await Api.integration_save(data) + const out = await Api.integration_save(data) if (out != null) { this.services = out } - window.console.log(out) const integrations = await Api.integrations() this.$store.commit('setIntegrations', integrations) } diff --git a/frontend/src/forms/User.vue b/frontend/src/forms/User.vue index 430c190b..c5acfa67 100644 --- a/frontend/src/forms/User.vue +++ b/frontend/src/forms/User.vue @@ -3,7 +3,7 @@

{{user.id ? `Update ${user.username}` : "Create User"}} -

+
@@ -69,7 +69,7 @@ }, data () { return { - loading: false, + loading: false, user: { username: "", admin: false, @@ -81,7 +81,9 @@ }, watch: { in_user() { - this.user = this.in_user + const u = this.in_user + delete u.password + this.user = u } }, methods: {