statping/source/tmpl/service.html

253 lines
8.3 KiB
HTML
Raw Normal View History

2018-10-02 06:21:14 +00:00
{{define "title"}}{{.Service.Name}} Status{{end}}
2018-11-06 07:15:55 +00:00
{{define "description"}}{{$s := .Service}}{{if $s.Online }}{{.Service.Name}} is currently online and responding within {{$s.AvgTime}} milliseconds with {{$s.TotalUptime}}% total uptime on {{$s.Domain}}.{{else}}{{.Service.Name}} is currently offline on {{$s.Domain}}. Notify the admin to let them know their service is offline.{{end}}{{end}}
2018-10-02 06:21:14 +00:00
{{ define "content" }}
2018-09-18 22:02:27 +00:00
{{$s := .Service}}
2018-06-24 11:51:07 +00:00
<div class="container col-md-7 col-sm-12 mt-md-5 bg-light">
2018-06-11 03:41:02 +00:00
2018-06-19 04:48:25 +00:00
{{if Auth}}
2018-06-11 03:41:02 +00:00
{{template "nav"}}
{{end}}
2018-10-02 06:21:14 +00:00
<div class="col-12 mb-4">
2018-06-11 03:41:02 +00:00
2018-10-02 06:21:14 +00:00
{{if $s.Online }}
<span class="mt-3 mb-3 text-white d-md-none btn bg-success d-block d-md-none">ONLINE</span>
{{ else }}
<span class="mt-3 mb-3 text-white d-md-none btn bg-danger d-block d-md-none">OFFLINE</span>
{{end}}
<h4 class="mt-2">{{ $s.Name }}
{{if $s.Online }}
<span class="badge bg-success float-right d-none d-md-block">ONLINE</span>
{{ else }}
<span class="badge bg-danger float-right d-none d-md-block">OFFLINE</span>
{{end}}</h4>
2018-06-11 03:41:02 +00:00
2018-10-02 06:21:14 +00:00
<div class="row stats_area mt-5 mb-5">
<div class="col-4">
<span class="lg_number">{{$s.Online24}}%</span>
Online last 24 Hours
</div>
<div class="col-4">
<span class="lg_number">{{$s.AvgTime}}ms</span>
Average Response
2018-06-22 04:02:57 +00:00
</div>
2018-06-11 03:41:02 +00:00
2018-10-02 06:21:14 +00:00
<div class="col-4">
<span class="lg_number">{{$s.TotalUptime}}%</span>
Total Uptime
</div>
</div>
<div class="service-chart-container">
<canvas id="service"></canvas>
</div>
<form id="service_date_form" class="col-12 mt-2 mb-3">
<span id="start_date" class="text-muted small float-left pointer">{{FromUnix .Start}}</span>
<span id="end_date" class="text-muted small float-right pointer" style="position: absolute;right: 0;">{{FromUnix .End}}</span>
<input type="hidden" name="start" class="form-control" id="service_start" spellcheck="false">
<input type="hidden" name="end" class="form-control" id="service_end" spellcheck="false">
<button type="submit" class="btn btn-light btn-block btn-sm mt-2">Set Timeframe</button>
<div id="start_container"></div>
<div id="end_container"></div>
</form>
{{if not $s.Online}}
<div class="col-12 small text-center mt-3 text-muted">{{$s.DowntimeText}}</div>
{{end}}
{{ if $s.LimitedFailures }}
<div class="list-group mt-3 mb-4">
{{ range $s.LimitedFailures }}
<a href="#" class="list-group-item list-group-item-action flex-column align-items-start">
<div class="d-flex w-100 justify-content-between">
<h5 class="mb-1">{{.ParseError}}</h5>
<small>{{.Ago}}</small>
</div>
<p class="mb-1">{{.Issue}}</p>
</a>
{{ end }}
</div>
{{ end }}
</div>
2018-06-11 03:41:02 +00:00
2018-06-26 07:01:41 +00:00
{{if Auth}}
2018-06-22 06:56:44 +00:00
2018-10-05 04:28:38 +00:00
<div class="col-12 mt-4{{if ne $s.Type "http"}} d-none{{end}}">
2018-10-02 06:21:14 +00:00
<h3>Last Response</h3>
<textarea rows="8" class="form-control" readonly>{{ $s.LastResponse }}</textarea>
<div class="form-group row mt-2">
<label for="last_status_code" class="col-sm-3 col-form-label">HTTP Status Code</label>
<div class="col-sm-2">
<input type="text" id="last_status_code" class="form-control" value="{{ $s.LastStatusCode }}" readonly>
</div>
2018-06-23 08:42:50 +00:00
</div>
</div>
2018-06-11 03:41:02 +00:00
2018-10-05 04:28:38 +00:00
<div class="col-12 mt-4">
<h3>Edit Service</h3>
{{template "form_service" $s}}
</div>
2018-10-04 08:18:55 +00:00
<div class="col-12 mt-4">
<h3>Service Checkin</h3>
2018-10-07 22:38:56 +00:00
{{if $s.LimitedCheckins}}
2018-10-04 08:18:55 +00:00
<table class="table">
<thead>
2018-10-05 04:28:38 +00:00
<tr>
<th scope="col">Checkin</th>
<th scope="col">Report Period<br>Grace Period</th>
<th scope="col">Last Seen</th>
<th scope="col">Expected</th>
2018-10-07 22:38:56 +00:00
<th scope="col"></th>
2018-10-05 04:28:38 +00:00
</tr>
2018-10-04 08:18:55 +00:00
</thead>
<tbody>
2018-10-07 22:38:56 +00:00
{{range $s.LimitedCheckins}}
2018-10-06 03:35:53 +00:00
{{ $ch := . }}
2018-10-07 22:38:56 +00:00
<tr class="{{ if lt $ch.Expected 0}}bg-warning text-black{{else}}bg-light{{end}}">
<td>{{$ch.Name}}<br><a href="{{$ch.Link}}" target="_blank">{{$ch.Link}}</a></td>
2018-10-05 04:28:38 +00:00
<td>every {{Duration $ch.Period}}<br>after {{Duration $ch.Grace}}</td>
2018-10-07 22:38:56 +00:00
<td>{{ if $ch.Last.CreatedAt.IsZero}}
Never
{{else}}
{{Ago $ch.Last.CreatedAt}}
{{end}}
</td>
<td>
{{ if $ch.Last.CreatedAt.IsZero}}
-
{{else}}
{{ if lt $ch.Expected 0}}{{Duration $ch.Expected}} ago{{else}}in {{Duration $ch.Expected}}{{end}}
{{end}}
</td>
<td><a href="/checkin/{{$ch.Id}}/delete" class="btn btn-sm btn-danger">Delete</a></td>
2018-10-04 08:18:55 +00:00
</tr>
2018-10-06 03:35:53 +00:00
{{end}}
2018-10-04 08:18:55 +00:00
</tbody>
</table>
2018-10-07 22:38:56 +00:00
{{end}}
{{template "form_checkin" $s}}
2018-10-02 06:21:14 +00:00
</div>
2018-06-30 03:40:00 +00:00
2018-06-30 19:30:58 +00:00
{{end}}
2018-06-30 03:40:00 +00:00
</div>
2018-10-02 06:21:14 +00:00
{{end}}
{{define "extra_scripts"}}
{{if USE_CDN}}
2018-09-18 22:02:27 +00:00
<script src="https://assets.statup.io/pikaday.js"></script>
{{ else }}
2018-09-18 22:02:27 +00:00
<script src="/js/pikaday.js"></script>
{{end}}
2018-10-02 06:21:14 +00:00
{{$s := .Service}}
2018-09-18 22:02:27 +00:00
<script>
2018-09-21 04:17:24 +00:00
var ctx = document.getElementById("service").getContext('2d');
var chartdata = new Chart(ctx, {
type: 'line',
data: {
datasets: [{
label: 'Response Time (Milliseconds)',
data: [],
2018-09-21 04:17:24 +00:00
backgroundColor: [
'rgba(47, 206, 30, 0.92)'
],
borderColor: [
'rgb(47, 171, 34)'
],
borderWidth: 1
}]
},
options: {
legend: {
display: false
},
scales: {
yAxes: [{
ticks: {
beginAtZero: true
},
gridLines: {
display: true
2018-09-21 04:17:24 +00:00
}
}],
xAxes: [{
type: 'time',
distribution: 'series',
time: {
displayFormats: {
'millisecond': 'MMM DD',
'second': 'MMM DD',
'minute': 'MMM DD',
'hour': 'MMM DD hA',
'day': 'MMM DD',
'week': 'MMM DD',
'month': 'MMM DD',
'quarter': 'MMM DD',
'year': 'MMM DD',
}
},
2018-09-21 04:17:24 +00:00
gridLines: {
display: true
},
ticks: {
source: 'auto'
2018-09-21 04:17:24 +00:00
}
}],
2018-09-21 04:17:24 +00:00
},
elements: {
point: {
radius: 0
}
}
}
});
2018-09-18 22:02:27 +00:00
var startPick = new Pikaday({
field: $('#service_start')[0],
bound: false,
trigger: $("#start_date"),
container: $("#start_container")[0],
maxDate: new Date(),
onSelect: function(date) {
2018-10-02 06:21:14 +00:00
$('#service_start')[0].value = Math.round(date.getTime() / 1000);
this.hide();
2018-09-18 22:02:27 +00:00
}
});
var endPick = new Pikaday({
field: $('#service_end')[0],
bound: false,
trigger: $("#end_date"),
container: $("#end_container")[0],
maxDate: new Date(),
onSelect: function(date) {
2018-10-02 06:21:14 +00:00
$('#service_end')[0].value = Math.round(date.getTime() / 1000);
this.hide();
2018-09-18 22:02:27 +00:00
}
});
2018-10-11 04:08:55 +00:00
startPick.setDate(new Date({{.Start}}* 1000));
endPick.setDate(new Date({{.End}}* 1000));
2018-10-07 22:38:56 +00:00
startPick.hide();
endPick.hide();
2018-09-18 22:02:27 +00:00
$("#start_date").click(function(e) {
startPick.show()
2018-10-07 22:38:56 +00:00
});
2018-09-18 22:02:27 +00:00
$("#end_date").click(function(e) {
endPick.show()
2018-10-07 22:38:56 +00:00
});
2018-09-18 22:02:27 +00:00
AjaxChart(chartdata,{{$s.Id}},{{.Start}},{{.End}},"hour");
2018-09-18 22:02:27 +00:00
</script>
2018-10-02 06:21:14 +00:00
{{end}}