Added utils.WriteOption and refactor, added enablePublicDashb0oard
parent
380172f6f0
commit
4614a0f070
|
@ -341,6 +341,8 @@ func EnablePublicDashboard(InternetURL string) bool {
|
||||||
env, _ := godotenv.Unmarshal("INTERNET_URL=" + InternetURL)
|
env, _ := godotenv.Unmarshal("INTERNET_URL=" + InternetURL)
|
||||||
_ = godotenv.Write(env, envFilePath)
|
_ = godotenv.Write(env, envFilePath)
|
||||||
|
|
||||||
|
buildFrameworkContainers()
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -415,6 +415,9 @@ func taskEnablePublicDashboard(args taskEnablePublicDashboardArgs) string {
|
||||||
fmt.Println("Enabling taskEnablePublicDashboard")
|
fmt.Println("Enabling taskEnablePublicDashboard")
|
||||||
result := edgeapps.EnablePublicDashboard(args.InternetURL)
|
result := edgeapps.EnablePublicDashboard(args.InternetURL)
|
||||||
if result {
|
if result {
|
||||||
|
|
||||||
|
utils.WriteOption("PUBLIC_DASHBOARD", "true")
|
||||||
|
|
||||||
return "{result: true}"
|
return "{result: true}"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -428,6 +431,7 @@ func taskDisablePublicDashboard() string {
|
||||||
fmt.Println("Executing taskDisablePublicDashboard")
|
fmt.Println("Executing taskDisablePublicDashboard")
|
||||||
result := edgeapps.DisablePublicDashboard()
|
result := edgeapps.DisablePublicDashboard()
|
||||||
if result {
|
if result {
|
||||||
|
utils.WriteOption("PUBLIC_DASBOARD", "false")
|
||||||
return "{result: true}"
|
return "{result: true}"
|
||||||
}
|
}
|
||||||
return "{result: false}"
|
return "{result: false}"
|
||||||
|
@ -438,25 +442,7 @@ func taskSetReleaseVersion() string {
|
||||||
|
|
||||||
fmt.Println("Executing taskSetReleaseVersion")
|
fmt.Println("Executing taskSetReleaseVersion")
|
||||||
|
|
||||||
db, err := sql.Open("sqlite3", utils.GetSQLiteDbConnectionDetails())
|
utils.WriteOption("RELEASE_VERSION", diagnostics.Version)
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
statement, err := db.Prepare("REPLACE into option (name, value, created, updated) VALUES (?, ?, ?, ?);") // Prepare SQL Statement
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
formatedDatetime := utils.GetSQLiteFormattedDateTime(time.Now())
|
|
||||||
|
|
||||||
_, err = statement.Exec("RELEASE_VERSION", diagnostics.Version, formatedDatetime, formatedDatetime) // Execute SQL Statement
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
db.Close()
|
|
||||||
|
|
||||||
return diagnostics.Version
|
return diagnostics.Version
|
||||||
}
|
}
|
||||||
|
@ -468,25 +454,7 @@ func taskGetEdgeApps() string {
|
||||||
edgeApps := edgeapps.GetEdgeApps()
|
edgeApps := edgeapps.GetEdgeApps()
|
||||||
edgeAppsJSON, _ := json.Marshal(edgeApps)
|
edgeAppsJSON, _ := json.Marshal(edgeApps)
|
||||||
|
|
||||||
db, err := sql.Open("sqlite3", utils.GetSQLiteDbConnectionDetails())
|
utils.WriteOption("EDGEAPPS_LIST", string(edgeAppsJSON))
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
statement, err := db.Prepare("REPLACE into option (name, value, created, updated) VALUES (?, ?, ?, ?);") // Prepare SQL Statement
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
formatedDatetime := utils.GetSQLiteFormattedDateTime(time.Now())
|
|
||||||
|
|
||||||
_, err = statement.Exec("EDGEAPPS_LIST", string(edgeAppsJSON), formatedDatetime, formatedDatetime) // Execute SQL Statement
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
db.Close()
|
|
||||||
|
|
||||||
return string(edgeAppsJSON)
|
return string(edgeAppsJSON)
|
||||||
|
|
||||||
|
@ -497,25 +465,7 @@ func taskGetSystemUptime() string {
|
||||||
|
|
||||||
uptime := system.GetUptimeInSeconds()
|
uptime := system.GetUptimeInSeconds()
|
||||||
|
|
||||||
db, err := sql.Open("sqlite3", utils.GetSQLiteDbConnectionDetails())
|
utils.WriteOption("SYSTEM_UPTIME", uptime)
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
statement, err := db.Prepare("REPLACE into option (name, value, created, updated) VALUES (?, ?, ?, ?);") // Prepare SQL Statement
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
formatedDatetime := utils.GetSQLiteFormattedDateTime(time.Now())
|
|
||||||
|
|
||||||
_, err = statement.Exec("SYSTEM_UPTIME", uptime, formatedDatetime, formatedDatetime) // Execute SQL Statement
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
db.Close()
|
|
||||||
|
|
||||||
return uptime
|
return uptime
|
||||||
|
|
||||||
|
@ -527,25 +477,7 @@ func taskGetStorageDevices() string {
|
||||||
devices := storage.GetDevices(diagnostics.Version)
|
devices := storage.GetDevices(diagnostics.Version)
|
||||||
devicesJSON, _ := json.Marshal(devices)
|
devicesJSON, _ := json.Marshal(devices)
|
||||||
|
|
||||||
db, err := sql.Open("sqlite3", utils.GetSQLiteDbConnectionDetails())
|
utils.WriteOption("STORAGE_DEVICES_LIST", string(devicesJSON))
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
statement, err := db.Prepare("REPLACE into option (name, value, created, updated) VALUES (?, ?, ?, ?);") // Prepare SQL Statement
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
formatedDatetime := utils.GetSQLiteFormattedDateTime(time.Now())
|
|
||||||
|
|
||||||
_, err = statement.Exec("STORAGE_DEVICES_LIST", devicesJSON, formatedDatetime, formatedDatetime) // Execute SQL Statement
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
db.Close()
|
|
||||||
|
|
||||||
return string(devicesJSON)
|
return string(devicesJSON)
|
||||||
|
|
||||||
|
@ -556,25 +488,7 @@ func taskGetSystemIP() string {
|
||||||
|
|
||||||
ip := system.GetIP()
|
ip := system.GetIP()
|
||||||
|
|
||||||
db, err := sql.Open("sqlite3", utils.GetSQLiteDbConnectionDetails())
|
utils.WriteOption("IP_ADDRESS", ip)
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
statement, err := db.Prepare("REPLACE into option (name, value, created, updated) VALUES (?, ?, ?, ?);") // Prepare SQL Statement
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
formatedDatetime := utils.GetSQLiteFormattedDateTime(time.Now())
|
|
||||||
|
|
||||||
_, err = statement.Exec("IP_ADDRESS", ip, formatedDatetime, formatedDatetime) // Execute SQL Statement
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
db.Close()
|
|
||||||
|
|
||||||
return ip
|
return ip
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package utils
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"database/sql"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
|
@ -145,3 +146,26 @@ func GetPath(pathKey string) string {
|
||||||
return targetPath
|
return targetPath
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func WriteOption(optionKey string, optionValue string) {
|
||||||
|
|
||||||
|
db, err := sql.Open("sqlite3", GetSQLiteDbConnectionDetails())
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
statement, err := db.Prepare("REPLACE into option (name, value, created, updated) VALUES (?, ?, ?, ?);") // Prepare SQL Statement
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
formatedDatetime := GetSQLiteFormattedDateTime(time.Now())
|
||||||
|
|
||||||
|
_, err = statement.Exec(optionKey, optionValue, formatedDatetime, formatedDatetime) // Execute SQL Statement
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
db.Close()
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue