Merge pull request #17 from hunterlong/dev

load from .env - view updates - enable CDN
pull/18/merge v0.29.7
Hunter Long 2018-07-06 22:24:37 -07:00 committed by GitHub
commit f1d02e73cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 328 additions and 42 deletions

View File

@ -18,7 +18,7 @@ services:
env: env:
global: global:
- VERSION=0.29.6 - VERSION=0.29.7
- DB_HOST=localhost - DB_HOST=localhost
- DB_USER=travis - DB_USER=travis
- DB_PASS= - DB_PASS=

View File

@ -1,6 +1,6 @@
FROM alpine:latest FROM alpine:latest
ENV VERSION=v0.29.6 ENV VERSION=v0.29.7
RUN apk --no-cache add libstdc++ ca-certificates RUN apk --no-cache add libstdc++ ca-certificates
RUN wget -q https://github.com/hunterlong/statup/releases/download/$VERSION/statup-linux-alpine.tar.gz && \ RUN wget -q https://github.com/hunterlong/statup/releases/download/$VERSION/statup-linux-alpine.tar.gz && \

View File

@ -1,25 +1,62 @@
package core package core
import ( import (
"errors"
"github.com/go-yaml/yaml" "github.com/go-yaml/yaml"
"github.com/hunterlong/statup/types" "github.com/hunterlong/statup/types"
"io/ioutil" "io/ioutil"
"os"
) )
type Config types.Config func LoadConfig() (*types.Config, error) {
if os.Getenv("DB_CONN") != "" {
var ( return LoadUsingEnv()
VERSION string }
) Configs = new(types.Config)
func LoadConfig() (*Config, error) {
var config *Config
file, err := ioutil.ReadFile("config.yml") file, err := ioutil.ReadFile("config.yml")
if err != nil { if err != nil {
return nil, err return nil, errors.New("config.yml file not found - starting in setup mode")
} }
err = yaml.Unmarshal(file, &config) err = yaml.Unmarshal(file, &Configs)
Configs = config CoreApp.DbConnection = Configs.Connection
CoreApp.DbConnection = config.Connection return Configs, err
return config, err }
func LoadUsingEnv() (*types.Config, error) {
Configs = new(types.Config)
if os.Getenv("DB_CONN") == "" {
return nil, errors.New("Missing DB_CONN environment variable")
}
if os.Getenv("DB_HOST") == "" {
return nil, errors.New("Missing DB_HOST environment variable")
}
if os.Getenv("DB_USER") == "" {
return nil, errors.New("Missing DB_USER environment variable")
}
if os.Getenv("DB_PASS") == "" {
return nil, errors.New("Missing DB_PASS environment variable")
}
if os.Getenv("DB_DATABASE") == "" {
return nil, errors.New("Missing DB_DATABASE environment variable")
}
Configs.Connection = os.Getenv("DB_CONN")
Configs.Host = os.Getenv("DB_HOST")
Configs.Port = os.Getenv("DB_PORT")
Configs.User = os.Getenv("DB_USER")
Configs.Password = os.Getenv("DB_PASS")
Configs.Database = os.Getenv("DB_DATABASE")
CoreApp.DbConnection = os.Getenv("DB_CONN")
CoreApp.Name = os.Getenv("NAME")
CoreApp.Domain = os.Getenv("DOMAIN")
if os.Getenv("USE_CDN") == "true" {
CoreApp.UseCdn = true
}
return Configs, nil
}
func ifOr(val, def string) string {
if val == "" {
return def
}
return val
} }

View File

@ -4,6 +4,8 @@ import (
"github.com/GeertJohan/go.rice" "github.com/GeertJohan/go.rice"
"github.com/hunterlong/statup/plugin" "github.com/hunterlong/statup/plugin"
"github.com/hunterlong/statup/types" "github.com/hunterlong/statup/types"
"github.com/pkg/errors"
"os"
"time" "time"
) )
@ -27,13 +29,12 @@ type Core struct {
Repos []PluginJSON Repos []PluginJSON
AllPlugins []plugin.PluginActions AllPlugins []plugin.PluginActions
Communications []*types.Communication Communications []*types.Communication
OfflineAssets bool
DbConnection string DbConnection string
started time.Time started time.Time
} }
var ( var (
Configs *Config Configs *types.Config
CoreApp *Core CoreApp *Core
SqlBox *rice.Box SqlBox *rice.Box
CssBox *rice.Box CssBox *rice.Box
@ -43,6 +44,7 @@ var (
EmailBox *rice.Box EmailBox *rice.Box
SetupMode bool SetupMode bool
UsingAssets bool UsingAssets bool
VERSION string
) )
func init() { func init() {
@ -107,6 +109,9 @@ func (c Core) AllOnline() bool {
func SelectLastMigration() (int64, error) { func SelectLastMigration() (int64, error) {
var c *Core var c *Core
if DbSession == nil {
return 0, errors.New("Database connection has not been created yet")
}
err := DbSession.Collection("core").Find().One(&c) err := DbSession.Collection("core").Find().One(&c)
if err != nil { if err != nil {
return 0, err return 0, err
@ -124,6 +129,9 @@ func SelectCore() (*Core, error) {
CoreApp.DbConnection = Configs.Connection CoreApp.DbConnection = Configs.Connection
CoreApp.Version = VERSION CoreApp.Version = VERSION
CoreApp.Services, _ = SelectAllServices() CoreApp.Services, _ = SelectAllServices()
if os.Getenv("USE_CDN") == "true" {
CoreApp.UseCdn = true
}
//store = sessions.NewCookieStore([]byte(core.ApiSecret)) //store = sessions.NewCookieStore([]byte(core.ApiSecret))
return CoreApp, err return CoreApp, err
} }

View File

@ -157,6 +157,9 @@ func reverseSlice(s []string) []string {
func RunDatabaseUpgrades() error { func RunDatabaseUpgrades() error {
var err error var err error
currentMigration, err = SelectLastMigration() currentMigration, err = SelectLastMigration()
if err != nil {
return err
}
utils.Log(1, fmt.Sprintf("Checking for Database Upgrades since #%v", currentMigration)) utils.Log(1, fmt.Sprintf("Checking for Database Upgrades since #%v", currentMigration))
upgrade, _ := SqlBox.String(CoreApp.DbConnection + "_upgrade.sql") upgrade, _ := SqlBox.String(CoreApp.DbConnection + "_upgrade.sql")
// parse db version and upgrade file // parse db version and upgrade file

View File

@ -8,7 +8,7 @@ import (
) )
func ExportIndexHTML() string { func ExportIndexHTML() string {
CoreApp.OfflineAssets = true CoreApp.UseCdn = true
//out := index{*CoreApp, CoreApp.Services} //out := index{*CoreApp, CoreApp.Services}
nav, _ := TmplBox.String("nav.html") nav, _ := TmplBox.String("nav.html")
footer, _ := TmplBox.String("footer.html") footer, _ := TmplBox.String("footer.html")

View File

@ -86,6 +86,9 @@ func ExecuteResponse(w http.ResponseWriter, r *http.Request, file string, data i
"VERSION": func() string { "VERSION": func() string {
return core.VERSION return core.VERSION
}, },
"USE_CDN": func() bool {
return core.CoreApp.UseCdn
},
"underscore": func(html string) string { "underscore": func(html string) string {
return utils.UnderScoreString(html) return utils.UnderScoreString(html)
}, },

View File

@ -29,6 +29,7 @@ func Router() *mux.Router {
r.Handle("/service/{id}/delete_failures", http.HandlerFunc(ServicesDeleteFailuresHandler)).Methods("GET") r.Handle("/service/{id}/delete_failures", http.HandlerFunc(ServicesDeleteFailuresHandler)).Methods("GET")
r.Handle("/service/{id}/checkin", http.HandlerFunc(CheckinCreateUpdateHandler)).Methods("POST") r.Handle("/service/{id}/checkin", http.HandlerFunc(CheckinCreateUpdateHandler)).Methods("POST")
r.Handle("/users", http.HandlerFunc(UsersHandler)).Methods("GET") r.Handle("/users", http.HandlerFunc(UsersHandler)).Methods("GET")
r.Handle("/user/{id}", http.HandlerFunc(UsersHandler)).Methods("GET")
r.Handle("/users", http.HandlerFunc(CreateUserHandler)).Methods("POST") r.Handle("/users", http.HandlerFunc(CreateUserHandler)).Methods("POST")
r.Handle("/users/{id}/delete", http.HandlerFunc(UsersDeleteHandler)).Methods("GET") r.Handle("/users/{id}/delete", http.HandlerFunc(UsersDeleteHandler)).Methods("GET")
r.Handle("/settings", http.HandlerFunc(PluginsHandler)).Methods("GET") r.Handle("/settings", http.HandlerFunc(PluginsHandler)).Methods("GET")

View File

@ -54,6 +54,7 @@ func SaveSettingsHandler(w http.ResponseWriter, r *http.Request) {
if domain != core.CoreApp.Domain { if domain != core.CoreApp.Domain {
core.CoreApp.Domain = domain core.CoreApp.Domain = domain
} }
core.CoreApp.UseCdn = (r.PostForm.Get("enable_cdn") == "on")
core.CoreApp.Update() core.CoreApp.Update()
core.OnSettingsSaved(core.CoreApp) core.OnSettingsSaved(core.CoreApp)
http.Redirect(w, r, "/settings", http.StatusSeeOther) http.Redirect(w, r, "/settings", http.StatusSeeOther)

View File

@ -16,7 +16,8 @@ import (
) )
var ( var (
VERSION string VERSION string
usingEnv bool
) )
func init() { func init() {
@ -36,7 +37,7 @@ func main() {
core.Configs, err = core.LoadConfig() core.Configs, err = core.LoadConfig()
if err != nil { if err != nil {
utils.Log(2, "config.yml file not found - starting in setup mode") utils.Log(3, err)
core.SetupMode = true core.SetupMode = true
handlers.RunHTTPServer() handlers.RunHTTPServer()
} }
@ -56,6 +57,7 @@ func LoadDotEnvs() {
err := godotenv.Load() err := godotenv.Load()
if err == nil { if err == nil {
utils.Log(1, "Environment file '.env' Loaded") utils.Log(1, "Environment file '.env' Loaded")
usingEnv = true
} }
} }

View File

@ -3,8 +3,13 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, maximum-scale=1.0, user-scalable=0"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, maximum-scale=1.0, user-scalable=0">
{{if USE_CDN}}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<link rel="stylesheet" href="https://assets.statup.io/base.css">
{{ else }}
<link rel="stylesheet" href="/css/bootstrap.min.css"> <link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/base.css"> <link rel="stylesheet" href="/css/base.css">
{{end}}
<title>Statup | Dashboard</title> <title>Statup | Dashboard</title>
</head> </head>
@ -83,8 +88,16 @@
{{template "footer"}} {{template "footer"}}
{{if USE_CDN}}
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
<script src="https://assets.statup.io/main.js"></script>
{{ else }}
<script src="/js/jquery-3.3.1.slim.min.js"></script> <script src="/js/jquery-3.3.1.slim.min.js"></script>
<script src="/js/bootstrap.min.js"></script> <script src="/js/bootstrap.min.js"></script>
<script src="/js/main.js"></script>
{{end}}
</body> </body>
</html> </html>

View File

@ -3,8 +3,13 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, maximum-scale=1.0, user-scalable=0"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, maximum-scale=1.0, user-scalable=0">
{{if USE_CDN}}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<link rel="stylesheet" href="https://assets.statup.io/base.css">
{{ else }}
<link rel="stylesheet" href="/css/bootstrap.min.css"> <link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/base.css"> <link rel="stylesheet" href="/css/base.css">
{{end}}
<title>Statup | Page Not Found</title> <title>Statup | Page Not Found</title>
</head> </head>
@ -25,7 +30,15 @@
{{template "footer"}} {{template "footer"}}
{{if USE_CDN}}
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
<script src="https://assets.statup.io/main.js"></script>
{{ else }}
<script src="/js/jquery-3.3.1.slim.min.js"></script> <script src="/js/jquery-3.3.1.slim.min.js"></script>
<script src="/js/bootstrap.min.js"></script> <script src="/js/bootstrap.min.js"></script>
<script src="/js/main.js"></script>
{{end}}
</body> </body>
</html> </html>

View File

@ -3,10 +3,13 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
{{if USE_CDN}}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<link rel="stylesheet" href="https://assets.statup.io/base.css">
{{ else }}
<link rel="stylesheet" href="/css/bootstrap.min.css"> <link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/base.css"> <link rel="stylesheet" href="/css/base.css">
{{end}}
<title>Statup | Help</title> <title>Statup | Help</title>
</head> </head>
<body> <body>
@ -52,7 +55,15 @@
{{template "footer"}} {{template "footer"}}
<script src="/js/jquery-3.3.1.slim.min.js"></script> {{if USE_CDN}}
<script src="/js/bootstrap.min.js"></script> <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
<script src="https://assets.statup.io/main.js"></script>
{{ else }}
<script src="/js/jquery-3.3.1.slim.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script src="/js/main.js"></script>
{{end}}
</body> </body>
</html> </html>

View File

@ -4,12 +4,13 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, maximum-scale=1.0, user-scalable=0"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, maximum-scale=1.0, user-scalable=0">
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico"> <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico">
{{if .Core.OfflineAssets}} {{if USE_CDN}}
<link rel="stylesheet" href="https://assets.statup.io/bootstrap.min.css"> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<link rel="stylesheet" href="https://assets.statup.io/base.css">
{{ else }} {{ else }}
<link rel="stylesheet" href="/css/bootstrap.min.css"> <link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/base.css">
{{end}} {{end}}
<link rel="stylesheet" href="/css/base.css">
<title>{{.Core.Name}} Status</title> <title>{{.Core.Name}} Status</title>
</head> </head>
@ -101,16 +102,17 @@
{{template "footer"}} {{template "footer"}}
{{if .Core.OfflineAssets}} {{if USE_CDN}}
<script src="https://assets.statup.io/jquery-3.3.1.slim.min.js"></script> <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://assets.statup.io/bootstrap.min.js"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
<script src="https://assets.statup.io/Chart.bundle.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.bundle.min.js"></script>
<script src="https://assets.statup.io/main.js"></script>
{{ else }} {{ else }}
<script src="/js/jquery-3.3.1.slim.min.js"></script> <script src="/js/jquery-3.3.1.slim.min.js"></script>
<script src="/js/bootstrap.min.js"></script> <script src="/js/bootstrap.min.js"></script>
<script src="/js/Chart.bundle.min.js"></script> <script src="/js/Chart.bundle.min.js"></script>
{{end}}
<script src="/js/main.js"></script> <script src="/js/main.js"></script>
{{end}}
<script src="/charts.js"></script> <script src="/charts.js"></script>
{{ if .Core.Style }} {{ if .Core.Style }}

View File

@ -3,9 +3,13 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, maximum-scale=1.0, user-scalable=0"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, maximum-scale=1.0, user-scalable=0">
{{if USE_CDN}}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<link rel="stylesheet" href="https://assets.statup.io/base.css">
{{ else }}
<link rel="stylesheet" href="/css/bootstrap.min.css"> <link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/base.css"> <link rel="stylesheet" href="/css/base.css">
{{end}}
<title>Statup | Login</title> <title>Statup | Login</title>
</head> </head>
<body> <body>
@ -47,7 +51,15 @@
{{template "footer"}} {{template "footer"}}
{{if USE_CDN}}
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
<script src="https://assets.statup.io/main.js"></script>
{{ else }}
<script src="/js/jquery-3.3.1.slim.min.js"></script> <script src="/js/jquery-3.3.1.slim.min.js"></script>
<script src="/js/bootstrap.min.js"></script> <script src="/js/bootstrap.min.js"></script>
<script src="/js/main.js"></script>
{{end}}
</body> </body>
</html> </html>

View File

@ -3,9 +3,15 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, maximum-scale=1.0, user-scalable=0"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, maximum-scale=1.0, user-scalable=0">
{{if USE_CDN}}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<link rel="stylesheet" href="https://assets.statup.io/base.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.bundle.min.js"></script>
{{ else }}
<link rel="stylesheet" href="/css/bootstrap.min.css"> <link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/base.css"> <link rel="stylesheet" href="/css/base.css">
<script src="/js/Chart.bundle.min.js"></script> <script src="/js/Chart.bundle.min.js"></script>
{{end}}
<title>Statup | {{.Name}} Service</title> <title>Statup | {{.Name}} Service</title>
</head> </head>
@ -245,7 +251,15 @@
}); });
</script> </script>
{{if USE_CDN}}
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
<script src="https://assets.statup.io/main.js"></script>
{{ else }}
<script src="/js/jquery-3.3.1.slim.min.js"></script> <script src="/js/jquery-3.3.1.slim.min.js"></script>
<script src="/js/bootstrap.min.js"></script> <script src="/js/bootstrap.min.js"></script>
<script src="/js/main.js"></script>
{{end}}
</body> </body>
</html> </html>

View File

@ -3,9 +3,13 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, maximum-scale=1.0, user-scalable=0"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, maximum-scale=1.0, user-scalable=0">
{{if USE_CDN}}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<link rel="stylesheet" href="https://assets.statup.io/base.css">
{{ else }}
<link rel="stylesheet" href="/css/bootstrap.min.css"> <link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/base.css"> <link rel="stylesheet" href="/css/base.css">
{{end}}
<title>Statup | Services</title> <title>Statup | Services</title>
</head> </head>
<body> <body>
@ -120,7 +124,15 @@
{{template "footer"}} {{template "footer"}}
{{if USE_CDN}}
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
<script src="https://assets.statup.io/main.js"></script>
{{ else }}
<script src="/js/jquery-3.3.1.slim.min.js"></script> <script src="/js/jquery-3.3.1.slim.min.js"></script>
<script src="/js/bootstrap.min.js"></script> <script src="/js/bootstrap.min.js"></script>
<script src="/js/main.js"></script>
{{end}}
</body> </body>
</html> </html>

View File

@ -3,10 +3,15 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, maximum-scale=1.0, user-scalable=0"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="https://assets.statup.io/bootstrap.min.css"> {{if USE_CDN}}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<link rel="stylesheet" href="https://assets.statup.io/base.css">
{{ else }}
<link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/base.css">
{{end}}
<link rel="stylesheet" href="https://assets.statup.io/codemirror.css"> <link rel="stylesheet" href="https://assets.statup.io/codemirror.css">
<link rel="stylesheet" href="https://assets.statup.io/codemirror-colorpicker.css"/> <link rel="stylesheet" href="https://assets.statup.io/codemirror-colorpicker.css"/>
<link rel="stylesheet" href="/css/base.css">
<title>Statup | Settings</title> <title>Statup | Settings</title>
</head> </head>
@ -55,9 +60,18 @@
<input type="text" name="description" class="form-control" value="{{ .Description }}" id="description" placeholder="Great Uptime"> <input type="text" name="description" class="form-control" value="{{ .Description }}" id="description" placeholder="Great Uptime">
</div> </div>
<div class="form-group"> <div class="form-group row">
<label for="domain">Domain</label> <div class="col-sm-7">
<input type="text" name="domain" class="form-control" value="{{ .Domain }}" id="domain"> <label for="domain">Domain</label>
<input type="text" name="domain" class="form-control" value="{{ .Domain }}" id="domain">
</div>
<div class="col-sm-5 mt-4">
<span class="switch">
<input type="checkbox" name="enable_cdn" class="switch" id="switch-normal" {{if USE_CDN}}checked{{end}}>
<label for="switch-normal">Enable CDN</label>
</span>
</div>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -226,12 +240,24 @@
</div> </div>
{{template "footer"}} {{template "footer"}}
<script src="https://assets.statup.io/jquery-3.3.1.slim.min.js"></script> {{if USE_CDN}}
<script src="https://assets.statup.io/bootstrap.min.js"></script> <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
{{ else }}
<script src="/js/jquery-3.3.1.slim.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
{{end}}
<script src="https://assets.statup.io/codemirror.js"></script> <script src="https://assets.statup.io/codemirror.js"></script>
<script src="https://assets.statup.io/css.js"></script> <script src="https://assets.statup.io/css.js"></script>
<script src="https://assets.statup.io/codemirror-colorpicker.min.js"></script> <script src="https://assets.statup.io/codemirror-colorpicker.min.js"></script>
{{if USE_CDN}}
<script src="https://assets.statup.io/main.js"></script>
{{else}}
<script src="/js/main.js"></script> <script src="/js/main.js"></script>
{{end}}
</body> </body>
</html> </html>

View File

@ -3,8 +3,13 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, maximum-scale=1.0, user-scalable=0"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, maximum-scale=1.0, user-scalable=0">
{{if USE_CDN}}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<link rel="stylesheet" href="https://assets.statup.io/base.css">
{{ else }}
<link rel="stylesheet" href="/css/bootstrap.min.css"> <link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/base.css"> <link rel="stylesheet" href="/css/base.css">
{{end}}
<title>Statup | Setup</title> <title>Statup | Setup</title>
</head> </head>
@ -110,9 +115,15 @@
{{template "footer"}} {{template "footer"}}
{{if USE_CDN}}
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
<script src="https://assets.statup.io/setup.js"></script>
{{ else }}
<script src="/js/jquery-3.3.1.slim.min.js"></script> <script src="/js/jquery-3.3.1.slim.min.js"></script>
<script src="/js/bootstrap.min.js"></script> <script src="/js/bootstrap.min.js"></script>
<script src="/js/setup.js"></script> <script src="/js/setup.js"></script>
{{end}}
</body> </body>
</html> </html>

104
source/tmpl/user.html Normal file
View File

@ -0,0 +1,104 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, maximum-scale=1.0, user-scalable=0">
{{if USE_CDN}}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<link rel="stylesheet" href="https://assets.statup.io/base.css">
{{ else }}
<link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/base.css">
{{end}}
<title>Statup | Users</title>
</head>
<body>
<div class="container col-md-7 col-sm-12 mt-md-5 bg-light">
{{template "nav"}}
<div class="col-12">
<h3>Users</h3>
<table class="table table-striped">
<thead>
<tr>
<th scope="col">Username</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
{{range .}}
<tr>
<td>{{.Username}}</td>
<td class="text-right">
<div class="btn-group">
<a href="/users/{{.Id}}/delete" class="btn btn-danger">Delete</a>
</div>
</td>
</tr>
{{end}}
</tbody>
</table>
<h3>Create User</h3>
<form action="/users" method="POST">
<div class="form-group row">
<label for="username" class="col-sm-4 col-form-label">Username</label>
<div class="col-sm-4">
<input type="text" name="username" class="form-control" id="username" placeholder="Username" required>
</div>
<div class="col-sm-4">
<span class="switch">
<input type="checkbox" name="admin" class="switch" id="switch-normal">
<label for="switch-normal">Administrator</label>
</span>
</div>
</div>
<div class="form-group row">
<label for="email" class="col-sm-4 col-form-label">Email Address</label>
<div class="col-sm-8">
<input type="email" name="email" class="form-control" id="email" placeholder="user@domain.com" required>
</div>
</div>
<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" 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" placeholder="Confirm Password" required>
</div>
</div>
<div class="form-group row">
<div class="col-sm-12">
<button type="submit" class="btn btn-primary btn-block">Create User</button>
</div>
</div>
</form>
</div>
</div>
{{template "footer"}}
{{if USE_CDN}}
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
<script src="https://assets.statup.io/main.js"></script>
{{ else }}
<script src="/js/jquery-3.3.1.slim.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script src="/js/main.js"></script>
{{end}}
</body>
</html>

View File

@ -3,8 +3,13 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, maximum-scale=1.0, user-scalable=0"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, maximum-scale=1.0, user-scalable=0">
{{if USE_CDN}}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<link rel="stylesheet" href="https://assets.statup.io/base.css">
{{ else }}
<link rel="stylesheet" href="/css/bootstrap.min.css"> <link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/base.css"> <link rel="stylesheet" href="/css/base.css">
{{end}}
<title>Statup | Users</title> <title>Statup | Users</title>
</head> </head>
@ -85,7 +90,15 @@
{{template "footer"}} {{template "footer"}}
{{if USE_CDN}}
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
<script src="https://assets.statup.io/main.js"></script>
{{ else }}
<script src="/js/jquery-3.3.1.slim.min.js"></script> <script src="/js/jquery-3.3.1.slim.min.js"></script>
<script src="/js/bootstrap.min.js"></script> <script src="/js/bootstrap.min.js"></script>
<script src="/js/main.js"></script>
{{end}}
</body> </body>
</html> </html>