Permalink
Browse files

ui/mobile updates - checkin update

  • Loading branch information...
hunterlong committed Jan 10, 2019
1 parent 0c2d2f3 commit 638adbd3abe24c26531eb47b7758255811fb7a6f
Showing with 76 additions and 14 deletions.
  1. +14 −0 core/checkin.go
  2. +4 −2 handlers/routes.go
  3. +37 −0 handlers/services.go
  4. +6 −2 source/css/base.css
  5. +7 −2 source/scss/mobile.scss
  6. +1 −1 source/tmpl/index.gohtml
  7. +1 −1 source/wiki.go
  8. +5 −5 types/types.go
  9. +1 −1 version.txt
@@ -190,10 +190,24 @@ func (c *Checkin) AllFailures() []*types.Failure {
// Create will create a new Checkin
func (c *Checkin) Delete() error {
c.Close()
i := c.index()
service := c.Service()
slice := service.Checkins
service.Checkins = append(slice[:i], slice[i+1:]...)
row := checkinDB().Delete(&c)
return row.Error
}

// index returns a checkin index int for updating the *checkin.Service slice
func (c *Checkin) index() int {
for k, checkin := range c.Service().Checkins {
if c.Id == checkin.Select().Id {
return k
}
}
return 0
}

// Create will create a new Checkin
func (c *Checkin) Create() (int64, error) {
c.ApiKey = utils.RandomString(7)
@@ -35,7 +35,7 @@ func Router() *mux.Router {
dir := utils.Directory
CacheStorage = NewStorage()
r := mux.NewRouter()
r.Handle("/", cached("15s", "text/html", http.HandlerFunc(indexHandler)))
r.Handle("/", cached("120s", "text/html", http.HandlerFunc(indexHandler)))
if source.UsingAssets(dir) {
indexHandler := http.FileServer(http.Dir(dir + "/assets/"))
r.PathPrefix("/css/").Handler(http.StripPrefix("/css/", http.FileServer(http.Dir(dir+"/assets/css"))))
@@ -82,7 +82,7 @@ func Router() *mux.Router {
// SERVICE Routes
r.Handle("/services", http.HandlerFunc(servicesHandler)).Methods("GET")
r.Handle("/service/{id}", http.HandlerFunc(servicesViewHandler)).Methods("GET")
r.Handle("/service/{id}/edit", http.HandlerFunc(servicesViewHandler))
r.Handle("/service/{id}/edit", http.HandlerFunc(servicesViewHandler)).Methods("GET")
r.Handle("/service/{id}/delete_failures", http.HandlerFunc(servicesDeleteFailuresHandler)).Methods("GET")

// API GROUPS Routes
@@ -104,6 +104,8 @@ func Router() *mux.Router {
r.Handle("/api/services/{id}/ping", http.HandlerFunc(apiServicePingDataHandler)).Methods("GET")
r.Handle("/api/services/{id}", http.HandlerFunc(apiServiceUpdateHandler)).Methods("POST")
r.Handle("/api/services/{id}", http.HandlerFunc(apiServiceDeleteHandler)).Methods("DELETE")
r.Handle("/api/services/{id}/failures", http.HandlerFunc(apiServiceFailuresHandler)).Methods("GET")
r.Handle("/api/services/{id}/hits", http.HandlerFunc(apiServiceHitsHandler)).Methods("GET")

// API USER Routes
r.Handle("/api/users", http.HandlerFunc(apiAllUsersHandler)).Methods("GET")
@@ -260,3 +260,40 @@ func servicesDeleteFailuresHandler(w http.ResponseWriter, r *http.Request) {
service.DeleteFailures()
ExecuteResponse(w, r, "services.gohtml", core.CoreApp.Services, "/services")
}

func apiServiceFailuresHandler(w http.ResponseWriter, r *http.Request) {
if !IsReadAuthenticated(r) {
sendUnauthorizedJson(w, r)
return
}
vars := mux.Vars(r)
servicer := core.SelectService(utils.ToInt(vars["id"]))
if servicer == nil {
sendErrorJson(errors.New("service not found"), w, r)
return
}
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(servicer.AllFailures())
}

func apiServiceHitsHandler(w http.ResponseWriter, r *http.Request) {
if !IsReadAuthenticated(r) {
sendUnauthorizedJson(w, r)
return
}
vars := mux.Vars(r)
servicer := core.SelectService(utils.ToInt(vars["id"]))
if servicer == nil {
sendErrorJson(errors.New("service not found"), w, r)
return
}

hits, err := servicer.Hits()
if err != nil {
sendErrorJson(err, w, r)
return
}

w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(hits)
}
@@ -414,14 +414,18 @@ HTML, BODY {
background-color: #fcfcfc; }

.sm-container {
margin-top: 40px !important;
margin-top: 0px !important;
padding: 0 !important; }

.list-group-item H5 {
font-size: 0.9rem; }

.container {
padding: 0 !important; }
padding: 0px !important;
padding-top: 15px !important; }

.group_header {
margin-left: 15px; }

.navbar {
margin-left: 0px;
@@ -5,7 +5,7 @@
}

.sm-container {
margin-top: 40px !important;
margin-top: 0px !important;
padding: 0 !important;
}

@@ -14,7 +14,12 @@
}

.container {
padding: 0 !important;
padding: 0px !important;
padding-top: 15px !important;
}

.group_header {
margin-left: 15px;
}

.navbar {
@@ -10,7 +10,7 @@

{{ range Groups true }}
<div class="col-12 full-col-12">
<h4>{{.Name}}</h4>
<h4 class="group_header">{{.Name}}</h4>
<div class="list-group online_list mb-3">
{{ 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}}">

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -21,11 +21,11 @@ import (

// Hit struct is a 'successful' ping or web response entry for a service.
type Hit struct {
Id int64 `gorm:"primary_key;column:id"`
Service int64 `gorm:"column:service"`
Latency float64 `gorm:"column:latency"`
PingTime float64 `gorm:"column:ping_time"`
CreatedAt time.Time `gorm:"column:created_at"`
Id int64 `gorm:"primary_key;column:id" json:"id"`
Service int64 `gorm:"column:service" json:"-"`
Latency float64 `gorm:"column:latency" json:"latency"`
PingTime float64 `gorm:"column:ping_time" json:"ping_time"`
CreatedAt time.Time `gorm:"column:created_at" json:"created_at"`
}

// DbConfig struct is used for the database connection and creates the 'config.yml' file
@@ -1 +1 @@
0.80.35
0.80.36

0 comments on commit 638adbd

Please sign in to comment.