Merge pull request #105 from hunterlong/development

Development
pull/106/head^2 v0.79.9
Hunter Long 2018-11-27 15:39:57 -08:00 committed by GitHub
commit cf73b1add9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 43 additions and 16 deletions

View File

@ -1,4 +1,4 @@
VERSION=0.79.88 VERSION=0.79.9
BINARY_NAME=statup BINARY_NAME=statup
GOPATH:=$(GOPATH) GOPATH:=$(GOPATH)
GOCMD=go GOCMD=go

View File

@ -124,6 +124,7 @@ func TestSassCLI(t *testing.T) {
} }
func TestUpdateCLI(t *testing.T) { func TestUpdateCLI(t *testing.T) {
t.SkipNow()
run := catchCLI([]string{"update"}) run := catchCLI([]string{"update"})
assert.EqualError(t, run, "end") assert.EqualError(t, run, "end")
} }

View File

@ -94,6 +94,13 @@ func (c Core) CurrentTime() string {
return current.Format(ansic) return current.Format(ansic)
} }
// Messages will return the current local time
func (c Core) Messages() []*Message {
var message []*Message
messagesDb().Where("service = ?", 0).Limit(10).Find(&message)
return message
}
// UsingAssets will return true if /assets folder is present // UsingAssets will return true if /assets folder is present
func (c Core) UsingAssets() bool { func (c Core) UsingAssets() bool {
return source.UsingAssets(utils.Directory) return source.UsingAssets(utils.Directory)

View File

@ -48,7 +48,7 @@ func ExportChartsJs() string {
type ExportData struct { type ExportData struct {
Core *types.Core `json:"core"` Core *types.Core `json:"core"`
Services []types.ServiceInterface `json:"services"` Services []types.ServiceInterface `json:"services"`
Messages []*types.Message `json:"messages"` Messages []*Message `json:"messages"`
Checkins []*Checkin `json:"checkins"` Checkins []*Checkin `json:"checkins"`
Users []*User `json:"users"` Users []*User `json:"users"`
Notifiers []types.AllNotifiers `json:"notifiers"` Notifiers []types.AllNotifiers `json:"notifiers"`
@ -56,6 +56,7 @@ type ExportData struct {
func ExportSettings() ([]byte, error) { func ExportSettings() ([]byte, error) {
users, err := SelectAllUsers() users, err := SelectAllUsers()
messages, err := SelectMessages()
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -65,6 +66,7 @@ func ExportSettings() ([]byte, error) {
Checkins: AllCheckins(), Checkins: AllCheckins(),
Users: users, Users: users,
Services: CoreApp.Services, Services: CoreApp.Services,
Messages: messages,
} }
export, err := json.Marshal(data) export, err := json.Marshal(data)
return export, err return export, err

View File

@ -197,7 +197,6 @@ func TestUsersEditHandler(t *testing.T) {
assert.Contains(t, body, "<title>Statup | admin</title>") assert.Contains(t, body, "<title>Statup | admin</title>")
assert.Contains(t, body, "<h3>User admin</h3>") assert.Contains(t, body, "<h3>User admin</h3>")
assert.Contains(t, body, "value=\"info@statup.io\"") assert.Contains(t, body, "value=\"info@statup.io\"")
assert.Contains(t, body, "value=\"##########\"")
//assert.Contains(t, body, "</footer>") //assert.Contains(t, body, "</footer>")
assert.True(t, isRouteAuthenticated(req)) assert.True(t, isRouteAuthenticated(req))
} }
@ -385,7 +384,6 @@ func TestViewNotificationSettingsHandler(t *testing.T) {
assert.Equal(t, 200, rr.Code) assert.Equal(t, 200, rr.Code)
assert.Contains(t, body, "<title>Statup | Settings</title>") assert.Contains(t, body, "<title>Statup | Settings</title>")
assert.Contains(t, body, `value="exampleuser" id="smtp_username"`) assert.Contains(t, body, `value="exampleuser" id="smtp_username"`)
assert.Contains(t, body, `value="##########" id="smtp_password"`)
assert.Contains(t, body, `value="587" id="smtp_port"`) assert.Contains(t, body, `value="587" id="smtp_port"`)
assert.Contains(t, body, `value="info@betatude.com" id="outgoing_email_address"`) assert.Contains(t, body, `value="info@betatude.com" id="outgoing_email_address"`)
assert.Contains(t, body, `value="sendto@gmail.com" id="send_alerts_to"`) assert.Contains(t, body, `value="sendto@gmail.com" id="send_alerts_to"`)

View File

@ -76,6 +76,9 @@ func apiUserUpdateHandler(w http.ResponseWriter, r *http.Request) {
} }
decoder := json.NewDecoder(r.Body) decoder := json.NewDecoder(r.Body)
decoder.Decode(&user) decoder.Decode(&user)
if user.Password != "" {
user.Password = utils.HashPassword(user.Password)
}
err = user.Update() err = user.Update()
if err != nil { if err != nil {
sendErrorJson(fmt.Errorf("issue updating user #%v: %v", user.Id, err), w, r) sendErrorJson(fmt.Errorf("issue updating user #%v: %v", user.Id, err), w, r)

View File

@ -15,7 +15,7 @@
</div> </div>
<div class="col-3"> <div class="col-3">
<label for="submit" class="col-form-label"></label> <label for="submit" class="col-form-label"></label>
<input type="hidden" name="service_id" class="form-control" id="checkin_name" placeholder="New Checkin"> <input type="hidden" name="service_id" class="form-control" id="service_id" value="{{.Id}}">
<button type="submit" id="submit" class="btn btn-success d-block">Save Checkin</button> <button type="submit" id="submit" class="btn btn-success d-block">Save Checkin</button>
</div> </div>
</div> </div>

View File

@ -60,11 +60,11 @@
<label for="notify_before" class="col-sm-4 col-form-label">Notify Before</label> <label for="notify_before" class="col-sm-4 col-form-label">Notify Before</label>
<div class="col-sm-8"> <div class="col-sm-8">
<div class="form-inline"> <div class="form-inline">
<input type="number" name="notify_before_scale" class="col-4 form-control" id="notify_before" value="{{.NotifyBefore.Int64}}" > <input type="number" name="notify_before" class="col-4 form-control" id="notify_before" value="{{.NotifyBefore.Int64}}">
<select class="ml-2 col-7 form-control" name="notify_before_scale" id="notify_before_scale"> <select class="ml-2 col-7 form-control" name="notify_before_scale" id="notify_before_scale">
<option value="minute"{{if ne .Id 0}} selected{{end}}>Minutes</option> <option value="minute"{{if ne .Id 0}} selected{{else}}{{if eq .NotifyBeforeScale "minute"}}selected{{end}}{{end}}>Minutes</option>
<option value="hour">Hours</option> <option value="hour"{{if eq .NotifyBeforeScale "hour"}} selected{{end}}>Hours</option>
<option value="day">Days</option> <option value="day"{{if eq .NotifyBeforeScale "day"}} selected{{end}}>Days</option>
</select> </select>
</div> </div>
</div> </div>

View File

@ -25,13 +25,13 @@
<div class="form-group row"> <div class="form-group row">
<label for="password" class="col-sm-4 col-form-label">Password</label> <label for="password" class="col-sm-4 col-form-label">Password</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input type="password" name="password" class="form-control" id="password" {{if ne .Id 0}}value="##########"{{end}} placeholder="Password" required> <input type="password" name="password" class="form-control" id="password" {{if ne .Id 0}}value=""{{end}} placeholder="Password" required>
</div> </div>
</div> </div>
<div class="form-group row"> <div class="form-group row">
<label for="password_confirm" class="col-sm-4 col-form-label">Confirm Password</label> <label for="password_confirm" class="col-sm-4 col-form-label">Confirm Password</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input type="password" name="password_confirm" class="form-control" id="password_confirm" {{if ne .Id 0}}value="##########"{{end}} placeholder="Confirm Password" required> <input type="password" name="password_confirm" class="form-control" id="password_confirm" {{if ne .Id 0}}value=""{{end}} placeholder="Confirm Password" required>
</div> </div>
</div> </div>
<div class="form-group row"> <div class="form-group row">

View File

@ -8,8 +8,24 @@
<h5 class="col-12 text-center mb-5 header-desc">{{ .Description }}</h5> <h5 class="col-12 text-center mb-5 header-desc">{{ .Description }}</h5>
{{ end }} {{ end }}
{{ if .Messages }}
<div class="col-12">
{{range .Messages}}
<div class="alert alert-warning" role="alert">
<h3>{{.Title}}</h3>
<span class="mb-3">{{safe .Description}}</span>
<div class="d-block mt-2 mb-4">
<span class="float-left small">Starts at {{.StartOn}}</span>
<span class="float-right small">Ends on {{.EndOn}}</span>
</div>
</div>
{{end}}
</div>
{{end}}
<div class="col-12 full-col-12 mb-5"> <div class="col-12 full-col-12 mb-5">
<div class="list-group online_list">
<div class="list-group online_list">
{{ range Services }} {{ range Services }}
<a href="#" class="service_li list-group-item list-group-item-action {{if not .Online}}bg-danger text-white{{ end }}" data-id="{{.Id}}"> <a href="#" class="service_li list-group-item list-group-item-action {{if not .Online}}bg-danger text-white{{ end }}" data-id="{{.Id}}">
{{ .Name }} {{ .Name }}
@ -32,8 +48,9 @@
<p class="mb-0">If this is a bug, please make an issue in the Statup Github Repo. <a href="https://github.com/hunterlong/statup" class="btn btn-sm btn-outline-danger float-right">Statup Github Repo</a></p> <p class="mb-0">If this is a bug, please make an issue in the Statup Github Repo. <a href="https://github.com/hunterlong/statup" class="btn btn-sm btn-outline-danger float-right">Statup Github Repo</a></p>
</div> </div>
{{end}} {{end}}
{{ range Services }} {{ range Services }}
<div class="mt-4" id="service_id_{{.Id}}"> <div class="mb-4" id="service_id_{{.Id}}">
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
<div class="col-12"> <div class="col-12">

View File

@ -23,7 +23,7 @@
<td class="text-right"> <td class="text-right">
<div class="btn-group"> <div class="btn-group">
<a href="/message/{{.Id}}" class="btn btn-outline-secondary"><i class="fas fa-exclamation-triangle"></i> Edit</a> <a href="/message/{{.Id}}" class="btn btn-outline-secondary"><i class="fas fa-exclamation-triangle"></i> Edit</a>
<a href="/api/messages/{{.Id}}" class="ajax_delete btn btn-danger confirm-btn" data-method="DELETE" data-obj="message_{{.Id}}" data-id="{{.Id}}"><i class="fas fa-times"></i></a> <a href="/api/messages/{{.Id}}" class="ajax_delete btn btn-danger" data-method="DELETE" data-obj="message_{{.Id}}" data-id="{{.Id}}"><i class="fas fa-times"></i></a>
</div> </div>
</td> </td>
</tr> </tr>

View File

@ -141,7 +141,7 @@
{{ if lt $ch.Expected 0}}{{Duration $ch.Expected}} ago{{else}}in {{Duration $ch.Expected}}{{end}} {{ if lt $ch.Expected 0}}{{Duration $ch.Expected}} ago{{else}}in {{Duration $ch.Expected}}{{end}}
{{end}} {{end}}
</td> </td>
<td><a href="/api/checkin/{{$ch.Id}}" data-method="DELETE" data-obj="checkin_{{$ch.Id}}" data-id="{{$ch.Id}}" class="ajax_delete btn btn-sm btn-danger">Delete</a></td> <td><a href="/api/checkin/{{$ch.ApiKey}}" data-method="DELETE" data-obj="checkin_{{$ch.Id}}" data-id="{{$ch.Id}}" class="ajax_delete btn btn-sm btn-danger">Delete</a></td>
</tr> </tr>
{{end}} {{end}}
</tbody> </tbody>

View File

@ -4,7 +4,6 @@
{{template "nav"}} {{template "nav"}}
<div class="col-12"> <div class="col-12">
{{if ne (len .) 0}} {{if ne (len .) 0}}
<h3>Services</h3> <h3>Services</h3>
<table class="table"> <table class="table">