diff --git a/api/controllers/settings.go b/api/controllers/settings.go
index c312417..e768dd7 100644
--- a/api/controllers/settings.go
+++ b/api/controllers/settings.go
@@ -27,14 +27,17 @@ var SettingsGet = func(c *fiber.Ctx) error {
}
}(querySettings)
- var startup, wallpaper, save_logg int
+ var startup, wallpaper, save_logg, analytics int
for querySettings.Next() {
- err := querySettings.Scan(&startup, &wallpaper, &save_logg)
+ err := querySettings.Scan(&startup, &wallpaper, &save_logg, &analytics)
if err != nil {
functions.Logger(err.Error())
}
- var data = map[string]interface{}{"startup": startup, "wallpaper": wallpaper, "save_logg": save_logg}
+ var data = map[string]interface{}{"startup": startup,
+ "wallpaper": wallpaper,
+ "save_logg": save_logg,
+ "analytics": analytics}
utils.Respond(c, data)
}
@@ -50,8 +53,9 @@ var SettingsUpdate = func(c *fiber.Ctx) error {
startup := c.FormValue("startup")
wallpaper := c.FormValue("wallpaper")
save_logg := c.FormValue("save_logg")
+ analytics := c.FormValue("analytics")
- if startup == "" && wallpaper == "" && save_logg == "" {
+ if startup == "" && wallpaper == "" && save_logg == "" && analytics == "" {
utils.Respond(c, utils.Message(false, "All fields are required."))
return nil
}
@@ -81,6 +85,13 @@ var SettingsUpdate = func(c *fiber.Ctx) error {
}
}
+ if analytics != "" {
+ _, err := db.Exec("UPDATE settings SET analytics = ?", analytics)
+ if err != nil {
+ functions.Logger(err.Error())
+ }
+ }
+
utils.Respond(c, utils.Message(true, "The settings have been applied successfully."))
return nil
}
diff --git a/functions/database.go b/functions/database.go
index dfced22..52dd11c 100644
--- a/functions/database.go
+++ b/functions/database.go
@@ -2,9 +2,6 @@ package functions
import (
"database/sql"
- "encoding/json"
- "github.com/rodkranz/fetch"
-
_ "github.com/mattn/go-sqlite3"
)
@@ -26,7 +23,8 @@ func Database() {
CREATE TABLE IF NOT EXISTS settings (
startup INTEGER DEFAULT 0,
wallpaper INTEGER DEFAULT 0,
- save_logg INTEGER DEFAULT 0
+ save_logg INTEGER DEFAULT 1,
+ analytics INTEGER DEFAULT 1
);`
_, err = db.Exec(sqlTable)
@@ -34,39 +32,14 @@ func Database() {
Logger(err.Error())
}
- stmt, err := db.Prepare("INSERT INTO settings(startup, wallpaper, save_logg) values(?,?,?)")
+ stmt, err := db.Prepare("INSERT INTO settings(startup, wallpaper, save_logg, analytics) values(?,?,?,?)")
if err != nil {
Logger(err.Error())
}
- _, err = stmt.Exec(0, 0, 0)
+ _, err = stmt.Exec(0, 0, 1, 1)
if err != nil {
Logger(err.Error())
}
}
}
-
-func getDatabase() int {
- client := fetch.NewDefault()
- res, err := client.Get("http://localhost:3000/api/get/settings", nil)
- if err != nil {
- panic(err)
- }
-
- body, err := res.ToString()
- if err != nil {
- panic(err)
- }
-
- type DatabaseStruct struct {
- Save_logg int `json:"save_logg"`
- }
-
- var Database DatabaseStruct
- err = json.Unmarshal([]byte(body), &Database)
- if err != nil {
- panic(err)
- }
-
- return Database.Save_logg
-}
diff --git a/functions/logger.go b/functions/logger.go
index e746826..65bf736 100644
--- a/functions/logger.go
+++ b/functions/logger.go
@@ -1,11 +1,14 @@
package functions
import (
+ "encoding/json"
"fmt"
"os"
"runtime"
"strings"
"time"
+
+ "github.com/rodkranz/fetch"
)
func Logger(text string) {
@@ -93,3 +96,28 @@ func CreateFolder(name string) error {
}
return nil
}
+
+func getDatabase() int {
+ client := fetch.NewDefault()
+ res, err := client.Get("http://localhost:3000/api/get/settings", nil)
+ if err != nil {
+ panic(err)
+ }
+
+ body, err := res.ToString()
+ if err != nil {
+ panic(err)
+ }
+
+ type DatabaseStruct struct {
+ Save_logg int `json:"save_logg"`
+ }
+
+ var Database DatabaseStruct
+ err = json.Unmarshal([]byte(body), &Database)
+ if err != nil {
+ panic(err)
+ }
+
+ return Database.Save_logg
+}
diff --git a/main.go b/main.go
index 5a2d450..6a9bd9d 100644
--- a/main.go
+++ b/main.go
@@ -68,10 +68,6 @@ func main() {
return controllers.SettingsGet(c)
})
- get.Get("/settings", func(c *fiber.Ctx) error {
- return controllers.SettingsGet(c)
- })
-
err := app.Listen(":3000")
if err != nil {
return
diff --git a/web/src/about.html b/web/src/about.html
index 679beaa..ca2214b 100644
--- a/web/src/about.html
+++ b/web/src/about.html
@@ -53,5 +53,5 @@
-