pull/429/head
hunterlong 2020-02-02 17:03:12 -08:00
parent 94ac3d8299
commit 3fbf5b99f3
4 changed files with 41 additions and 36 deletions

View File

@ -7,17 +7,11 @@
</span> </span>
</h5> </h5>
<div class="row"> <div class="row">
<div class="col-md-3 col-sm-6"> <div class="col-6">
<ServiceSparkLine title="here" subtitle="Failures in 7 Days" :series="first"/> <ServiceSparkLine :title="calc(set1)" subtitle="Last Day Latency" :series="set1"/>
</div> </div>
<div class="col-md-3 col-sm-6"> <div class="col-6">
<ServiceSparkLine title="here" subtitle="Failures Last Month" :series="second"/> <ServiceSparkLine :title="calc(set2)" subtitle="Last 7 Days Latency" :series="set2"/>
</div>
<div class="col-md-3 col-sm-6">
<ServiceSparkLine title="here" subtitle="Average Response" :series="third"/>
</div>
<div class="col-md-3 col-sm-6">
<ServiceSparkLine title="here" subtitle="Ping Time" :series="fourth"/>
</div> </div>
</div> </div>
</div> </div>
@ -41,28 +35,31 @@
}, },
data() { data() {
return { return {
first: [], set1: [],
second: [], set2: []
third: [],
fourth: []
} }
}, },
async created() { async created() {
this.first = await this.getFailures(7, "hour") this.set1 = await this.getHits(24, "hour")
this.second = await this.getFailures(30, "hour") this.set2 = await this.getHits(24 * 7, "day")
this.third = await this.getHits(7, "hour")
this.fourth = await this.getHits(30, "hour")
}, },
methods: { methods: {
async getHits(days, group) { async getHits(hours, group) {
const start = this.ago(3600 * 24) const start = this.ago(3600 * hours)
const data = await Api.service_hits(this.service.id, start, this.now(), group) 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) { calc (s) {
const start = this.ago(3600 * 24) let data = s[0].data
const data = await Api.service_failures(this.service.id, start, this.now()) let total = 0
return [data] data.forEach((f) => {
total += f.y
});
total = total / data.length
return total.toFixed(0) + "ms Average"
} }
} }
} }

View File

@ -17,6 +17,14 @@ export default {
type: String, type: String,
} }
}, },
watch: {
title () {
},
subtitle () {
}
},
data() { data() {
return { return {
chartOpts: { chartOpts: {
@ -41,7 +49,7 @@ export default {
enabled: false enabled: false
}, },
title: { title: {
text: "title", text: this.title,
offsetX: 0, offsetX: 0,
style: { style: {
fontSize: '28px', fontSize: '28px',
@ -49,7 +57,7 @@ export default {
} }
}, },
subtitle: { subtitle: {
text: "subtitle", text: this.subtitle,
offsetX: 0, offsetX: 0,
style: { style: {
fontSize: '14px', fontSize: '14px',

View File

@ -43,14 +43,12 @@
<td><input v-model="service.check_interval" type="number" style="width: 35pt"></td> <td><input v-model="service.check_interval" type="number" style="width: 35pt"></td>
<td><input v-model="service.timeout" type="number" style="width: 35pt"></td> <td><input v-model="service.timeout" type="number" style="width: 35pt"></td>
<td>{{service.type}}</td> <td>{{service.type}}</td>
<td><button @click.prevent="addService(service)" v-bind:disabled="service.added" class="btn btn-sm btn-outline-primary">Add</button></td> <td><button @click.prevent="addService(service)" v-bind:disabled="service.added" :disabled="service.added" class="btn btn-sm btn-outline-primary">Add</button></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>
{{out}}
<div class="col-12"> <div class="col-12">
<button @click.prevent="updateIntegration" type="submit" class="btn btn-block btn-info">Fetch Services</button> <button @click.prevent="updateIntegration" type="submit" class="btn btn-block btn-info">Fetch Services</button>
</div> </div>
@ -83,18 +81,18 @@
async addService(s) { 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 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) const out = await Api.service_create(data)
window.console.log(out) const services = await Api.services()
this.$store.commit('setServices', services)
s.added = true s.added = true
}, },
async updateIntegration() { async updateIntegration() {
const i = this.integration const i = this.integration
const data = {name: i.name, enabled: i.enabled, fields: i.fields} const data = {name: i.name, enabled: i.enabled, fields: i.fields}
this.out = data this.out = data
const out = await Api.integration_save(data) const out = await Api.integration_save(data)
if (out != null) { if (out != null) {
this.services = out this.services = out
} }
window.console.log(out)
const integrations = await Api.integrations() const integrations = await Api.integrations()
this.$store.commit('setIntegrations', integrations) this.$store.commit('setIntegrations', integrations)
} }

View File

@ -3,7 +3,7 @@
<h1 class="text-black-50 mt-5"> <h1 class="text-black-50 mt-5">
{{user.id ? `Update ${user.username}` : "Create User"}} {{user.id ? `Update ${user.username}` : "Create User"}}
<button @click="removeEdit" v-if="user.id" class="mt-3 btn float-right btn-danger btn-sm">Close</button></h1> <button @click.prevent="removeEdit" v-if="user.id" class="mt-3 btn float-right btn-danger btn-sm">Close</button></h1>
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
@ -69,7 +69,7 @@
}, },
data () { data () {
return { return {
loading: false, loading: false,
user: { user: {
username: "", username: "",
admin: false, admin: false,
@ -81,7 +81,9 @@
}, },
watch: { watch: {
in_user() { in_user() {
this.user = this.in_user const u = this.in_user
delete u.password
this.user = u
} }
}, },
methods: { methods: {