Skip to content

Commit

Permalink
added 7 day uptime on index - JS updates
Browse files Browse the repository at this point in the history
  • Loading branch information
hunterlong committed Dec 13, 2018
1 parent 8f9d55f commit 86958c1
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 17 deletions.
6 changes: 6 additions & 0 deletions core/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ func (s *Service) Online24() float32 {
return s.OnlineSince(ago)
}

// Online7Days returns the service's uptime percent within last 7 days
func (s *Service) Online7Days() float32 {
ago := time.Now().Add((-24 * 7) * time.Hour)
return s.OnlineSince(ago)
}

// OnlineSince accepts a time since parameter to return the percent of a service's uptime.
func (s *Service) OnlineSince(ago time.Time) float32 {
failed, _ := s.TotalFailuresSince(ago)
Expand Down
9 changes: 9 additions & 0 deletions source/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,15 @@ function PingAjaxChart(chart, service, start=0, end=9999999999, group="hour") {
});
}

$('.confirm_btn').on('click', function() {
let msg = $(this).attr('data-msg');
var r = confirm(msg);
if (r !== true) {
return false;
}
return true;
});

$('.ajax_delete').on('click', function() {
var r = confirm('Are you sure you want to delete?');
if (r !== true) {
Expand Down
10 changes: 5 additions & 5 deletions source/tmpl/index.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,18 @@
{{end}}</h4>

<div class="row stats_area mt-5 mb-5">
<div class="col-4">
<span class="lg_number">{{.Online24}}%</span>
Online last 24 Hours
</div>
<div class="col-4">
<span class="lg_number">{{.AvgTime}}ms</span>
Average Response
</div>
<div class="col-4">
<span class="lg_number">{{.AvgUptime24}}%</span>
<span class="lg_number">{{.Online24}}%</span>
Uptime last 24 Hours
</div>
<div class="col-4">
<span class="lg_number">{{.Online7Days}}%</span>
Uptime last 7 Days
</div>
</div>

</div>
Expand Down
24 changes: 13 additions & 11 deletions source/tmpl/settings.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -113,25 +113,27 @@
<label for="api_secret" class="col-sm-3 col-form-label">API Secret</label>
<div class="col-sm-9">
<input type="text" class="form-control select-input" value="{{ .ApiSecret }}" id="api_secret" readonly>
<small class="form-text text-muted">You can <a href="/api/renew">Regenerate API Keys</a> if you need to.</small>
<small class="form-text text-muted">You can <a class="confirm_btn" data-msg="Are you sure you want to reset the API keys?" href="/api/renew">Regenerate API Keys</a> if you need to.</small>
</div>
</div>

<div class="row">
<a href="/settings/export" class="btn btn-sm btn-secondary float-right">Export Settings</a>
{{if .Domain}}
<a href="#" class="btn btn-sm btn-secondary float-right ml-1">Authentication QR Code</a>
{{end}}
</div>
</form>

<h3>Additional Settings</h3>

<div class="row">
<a href="/settings/export" class="btn btn-sm btn-secondary float-right">Export Settings</a>
{{if .Domain}}
<a href="#" class="btn btn-sm btn-secondary float-right ml-1">Authentication QR Code</a>
{{end}}
</div>

{{if .Domain}}
<div class="row align-content-center">
<img class="rounded text-center" width="300" height="300" src="https://chart.googleapis.com/chart?chs=500x500&cht=qr&chl={{ QrAuth }}">
</div>
<a class="btn btn-sm btn-primary" href={{safeURL QrAuth}}>Open in Statping App</a>
{{end}}

</form>
{{end}}

</div>

Expand All @@ -141,7 +143,7 @@
<div class="jumbotron jumbotron-fluid">
<div class="text-center col-12">
<h1 class="display-5">Enable Local Assets</h1>
<a class="lead">Customize your status page design by enabling local assets. This will create a 'assets' directory containing all CSS.<p><a href="/settings/build" class="btn btn-primary mt-3"{{if USE_CDN}} disabled{{end}}>Enable Local Assets</a></p></p>
<span class="lead">Customize your status page design by enabling local assets. This will create a 'assets' directory containing all CSS.<p><a href="/settings/build" class="btn btn-primary mt-3"{{if USE_CDN}} disabled{{end}}>Enable Local Assets</a></p></span>
</div>
</div>
{{ else }}
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.80.0
0.80.1

0 comments on commit 86958c1

Please sign in to comment.