mirror of https://github.com/statping/statping
additional
parent
70276d490d
commit
8170885236
|
@ -53,7 +53,7 @@ class Api {
|
|||
}
|
||||
|
||||
async service_failures(id, start, end, limit = 999, offset = 0) {
|
||||
return axios.get('/api/services/' + id + '/failures?start=' + start + '&end=' + end + '&limit=' + limit).then(response => (response.data))
|
||||
return axios.get('/api/services/' + id + '/failures?start=' + start + '&end=' + end + '&limit=' + limit+ '&offset=' + offset).then(response => (response.data))
|
||||
}
|
||||
|
||||
async service_delete(id) {
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
<span class="badge float-right" :class="{'bg-success': service.online, 'bg-danger': !service.online }">{{service.online ? "ONLINE" : "OFFLINE"}}</span>
|
||||
|
||||
<GroupServiceFailures :service="service"/>
|
||||
|
||||
</a>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -9,19 +9,19 @@
|
|||
<p class="mb-1">{{failure.issue}}</p>
|
||||
</div>
|
||||
|
||||
<nav aria-label="page navigation example">
|
||||
<ul class="pagination">
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="#" aria-label="Previous">
|
||||
<nav v-if="total > 4" aria-label="page navigation example">
|
||||
<ul class="pagination justify-content-center">
|
||||
<li class="page-item" :class="{'disabled': page===1}">
|
||||
<a @click.prevent="gotoPage(page-1)" :disabled="page===1" class="page-link" href="#" aria-label="Previous">
|
||||
<span aria-hidden="true">«</span>
|
||||
<span class="sr-only">Previous</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="page-item"><a class="page-link" href="#">1</a></li>
|
||||
<li class="page-item"><a class="page-link" href="#">2</a></li>
|
||||
<li class="page-item"><a class="page-link" href="#">3</a></li>
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="#" aria-label="Next">
|
||||
<li v-for="n in Math.floor(total / limit)" class="page-item" :class="{'active': page === n}">
|
||||
<a @click.prevent="gotoPage(n)" class="page-link" href="#">{{n}}</a>
|
||||
</li>
|
||||
<li class="page-item" :class="{'disabled': page===Math.floor(total / limit)}">
|
||||
<a @click.prevent="gotoPage(page+1)" :disabled="page===Math.floor(total / limit)" class="page-link" href="#" aria-label="Next">
|
||||
<span aria-hidden="true">»</span>
|
||||
<span class="sr-only">Next</span>
|
||||
</a>
|
||||
|
@ -47,15 +47,25 @@ export default {
|
|||
data () {
|
||||
return {
|
||||
failures: [],
|
||||
limit: 15,
|
||||
limit: 4,
|
||||
offset: 0,
|
||||
total: this.service.stats.failures
|
||||
total: this.service.stats.failures,
|
||||
page: 1
|
||||
}
|
||||
},
|
||||
async mounted () {
|
||||
this.failures = await Api.service_failures(this.service.id, this.now(), this.now(), this.limit, this.offset)
|
||||
await this.gotoPage(1)
|
||||
},
|
||||
methods: {
|
||||
async gotoPage(page) {
|
||||
this.page = page;
|
||||
|
||||
this.offset = (page-1) * this.limit;
|
||||
|
||||
window.console.log('page', this.page, this.limit, this.offset);
|
||||
|
||||
this.failures = await Api.service_failures(this.service.id, 0, 9999999999, this.limit, this.offset)
|
||||
},
|
||||
smallText(s) {
|
||||
if (s.online) {
|
||||
return `Online, last checked ${this.ago(s.last_success)}`
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<template v-if="service">
|
||||
<div class="col-12 card mb-4" style="min-height: 280px" :class="{'offline-card': !service.online}">
|
||||
<div class="col-12 card mb-4" style="min-height: 280px;" :class="{'offline-card': !service.online}">
|
||||
<div class="card-body p-3 p-md-1 pt-md-3 pb-md-1">
|
||||
<h4 class="card-title mb-4"><router-link :to="serviceLink(service)">{{service.name}}</router-link>
|
||||
<span class="badge float-right" :class="{'badge-success': service.online, 'badge-danger': !service.online}">
|
||||
|
@ -44,13 +44,13 @@
|
|||
</div>
|
||||
|
||||
<div class="col-4">
|
||||
<button @click.prevent="openTab='incident'" class="btn btn-block btn-outline-secondary">Create Incident</button>
|
||||
<button @click.prevent="Tab('incident')" class="btn btn-block btn-outline-secondary" :class="{'text-white btn-secondary': openTab==='incident'}" >Create Incident</button>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<button @click.prevent="openTab='message'" class="btn btn-block btn-outline-secondary">Create Announcement</button>
|
||||
<button @click.prevent="Tab('message')" class="btn btn-block btn-outline-secondary" :class="{'text-white btn-secondary': openTab==='message'}">Create Announcement</button>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<button @click.prevent="openTab='failures'" class="btn btn-block btn-outline-secondary" :disabled="!service.failures">
|
||||
<button @click.prevent="Tab('failures')" class="btn btn-block btn-outline-secondary" :disabled="service.stats.failures === 0" :class="{'text-white btn-secondary': openTab==='failures'}">
|
||||
Failures <span class="badge badge-danger float-right mt-1">{{service.stats.failures}}</span></button>
|
||||
</div>
|
||||
|
||||
|
@ -121,6 +121,13 @@
|
|||
this.loaded = true
|
||||
},
|
||||
methods: {
|
||||
Tab(name) {
|
||||
if (this.openTab === name) {
|
||||
this.openTab = ''
|
||||
return
|
||||
}
|
||||
this.openTab=name;
|
||||
},
|
||||
sinceYesterday(data) {
|
||||
window.console.log(data)
|
||||
let total = 0
|
||||
|
|
|
@ -30,7 +30,7 @@ func apiNotifiersHandler(w http.ResponseWriter, r *http.Request) {
|
|||
notifiers := services.AllNotifiers()
|
||||
var notifs []*notifications.Notification
|
||||
for _, n := range notifiers {
|
||||
notifs = append(notifs, n.Select())
|
||||
notifs = append(notifs, notifications.SelectNotifier(n.Select()))
|
||||
}
|
||||
returnJson(notifs, w, r)
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ var Command = &commandLine{¬ifications.Notification{
|
|||
Delay: time.Duration(1 * time.Second),
|
||||
Icon: "fas fa-terminal",
|
||||
Host: "/bin/bash",
|
||||
Limits: 60,
|
||||
Form: []notifications.NotificationForm{{
|
||||
Type: "text",
|
||||
Title: "Shell or Bash",
|
||||
|
@ -72,14 +73,14 @@ func runCommand(app string, cmd ...string) (string, string, error) {
|
|||
|
||||
// OnFailure for commandLine will trigger failing service
|
||||
func (u *commandLine) OnFailure(s *services.Service, f *failures.Failure) error {
|
||||
msg := u.GetValue("host")
|
||||
msg := u.GetValue("var2")
|
||||
_, _, err := runCommand(u.Host, msg)
|
||||
return err
|
||||
}
|
||||
|
||||
// OnSuccess for commandLine will trigger successful service
|
||||
func (u *commandLine) OnSuccess(s *services.Service) error {
|
||||
msg := u.GetValue("host")
|
||||
msg := u.GetValue("var1")
|
||||
_, _, err := runCommand(u.Host, msg)
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ var Discorder = &discord{¬ifications.Notification{
|
|||
Delay: time.Duration(5 * time.Second),
|
||||
Host: "https://discordapp.com/api/webhooks/****/*****",
|
||||
Icon: "fab fa-discord",
|
||||
Limits: 60,
|
||||
Form: []notifications.NotificationForm{{
|
||||
Type: "text",
|
||||
Title: "discord webhooker URL",
|
||||
|
|
|
@ -127,6 +127,7 @@ var email = &emailer{¬ifications.Notification{
|
|||
Author: "Hunter Long",
|
||||
AuthorUrl: "https://github.com/hunterlong",
|
||||
Icon: "far fa-envelope",
|
||||
Limits: 30,
|
||||
Form: []notifications.NotificationForm{{
|
||||
Type: "text",
|
||||
Title: "SMTP Host",
|
||||
|
|
|
@ -48,6 +48,7 @@ var LineNotify = &lineNotifier{¬ifications.Notification{
|
|||
Author: "Kanin Peanviriyakulkit",
|
||||
AuthorUrl: "https://github.com/dogrocker",
|
||||
Icon: "far fa-bell",
|
||||
Limits: 60,
|
||||
Form: []notifications.NotificationForm{{
|
||||
Type: "text",
|
||||
Title: "Access Token",
|
||||
|
|
|
@ -48,6 +48,7 @@ var Mobile = &mobilePush{¬ifications.Notification{
|
|||
AuthorUrl: "https://github.com/hunterlong",
|
||||
Delay: time.Duration(5 * time.Second),
|
||||
Icon: "fas fa-mobile-alt",
|
||||
Limits: 30,
|
||||
Form: []notifications.NotificationForm{{
|
||||
Type: "text",
|
||||
Title: "Device Identifiers",
|
||||
|
|
|
@ -55,6 +55,7 @@ var slacker = &slack{¬ifications.Notification{
|
|||
Delay: time.Duration(10 * time.Second),
|
||||
Host: "https://webhooksurl.slack.com/***",
|
||||
Icon: "fab fa-slack",
|
||||
Limits: 60,
|
||||
Form: []notifications.NotificationForm{{
|
||||
Type: "text",
|
||||
Title: "Incoming webhooker Url",
|
||||
|
@ -118,9 +119,5 @@ func (u *slack) OnSuccess(s *services.Service) error {
|
|||
Time: utils.Now().Unix(),
|
||||
}
|
||||
msg := parseSlackMessage(s.Id, successTemplate, message)
|
||||
|
||||
fmt.Println("Sending OnSuccess message!")
|
||||
fmt.Println(msg)
|
||||
fmt.Printf("%s\n", u.Host)
|
||||
return u.sendSlack(msg)
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ var Telegram = &telegram{¬ifications.Notification{
|
|||
AuthorUrl: "https://github.com/hunterlong",
|
||||
Icon: "fab fa-telegram-plane",
|
||||
Delay: time.Duration(5 * time.Second),
|
||||
Limits: 60,
|
||||
Form: []notifications.NotificationForm{{
|
||||
Type: "text",
|
||||
Title: "Telegram API Token",
|
||||
|
|
|
@ -47,6 +47,7 @@ var Twilio = &twilio{¬ifications.Notification{
|
|||
AuthorUrl: "https://github.com/hunterlong",
|
||||
Icon: "far fa-comment-alt",
|
||||
Delay: time.Duration(10 * time.Second),
|
||||
Limits: 15,
|
||||
Form: []notifications.NotificationForm{{
|
||||
Type: "text",
|
||||
Title: "Account SID",
|
||||
|
|
|
@ -47,6 +47,7 @@ var Webhook = &webhooker{¬ifications.Notification{
|
|||
AuthorUrl: "https://github.com/hunterlong",
|
||||
Icon: "fas fa-code-branch",
|
||||
Delay: time.Duration(1 * time.Second),
|
||||
Limits: 180,
|
||||
Form: []notifications.NotificationForm{{
|
||||
Type: "text",
|
||||
Title: "HTTP Endpoint",
|
||||
|
|
|
@ -38,6 +38,22 @@ func (n *Notification) LastSent() time.Duration {
|
|||
return since
|
||||
}
|
||||
|
||||
func SelectNotifier(n *Notification) *Notification {
|
||||
notif, err := Find(n.Method)
|
||||
if err != nil {
|
||||
log.Errorln(err)
|
||||
return n
|
||||
}
|
||||
n.Host = notif.Host
|
||||
n.Username = notif.Username
|
||||
n.Password = notif.Password
|
||||
n.ApiSecret = notif.ApiSecret
|
||||
n.ApiKey = notif.ApiKey
|
||||
n.Var1 = notif.Var1
|
||||
n.Host = notif.Var2
|
||||
return n
|
||||
}
|
||||
|
||||
func (n *Notification) CanSend() bool {
|
||||
if !n.Enabled.Bool {
|
||||
return false
|
||||
|
|
Loading…
Reference in New Issue