Display settings with hacky solution to retain order

Python utility included to convert config-base.json into a new version
which includes lists that define the order settings should be displayed.
admin.js edited to recognize this.
This commit is contained in:
Harvey Tindall
2020-07-31 16:09:30 +01:00
parent ef4f2503c9
commit 024c0b56aa
9 changed files with 811 additions and 20 deletions
+24 -15
View File
@@ -3,11 +3,13 @@ package main
import (
"crypto/rand"
"encoding/base64"
"encoding/json"
"fmt"
"github.com/gin-contrib/static"
"github.com/gin-gonic/gin"
"github.com/google/uuid"
"gopkg.in/ini.v1"
"io/ioutil"
"os"
"path/filepath"
)
@@ -20,21 +22,23 @@ type User struct {
}
type appContext struct {
config *ini.File
config_path string
data_path string
local_path string
cssFile string
bsVersion int
jellyfinLogin bool
users []User
jf Jellyfin
authJf Jellyfin
datePattern string
timePattern string
storage Storage
validator Validator
email Emailer
config *ini.File
config_path string
configBase_path string
configBase map[string]interface{}
data_path string
local_path string
cssFile string
bsVersion int
jellyfinLogin bool
users []User
jf Jellyfin
authJf Jellyfin
datePattern string
timePattern string
storage Storage
validator Validator
email Emailer
}
func GenerateSecret(length int) (string, error) {
@@ -89,6 +93,10 @@ func main() {
ctx.storage.displayprefs_path = filepath.Join(ctx.data_path, "user_displayprefs.json")
ctx.storage.loadDisplayprefs()
ctx.configBase_path = filepath.Join(ctx.local_path, "config-base.json")
config_base, _ := ioutil.ReadFile(ctx.configBase_path)
json.Unmarshal(config_base, &ctx.configBase)
//bson.UnmarshalExtJSON(config_base, true, &ctx.configBase)
themes := map[string]string{
"Jellyfin (Dark)": fmt.Sprintf("bs%d-jf.css", ctx.bsVersion),
"Bootstrap (Light)": fmt.Sprintf("bs%d.css", ctx.bsVersion),
@@ -152,6 +160,7 @@ func main() {
api.GET("/getUsers", ctx.GetUsers)
api.POST("/modifyUsers", ctx.ModifyEmails)
api.POST("/setDefaults", ctx.SetDefaults)
api.GET("/getConfig", ctx.GetConfig)
router.Run(":8080")
}