dashboard: can now change the sidebar
This commit is contained in:
parent
196f10dc9f
commit
a4e0a90adf
7 changed files with 410 additions and 57 deletions
|
@ -22,8 +22,17 @@ type FICPublicScene struct {
|
|||
Params map[string]interface{} `json:"params"`
|
||||
}
|
||||
|
||||
func readPublic(path string) ([]FICPublicScene, error) {
|
||||
var s []FICPublicScene
|
||||
type FICPublicDisplay struct {
|
||||
Scenes []FICPublicScene `json:"scenes"`
|
||||
Side []FICPublicScene `json:"side"`
|
||||
CustomCountdown map[string]interface{} `json:"customCountdown"`
|
||||
HideEvents bool `json:"hideEvents"`
|
||||
HideCountdown bool `json:"hideCountdown"`
|
||||
HideCarousel bool `json:"hideCarousel"`
|
||||
}
|
||||
|
||||
func readPublic(path string) (FICPublicDisplay, error) {
|
||||
var s FICPublicDisplay
|
||||
if fd, err := os.Open(path); err != nil {
|
||||
return s, err
|
||||
} else {
|
||||
|
@ -38,7 +47,7 @@ func readPublic(path string) ([]FICPublicScene, error) {
|
|||
}
|
||||
}
|
||||
|
||||
func savePublicTo(path string, s []FICPublicScene) error {
|
||||
func savePublicTo(path string, s FICPublicDisplay) error {
|
||||
if fd, err := os.Create(path); err != nil {
|
||||
return err
|
||||
} else {
|
||||
|
@ -57,20 +66,20 @@ func getPublic(ps httprouter.Params, body []byte) (interface{}, error) {
|
|||
if _, err := os.Stat(path.Join(DashboardDir, fmt.Sprintf("public%s.json", ps.ByName("sid")))); !os.IsNotExist(err) {
|
||||
return readPublic(path.Join(DashboardDir, fmt.Sprintf("public%s.json", ps.ByName("sid"))))
|
||||
} else {
|
||||
return []FICPublicScene{}, nil
|
||||
return FICPublicDisplay{Scenes: []FICPublicScene{}, Side: []FICPublicScene{}}, nil
|
||||
}
|
||||
}
|
||||
|
||||
func deletePublic(ps httprouter.Params, body []byte) (interface{}, error) {
|
||||
if err := savePublicTo(path.Join(DashboardDir, fmt.Sprintf("public%s.json", ps.ByName("sid"))), []FICPublicScene{}); err != nil {
|
||||
if err := savePublicTo(path.Join(DashboardDir, fmt.Sprintf("public%s.json", ps.ByName("sid"))), FICPublicDisplay{}); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return []FICPublicScene{}, err
|
||||
return FICPublicDisplay{Scenes: []FICPublicScene{}, Side: []FICPublicScene{}}, nil
|
||||
}
|
||||
}
|
||||
|
||||
func savePublic(ps httprouter.Params, body []byte) (interface{}, error) {
|
||||
var scenes []FICPublicScene
|
||||
var scenes FICPublicDisplay
|
||||
if err := json.Unmarshal(body, &scenes); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
Reference in a new issue