user api fix - message fixes - checkin fix

pull/105/head
Hunter Long 2018-11-27 15:11:00 -08:00
parent 3e433ea8bf
commit 07899b05a3
9 changed files with 35 additions and 9 deletions

View File

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

View File

@ -94,6 +94,13 @@ func (c Core) CurrentTime() string {
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
func (c Core) UsingAssets() bool {
return source.UsingAssets(utils.Directory)

View File

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

View File

@ -15,7 +15,7 @@
</div>
<div class="col-3">
<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>
</div>
</div>

View File

@ -25,13 +25,13 @@
<div class="form-group row">
<label for="password" class="col-sm-4 col-form-label">Password</label>
<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 class="form-group row">
<label for="password_confirm" class="col-sm-4 col-form-label">Confirm Password</label>
<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 class="form-group row">

View File

@ -8,8 +8,24 @@
<h5 class="col-12 text-center mb-5 header-desc">{{ .Description }}</h5>
{{ 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="list-group online_list">
<div class="list-group online_list">
{{ 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}}">
{{ .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>
</div>
{{end}}
{{ range Services }}
<div class="mt-4" id="service_id_{{.Id}}">
<div class="mb-4" id="service_id_{{.Id}}">
<div class="card">
<div class="card-body">
<div class="col-12">

View File

@ -23,7 +23,7 @@
<td class="text-right">
<div class="btn-group">
<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>
</td>
</tr>

View File

@ -141,7 +141,7 @@
{{ if lt $ch.Expected 0}}{{Duration $ch.Expected}} ago{{else}}in {{Duration $ch.Expected}}{{end}}
{{end}}
</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>
{{end}}
</tbody>

View File

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