feature (admin): admin console

This commit is contained in:
Mickael KERJEAN
2018-12-07 12:54:28 +11:00
parent 1b591af5b3
commit ce6a228968
78 changed files with 2699 additions and 386 deletions

View File

@ -9,26 +9,28 @@ import (
func NewBackend(ctx *App, conn map[string]string) (IBackend, error) {
isAllowed := func() bool {
ret := false
var conns [] struct {
Type string `json:"type"`
Hostname string `json:"hostname"`
Path string `json:"path"`
}
ctx.Config.Get("connections").Scan(&conns)
for i := range conns {
if conns[i].Type == conn["type"] {
if conns[i].Hostname != "" && conns[i].Hostname != conn["hostname"] {
continue
} else if conns[i].Path != "" && conns[i].Path != conn["path"] {
continue
} else {
ret = true
break
}
}
}
return ret
return true
// ret := false
// var conns [] struct {
// Type string `json:"type"`
// Hostname string `json:"hostname"`
// Path string `json:"path"`
// }
// Config.Get("connections").Interface()
// Config.Get("connections").Scan(&conns)
// for i := range conns {
// if conns[i].Type == conn["type"] {
// if conns[i].Hostname != "" && conns[i].Hostname != conn["hostname"] {
// continue
// } else if conns[i].Path != "" && conns[i].Path != conn["path"] {
// continue
// } else {
// ret = true
// break
// }
// }
// }
// return ret
}()
if isAllowed == false {
@ -57,6 +59,9 @@ func MapStringInterfaceToMapStringString(m map[string]interface{}) map[string]st
res := make(map[string]string)
for key, value := range m {
res[key] = fmt.Sprintf("%v", value)
if res[key] == "<nil>" {
res[key] = ""
}
}
return res
}