pull/10/head
Hunter Long 2018-06-09 18:47:57 -07:00
parent decd9a2fc5
commit ad78d2250a
4 changed files with 28 additions and 43 deletions

View File

@ -1,6 +1,5 @@
package main package main
type Core struct { type Core struct {
Name string Name string
Config string Config string
@ -9,7 +8,6 @@ type Core struct {
Version string Version string
} }
func SelectCore() (*Core, error) { func SelectCore() (*Core, error) {
var core Core var core Core
rows, err := db.Query("SELECT * FROM core") rows, err := db.Query("SELECT * FROM core")

View File

@ -2,13 +2,13 @@ package main
import ( import (
"database/sql" "database/sql"
"fmt"
"github.com/GeertJohan/go.rice" "github.com/GeertJohan/go.rice"
"github.com/go-yaml/yaml" "github.com/go-yaml/yaml"
"github.com/gorilla/sessions" "github.com/gorilla/sessions"
_ "github.com/lib/pq" _ "github.com/lib/pq"
"golang.org/x/crypto/bcrypt" "golang.org/x/crypto/bcrypt"
"io/ioutil" "io/ioutil"
"fmt"
) )
var ( var (
@ -46,7 +46,6 @@ func main() {
mainProcess() mainProcess()
} }
func mainProcess() { func mainProcess() {
var err error var err error
DbConnection() DbConnection()
@ -60,8 +59,6 @@ func mainProcess() {
} }
} }
func RenderBoxes() { func RenderBoxes() {
sqlBox = rice.MustFindBox("sql") sqlBox = rice.MustFindBox("sql")
cssBox = rice.MustFindBox("html/css") cssBox = rice.MustFindBox("html/css")

View File

@ -1,10 +1,10 @@
package main package main
import ( import (
"net/http"
"strconv"
"os"
"github.com/go-yaml/yaml" "github.com/go-yaml/yaml"
"net/http"
"os"
"strconv"
"time" "time"
) )
@ -56,7 +56,6 @@ func ProcessSetupHandler(w http.ResponseWriter, r *http.Request) {
} }
func (c *DbConfig) Save() error { func (c *DbConfig) Save() error {
var err error var err error
config, err := os.Create("config.yml") config, err := os.Create("config.yml")

19
web.go
View File

@ -91,7 +91,6 @@ func CreateServiceHandler(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/services", http.StatusSeeOther) http.Redirect(w, r, "/services", http.StatusSeeOther)
} }
func SetupHandler(w http.ResponseWriter, r *http.Request) { func SetupHandler(w http.ResponseWriter, r *http.Request) {
setupFile, err := tmplBox.String("setup.html") setupFile, err := tmplBox.String("setup.html")
if err != nil { if err != nil {
@ -109,31 +108,23 @@ type index struct {
} }
func IndexHandler(w http.ResponseWriter, r *http.Request) { func IndexHandler(w http.ResponseWriter, r *http.Request) {
//session, _ := store.Get(r, "apizer_auth") if core == nil {
//if auth, ok := session.Values["authenticated"].(bool); !ok || !auth {
// http.Redirect(w, r, "/", http.StatusSeeOther)
// return
//}
if setupMode {
http.Redirect(w, r, "/setup", http.StatusSeeOther) http.Redirect(w, r, "/setup", http.StatusSeeOther)
return return
} }
dashboardFile, err := tmplBox.String("index.html") indexFile, err := tmplBox.String("index.html")
if err != nil { if err != nil {
panic(err) panic(err)
} }
dashboardTmpl, err := template.New("message").Funcs(template.FuncMap{ indexTmpl, err := template.New("message").Funcs(template.FuncMap{
"js": func(html string) template.JS { "js": func(html string) template.JS {
return template.JS(html) return template.JS(html)
}, },
}).Parse(dashboardFile) }).Parse(indexFile)
out := index{SelectAllServices()} out := index{SelectAllServices()}
indexTmpl.Execute(w, out)
dashboardTmpl.Execute(w, out)
} }
func DashboardHandler(w http.ResponseWriter, r *http.Request) { func DashboardHandler(w http.ResponseWriter, r *http.Request) {