Esempio n. 1
0
// GET render specified record from specified store in connected DB
func Record(w http.ResponseWriter, r *http.Request, c *webc.Context) {
	if !rpc.Alive() {
		http.Redirect(w, r, "/", 303)
		c.SetFlash("alertError", "Error no connection to a database")
		return
	}
	if c.Get("db") == nil || c.Get("db").(string) == "" {
		http.Redirect(w, r, "/disconnect", 303)
		return
	}
	msgk, msgv := c.GetFlash()
	record := rpc.Get(c.GetPathVar("store"), GetId(c.GetPathVar("record")))
	if record == nil {
		c.SetFlash("alertError", "Invalid Record")
		http.Redirect(w, r, fmt.Sprintf("/%s/%s", c.GetPathVar("db"), c.GetPathVar("store")), 303)
		return
	}
	ts.Render(w, "record.tmpl", tmpl.Model{
		msgk:        msgv,
		"db":        c.Get("db"),
		"stores":    rpc.GetAllStoreStats(),
		"storeName": c.GetPathVar("store"),
		"record":    record,
	})
	return
}
Esempio n. 2
0
// GET render specified store from specified DB
func Store(w http.ResponseWriter, r *http.Request, c *webc.Context) {
	if !rpc.Alive() {
		http.Redirect(w, r, "/", 303)
		c.SetFlash("alertError", "Error no connection to a database")
		return
	}
	if c.Get("db") == nil || c.Get("db").(string) == "" {
		http.Redirect(w, r, "/disconnect", 303)
		return
	}
	msgk, msgv := c.GetFlash()
	if !rpc.HasStore(c.GetPathVar("store")) {
		c.SetFlash("alertError", "Invalid store")
		http.Redirect(w, r, fmt.Sprintf("/%s", c.GetPathVar("db")), 303)
		return
	}
	ts.Render(w, "store.tmpl", tmpl.Model{
		msgk:          msgv,
		"savedSearch": GetSavedSearches(c.Get("db").(string), c.GetPathVar("store")),
		"db":          c.Get("db"),
		"stores":      rpc.GetAllStoreStats(),
		"store":       rpc.GetAll(c.GetPathVar("store")),
		"storeName":   c.GetPathVar("store"),
		"query":       GetSavedSearch(c.Get("db").(string), c.GetPathVar("store"), r.FormValue("query")),
	})
	return
}
Esempio n. 3
0
func homeController(w http.ResponseWriter, r *http.Request, c *webc.Context) {
	msgK, msgV := c.GetFlash()
	ts.Render(w, "index.tmpl", tmpl.Model{
		msgK:    msgV,
		"name":  "Greg",
		"age":   28,
		"email": "*****@*****.**",
		"data":  "bubb hghb hghgv bj hbkjb jhb jhbjh bhjb jhb jhb jhbj bjk bjhb jhbj hbjhbjh jhb Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
	})
}
Esempio n. 4
0
// GET render empty record for specified store from connected DB
func NewRecord(w http.ResponseWriter, r *http.Request, c *webc.Context) {
	if !rpc.Alive() {
		http.Redirect(w, r, "/", 303)
		c.SetFlash("alertError", "Error no connection to a database")
		return
	}
	if c.Get("db") == nil || c.Get("db").(string) == "" {
		http.Redirect(w, r, "/disconnect", 303)
		return
	}
	msgk, msgv := c.GetFlash()
	ts.Render(w, "record.tmpl", tmpl.Model{
		msgk:        msgv,
		"db":        c.Get("db"),
		"stores":    rpc.GetAllStoreStats(),
		"storeName": c.GetPathVar("store"),
		"record":    "",
	})
	return
}
Esempio n. 5
0
// GET render all saved DBs or show currently cinnected DB
func Root(w http.ResponseWriter, r *http.Request, c *webc.Context) {
	msgk, msgv := c.GetFlash()

	// Not connected display all DBs
	if !rpc.Alive() {
		ts.Render(w, "index.tmpl", tmpl.Model{
			msgk:    msgv,
			"dbs":   GetSavedDBs(),
			"conns": config.GetStore("connections"),
		})
		return
	}

	if c.Get("db") == nil || c.Get("db").(string) == "" {
		http.Redirect(w, r, "/disconnect", 303)
		return
	}
	ts.Render(w, "db.tmpl", tmpl.Model{
		msgk:     msgv,
		"db":     c.Get("db"),
		"stores": rpc.GetAllStoreStats(),
	})
	return
}
Esempio n. 6
0
func landing(w http.ResponseWriter, r *http.Request, c *webc.Context) {
	slug := c.GetPathVar("slug")
	_, msgV := c.GetFlash()
	fmt.Fprintf(w, "Your are at the landing page for %s. %s", slug, msgV)
}