Skip to content

Commit

Permalink
bulk import - issue #144
Browse files Browse the repository at this point in the history
  • Loading branch information
hunterlong committed May 14, 2019
1 parent 359c00c commit 355e7e3
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 29 deletions.
4 changes: 2 additions & 2 deletions core/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,13 @@ func (s *Service) lastFailure() *Failure {
// // Online since Monday 3:04:05PM, Jan _2 2006
func (s *Service) SmallText() string {
last := s.LimitedFailures(1)
hits, _ := s.LimitedHits(1)
//hits, _ := s.LimitedHits(1)
zone := CoreApp.Timezone
if s.Online {
if len(last) == 0 {
return fmt.Sprintf("Online since %v", utils.Timezoner(s.CreatedAt, zone).Format("Monday 3:04:05PM, Jan _2 2006"))
} else {
return fmt.Sprintf("Online, last Failure was %v", utils.Timezoner(hits[0].CreatedAt, zone).Format("Monday 3:04:05PM, Jan _2 2006"))
return fmt.Sprintf("Online, last Failure was %v", utils.Timezoner(last[0].CreatedAt, zone).Format("Monday 3:04:05PM, Jan _2 2006"))
}
}
if len(last) > 0 {
Expand Down
10 changes: 5 additions & 5 deletions handlers/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ func commaToService(s []string) (*types.Service, error) {
return nil, err
}

allowNotifications, err := strconv.ParseBool(s[10])
allowNotifications, err := strconv.ParseBool(s[11])
if err != nil {
return nil, err
}

public, err := strconv.ParseBool(s[11])
public, err := strconv.ParseBool(s[12])
if err != nil {
return nil, err
}
Expand All @@ -182,9 +182,9 @@ func commaToService(s []string) (*types.Service, error) {
Timeout: int(utils.ToInt(timeout.Seconds())),
AllowNotifications: types.NewNullBool(allowNotifications),
Public: types.NewNullBool(public),
GroupId: int(utils.ToInt(s[12])),
Headers: types.NewNullString(s[13]),
Permalink: types.NewNullString(s[14]),
GroupId: int(utils.ToInt(s[13])),
Headers: types.NewNullString(s[14]),
Permalink: types.NewNullString(s[15]),
}

return newService, nil
Expand Down
10 changes: 6 additions & 4 deletions source/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ $('.toggle-service').on('click',function(e) {
let obj = $(this);
let serviceId = obj.attr("data-id");
let online = obj.attr("data-online");
let d = confirm("Do you want to "+online ? "stop" : "start"+" checking this service?");
let d = confirm("Do you want to "+(online ? "stop" : "start")+" checking this service?");
if (d) {
$.ajax({
url: "/api/services/" + serviceId + "/running",
Expand Down Expand Up @@ -150,9 +150,11 @@ async function RenderChart(chart, service, start=0, end=9999999999, group="hour"
chartData = await ChartLatency(service, start, end, "minute", retry);
}
chart.render();
chart.updateSeries([{
data: chartData
}]);
if (chartData) {
chart.updateSeries([{
data: chartData
}]);
}
}


Expand Down
File renamed without changes.
40 changes: 23 additions & 17 deletions source/tmpl/settings.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@

{{if not .Domain}}
<div class="alert alert-danger" role="alert">
Your Statup server does not have a dedicated URL!
Your Statping server does not have a dedicated URL!
</div>
{{end}}

Expand Down Expand Up @@ -123,14 +123,31 @@

</form>

<h3>Additional Settings</h3>
<h3 class="mt-4">Bulk Import Services</h3>
You can import multiple services based on a CSV file with the format shown on the <a href="https://github.com/hunterlong/statping/wiki/Bulk-Import-Services" target="_blank">Bulk Import Wiki</a>.

<div class="card">
<div class="card-body">
<form action="/settings/bulk_import" method="POST" enctype="multipart/form-data" class="form-inline">
<div class="form-group col-10">
<input type="file" name="file" class="form-control-file" accept=".csv">
</div>
<div class="form-group">
<button type="submit" class="btn btn-outline-success right">Import</button>
</div>
</form>
</div>
</div>


<h3 class="mt-4">Additional Settings</h3>

<div class="row">
<a href="/settings/export" class="btn btn-sm btn-secondary float-right">Export Settings</a>
<div class="col-12">
<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">
Expand All @@ -139,19 +156,8 @@
<a class="btn btn-sm btn-primary" href={{safeURL QrAuth}}>Open in Statping App</a>
{{end}}


<h3 class="mt-3">Bulk Import Services</h3>
You can import multiple services based on a CSV file with the format shown on the <a href="https://github.com/hunterlong/statping/wiki/Bulk-Import-Services" target="_blank">Bulk Import Wiki</a>.

<form action="/settings/bulk_import" method="POST" enctype="multipart/form-data" class="form-inline">
<div class="form-group">
<input type="file" name="file" class="form-control-file" accept=".csv">
</div>
<div class="form-group">
<button type="submit" class="btn btn-success ml-3">Upload</button>
</div>
</form>

</div>
</div>
</div>

<div class="tab-pane" id="v-pills-style" role="tabpanel" aria-labelledby="v-pills-style-tab">
Expand Down
2 changes: 1 addition & 1 deletion source/wiki.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 355e7e3

Please sign in to comment.