Merge pull request #679 from statping/ui-fixes-bugs

Ui fixes bugs
pull/680/head v0.90.54
Hunter Long 2020-06-18 16:19:59 -07:00 committed by GitHub
commit 6b378039aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
43 changed files with 738 additions and 355 deletions

View File

@ -1,3 +1,7 @@
# 0.90.54 (06-17-2020)
- Fixed Slack Notifier's failure/success data saving issue
- Added additional i18n Languages (help needed!)
# 0.90.53 (06-16-2020) # 0.90.53 (06-16-2020)
- Modified most of the key's for prometheus metrics - Modified most of the key's for prometheus metrics
- Added Database Stats in prometheus metrics - Added Database Stats in prometheus metrics

View File

@ -1,6 +1,9 @@
<template> <template>
<div> <div class="card text-black-50 bg-white mb-5">
<table class="table"> <div class="card-header">Cache</div>
<div class="card-body">
<span v-if="!cache" class="text-muted">There are no cached pages yet!</span>
<table v-if="cache" class="table">
<thead> <thead>
<tr> <tr>
<th scope="col">URL</th> <th scope="col">URL</th>
@ -18,7 +21,8 @@
</tbody> </tbody>
</table> </table>
<button @click.prevent="clearCache" class="btn btn-danger btn-block">Clear Cache</button> <button v-if="cache" @click.prevent="clearCache" class="btn btn-danger btn-block">Clear Cache</button>
</div>
</div> </div>
</template> </template>

View File

@ -1,14 +1,14 @@
<template> <template>
<div class="col-12"> <div class="col-12">
<div class="card contain-card text-black-50 bg-white mb-4"> <div class="card contain-card text-black-50 bg-white mb-4">
<div class="card-header">Announcements</div> <div class="card-header">{{ $t('top_nav.announcements') }}</div>
<div class="card-body pt-0"> <div class="card-body pt-0">
<table class="table table-striped"> <table class="table table-striped">
<thead> <thead>
<tr> <tr>
<th scope="col">Title</th> <th scope="col">{{ $t('dashboard.title') }}</th>
<th scope="col" class="d-none d-md-table-cell">Service</th> <th scope="col" class="d-none d-md-table-cell">{{ $tc('dashboard.service', 1) }}</th>
<th scope="col" class="d-none d-md-table-cell">Begins</th> <th scope="col" class="d-none d-md-table-cell">{{ $t('dashboard.begins') }}</th>
<th scope="col"></th> <th scope="col"></th>
</tr> </tr>
</thead> </thead>
@ -21,8 +21,12 @@
<td class="d-none d-md-table-cell">{{niceDate(message.start_on)}}</td> <td class="d-none d-md-table-cell">{{niceDate(message.start_on)}}</td>
<td class="text-right"> <td class="text-right">
<div v-if="$store.state.admin" class="btn-group"> <div v-if="$store.state.admin" class="btn-group">
<a @click.prevent="editMessage(message, edit)" href="#" class="btn btn-outline-secondary"><i class="fas fa-exclamation-triangle"></i> Edit</a> <button @click.prevent="editMessage(message, edit)" href="#" class="btn btn-sm btn-outline-secondary">
<a @click.prevent="deleteMessage(message)" href="#" class="btn btn-danger"><font-awesome-icon icon="times" /></a> <font-awesome-icon icon="edit" />
</button>
<button @click.prevent="deleteMessage(message)" href="#" class="btn btn-sm btn-danger">
<font-awesome-icon icon="times" />
</button>
</div> </div>
</td> </td>
</tr> </tr>
@ -48,6 +52,9 @@
} }
}, },
methods: { methods: {
goto(to) {
this.$router.push(to)
},
editChange(v) { editChange(v) {
this.message = {} this.message = {}
this.edit = v this.edit = v

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="col-12"> <div class="col-12">
<div class="card contain-card text-black-50 bg-white mb-4"> <div class="card contain-card text-black-50 bg-white mb-4">
<div class="card-header">Services <div class="card-header">{{ $t('top_nav.services') }}
<router-link v-if="$store.state.admin" to="/dashboard/create_service" class="btn btn-sm btn-outline-success float-right"> <router-link v-if="$store.state.admin" to="/dashboard/create_service" class="btn btn-sm btn-outline-success float-right">
<font-awesome-icon icon="plus"/> Create <font-awesome-icon icon="plus"/> Create
</router-link> </router-link>
@ -12,14 +12,14 @@
</div> </div>
<div class="card contain-card text-black-50 bg-white mb-4"> <div class="card contain-card text-black-50 bg-white mb-4">
<div class="card-header">Groups</div> <div class="card-header">{{ $t('top_nav.groups') }}</div>
<div class="card-body pt-0"> <div class="card-body pt-0">
<table class="table"> <table class="table">
<thead> <thead>
<tr> <tr>
<th scope="col">Name</th> <th scope="col">{{ $t('dashboard.name') }}</th>
<th scope="col">Services</th> <th scope="col">{{ $tc('dashboard.service', 2) }}</th>
<th scope="col">Visibility</th> <th scope="col">{{ $t('dashboard.visibility') }}</th>
<th scope="col"></th> <th scope="col"></th>
</tr> </tr>
</thead> </thead>
@ -31,8 +31,9 @@
</td> </td>
<td>{{$store.getters.servicesInGroup(group.id).length}}</td> <td>{{$store.getters.servicesInGroup(group.id).length}}</td>
<td> <td>
<span v-if="group.public" class="badge badge-primary text-uppercase">{{ $t('public') }}</span> <span class="badge text-uppercase" :class="{'badge-primary': group.public, 'badge-secondary': !group.public}">
<span v-if="!group.public" class="badge badge-secondary text-uppercase">{{ $t('private') }}</span> {{group.public ? $t('public') : $t('private')}}
</span>
</td> </td>
<td class="text-right"> <td class="text-right">
<div v-if="$store.state.admin" class="btn-group"> <div v-if="$store.state.admin" class="btn-group">

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="col-12"> <div class="col-12">
<div class="card contain-card text-black-50 bg-white mb-4"> <div class="card contain-card text-black-50 bg-white mb-4">
<div class="card-header">Users</div> <div class="card-header">{{ $t('top_nav.users') }}</div>
<div class="card-body pt-0"> <div class="card-body pt-0">
<table class="table table-striped"> <table class="table table-striped">
<thead> <thead>

View File

@ -16,7 +16,7 @@
</span> {{service.name}} </span> {{service.name}}
</td> </td>
<td class="d-none d-md-table-cell"> <td class="d-none d-md-table-cell">
<span class="badge" :class="{'badge-primary': service.public, 'badge-secondary': !service.public}"> <span class="badge text-uppercase" :class="{'badge-primary': service.public, 'badge-secondary': !service.public}">
{{service.public ? $t('public') : $t('private')}} {{service.public ? $t('public') : $t('private')}}
</span> </span>
</td> </td>
@ -27,15 +27,16 @@
</td> </td>
<td class="text-right"> <td class="text-right">
<div class="btn-group"> <div class="btn-group">
<router-link v-if="$store.state.admin" :to="{path: `/dashboard/edit_service/${service.id}`, params: {service: service} }" class="btn btn-outline-secondary"> <button v-if="$store.state.admin" @click.prevent="goto({path: `/dashboard/edit_service/${service.id}`, params: {service: service} })" class="btn btn-sm btn-outline-secondary">
<i class="fas fa-chart-area"></i> Edit <font-awesome-icon icon="edit" />
</router-link> </button>
<router-link :to="{path: serviceLink(service), params: {service: service} }" class="btn btn-outline-secondary"> <button @click.prevent="goto({path: serviceLink(service), params: {service: service} })" class="btn btn-sm btn-outline-secondary">
<i class="fas fa-chart-area"></i> View <font-awesome-icon icon="chart-area" />
</router-link> </button>
<a v-if="$store.state.admin" @click.prevent="deleteService(service)" href="#" class="btn btn-danger"> <button v-if="$store.state.admin" @click.prevent="deleteService(service)" href="#" class="btn btn-sm btn-danger">
<font-awesome-icon icon="times" /> <font-awesome-icon v-if="!loading" icon="times" />
</a> <font-awesome-icon v-if="loading" icon="circle-notch" spin/>
</button>
</div> </div>
</td> </td>
</tr> </tr>
@ -54,6 +55,11 @@ export default {
ToggleSwitch, ToggleSwitch,
draggable draggable
}, },
data() {
return {
loading: false,
}
},
computed: { computed: {
servicesList: { servicesList: {
get () { get () {
@ -65,6 +71,9 @@ export default {
} }
}, },
methods: { methods: {
goto(to) {
this.$router.push(to)
},
async updateOrder(value) { async updateOrder(value) {
let data = []; let data = [];
value.forEach((s, k) => { value.forEach((s, k) => {
@ -76,8 +85,10 @@ export default {
async deleteService(s) { async deleteService(s) {
let c = confirm(`Are you sure you want to delete '${s.name}'?`) let c = confirm(`Are you sure you want to delete '${s.name}'?`)
if (c) { if (c) {
this.loading = true
await Api.service_delete(s.id) await Api.service_delete(s.id)
await this.update() await this.update()
this.loading = false
} }
}, },
serviceGroup(s) { serviceGroup(s) {

View File

@ -1,13 +1,22 @@
<template> <template>
<div> <div class="card text-black-50 bg-white mb-5">
<div class="card-header">Theme Editor</div>
<div class="card-body">
<div v-if="error" class="alert alert-danger mt-3" style="white-space: pre-line;">
{{error}}
</div>
<div v-if="loaded && !directory" class="jumbotron jumbotron-fluid"> <div v-if="loaded && !directory" class="jumbotron jumbotron-fluid">
<div class="text-center col-12"> <div class="text-center col-12">
<h1 class="display-5">Enable Local Assets</h1> <h1 class="display-5">Enable Local Assets</h1>
<span class="lead">Customize your status page design by enabling local assets. This will create a 'assets' directory containing all CSS.<p> <span class="lead">Customize your status page design by enabling local assets. This will create a 'assets' directory containing all CSS.<p>
<button id="enable_assets" @click.prevent="createAssets" :disabled="pending" href="#" class="btn btn-primary mt-3">Enable Local Assets</button> <button id="enable_assets" @click.prevent="createAssets" :disabled="pending" href="#" class="btn btn-primary mt-3">
<font-awesome-icon v-if="pending" icon="circle-notch" class="mr-2" spin/>{{pending ? "Creating Assets" : "Enable Local Assets"}}
</button>
</p></span> </p></span>
</div> </div>
</div> </div>
<form v-observe-visibility="visible" v-if="loaded && directory" @submit.prevent="saveAssets" :disabled="pending"> <form v-observe-visibility="visible" v-if="loaded && directory" @submit.prevent="saveAssets" :disabled="pending">
<h3>Variables</h3> <h3>Variables</h3>
<codemirror v-show="loaded" v-model="vars" ref="vars" :options="cmOptions" class="codemirrorInput"/> <codemirror v-show="loaded" v-model="vars" ref="vars" :options="cmOptions" class="codemirrorInput"/>
@ -18,8 +27,6 @@
<h3 class="mt-3">Mobile Overwrites</h3> <h3 class="mt-3">Mobile Overwrites</h3>
<codemirror v-show="loaded" v-model="mobile" ref="mobile" :options="cmOptions" class="codemirrorInput"/> <codemirror v-show="loaded" v-model="mobile" ref="mobile" :options="cmOptions" class="codemirrorInput"/>
<div v-if="error" class="alert alert-danger mt-3" style="white-space: pre-line;">{{error}}</div>
<button id="save_assets" @submit.prevent="saveAssets" type="submit" class="btn btn-primary btn-block mt-2" :disabled="pending">{{pending ? "Saving..." : "Save Style"}}</button> <button id="save_assets" @submit.prevent="saveAssets" type="submit" class="btn btn-primary btn-block mt-2" :disabled="pending">{{pending ? "Saving..." : "Save Style"}}</button>
<button id="delete_assets" v-if="directory" @click.prevent="deleteAssets" href="#" class="btn btn-danger btn-block confirm-btn" :disabled="pending">Delete Local Assets</button> <button id="delete_assets" v-if="directory" @click.prevent="deleteAssets" href="#" class="btn btn-danger btn-block confirm-btn" :disabled="pending">Delete Local Assets</button>
@ -28,6 +35,7 @@
</h6> </h6>
</form> </form>
</div> </div>
</div>
</template> </template>
<script> <script>
@ -115,7 +123,12 @@
async saveAssets() { async saveAssets() {
this.pending = true this.pending = true
const data = {base: this.base, variables: this.vars, mobile: this.mobile} const data = {base: this.base, variables: this.vars, mobile: this.mobile}
const resp = await Api.theme_save(data) let resp
try {
resp = await Api.theme_save(data)
} catch(e) {
resp = {status: 'error', error: e.response.data.error}
}
if (resp.error) { if (resp.error) {
this.error = resp.error this.error = resp.error
this.pending = false this.pending = false

View File

@ -0,0 +1,138 @@
<template>
<div>
<h2>Notifier Variables</h2>
You can insert dynamic fields within the notifier payloads for some notifiers.
<p class="mt-2">
Checkout the <a href="https://github.com/statping/statping/blob/master/types/services/struct.go">Service struct</a> and the <a href="https://github.com/statping/statping/blob/master/types/failures/struct.go">Failures struct</a> and create variables in golang template format.
</p>
<p class="mt-2">
For example, if you have <b>{{"\{\{.Service.Name\}\}"}}</b> it will return the service name.
</p>
<h2 class="mt-3">Service Variables</h2>
<table class="table">
<thead>
<tr>
<th scope="col">Variable</th>
<th scope="col">True Value</th>
</tr>
</thead>
<tbody>
<tr>
<td><kbd>{{"\{\{.Service.Id\}\}"}}</kbd></td>
<td>1</td>
</tr>
<tr>
<td><kbd>{{"\{\{.Service.Name\}\}"}}</kbd></td>
<td>Example Service</td>
</tr>
<tr>
<td><kbd>{{"\{\{.Service.Domain\}\}"}}</kbd></td>
<td>https://statping.com</td>
</tr>
<tr>
<td><kbd>{{"\{\{.Service.Port\}\}"}}</kbd></td>
<td>8080</td>
</tr>
<tr>
<td><kbd>{{"\{\{.Service.DowntimeAgo\}\}"}}</kbd></td>
<td>35 minutes ago</td>
</tr>
<tr>
<td><kbd>{{"\{\{.Service.LastStatusCode\}\}"}}</kbd></td>
<td>404</td>
</tr>
<tr>
<td><kbd>{{"\{\{.Service.FailuresLast24Hours\}\}"}}</kbd></td>
<td>38</td>
</tr>
</tbody>
<small>Additional variables within the Service struct</small>
</table>
<h2 class="mt-3">Failure Variables</h2>
<table class="table">
<thead>
<tr>
<th scope="col">Variable</th>
<th scope="col">True Value</th>
</tr>
</thead>
<tbody>
<tr>
<td><kbd>{{"\{\{.Failure.Issue\}\}"}}</kbd></td>
<td>Received 404 status code</td>
</tr>
<tr>
<td><kbd>{{"\{\{.Failure.ErrorCode\}\}"}}</kbd></td>
<td>404</td>
</tr>
<tr>
<td><kbd>{{"\{\{.Failure.Service\}\}"}}</kbd></td>
<td>1</td>
</tr>
<tr>
<td><kbd>{{"\{\{.Failure.PingTime\}\}"}}</kbd></td>
<td>12482 (microseconds)</td>
</tr>
<tr>
<td><kbd>{{"\{\{.Failure.DowntimeAgo\}\}"}}</kbd></td>
<td>35 minutes ago</td>
</tr>
<tr>
<td><kbd>{{"\{\{.Failure.CreatedAt\}\}"}}</kbd></td>
<td>2020-05-02 09:14:43.66381 +0000 UTC</td>
</tr>
</tbody>
<small>Additional variables within the Failures struct</small>
</table>
<h2 class="mt-3">Core Variables</h2>
<table class="table">
<thead>
<tr>
<th scope="col">Variable</th>
<th scope="col">True Value</th>
</tr>
</thead>
<tbody>
<tr>
<td><kbd>{{"\{\{.Core.Domain\}\}"}}</kbd></td>
<td>http://localhost:8080</td>
</tr>
<tr>
<td><kbd>{{"\{\{.Core.Name\}\}"}}</kbd></td>
<td>Statping Demo</td>
</tr>
<tr>
<td><kbd>{{"\{\{.Core.Description\}\}"}}</kbd></td>
<td>Statping will monitor your stuff!</td>
</tr>
<tr>
<td><kbd>{{"\{\{.Core.Version\}\}"}}</kbd></td>
<td>v0.90.34</td>
</tr>
<tr>
<td><kbd>{{"\{\{.Core.Started\}\}"}}</kbd></td>
<td>2020-05-02 09:14:43.66381 +0000 UTC</td>
</tr>
</tbody>
<small>Additional variables within the Core struct</small>
</table>
</div>
</template>
<script>
export default {
name: 'Variables',
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
</style>

View File

@ -2,9 +2,9 @@
<footer> <footer>
<div v-if="!core.footer" class="footer text-center mb-4 p-2"> <div v-if="!core.footer" class="footer text-center mb-4 p-2">
<a href="https://github.com/statping/statping" target="_blank"> <a href="https://github.com/statping/statping" target="_blank">
Statping {{core.version}} made with <font-awesome-icon icon="heart"/> Statping {{core.version}} made with <font-awesome-icon icon="heart" class="text-danger"/>
</a> | </a> |
<router-link :to="$store.state.admin ? '/dashboard' : '/login'">Dashboard</router-link> <router-link :to="$store.state.admin ? '/dashboard' : '/login'">{{$t('top_nav.dashboard')}}</router-link>
</div> </div>
<div v-else class="footer text-center mb-4 p-2" v-html="core.footer"></div> <div v-else class="footer text-center mb-4 p-2" v-html="core.footer"></div>
</footer> </footer>

View File

@ -5,7 +5,9 @@
<a v-for="(service, index) in $store.getters.servicesInGroup(group.id)" v-bind:key="index" class="service_li list-group-item list-group-item-action"> <a v-for="(service, index) in $store.getters.servicesInGroup(group.id)" v-bind:key="index" class="service_li list-group-item list-group-item-action">
<router-link class="no-decoration font-3" :to="serviceLink(service)">{{service.name}}</router-link> <router-link class="no-decoration font-3" :to="serviceLink(service)">{{service.name}}</router-link>
<span class="badge float-right" :class="{'bg-success': service.online, 'bg-danger': !service.online }">{{service.online ? "ONLINE" : "OFFLINE"}}</span> <span class="badge text-uppercase float-right" :class="{'bg-success': service.online, 'bg-danger': !service.online }">
{{service.online ? $t('online') : $t('offline')}}
</span>
<GroupServiceFailures :service="service"/> <GroupServiceFailures :service="service"/>

View File

@ -62,7 +62,7 @@
<div class="col-md-2 col-6 float-right"> <div class="col-md-2 col-6 float-right">
<button v-if="!expanded" @click="setService" class="btn btn-sm float-right dyn-dark text-white" :class="{'bg-success': service.online, 'bg-danger': !service.online}"> <button v-if="!expanded" @click="setService" class="btn btn-sm float-right dyn-dark text-white" :class="{'bg-success': service.online, 'bg-danger': !service.online}">
View Service {{$t('service.view')}}
</button> </button>
</div> </div>
</div> </div>

View File

@ -3,9 +3,9 @@
<div class="card-title px-4 pt-3"> <div class="card-title px-4 pt-3">
<h4 v-observe-visibility="setVisible"> <h4 v-observe-visibility="setVisible">
<router-link :to="serviceLink(service)">{{service.name}}</router-link> <router-link :to="serviceLink(service)">{{service.name}}</router-link>
<span class="badge float-right" :class="{'badge-success': service.online, 'badge-danger': !service.online}"> <span class="badge float-right text-uppercase" :class="{'badge-success': service.online, 'badge-danger': !service.online}">
{{service.online ? "ONLINE" : "OFFLINE"}} {{service.online ? $t('online') : $t('offline')}}
</span> </span>
</h4> </h4>
</div> </div>
@ -17,7 +17,7 @@
<div v-if="false" class="row mb-4 align-content-center"> <div v-if="false" class="row mb-4 align-content-center">
<div v-if="!service.online" class="col-3 text-left"> <div v-if="!service.online" class="col-3 text-left">
<span class="text-danger font-5 font-weight-bold">okko</span> <span class="text-danger font-5 font-weight-bold"></span>
<span class="font-2 d-block">Current Downtime</span> <span class="font-2 d-block">Current Downtime</span>
</div> </div>
@ -68,22 +68,24 @@
<div class="row"> <div class="row">
<div class="col-12 col-md-3 mb-2 mb-md-0"> <div class="col-12 col-md-3 mb-2 mb-md-0">
<router-link :to="{path: `/dashboard/service/${service.id}/incidents`, params: {id: service.id} }" class="btn btn-block btn-white incident"> <router-link :to="{path: `/dashboard/service/${service.id}/incidents`, params: {id: service.id} }" class="btn btn-block btn-white text-capitalize incident">
Incidents {{$tc('incident', 2)}}
</router-link> </router-link>
</div> </div>
<div class="col-12 col-md-3 mb-2 mb-md-0"> <div class="col-12 col-md-3 mb-2 mb-md-0">
<router-link :to="{path: `/dashboard/service/${service.id}/checkins`, params: {id: service.id} }" class="btn btn-block btn-white checkins"> <router-link :to="{path: `/dashboard/service/${service.id}/checkins`, params: {id: service.id} }" class="btn btn-block btn-white text-capitalize checkins">
Checkins {{$tc('checkin', 2)}}
</router-link> </router-link>
</div> </div>
<div class="col-12 col-md-3 mb-2 mb-md-0"> <div class="col-12 col-md-3 mb-2 mb-md-0">
<router-link :to="{path: `/dashboard/service/${service.id}/failures`, params: {id: service.id} }" class="btn btn-block btn-white failures"> <router-link :to="{path: `/dashboard/service/${service.id}/failures`, params: {id: service.id} }" class="btn btn-block btn-white text-capitalize failures">
Failures <span class="badge badge-danger float-right mt-1">{{service.stats.failures}}</span> {{$tc('failure', 2)}} <span class="badge badge-danger float-right mt-1">{{service.stats.failures}}</span>
</router-link> </router-link>
</div> </div>
<div class="col-12 col-md-3 mb-2 mb-md-0 mt-0 mt-md-1"> <div class="col-12 col-md-3 mb-2 mb-md-0 mt-0 mt-md-1">
<span class="text-black-50 float-md-right">{{service.online_7_days}} % Uptime</span> <span class="text-black-50 float-md-right">
{{$t('uptime', [service.online_7_days])}}
</span>
</div> </div>
</div> </div>

View File

@ -2,15 +2,15 @@
<div class="row stats_area mt-5 mb-4"> <div class="row stats_area mt-5 mb-4">
<div class="col-4"> <div class="col-4">
<span class="font-5 d-block font-weight-bold">{{humanTime(service.avg_response)}}</span> <span class="font-5 d-block font-weight-bold">{{humanTime(service.avg_response)}}</span>
<span class="font-1 subtitle">Average Response</span> <span class="font-1 subtitle">{{$t('service.average')}}</span>
</div> </div>
<div class="col-4"> <div class="col-4">
<span class="font-5 d-block font-weight-bold">{{service.online_24_hours}} %</span> <span class="font-5 d-block font-weight-bold">{{service.online_24_hours}} %</span>
<span class="font-1 subtitle">Uptime last 24 Hours</span> <span class="font-1 subtitle">{{$t('service.last_uptime', [24, $tc('hour', 24)])}}</span>
</div> </div>
<div class="col-4"> <div class="col-4">
<span class="font-5 d-block font-weight-bold">{{service.online_7_days}} %</span> <span class="font-5 d-block font-weight-bold">{{service.online_7_days}} %</span>
<span class="font-1 subtitle">Uptime last 7 Days</span> <span class="font-1 subtitle">{{$t('service.last_uptime', [7, $tc('day', 7)])}}</span>
</div> </div>
</div> </div>
</template> </template>

View File

@ -33,7 +33,7 @@
<div class="form-group"> <div class="form-group">
<label>{{ $t('setup.language') }}</label> <label>{{ $t('setup.language') }}</label>
<select v-model="core.language" v-bind:value="core.language" class="form-control"> <select v-model="core.language" class="form-control">
<option value="en">English</option> <option value="en">English</option>
<option value="es">Spanish</option> <option value="es">Spanish</option>
<option value="fr">French</option> <option value="fr">French</option>
@ -84,7 +84,7 @@
await Api.core_save(c) await Api.core_save(c)
const core = await Api.core() const core = await Api.core()
this.$store.commit('setCore', core) this.$store.commit('setCore', core)
setInterval(() => { this.loading = false }, 1500) this.loading = false
}, },
selectAll() { selectAll() {
this.$refs.input.select(); this.$refs.input.select();

View File

@ -2,19 +2,21 @@
<div class="card contain-card text-black-50 bg-white mb-3"> <div class="card contain-card text-black-50 bg-white mb-3">
<div class="card-header">{{group.id ? `Update ${group.name}` : "Create Group"}} <div class="card-header">{{group.id ? `Update ${group.name}` : "Create Group"}}
<transition name="slide-fade"> <transition name="slide-fade">
<button @click="removeEdit" v-if="group.id" class="btn float-right btn-danger btn-sm">Close</button> <button @click="removeEdit" v-if="group.id" class="btn float-right btn-danger btn-sm">
{{ $t('close') }}
</button>
</transition></div> </transition></div>
<div class="card-body"> <div class="card-body">
<form @submit.prevent="saveGroup"> <form @submit.prevent="saveGroup">
<div class="form-group row"> <div class="form-group row">
<label for="title" class="col-sm-4 col-form-label">Group Name</label> <label for="title" class="col-sm-4 col-form-label">{{ $t('dashboard.group') }} {{ $t('dashboard.name') }}</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input v-model="group.name" type="text" class="form-control" id="title" placeholder="Group Name" required> <input v-model="group.name" type="text" class="form-control" id="title" placeholder="Group Name" required>
</div> </div>
</div> </div>
<div class="form-group row"> <div class="form-group row">
<label for="switch-group-public" class="col-sm-4 col-form-label">Public Group</label> <label for="switch-group-public" class="col-sm-4 col-form-label text-capitalize">{{ $t('public') }} {{ $t('dashboard.group') }}</label>
<div class="col-md-8 col-xs-12 mt-1"> <div class="col-md-8 col-xs-12 mt-1">
<span @click="group.public = !!group.public" class="switch float-left"> <span @click="group.public = !!group.public" class="switch float-left">
<input v-model="group.public" type="checkbox" class="switch" id="switch-group-public" :checked="group.public"> <input v-model="group.public" type="checkbox" class="switch" id="switch-group-public" :checked="group.public">

View File

@ -2,13 +2,13 @@
<div> <div>
<form @submit.prevent="login" autocomplete="on"> <form @submit.prevent="login" autocomplete="on">
<div class="form-group row"> <div class="form-group row">
<label for="username" class="col-sm-2 col-form-label">Username</label> <label for="username" class="col-sm-2 col-form-label">{{$t('username')}}</label>
<div class="col-sm-10"> <div class="col-sm-10">
<input @keyup="checkForm" type="text" v-model="username" name="username" class="form-control" id="username" placeholder="Username" autocorrect="off" autocapitalize="none"> <input @keyup="checkForm" type="text" v-model="username" name="username" class="form-control" id="username" placeholder="Username" autocorrect="off" autocapitalize="none">
</div> </div>
</div> </div>
<div class="form-group row"> <div class="form-group row">
<label for="password" class="col-sm-2 col-form-label">Password</label> <label for="password" class="col-sm-2 col-form-label">{{$t('password')}}</label>
<div class="col-sm-10"> <div class="col-sm-10">
<input @keyup="checkForm" type="password" v-model="password" name="password" class="form-control" id="password" placeholder="Password"> <input @keyup="checkForm" type="password" v-model="password" name="password" class="form-control" id="password" placeholder="Password">
</div> </div>
@ -16,10 +16,10 @@
<div class="form-group row"> <div class="form-group row">
<div class="col-sm-12"> <div class="col-sm-12">
<div v-if="error" class="alert alert-danger" role="alert"> <div v-if="error" class="alert alert-danger" role="alert">
Incorrect username or password {{$t('dashboard.wrong_login')}}
</div> </div>
<button @click.prevent="login" type="submit" class="btn btn-block mb-3 btn-primary" :disabled="disabled || loading"> <button @click.prevent="login" type="submit" class="btn btn-block mb-3 btn-primary" :disabled="disabled || loading">
{{loading ? "Loading" : "Sign in"}} {{loading ? $t('dashboard.loading') : $t('dashboard.sign_in')}}
</button> </button>
</div> </div>
</div> </div>

View File

@ -3,13 +3,15 @@
<div class="card contain-card text-black-50 bg-white mb-5"> <div class="card contain-card text-black-50 bg-white mb-5">
<div class="card-header">{{message.id ? `Update ${message.title}` : "Create Announcement"}} <div class="card-header">{{message.id ? `Update ${message.title}` : "Create Announcement"}}
<transition name="slide-fade"> <transition name="slide-fade">
<button @click="removeEdit" v-if="message.id" class="btn btn-sm float-right btn-danger btn-sm">Close</button> <button @click="removeEdit" v-if="message.id" class="btn btn-sm float-right btn-danger btn-sm">
{{ $t('close') }}
</button>
</transition> </transition>
</div> </div>
<div class="card-body"> <div class="card-body">
<form @submit="saveMessage"> <form @submit="saveMessage">
<div class="form-group row"> <div class="form-group row">
<label class="col-sm-4 col-form-label">Title</label> <label class="col-sm-4 col-form-label">{{ $t('dashboard.title') }}</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input v-model="message.title" type="text" name="title" class="form-control" id="title" placeholder="Announcement Title" required> <input v-model="message.title" type="text" name="title" class="form-control" id="title" placeholder="Announcement Title" required>
</div> </div>

View File

@ -49,7 +49,7 @@
<input @keyup="canSubmit" v-model="setup.db_password" id="db_password" type="password" class="form-control" placeholder="password123"> <input @keyup="canSubmit" v-model="setup.db_password" id="db_password" type="password" class="form-control" placeholder="password123">
</div> </div>
<div v-if="setup.db_connection !== 'sqlite'" class="form-group"> <div v-if="setup.db_connection !== 'sqlite'" class="form-group">
<label for="db_database" class="text-capitalize">{{ $t('database') }}</label> <label for="db_database" class="text-capitalize">{{ $t('setup.database') }}</label>
<input @keyup="canSubmit" v-model="setup.db_database" id="db_database" type="text" class="form-control" placeholder="Database name"> <input @keyup="canSubmit" v-model="setup.db_database" id="db_database" type="text" class="form-control" placeholder="Database name">
</div> </div>
@ -125,7 +125,7 @@
</div> </div>
<button @click.prevent="saveSetup" v-bind:disabled="disabled || loading" type="submit" class="btn btn-primary btn-block" :class="{'btn-primary': !loading, 'btn-default': loading}"> <button @click.prevent="saveSetup" v-bind:disabled="disabled || loading" type="submit" class="btn btn-primary btn-block" :class="{'btn-primary': !loading, 'btn-default': loading}">
{{loading ? "Loading..." : "Save Settings"}} <font-awesome-icon v-if="loading" icon="circle-notch" class="mr-2" spin/>{{loading ? "Loading..." : "Save Settings"}}
</button> </button>
</div> </div>
</form> </form>
@ -176,6 +176,7 @@
} }
}, },
mounted() { mounted() {
this.changeLanguages()
this.setup.domain = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":"+window.location.port : "") this.setup.domain = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":"+window.location.port : "")
}, },
methods: { methods: {
@ -203,13 +204,12 @@
}, },
async saveSetup() { async saveSetup() {
this.loading = true this.loading = true
const s = this.setup let resp
if (s.password !== s.confirm_password) { try {
alert('Passwords do not match!') resp = await Api.setup_save(this.setup)
this.loading = false } catch(e) {
return resp = {status: 'error', error: e.response.data.error}
} }
const resp = await Api.setup_save(s)
if (resp.status === 'error') { if (resp.status === 'error') {
this.error = resp.error this.error = resp.error
this.loading = false this.loading = false

View File

@ -32,7 +32,7 @@
</div> </div>
</div> </div>
<div class="form-group row"> <div class="form-group row">
<label class="col-sm-4 col-form-label">Confirm Password</label> <label class="col-sm-4 col-form-label">{{ $t('close') }}</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input v-model="user.confirm_password" type="password" id="password_confirm" class="form-control" placeholder="Confirm Password" required> <input v-model="user.confirm_password" type="password" id="password_confirm" class="form-control" placeholder="Confirm Password" required>
</div> </div>

View File

@ -3,6 +3,7 @@ const english = {
dashboard: "Dashboard", dashboard: "Dashboard",
services: "Services", services: "Services",
users: "Users", users: "Users",
groups: "Groups",
announcements: "Announcements", announcements: "Announcements",
settings: "Settings", settings: "Settings",
logs: "Logs", logs: "Logs",
@ -27,6 +28,16 @@ const english = {
total_services: "Total Services", total_services: "Total Services",
failures_24_hours: "Failures last 24 Hours", failures_24_hours: "Failures last 24 Hours",
online_services: "Online Services", online_services: "Online Services",
service: 'Service | Services',
group: 'Group',
title: 'Title',
begins: 'Begins',
name: 'Name',
loading: 'Loading',
login: 'Login',
sign_in: "Sign In",
visibility: 'Visibility',
wrong_login: 'Incorrect username or password'
}, },
settings: { settings: {
name: "Project Name", name: "Project Name",
@ -35,12 +46,23 @@ const english = {
footer_notes: "HTML is allowed inside the footer", footer_notes: "HTML is allowed inside the footer",
error_reporting: "Enable Error Reporting", error_reporting: "Enable Error Reporting",
error_reporting_notes: "Help the Statping project out by sending anonymous error logs back to our server.", error_reporting_notes: "Help the Statping project out by sending anonymous error logs back to our server.",
save: "Save Settings" save: "Save Settings",
main: "Main Settings",
theme: "Theme Editor",
cache: "Cache",
oauth: "OAuth",
beta: "BETA",
changelog: "Changelog",
repo: "Statping Github Repo",
docs: "Documentation",
}, },
service: { service: {
name: "Service Name", name: "Service Name",
type: "Service Type", type: "Service Type",
info: "Service Information" info: "Service Information",
view: "View Service",
average: "Average Response",
last_uptime: "Uptime last {0} {1}",
}, },
email: "Email Address", email: "Email Address",
port: "Database Port", port: "Database Port",
@ -53,9 +75,11 @@ const english = {
public: 'Public', public: 'Public',
private: 'Private', private: 'Private',
admin: 'Admin', admin: 'Admin',
user: 'User',
offline: 'offline', offline: 'offline',
incident: 'incident', failure: 'failure | failures',
incident: 'incident | incidents',
checkin: 'checkin | checkins',
user: 'User | Users',
group: 'Group', group: 'Group',
message: 'message', message: 'message',
edit: 'Edit', edit: 'Edit',
@ -63,9 +87,14 @@ const english = {
sample_data: 'Sample Data', sample_data: 'Sample Data',
today: 'Today', today: 'Today',
last_login: 'Last Login', last_login: 'Last Login',
day: 'day', uptime: '{0}% Uptime',
hour: 'hour', close: 'Close',
uptime: '{0} Uptime', second: 'second | seconds',
minute: 'minute | minutes',
hour: 'hour | hours',
day: 'day | days',
week: 'week | weeks',
month: 'month | months',
} }
export default english export default english

View File

@ -1,19 +1,100 @@
const french = { const french = {
setup: { top_nav: {
language: "Langue", dashboard: "Dashboard",
database_connection: "Database Connection" services: "Services",
users: "Users",
groups: "Groups",
announcements: "Announcements",
settings: "Settings",
logs: "Logs",
logout: 'Logout',
}, },
service: 'service', setup: {
language: "Language",
connection: "Database Connection",
host: "Host",
database: "Database",
project_name: "Project Name",
project_description: "Project Description",
domain: "Domain URL",
username: "Admin Username",
password: "Admin Password",
password_confirm: "Confirm Admin Password",
newsletter: "Newsletter",
newsletter_note: "We will not share your email, emails are only for major updates.",
send_reports: "Send Error Reports to Statping"
},
dashboard: {
total_services: "Total Services",
failures_24_hours: "Failures last 24 Hours",
online_services: "Online Services",
service: 'Service | Services',
group: 'Group',
title: 'Title',
begins: 'Begins',
name: 'Name',
loading: 'Loading',
login: 'Login',
sign_in: "Sign In",
visibility: 'Visibility',
wrong_login: 'Incorrect username or password'
},
settings: {
name: "Project Name",
description: "Project Name",
footer: "Custom Footer",
footer_notes: "HTML is allowed inside the footer",
error_reporting: "Enable Error Reporting",
error_reporting_notes: "Help the Statping project out by sending anonymous error logs back to our server.",
save: "Save Settings",
main: "Main Settings",
theme: "Theme Editor",
cache: "Cache",
oauth: "OAuth",
beta: "BETA",
changelog: "Changelog",
repo: "Statping Github Repo",
docs: "Documentation",
},
service: {
name: "Service Name",
type: "Service Type",
info: "Service Information",
view: "View Service",
average: "Average Response",
last_uptime: "Uptime last {0} {1}",
},
email: "Email Address",
port: "Database Port",
setting: "Settings",
username: "Username",
password: 'Password',
services: 'Services',
domain: 'Domain',
online: 'online', online: 'online',
public: 'Public',
private: 'Private',
admin: 'Admin',
offline: 'offline', offline: 'offline',
incident: 'incident', failure: 'failure | failures',
group: 'group', incident: 'incident | incidents',
checkin: 'checkin | checkins',
user: 'User | Users',
group: 'Group',
message: 'message', message: 'message',
logout: 'logout', edit: 'Edit',
type: 'Type',
sample_data: 'Sample Data', sample_data: 'Sample Data',
today: 'Today', today: 'Today',
day: 'day', last_login: 'Last Login',
hour: 'hour', uptime: '{0}% Uptime',
close: 'Close',
second: 'second | seconds',
minute: 'minute | minutes',
hour: 'hour | hours',
day: 'day | days',
week: 'week | weeks',
month: 'month | months',
} }
export default french export default french

View File

@ -1,19 +1,100 @@
const german = { const german = {
setup: { top_nav: {
language: "Sprache", dashboard: "Dashboard",
database_connection: "Database Connection" services: "Services",
users: "Users",
groups: "Groups",
announcements: "Announcements",
settings: "Settings",
logs: "Logs",
logout: 'Logout',
}, },
service: 'service', setup: {
language: "Language",
connection: "Database Connection",
host: "Host",
database: "Database",
project_name: "Project Name",
project_description: "Project Description",
domain: "Domain URL",
username: "Admin Username",
password: "Admin Password",
password_confirm: "Confirm Admin Password",
newsletter: "Newsletter",
newsletter_note: "We will not share your email, emails are only for major updates.",
send_reports: "Send Error Reports to Statping"
},
dashboard: {
total_services: "Total Services",
failures_24_hours: "Failures last 24 Hours",
online_services: "Online Services",
service: 'Service | Services',
group: 'Group',
title: 'Title',
begins: 'Begins',
name: 'Name',
loading: 'Loading',
login: 'Login',
sign_in: "Sign In",
visibility: 'Visibility',
wrong_login: 'Incorrect username or password'
},
settings: {
name: "Project Name",
description: "Project Name",
footer: "Custom Footer",
footer_notes: "HTML is allowed inside the footer",
error_reporting: "Enable Error Reporting",
error_reporting_notes: "Help the Statping project out by sending anonymous error logs back to our server.",
save: "Save Settings",
main: "Main Settings",
theme: "Theme Editor",
cache: "Cache",
oauth: "OAuth",
beta: "BETA",
changelog: "Changelog",
repo: "Statping Github Repo",
docs: "Documentation",
},
service: {
name: "Service Name",
type: "Service Type",
info: "Service Information",
view: "View Service",
average: "Average Response",
last_uptime: "Uptime last {0} {1}",
},
email: "Email Address",
port: "Database Port",
setting: "Settings",
username: "Username",
password: 'Password',
services: 'Services',
domain: 'Domain',
online: 'online', online: 'online',
public: 'Public',
private: 'Private',
admin: 'Admin',
offline: 'offline', offline: 'offline',
incident: 'incident', failure: 'failure | failures',
group: 'group', incident: 'incident | incidents',
checkin: 'checkin | checkins',
user: 'User | Users',
group: 'Group',
message: 'message', message: 'message',
logout: 'logout', edit: 'Edit',
type: 'Type',
sample_data: 'Sample Data', sample_data: 'Sample Data',
today: 'Today', today: 'Today',
day: 'day', last_login: 'Last Login',
hour: 'hour', uptime: '{0}% Uptime',
close: 'Close',
second: 'second | seconds',
minute: 'minute | minutes',
hour: 'hour | hours',
day: 'day | days',
week: 'week | weeks',
month: 'month | months',
} }
export default german export default german

View File

@ -1,19 +1,100 @@
const russian = { const russian = {
setup: { top_nav: {
language: "язык", dashboard: "Dashboard",
database_connection: "Database Connection" services: "Services",
users: "Users",
groups: "Groups",
announcements: "Announcements",
settings: "Settings",
logs: "Logs",
logout: 'Logout',
}, },
service: 'service', setup: {
online: 'online', language: "Language",
offline: 'offline', connection: "Database Connection",
incident: 'incident', host: "Host",
group: 'group', database: "Database",
project_name: "Project Name",
project_description: "Project Description",
domain: "Domain URL",
username: "Admin Username",
password: "Admin Password",
password_confirm: "Confirm Admin Password",
newsletter: "Newsletter",
newsletter_note: "We will not share your email, emails are only for major updates.",
send_reports: "Send Error Reports to Statping"
},
dashboard: {
total_services: "Total Services",
failures_24_hours: "Failures last 24 Hours",
online_services: "Online Services",
service: 'Service | Services',
group: 'Group',
title: 'Title',
begins: 'Begins',
name: 'Name',
loading: 'Loading',
login: 'Login',
sign_in: "Sign In",
visibility: 'Visibility',
wrong_login: 'Incorrect username or password'
},
settings: {
name: "Project Name",
description: "Project Name",
footer: "Custom Footer",
footer_notes: "HTML is allowed inside the footer",
error_reporting: "Enable Error Reporting",
error_reporting_notes: "Help the Statping project out by sending anonymous error logs back to our server.",
save: "Save Settings",
main: "Main Settings",
theme: "Theme Editor",
cache: "Cache",
oauth: "OAuth",
beta: "BETA",
changelog: "Changelog",
repo: "Statping Github Repo",
docs: "Documentation",
},
service: {
name: "Service Name",
type: "Service Type",
info: "Service Information",
view: "View Service",
average: "Average Response",
last_uptime: "Uptime last {0} {1}",
},
email: "Email Address",
port: "Database Port",
setting: "Settings",
username: "Username",
password: 'Password',
services: 'Services',
domain: 'Domain',
online: 'онлайн',
public: 'Public',
private: 'Private',
admin: 'Admin',
offline: 'не в сети',
failure: 'failure | failures',
incident: 'incident | incidents',
checkin: 'checkin | checkins',
user: 'User | Users',
group: 'Group',
message: 'message', message: 'message',
logout: 'logout', edit: 'Edit',
type: 'Type',
sample_data: 'Sample Data', sample_data: 'Sample Data',
today: 'Today', today: 'Today',
day: 'day', last_login: 'Last Login',
hour: 'hour', uptime: '{0}% Uptime',
close: 'близко',
second: 'второй | секунд',
minute: 'минут | минут',
hour: 'час | часов',
day: 'день | дней',
week: 'неделя | недель',
month: 'месяц | месяцы',
} }
export default russian export default russian

View File

@ -1,19 +1,100 @@
const spanish = { const spanish = {
setup: { top_nav: {
language: "Idioma", dashboard: "Dashboard",
database_connection: "Database Connection" services: "Services",
users: "Users",
groups: "Groups",
announcements: "Announcements",
settings: "Settings",
logs: "Logs",
logout: 'Logout',
}, },
service: 'service', setup: {
language: "Language",
connection: "Database Connection",
host: "Host",
database: "Database",
project_name: "Project Name",
project_description: "Project Description",
domain: "Domain URL",
username: "Admin Username",
password: "Admin Password",
password_confirm: "Confirm Admin Password",
newsletter: "Newsletter",
newsletter_note: "We will not share your email, emails are only for major updates.",
send_reports: "Send Error Reports to Statping"
},
dashboard: {
total_services: "Total Services",
failures_24_hours: "Failures last 24 Hours",
online_services: "Online Services",
service: 'Service | Services',
group: 'Group',
title: 'Title',
begins: 'Begins',
name: 'Name',
loading: 'Loading',
login: 'Login',
sign_in: "Sign In",
visibility: 'Visibility',
wrong_login: 'Incorrect username or password'
},
settings: {
name: "Project Name",
description: "Project Name",
footer: "Custom Footer",
footer_notes: "HTML is allowed inside the footer",
error_reporting: "Enable Error Reporting",
error_reporting_notes: "Help the Statping project out by sending anonymous error logs back to our server.",
save: "Save Settings",
main: "Main Settings",
theme: "Theme Editor",
cache: "Cache",
oauth: "OAuth",
beta: "BETA",
changelog: "Changelog",
repo: "Statping Github Repo",
docs: "Documentation",
},
service: {
name: "Service Name",
type: "Service Type",
info: "Service Information",
view: "View Service",
average: "Average Response",
last_uptime: "Uptime last {0} {1}",
},
email: "Email Address",
port: "Database Port",
setting: "Settings",
username: "Username",
password: 'Password',
services: 'Services',
domain: 'Domain',
online: 'online', online: 'online',
public: 'Public',
private: 'Private',
admin: 'Admin',
offline: 'offline', offline: 'offline',
incident: 'incident', failure: 'failure | failures',
group: 'group', incident: 'incident | incidents',
checkin: 'checkin | checkins',
user: 'User | Users',
group: 'Group',
message: 'message', message: 'message',
logout: 'logout', edit: 'Edit',
type: 'Type',
sample_data: 'Sample Data', sample_data: 'Sample Data',
today: 'Today', today: 'Today',
day: 'day', last_login: 'Last Login',
hour: 'hour', uptime: '{0}% Uptime',
close: 'Close',
second: 'second | seconds',
minute: 'minute | minutes',
hour: 'hour | hours',
day: 'day | days',
week: 'week | weeks',
month: 'month | months',
} }
export default spanish export default spanish

View File

@ -20,7 +20,7 @@ export default Vue.mixin({
return startOfToday() return startOfToday()
}, },
secondsHumanize (val) { secondsHumanize (val) {
return `${val} seconds` return `${val} ${this.$t('second', val)}`
}, },
utc(val) { utc(val) {
return new Date.UTC(val) return new Date.UTC(val)
@ -175,7 +175,7 @@ export default Vue.mixin({
return startOfMonth(date) return startOfMonth(date)
}, },
lastDayOfMonth(month) { lastDayOfMonth(month) {
return lastDayOfMonth(date) return lastDayOfMonth(month)
}, },
addMonths(date, amount) { addMonths(date, amount) {
return addMonths(date, amount) return addMonths(date, amount)

View File

@ -3,22 +3,20 @@
<div class="col-12 mb-4"> <div class="col-12 mb-4">
<span class="mt-3 mb-3 text-white d-md-none btn d-block d-md-none" :class="{'bg-success': service.online, 'bg-danger': !service.online}"> <span class="mt-3 mb-3 text-white d-md-none btn d-block d-md-none text-uppercase" :class="{'bg-success': service.online, 'bg-danger': !service.online}">
{{service.online ? "ONLINE" : "OFFLINE"}} {{service.online ? $t('online') : $t('offline')}}
</span> </span>
<h4 class="mt-2"> <h4 class="mt-2">
<router-link to="/" class="text-black-50 text-decoration-none">{{core.name}}</router-link> - <span class="text-muted">{{service.name}}</span> <router-link to="/" class="text-black-50 text-decoration-none">{{core.name}}</router-link> - <span class="text-muted">{{service.name}}</span>
<span class="badge float-right d-none d-md-block" :class="{'bg-success': service.online, 'bg-danger': !service.online}"> <span class="badge float-right d-none d-md-block text-uppercase" :class="{'bg-success': service.online, 'bg-danger': !service.online}">
{{service.online ? "ONLINE" : "OFFLINE"}} {{service.online ? $t('online') : $t('offline')}}
</span> </span>
</h4> </h4>
<ServiceTopStats :service="service"/> <ServiceTopStats :service="service"/>
<div> <MessageBlock v-for="message in messagesInRange" v-bind:key="message.id" :message="message"/>
<MessageBlock v-for="message in messagesInRange" v-bind:key="message.id" :message="message"/>
</div>
<div class="row mt-5 mb-4"> <div class="row mt-5 mb-4">
<div class="col-12 col-md-5 font-2 mb-3 mb-md-0"> <div class="col-12 col-md-5 font-2 mb-3 mb-md-0">

View File

@ -3,19 +3,19 @@
<div class="row"> <div class="row">
<div class="col-md-3 col-sm-12 mb-4 mb-md-0"> <div class="col-md-3 col-sm-12 mb-4 mb-md-0">
<div class="nav flex-column nav-pills" id="v-pills-tab" role="tablist" aria-orientation="vertical"> <div class="nav flex-column nav-pills" id="v-pills-tab" role="tablist" aria-orientation="vertical">
<h6 class="text-muted">Main Settings</h6> <h6 class="text-muted">{{ $t('settings.main') }}</h6>
<a @click.prevent="changeTab" class="nav-link" v-bind:class="{active: liClass('v-pills-home-tab')}" id="v-pills-home-tab" data-toggle="pill" href="#v-pills-home" role="tab" aria-controls="v-pills-home" aria-selected="true"> <a @click.prevent="changeTab" class="nav-link" v-bind:class="{active: liClass('v-pills-home-tab')}" id="v-pills-home-tab" data-toggle="pill" href="#v-pills-home" role="tab" aria-controls="v-pills-home" aria-selected="true">
<font-awesome-icon icon="cog" class="mr-2"/> Settings <font-awesome-icon icon="cog" class="mr-2"/> {{ $t('setting') }}
</a> </a>
<a @click.prevent="changeTab" class="nav-link" v-bind:class="{active: liClass('v-pills-style-tab')}" id="v-pills-style-tab" data-toggle="pill" href="#v-pills-style" role="tab" aria-controls="v-pills-style" aria-selected="false"> <a @click.prevent="changeTab" class="nav-link" v-bind:class="{active: liClass('v-pills-style-tab')}" id="v-pills-style-tab" data-toggle="pill" href="#v-pills-style" role="tab" aria-controls="v-pills-style" aria-selected="false">
<font-awesome-icon icon="image" class="mr-2"/> Theme Editor <font-awesome-icon icon="image" class="mr-2"/> {{ $t('settings.theme') }}
</a> </a>
<a @click.prevent="changeTab" class="nav-link" v-bind:class="{active: liClass('v-pills-cache-tab')}" id="v-pills-cache-tab" data-toggle="pill" href="#v-pills-cache" role="tab" aria-controls="v-pills-cache" aria-selected="false"> <a @click.prevent="changeTab" class="nav-link" v-bind:class="{active: liClass('v-pills-cache-tab')}" id="v-pills-cache-tab" data-toggle="pill" href="#v-pills-cache" role="tab" aria-controls="v-pills-cache" aria-selected="false">
<font-awesome-icon icon="paperclip" class="mr-2"/> Cache <font-awesome-icon icon="paperclip" class="mr-2"/> {{ $t('settings.cache') }}
</a> </a>
<a @click.prevent="changeTab" class="nav-link" v-bind:class="{active: liClass('v-pills-oauth-tab')}" id="v-pills-oauth-tab" data-toggle="pill" href="#v-pills-oauth" role="tab" aria-controls="v-pills-oauth" aria-selected="false"> <a @click.prevent="changeTab" class="nav-link" v-bind:class="{active: liClass('v-pills-oauth-tab')}" id="v-pills-oauth-tab" data-toggle="pill" href="#v-pills-oauth" role="tab" aria-controls="v-pills-oauth" aria-selected="false">
<font-awesome-icon icon="key" class="mr-2"/> OAuth <span class="mt-1 float-right badge badge-light text-dark font-1">BETA</span> <font-awesome-icon icon="key" class="mr-2"/> {{ $t('settings.oauth') }} <span class="mt-1 float-right badge badge-light text-dark font-1">{{ $t('settings.beta') }}</span>
</a> </a>
<h6 class="mt-4 text-muted">Notifiers</h6> <h6 class="mt-4 text-muted">Notifiers</h6>
@ -33,19 +33,19 @@
<h6 class="mt-4 mb-3 text-muted">Statping Links</h6> <h6 class="mt-4 mb-3 text-muted">Statping Links</h6>
<a href="https://github.com/statping/statping/wiki" class="mb-2 font-2 text-decoration-none text-muted"> <a href="https://github.com/statping/statping/wiki" class="mb-2 font-2 text-decoration-none text-muted">
<font-awesome-icon icon="question" class="mr-3"/> Documentation <font-awesome-icon icon="question" class="mr-3"/> {{$t('settings.docs')}}
</a> </a>
<a href="https://github.com/statping/statping/wiki/API" class="mb-2 font-2 text-decoration-none text-muted"> <a href="https://github.com/statping/statping/wiki/API" class="mb-2 font-2 text-decoration-none text-muted">
<font-awesome-icon icon="laptop" class="mr-2"/> API Documentation <font-awesome-icon icon="laptop" class="mr-2"/> API {{$t('settings.docs')}}
</a> </a>
<a href="https://raw.githubusercontent.com/statping/statping/master/CHANGELOG.md" class="mb-2 font-2 text-decoration-none text-muted"> <a href="https://raw.githubusercontent.com/statping/statping/master/CHANGELOG.md" class="mb-2 font-2 text-decoration-none text-muted">
<font-awesome-icon icon="book" class="mr-3"/> Changelog <font-awesome-icon icon="book" class="mr-3"/> {{$t('settings.changelog')}}
</a> </a>
<a href="https://github.com/statping/statping" class="mb-2 font-2 text-decoration-none text-muted"> <a href="https://github.com/statping/statping" class="mb-2 font-2 text-decoration-none text-muted">
<font-awesome-icon icon="code-branch" class="mr-3"/> Statping Github Repo <font-awesome-icon icon="code-branch" class="mr-3"/> {{$t('settings.repo')}}
</a> </a>
<div class="row justify-content-center mt-2"> <div class="row justify-content-center mt-2">
@ -89,30 +89,18 @@
<div class="card text-black-50 bg-white mt-3"> <div class="card text-black-50 bg-white mt-3">
<div class="card-header">QR Code for Mobile App</div> <div class="card-header">QR Code for Mobile App</div>
<div class="card-body"> <div class="card-body">
<img class="rounded" width="300" height="300" :src="qrcode"> <img class="rounded" width="300" height="300" :src="qrcode">
</div> </div>
</div> </div>
</div> </div>
<div class="tab-pane fade" v-bind:class="{active: liClass('v-pills-style-tab'), show: liClass('v-pills-style-tab')}" id="v-pills-style" role="tabpanel" aria-labelledby="v-pills-style-tab"> <div class="tab-pane fade" v-bind:class="{active: liClass('v-pills-style-tab'), show: liClass('v-pills-style-tab')}" id="v-pills-style" role="tabpanel" aria-labelledby="v-pills-style-tab">
<div class="card text-black-50 bg-white mb-5"> <ThemeEditor/>
<div class="card-header">Theme Editor</div>
<div class="card-body">
<ThemeEditor/>
</div>
</div>
</div> </div>
<div class="tab-pane fade" v-bind:class="{active: liClass('v-pills-cache-tab'), show: liClass('v-pills-cache-tab')}" id="v-pills-cache" role="tabpanel" aria-labelledby="v-pills-cache-tab"> <div class="tab-pane fade" v-bind:class="{active: liClass('v-pills-cache-tab'), show: liClass('v-pills-cache-tab')}" id="v-pills-cache" role="tabpanel" aria-labelledby="v-pills-cache-tab">
<div class="card text-black-50 bg-white mb-5"> <Cache/>
<div class="card-header">Cache</div>
<div class="card-body">
<Cache/>
</div>
</div>
</div> </div>
<div class="tab-pane fade" v-bind:class="{active: liClass('v-pills-oauth-tab'), show: liClass('v-pills-oauth-tab')}" id="v-pills-oauth" role="tabpanel" aria-labelledby="v-pills-oauth-tab"> <div class="tab-pane fade" v-bind:class="{active: liClass('v-pills-oauth-tab'), show: liClass('v-pills-oauth-tab')}" id="v-pills-oauth" role="tabpanel" aria-labelledby="v-pills-oauth-tab">
@ -120,132 +108,7 @@
</div> </div>
<div class="tab-pane fade" v-bind:class="{active: liClass(`v-pills-notifier-docs-tab`), show: liClass(`v-pills-notifier-docs-tab`)}" v-bind:id="`v-pills-notifier-docs-tab`" role="tabpanel" v-bind:aria-labelledby="`v-pills-notifier-docs-tab`"> <div class="tab-pane fade" v-bind:class="{active: liClass(`v-pills-notifier-docs-tab`), show: liClass(`v-pills-notifier-docs-tab`)}" v-bind:id="`v-pills-notifier-docs-tab`" role="tabpanel" v-bind:aria-labelledby="`v-pills-notifier-docs-tab`">
<h2>Notifier Variables</h2> <Variables/>
You can insert dynamic fields within the notifier payloads for some notifiers.
<p class="mt-2">
Checkout the <a href="https://github.com/statping/statping/blob/master/types/services/struct.go">Service struct</a> and the <a href="https://github.com/statping/statping/blob/master/types/failures/struct.go">Failures struct</a> and create variables in golang template format.
</p>
<p class="mt-2">
For example, if you have <b>{{"\{\{.Service.Name\}\}"}}</b> it will return the service name.
</p>
<h2 class="mt-3">Service Variables</h2>
<table class="table">
<thead>
<tr>
<th scope="col">Variable</th>
<th scope="col">True Value</th>
</tr>
</thead>
<tbody>
<tr>
<td><kbd>{{"\{\{.Service.Id\}\}"}}</kbd></td>
<td>1</td>
</tr>
<tr>
<td><kbd>{{"\{\{.Service.Name\}\}"}}</kbd></td>
<td>Example Service</td>
</tr>
<tr>
<td><kbd>{{"\{\{.Service.Domain\}\}"}}</kbd></td>
<td>https://statping.com</td>
</tr>
<tr>
<td><kbd>{{"\{\{.Service.Port\}\}"}}</kbd></td>
<td>8080</td>
</tr>
<tr>
<td><kbd>{{"\{\{.Service.DowntimeAgo\}\}"}}</kbd></td>
<td>35 minutes ago</td>
</tr>
<tr>
<td><kbd>{{"\{\{.Service.LastStatusCode\}\}"}}</kbd></td>
<td>404</td>
</tr>
<tr>
<td><kbd>{{"\{\{.Service.FailuresLast24Hours\}\}"}}</kbd></td>
<td>38</td>
</tr>
</tbody>
<small>Additional variables within the Service struct</small>
</table>
<h2 class="mt-3">Failure Variables</h2>
<table class="table">
<thead>
<tr>
<th scope="col">Variable</th>
<th scope="col">True Value</th>
</tr>
</thead>
<tbody>
<tr>
<td><kbd>{{"\{\{.Failure.Issue\}\}"}}</kbd></td>
<td>Received 404 status code</td>
</tr>
<tr>
<td><kbd>{{"\{\{.Failure.ErrorCode\}\}"}}</kbd></td>
<td>404</td>
</tr>
<tr>
<td><kbd>{{"\{\{.Failure.Service\}\}"}}</kbd></td>
<td>1</td>
</tr>
<tr>
<td><kbd>{{"\{\{.Failure.PingTime\}\}"}}</kbd></td>
<td>12482 (microseconds)</td>
</tr>
<tr>
<td><kbd>{{"\{\{.Failure.DowntimeAgo\}\}"}}</kbd></td>
<td>35 minutes ago</td>
</tr>
<tr>
<td><kbd>{{"\{\{.Failure.CreatedAt\}\}"}}</kbd></td>
<td>2020-05-02 09:14:43.66381 +0000 UTC</td>
</tr>
</tbody>
<small>Additional variables within the Failures struct</small>
</table>
<h2 class="mt-3">Core Variables</h2>
<table class="table">
<thead>
<tr>
<th scope="col">Variable</th>
<th scope="col">True Value</th>
</tr>
</thead>
<tbody>
<tr>
<td><kbd>{{"\{\{.Core.Domain\}\}"}}</kbd></td>
<td>http://localhost:8080</td>
</tr>
<tr>
<td><kbd>{{"\{\{.Core.Name\}\}"}}</kbd></td>
<td>Statping Demo</td>
</tr>
<tr>
<td><kbd>{{"\{\{.Core.Description\}\}"}}</kbd></td>
<td>Statping will monitor your stuff!</td>
</tr>
<tr>
<td><kbd>{{"\{\{.Core.Version\}\}"}}</kbd></td>
<td>v0.90.34</td>
</tr>
<tr>
<td><kbd>{{"\{\{.Core.Started\}\}"}}</kbd></td>
<td>2020-05-02 09:14:43.66381 +0000 UTC</td>
</tr>
</tbody>
<small>Additional variables within the Core struct</small>
</table>
</div> </div>
<div v-for="(notifier, index) in notifiers" v-bind:key="`${notifier.method}_${index}`" class="tab-pane fade" v-bind:class="{active: liClass(`v-pills-${notifier.method.toLowerCase()}-tab`), show: liClass(`v-pills-${notifier.method.toLowerCase()}-tab`)}" v-bind:id="`v-pills-${notifier.method.toLowerCase()}-tab`" role="tabpanel" v-bind:aria-labelledby="`v-pills-${notifier.method.toLowerCase()}-tab`"> <div v-for="(notifier, index) in notifiers" v-bind:key="`${notifier.method}_${index}`" class="tab-pane fade" v-bind:class="{active: liClass(`v-pills-${notifier.method.toLowerCase()}-tab`), show: liClass(`v-pills-${notifier.method.toLowerCase()}-tab`)}" v-bind:id="`v-pills-${notifier.method.toLowerCase()}-tab`" role="tabpanel" v-bind:aria-labelledby="`v-pills-${notifier.method.toLowerCase()}-tab`">
@ -262,6 +125,7 @@
<script> <script>
import Api from '../API'; import Api from '../API';
import GithubButton from 'vue-github-button' import GithubButton from 'vue-github-button'
import Variables from "@/components/Dashboard/Variables";
const CoreSettings = () => import('@/forms/CoreSettings') const CoreSettings = () => import('@/forms/CoreSettings')
const FormIntegration = () => import('@/forms/Integration') const FormIntegration = () => import('@/forms/Integration')
@ -273,6 +137,7 @@
export default { export default {
name: 'Settings', name: 'Settings',
components: { components: {
Variables,
GithubButton, GithubButton,
OAuth, OAuth,
Cache, Cache,

View File

@ -167,11 +167,17 @@ export default new Vuex.Store({
context.commit("setGroups", groups); context.commit("setGroups", groups);
const services = await Api.services() const services = await Api.services()
context.commit("setServices", services); context.commit("setServices", services);
const checkins = await Api.checkins() const messages = await Api.messages()
context.commit("setCheckins", checkins); context.commit("setMessages", messages)
const messages = await Api.messages() context.commit("setHasPublicData", true)
context.commit("setMessages", messages) try {
context.commit("setHasPublicData", true) const checkins = await Api.checkins()
context.commit("setCheckins", checkins);
} catch(e) {
window.console.error(e)
await Api.logout()
return
}
const notifiers = await Api.notifiers() const notifiers = await Api.notifiers()
context.commit("setNotifiers", notifiers); context.commit("setNotifiers", notifiers);
const users = await Api.users() const users = await Api.users()

View File

@ -64,7 +64,7 @@ func (c *commandLine) OnFailure(s *services.Service, f *failures.Failure) (strin
// OnTest for commandLine triggers when this notifier has been saved // OnTest for commandLine triggers when this notifier has been saved
func (c *commandLine) OnTest() (string, error) { func (c *commandLine) OnTest() (string, error) {
tmpl := ReplaceVars(c.Var1, services.Example(true), exampleFailure) tmpl := ReplaceVars(c.Var1, services.Example(true), failures.Example())
in, out, err := runCommand(c.Host, tmpl) in, out, err := runCommand(c.Host, tmpl)
utils.Log.Infoln(in) utils.Log.Infoln(in)
utils.Log.Infoln(out) utils.Log.Infoln(out)

View File

@ -2,8 +2,10 @@ package notifiers
import ( import (
"github.com/statping/statping/database" "github.com/statping/statping/database"
"github.com/statping/statping/types/failures"
"github.com/statping/statping/types/notifications" "github.com/statping/statping/types/notifications"
"github.com/statping/statping/types/null" "github.com/statping/statping/types/null"
"github.com/statping/statping/types/services"
"github.com/statping/statping/utils" "github.com/statping/statping/utils"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@ -39,12 +41,12 @@ func TestCommandNotifier(t *testing.T) {
}) })
t.Run("Command OnFailure", func(t *testing.T) { t.Run("Command OnFailure", func(t *testing.T) {
_, err := Command.OnFailure(exampleService, exampleFailure) _, err := Command.OnFailure(services.Example(false), failures.Example())
assert.Nil(t, err) assert.Nil(t, err)
}) })
t.Run("Command OnSuccess", func(t *testing.T) { t.Run("Command OnSuccess", func(t *testing.T) {
_, err := Command.OnSuccess(exampleService) _, err := Command.OnSuccess(services.Example(true))
assert.Nil(t, err) assert.Nil(t, err)
}) })

View File

@ -2,8 +2,10 @@ package notifiers
import ( import (
"github.com/statping/statping/database" "github.com/statping/statping/database"
"github.com/statping/statping/types/failures"
"github.com/statping/statping/types/notifications" "github.com/statping/statping/types/notifications"
"github.com/statping/statping/types/null" "github.com/statping/statping/types/null"
"github.com/statping/statping/types/services"
"github.com/statping/statping/utils" "github.com/statping/statping/utils"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@ -46,12 +48,12 @@ func TestDiscordNotifier(t *testing.T) {
}) })
t.Run("discord OnFailure", func(t *testing.T) { t.Run("discord OnFailure", func(t *testing.T) {
_, err := Discorder.OnFailure(exampleService, exampleFailure) _, err := Discorder.OnFailure(services.Example(false), failures.Example())
assert.Nil(t, err) assert.Nil(t, err)
}) })
t.Run("discord OnSuccess", func(t *testing.T) { t.Run("discord OnSuccess", func(t *testing.T) {
_, err := Discorder.OnSuccess(exampleService) _, err := Discorder.OnSuccess(services.Example(true))
assert.Nil(t, err) assert.Nil(t, err)
}) })

View File

@ -2,8 +2,10 @@ package notifiers
import ( import (
"github.com/statping/statping/database" "github.com/statping/statping/database"
"github.com/statping/statping/types/failures"
"github.com/statping/statping/types/notifications" "github.com/statping/statping/types/notifications"
"github.com/statping/statping/types/null" "github.com/statping/statping/types/null"
"github.com/statping/statping/types/services"
"github.com/statping/statping/utils" "github.com/statping/statping/utils"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@ -62,21 +64,21 @@ func TestEmailNotifier(t *testing.T) {
}) })
t.Run("email OnFailure", func(t *testing.T) { t.Run("email OnFailure", func(t *testing.T) {
_, err := email.OnFailure(exampleService, exampleFailure) _, err := email.OnFailure(services.Example(false), failures.Example())
assert.Nil(t, err) assert.Nil(t, err)
}) })
t.Run("email OnSuccess", func(t *testing.T) { t.Run("email OnSuccess", func(t *testing.T) {
_, err := email.OnSuccess(exampleService) _, err := email.OnSuccess(services.Example(false))
assert.Nil(t, err) assert.Nil(t, err)
}) })
t.Run("email Check Back Online", func(t *testing.T) { t.Run("email Check Back Online", func(t *testing.T) {
assert.True(t, exampleService.Online) assert.True(t, services.Example(true).Online)
}) })
t.Run("email OnSuccess Again", func(t *testing.T) { t.Run("email OnSuccess Again", func(t *testing.T) {
_, err := email.OnSuccess(exampleService) _, err := email.OnSuccess(services.Example(true))
assert.Nil(t, err) assert.Nil(t, err)
}) })

View File

@ -2,8 +2,10 @@ package notifiers
import ( import (
"github.com/statping/statping/database" "github.com/statping/statping/database"
"github.com/statping/statping/types/failures"
"github.com/statping/statping/types/notifications" "github.com/statping/statping/types/notifications"
"github.com/statping/statping/types/null" "github.com/statping/statping/types/null"
"github.com/statping/statping/types/services"
"github.com/statping/statping/utils" "github.com/statping/statping/utils"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@ -51,12 +53,12 @@ func TestMobileNotifier(t *testing.T) {
}) })
t.Run("Mobile OnFailure", func(t *testing.T) { t.Run("Mobile OnFailure", func(t *testing.T) {
_, err := Mobile.OnFailure(exampleService, exampleFailure) _, err := Mobile.OnFailure(services.Example(false), failures.Example())
assert.Nil(t, err) assert.Nil(t, err)
}) })
t.Run("Mobile OnSuccess", func(t *testing.T) { t.Run("Mobile OnSuccess", func(t *testing.T) {
_, err := Mobile.OnSuccess(exampleService) _, err := Mobile.OnSuccess(services.Example(true))
assert.Nil(t, err) assert.Nil(t, err)
}) })

View File

@ -4,7 +4,6 @@ import (
"bytes" "bytes"
"github.com/statping/statping/types/core" "github.com/statping/statping/types/core"
"github.com/statping/statping/types/failures" "github.com/statping/statping/types/failures"
"github.com/statping/statping/types/null"
"github.com/statping/statping/types/services" "github.com/statping/statping/types/services"
"github.com/statping/statping/utils" "github.com/statping/statping/utils"
"html/template" "html/template"
@ -12,7 +11,6 @@ import (
) )
var log = utils.Log.WithField("type", "notifier") var log = utils.Log.WithField("type", "notifier")
var exampleService = services.Example(true)
type replacer struct { type replacer struct {
Core *core.Core Core *core.Core
@ -63,46 +61,6 @@ func ReplaceVars(input string, s *services.Service, f *failures.Failure) string
return ReplaceTemplate(input, replacer{Service: s, Failure: f, Core: core.App}) return ReplaceTemplate(input, replacer{Service: s, Failure: f, Core: core.App})
} }
var ExampleService = &services.Service{
Id: 1,
Name: "Statping",
Domain: "https://statping.com",
Expected: null.NewNullString("a better response"),
ExpectedStatus: 200,
Interval: 60,
Type: "http",
Method: "get",
Timeout: 10,
Order: 2,
VerifySSL: null.NewNullBool(true),
Public: null.NewNullBool(true),
GroupId: 0,
Permalink: null.NewNullString("statping"),
Online: true,
Latency: 324399,
PingTime: 18399,
Online24Hours: 99.2,
Online7Days: 99.8,
AvgResponse: 300233,
FailuresLast24Hours: 4,
Checkpoint: utils.Now().Add(-10 * time.Minute),
SleepDuration: 55,
LastResponse: "returning from a response",
AllowNotifications: null.NewNullBool(true),
UserNotified: false,
UpdateNotify: null.NewNullBool(true),
SuccessNotified: false,
LastStatusCode: 200,
LastLookupTime: 5233,
LastLatency: 270233,
LastCheck: utils.Now().Add(-15 * time.Second),
LastOnline: utils.Now().Add(-15 * time.Second),
LastOffline: utils.Now().Add(-10 * time.Minute),
SecondsOnline: 4500,
SecondsOffline: 300,
Redirect: null.NewNullBool(true),
}
var exampleFailure = &failures.Failure{ var exampleFailure = &failures.Failure{
Id: 1, Id: 1,
Issue: "HTTP returned a 500 status code", Issue: "HTTP returned a 500 status code",

View File

@ -2,8 +2,10 @@ package notifiers
import ( import (
"github.com/statping/statping/database" "github.com/statping/statping/database"
"github.com/statping/statping/types/failures"
"github.com/statping/statping/types/notifications" "github.com/statping/statping/types/notifications"
"github.com/statping/statping/types/null" "github.com/statping/statping/types/null"
"github.com/statping/statping/types/services"
"github.com/statping/statping/utils" "github.com/statping/statping/utils"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@ -49,12 +51,12 @@ func TestPushoverNotifier(t *testing.T) {
}) })
t.Run("Pushover OnFailure", func(t *testing.T) { t.Run("Pushover OnFailure", func(t *testing.T) {
_, err := Pushover.OnFailure(exampleService, exampleFailure) _, err := Pushover.OnFailure(services.Example(false), failures.Example())
assert.Nil(t, err) assert.Nil(t, err)
}) })
t.Run("Pushover OnSuccess", func(t *testing.T) { t.Run("Pushover OnSuccess", func(t *testing.T) {
_, err := Pushover.OnSuccess(exampleService) _, err := Pushover.OnSuccess(services.Example(true))
assert.Nil(t, err) assert.Nil(t, err)
}) })

View File

@ -18,11 +18,6 @@ const (
slackMethod = "slack" slackMethod = "slack"
) )
var (
failingTemplate = `{ "blocks": [ { "type": "section", "text": { "type": "mrkdwn", "text": ":warning: The service {{.Service.Name}} is currently offline! :warning:" } }, { "type": "divider" }, { "type": "section", "fields": [ { "type": "mrkdwn", "text": "*Service:*\n{{.Service.Name}}" }, { "type": "mrkdwn", "text": "*URL:*\n{{.Service.Domain}}" }, { "type": "mrkdwn", "text": "*Status Code:*\n{{.Service.LastStatusCode}}" }, { "type": "mrkdwn", "text": "*When:*\n{{.Failure.CreatedAt}}" }, { "type": "mrkdwn", "text": "*Downtime:*\n{{.Service.DowntimeAgo}}" }, { "type": "plain_text", "text": "*Error:*\n{{.Failure.Issue}}" } ] }, { "type": "divider" }, { "type": "actions", "elements": [ { "type": "button", "text": { "type": "plain_text", "text": "View Offline Service", "emoji": true }, "style": "danger", "url": "{{.Core.Domain}}/service/{{.Service.Id}}" }, { "type": "button", "text": { "type": "plain_text", "text": "Go to Statping", "emoji": true }, "url": "{{.Core.Domain}}" } ] } ] }`
successTemplate = `{ "blocks": [ { "type": "section", "text": { "type": "mrkdwn", "text": "The service {{.Service.Name}} is back online." } }, { "type": "actions", "elements": [ { "type": "button", "text": { "type": "plain_text", "text": "View Service", "emoji": true }, "style": "primary", "url": "{{.Core.Domain}}/service/{{.Service.Id}}" }, { "type": "button", "text": { "type": "plain_text", "text": "Go to Statping", "emoji": true }, "url": "{{.Core.Domain}}" } ] } ] }`
)
type slack struct { type slack struct {
*notifications.Notification *notifications.Notification
} }
@ -40,8 +35,8 @@ var slacker = &slack{&notifications.Notification{
Delay: time.Duration(10 * time.Second), Delay: time.Duration(10 * time.Second),
Host: "https://webhooksurl.slack.com/***", Host: "https://webhooksurl.slack.com/***",
Icon: "fab fa-slack", Icon: "fab fa-slack",
SuccessData: successTemplate, SuccessData: `{ "blocks": [ { "type": "section", "text": { "type": "mrkdwn", "text": "The service {{.Service.Name}} is back online." } }, { "type": "actions", "elements": [ { "type": "button", "text": { "type": "plain_text", "text": "View Service", "emoji": true }, "style": "primary", "url": "{{.Core.Domain}}/service/{{.Service.Id}}" }, { "type": "button", "text": { "type": "plain_text", "text": "Go to Statping", "emoji": true }, "url": "{{.Core.Domain}}" } ] } ] }`,
FailureData: failingTemplate, FailureData: `{ "blocks": [ { "type": "section", "text": { "type": "mrkdwn", "text": ":warning: The service {{.Service.Name}} is currently offline! :warning:" } }, { "type": "divider" }, { "type": "section", "fields": [ { "type": "mrkdwn", "text": "*Service:*\n{{.Service.Name}}" }, { "type": "mrkdwn", "text": "*URL:*\n{{.Service.Domain}}" }, { "type": "mrkdwn", "text": "*Status Code:*\n{{.Service.LastStatusCode}}" }, { "type": "mrkdwn", "text": "*When:*\n{{.Failure.CreatedAt}}" }, { "type": "mrkdwn", "text": "*Downtime:*\n{{.Service.DowntimeAgo}}" }, { "type": "plain_text", "text": "*Error:*\n{{.Failure.Issue}}" } ] }, { "type": "divider" }, { "type": "actions", "elements": [ { "type": "button", "text": { "type": "plain_text", "text": "View Offline Service", "emoji": true }, "style": "danger", "url": "{{.Core.Domain}}/service/{{.Service.Id}}" }, { "type": "button", "text": { "type": "plain_text", "text": "Go to Statping", "emoji": true }, "url": "{{.Core.Domain}}" } ] } ] }`,
DataType: "json", DataType: "json",
RequestInfo: "Slack allows you to customize your own messages with many complex components. Checkout the <a target=\"_blank\" href=\"https://api.slack.com/reference/surfaces/formatting\">Slack Message API</a> to learn how you can create your own.", RequestInfo: "Slack allows you to customize your own messages with many complex components. Checkout the <a target=\"_blank\" href=\"https://api.slack.com/reference/surfaces/formatting\">Slack Message API</a> to learn how you can create your own.",
Limits: 60, Limits: 60,
@ -66,7 +61,7 @@ func (s *slack) sendSlack(msg string) (string, error) {
func (s *slack) OnTest() (string, error) { func (s *slack) OnTest() (string, error) {
example := services.Example(true) example := services.Example(true)
testMsg := ReplaceVars(failingTemplate, example, nil) testMsg := ReplaceVars(s.SuccessData, example, nil)
contents, resp, err := utils.HttpRequest(s.Host, "POST", "application/json", nil, bytes.NewBuffer([]byte(testMsg)), time.Duration(10*time.Second), true, nil) contents, resp, err := utils.HttpRequest(s.Host, "POST", "application/json", nil, bytes.NewBuffer([]byte(testMsg)), time.Duration(10*time.Second), true, nil)
if err != nil { if err != nil {
return "", err return "", err
@ -80,14 +75,14 @@ func (s *slack) OnTest() (string, error) {
// OnFailure will trigger failing service // OnFailure will trigger failing service
func (s *slack) OnFailure(srv *services.Service, f *failures.Failure) (string, error) { func (s *slack) OnFailure(srv *services.Service, f *failures.Failure) (string, error) {
msg := ReplaceVars(failingTemplate, srv, f) msg := ReplaceVars(s.FailureData, srv, f)
out, err := s.sendSlack(msg) out, err := s.sendSlack(msg)
return out, err return out, err
} }
// OnSuccess will trigger successful service // OnSuccess will trigger successful service
func (s *slack) OnSuccess(srv *services.Service) (string, error) { func (s *slack) OnSuccess(srv *services.Service) (string, error) {
msg := ReplaceVars(successTemplate, srv, nil) msg := ReplaceVars(s.SuccessData, srv, nil)
out, err := s.sendSlack(msg) out, err := s.sendSlack(msg)
return out, err return out, err
} }

View File

@ -2,8 +2,10 @@ package notifiers
import ( import (
"github.com/statping/statping/database" "github.com/statping/statping/database"
"github.com/statping/statping/types/failures"
"github.com/statping/statping/types/notifications" "github.com/statping/statping/types/notifications"
"github.com/statping/statping/types/null" "github.com/statping/statping/types/null"
"github.com/statping/statping/types/services"
"github.com/statping/statping/utils" "github.com/statping/statping/utils"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@ -47,12 +49,12 @@ func TestSlackNotifier(t *testing.T) {
}) })
t.Run("slack OnFailure", func(t *testing.T) { t.Run("slack OnFailure", func(t *testing.T) {
_, err := slacker.OnFailure(exampleService, exampleFailure) _, err := slacker.OnFailure(services.Example(false), failures.Example())
assert.Nil(t, err) assert.Nil(t, err)
}) })
t.Run("slack OnSuccess", func(t *testing.T) { t.Run("slack OnSuccess", func(t *testing.T) {
_, err := slacker.OnSuccess(exampleService) _, err := slacker.OnSuccess(services.Example(true))
assert.Nil(t, err) assert.Nil(t, err)
}) })

View File

@ -2,8 +2,10 @@ package notifiers
import ( import (
"github.com/statping/statping/database" "github.com/statping/statping/database"
"github.com/statping/statping/types/failures"
"github.com/statping/statping/types/notifications" "github.com/statping/statping/types/notifications"
"github.com/statping/statping/types/null" "github.com/statping/statping/types/null"
"github.com/statping/statping/types/services"
"github.com/statping/statping/utils" "github.com/statping/statping/utils"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@ -53,12 +55,12 @@ func TestTelegramNotifier(t *testing.T) {
}) })
t.Run("Telegram OnFailure", func(t *testing.T) { t.Run("Telegram OnFailure", func(t *testing.T) {
_, err := Telegram.OnFailure(exampleService, exampleFailure) _, err := Telegram.OnFailure(services.Example(false), failures.Example())
assert.Nil(t, err) assert.Nil(t, err)
}) })
t.Run("Telegram OnSuccess", func(t *testing.T) { t.Run("Telegram OnSuccess", func(t *testing.T) {
_, err := Telegram.OnSuccess(exampleService) _, err := Telegram.OnSuccess(services.Example(true))
assert.Nil(t, err) assert.Nil(t, err)
}) })

View File

@ -2,8 +2,10 @@ package notifiers
import ( import (
"github.com/statping/statping/database" "github.com/statping/statping/database"
"github.com/statping/statping/types/failures"
"github.com/statping/statping/types/notifications" "github.com/statping/statping/types/notifications"
"github.com/statping/statping/types/null" "github.com/statping/statping/types/null"
"github.com/statping/statping/types/services"
"github.com/statping/statping/utils" "github.com/statping/statping/utils"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@ -53,12 +55,12 @@ func TestTwilioNotifier(t *testing.T) {
}) })
t.Run("Twilio OnFailure", func(t *testing.T) { t.Run("Twilio OnFailure", func(t *testing.T) {
_, err := Twilio.OnFailure(exampleService, exampleFailure) _, err := Twilio.OnFailure(services.Example(false), failures.Example())
assert.Nil(t, err) assert.Nil(t, err)
}) })
t.Run("Twilio OnSuccess", func(t *testing.T) { t.Run("Twilio OnSuccess", func(t *testing.T) {
_, err := Twilio.OnSuccess(exampleService) _, err := Twilio.OnSuccess(services.Example(true))
assert.Nil(t, err) assert.Nil(t, err)
}) })

View File

@ -2,8 +2,10 @@ package notifiers
import ( import (
"github.com/statping/statping/database" "github.com/statping/statping/database"
"github.com/statping/statping/types/failures"
"github.com/statping/statping/types/notifications" "github.com/statping/statping/types/notifications"
"github.com/statping/statping/types/null" "github.com/statping/statping/types/null"
"github.com/statping/statping/types/services"
"github.com/statping/statping/utils" "github.com/statping/statping/utils"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@ -45,12 +47,12 @@ func TestWebhookNotifier(t *testing.T) {
}) })
t.Run("webhooker OnFailure", func(t *testing.T) { t.Run("webhooker OnFailure", func(t *testing.T) {
_, err := Webhook.OnFailure(exampleService, exampleFailure) _, err := Webhook.OnFailure(services.Example(false), failures.Example())
assert.Nil(t, err) assert.Nil(t, err)
}) })
t.Run("webhooker OnSuccess", func(t *testing.T) { t.Run("webhooker OnSuccess", func(t *testing.T) {
_, err := Webhook.OnSuccess(exampleService) _, err := Webhook.OnSuccess(services.Example(true))
assert.Nil(t, err) assert.Nil(t, err)
}) })

View File

@ -40,6 +40,9 @@ func Select() (*Core, error) {
if utils.Params.GetBool("ALLOW_REPORTS") { if utils.Params.GetBool("ALLOW_REPORTS") {
App.AllowReports = null.NewNullBool(true) App.AllowReports = null.NewNullBool(true)
} }
if utils.Params.GetString("LANGUAGE") != "" {
App.Language = utils.Params.GetString("LANGUAGE")
}
return App, q.Error() return App, q.Error()
} }

View File

@ -42,9 +42,10 @@ func SentryInit(v *string, allow bool) {
allowReports := Params.GetBool("ALLOW_REPORTS") allowReports := Params.GetBool("ALLOW_REPORTS")
if allowReports || allow || goEnv == "test" { if allowReports || allow || goEnv == "test" {
if err := sentry.Init(sentry.ClientOptions{ if err := sentry.Init(sentry.ClientOptions{
Dsn: errorReporter, Dsn: errorReporter,
Environment: goEnv, Environment: goEnv,
Release: version, Release: version,
AttachStacktrace: true,
}); err != nil { }); err != nil {
Log.Errorln(err) Log.Errorln(err)
} }

View File

@ -1 +1 @@
0.90.53 0.90.54