TC pushbot 5 2 жил өмнө
parent
commit
db8d0a87ae

+ 0 - 2
desktop.go

@@ -104,7 +104,6 @@ func desktop_hostdetailHandler(w http.ResponseWriter, r *http.Request) {
 		InternalVersion string
 		InternalVersion string
 		DeviceVendor    string
 		DeviceVendor    string
 		DeviceModel     string
 		DeviceModel     string
-		VendorIcon      string
 	}
 	}
 
 
 	jsonString, _ := json.Marshal(returnStruct{
 	jsonString, _ := json.Marshal(returnStruct{
@@ -114,7 +113,6 @@ func desktop_hostdetailHandler(w http.ResponseWriter, r *http.Request) {
 		InternalVersion: internal_version,
 		InternalVersion: internal_version,
 		DeviceVendor:    deviceVendor,
 		DeviceVendor:    deviceVendor,
 		DeviceModel:     deviceModel,
 		DeviceModel:     deviceModel,
-		VendorIcon:      iconVendor,
 	})
 	})
 
 
 	utils.SendJSONResponse(w, string(jsonString))
 	utils.SendJSONResponse(w, string(jsonString))

+ 7 - 1
ldap.go

@@ -2,14 +2,20 @@ package main
 
 
 import (
 import (
 	"net/http"
 	"net/http"
+	"path/filepath"
 
 
 	ldap "imuslab.com/arozos/mod/auth/ldap"
 	ldap "imuslab.com/arozos/mod/auth/ldap"
+	fs "imuslab.com/arozos/mod/filesystem"
 	prout "imuslab.com/arozos/mod/prouter"
 	prout "imuslab.com/arozos/mod/prouter"
 )
 )
 
 
 func ldapInit() {
 func ldapInit() {
 	//ldap
 	//ldap
-	ldapHandler := ldap.NewLdapHandler(authAgent, registerHandler, sysdb, permissionHandler, userHandler, nightlyManager, iconSystem)
+	authIcon := filepath.Join(vendorResRoot, "auth_icon.png")
+	if !fs.FileExists(authIcon) {
+		authIcon = "./web/img/public/auth_icon.png"
+	}
+	ldapHandler := ldap.NewLdapHandler(authAgent, registerHandler, sysdb, permissionHandler, userHandler, nightlyManager, authIcon)
 
 
 	//add a entry to the system settings
 	//add a entry to the system settings
 	adminRouter := prout.NewModuleRouter(prout.RouterOption{
 	adminRouter := prout.NewModuleRouter(prout.RouterOption{

+ 4 - 2
main.flags.go

@@ -35,8 +35,10 @@ var deviceVendor = "IMUSLAB.INC"                       //Vendor of the system
 var deviceVendorURL = "http://imuslab.com"             //Vendor contact information
 var deviceVendorURL = "http://imuslab.com"             //Vendor contact information
 var deviceModel = "AR100"                              //Hardware Model of the system
 var deviceModel = "AR100"                              //Hardware Model of the system
 var deviceModelDesc = "General Purpose Cloud Platform" //Device Model Description
 var deviceModelDesc = "General Purpose Cloud Platform" //Device Model Description
-var iconVendor = "img/vendor/vendor_icon.png"          //Vendor icon location
-var iconSystem = "img/vendor/system_icon.png"          //System icon location
+var vendorResRoot = "./vendor-res/"                    //Root folder for vendor overwrite resources
+
+//var iconVendor = "vendor/vendor_icon.png"              //Vendor icon location
+//var iconSystem = "vendor/system_icon.png"              //System icon location
 
 
 // =========== RUNTTIME RELATED ================
 // =========== RUNTTIME RELATED ================
 var max_upload_size int64 = 8192 << 20                         //Maxmium upload size, default 8GB
 var max_upload_size int64 = 8192 << 20                         //Maxmium upload size, default 8GB

+ 1 - 1
main.router.go

@@ -33,7 +33,7 @@ func mrouter(h http.Handler) http.Handler {
 			red, _ := utils.GetPara(r, "redirect")
 			red, _ := utils.GetPara(r, "redirect")
 
 
 			//Append the redirection addr into the template
 			//Append the redirection addr into the template
-			imgsrc := "./web/" + iconSystem
+			imgsrc := filepath.Join(vendorResRoot, "auth_icon.png")
 			if !fs.FileExists(imgsrc) {
 			if !fs.FileExists(imgsrc) {
 				imgsrc = "./web/img/public/auth_icon.png"
 				imgsrc = "./web/img/public/auth_icon.png"
 			}
 			}

+ 8 - 1
register.go

@@ -4,8 +4,10 @@ import (
 	"encoding/json"
 	"encoding/json"
 	"fmt"
 	"fmt"
 	"net/http"
 	"net/http"
+	"path/filepath"
 
 
 	reg "imuslab.com/arozos/mod/auth/register"
 	reg "imuslab.com/arozos/mod/auth/register"
+	fs "imuslab.com/arozos/mod/filesystem"
 	prout "imuslab.com/arozos/mod/prouter"
 	prout "imuslab.com/arozos/mod/prouter"
 	"imuslab.com/arozos/mod/utils"
 	"imuslab.com/arozos/mod/utils"
 )
 )
@@ -16,9 +18,14 @@ var (
 
 
 func RegisterSystemInit() {
 func RegisterSystemInit() {
 	//Register the endpoints for public registration
 	//Register the endpoints for public registration
+	imgsrc := filepath.Join(vendorResRoot, "vendor_icon.png")
+	if !fs.FileExists(imgsrc) {
+		imgsrc = "./web/img/public/vendor_icon.png"
+	}
+
 	rh := reg.NewRegisterHandler(sysdb, authAgent, permissionHandler, reg.RegisterOptions{
 	rh := reg.NewRegisterHandler(sysdb, authAgent, permissionHandler, reg.RegisterOptions{
 		Hostname:   *host_name,
 		Hostname:   *host_name,
-		VendorIcon: "web/" + iconVendor,
+		VendorIcon: imgsrc,
 	})
 	})
 
 
 	registerHandler = rh
 	registerHandler = rh

+ 0 - 2
system.go

@@ -156,7 +156,6 @@ func systemIdHandleRequest(w http.ResponseWriter, r *http.Request) {
 		Build      string
 		Build      string
 		Version    string
 		Version    string
 		Model      string
 		Model      string
-		VendorIcon string
 	}
 	}
 
 
 	//thisDevIP := network_info_GetOutboundIP().String()
 	//thisDevIP := network_info_GetOutboundIP().String()
@@ -169,7 +168,6 @@ func systemIdHandleRequest(w http.ResponseWriter, r *http.Request) {
 		Build:      build_version,
 		Build:      build_version,
 		Version:    internal_version,
 		Version:    internal_version,
 		Model:      deviceModel,
 		Model:      deviceModel,
-		VendorIcon: iconVendor,
 	})
 	})
 
 
 	utils.SendJSONResponse(w, string(jsonString))
 	utils.SendJSONResponse(w, string(jsonString))

+ 12 - 10
system.info.go

@@ -64,11 +64,12 @@ func SystemInfoInit() {
 			BuildVersion: build_version + "." + internal_version,
 			BuildVersion: build_version + "." + internal_version,
 			DeviceVendor: deviceVendor,
 			DeviceVendor: deviceVendor,
 			DeviceModel:  deviceModel,
 			DeviceModel:  deviceModel,
-			VendorIcon:   "../../" + iconVendor,
-			SN:           deviceUUID,
-			HostOS:       runtime.GOOS,
-			CPUArch:      runtime.GOARCH,
-			HostName:     *host_name,
+			//TODO: FIX THIS
+			//VendorIcon:   "../../" + iconVendor,
+			SN:       deviceUUID,
+			HostOS:   runtime.GOOS,
+			CPUArch:  runtime.GOARCH,
+			HostName: *host_name,
 		})
 		})
 
 
 		router.HandleFunc("/system/info/getCPUinfo", info.GetCPUInfo)
 		router.HandleFunc("/system/info/getCPUinfo", info.GetCPUInfo)
@@ -109,11 +110,12 @@ func SystemInfoInit() {
 			BuildVersion: build_version + "." + internal_version,
 			BuildVersion: build_version + "." + internal_version,
 			DeviceVendor: deviceVendor,
 			DeviceVendor: deviceVendor,
 			DeviceModel:  deviceModel,
 			DeviceModel:  deviceModel,
-			VendorIcon:   "../../" + iconVendor,
-			SN:           deviceUUID,
-			HostOS:       "virtualized",
-			CPUArch:      "generic",
-			HostName:     *host_name,
+			//TODO: FIX THIS
+			//VendorIcon:   "../../" + iconVendor,
+			SN:       deviceUUID,
+			HostOS:   "virtualized",
+			CPUArch:  "generic",
+			HostName: *host_name,
 		})
 		})
 	}
 	}
 
 

+ 13 - 3
system.resetpw.go

@@ -4,8 +4,10 @@ import (
 	"errors"
 	"errors"
 	"log"
 	"log"
 	"net/http"
 	"net/http"
+	"path/filepath"
 
 
 	auth "imuslab.com/arozos/mod/auth"
 	auth "imuslab.com/arozos/mod/auth"
+	fs "imuslab.com/arozos/mod/filesystem"
 	"imuslab.com/arozos/mod/utils"
 	"imuslab.com/arozos/mod/utils"
 )
 )
 
 
@@ -20,7 +22,7 @@ func system_resetpw_init() {
 	http.HandleFunc("/system/reset/confirmPasswordReset", system_resetpw_confirmReset)
 	http.HandleFunc("/system/reset/confirmPasswordReset", system_resetpw_confirmReset)
 }
 }
 
 
-//Validate if the ysername and rkey is valid
+// Validate if the ysername and rkey is valid
 func system_resetpw_validateResetKeyHandler(w http.ResponseWriter, r *http.Request) {
 func system_resetpw_validateResetKeyHandler(w http.ResponseWriter, r *http.Request) {
 	username, err := utils.PostPara(r, "username")
 	username, err := utils.PostPara(r, "username")
 	if err != nil {
 	if err != nil {
@@ -122,7 +124,11 @@ func system_resetpw_handlePasswordReset(w http.ResponseWriter, r *http.Request)
 	}
 	}
 
 
 	//OK. Create the New Password Entering UI
 	//OK. Create the New Password Entering UI
-	imageBase64, _ := utils.LoadImageAsBase64("./web/" + iconVendor)
+	vendorIconSrc := filepath.Join(vendorResRoot, "vendor_icon.png")
+	if !fs.FileExists(vendorIconSrc) {
+		vendorIconSrc = "./web/img/public/vendor_icon.png"
+	}
+	imageBase64, _ := utils.LoadImageAsBase64(vendorIconSrc)
 	template, err := utils.Templateload("system/reset/resetPasswordTemplate.html", map[string]interface{}{
 	template, err := utils.Templateload("system/reset/resetPasswordTemplate.html", map[string]interface{}{
 		"vendor_logo": imageBase64,
 		"vendor_logo": imageBase64,
 		"host_name":   *host_name,
 		"host_name":   *host_name,
@@ -138,7 +144,11 @@ func system_resetpw_handlePasswordReset(w http.ResponseWriter, r *http.Request)
 
 
 func system_resetpw_serveIdEnterInterface(w http.ResponseWriter, r *http.Request) {
 func system_resetpw_serveIdEnterInterface(w http.ResponseWriter, r *http.Request) {
 	//Reset Key or Username not found, Serve entering interface
 	//Reset Key or Username not found, Serve entering interface
-	imageBase64, _ := utils.LoadImageAsBase64("./web/" + iconVendor)
+	imgsrc := filepath.Join(vendorResRoot, "vendor_icon.png")
+	if !fs.FileExists(imgsrc) {
+		imgsrc = "./web/img/public/vendor_icon.png"
+	}
+	imageBase64, _ := utils.LoadImageAsBase64(imgsrc)
 	template, err := utils.Templateload("system/reset/resetCodeTemplate.html", map[string]interface{}{
 	template, err := utils.Templateload("system/reset/resetCodeTemplate.html", map[string]interface{}{
 		"vendor_logo": imageBase64,
 		"vendor_logo": imageBase64,
 		"host_name":   *host_name,
 		"host_name":   *host_name,

BIN
vendor-res/auth_icon.png


BIN
vendor-res/vendor_icon.png


+ 0 - 0
web/img/vendor/vendor_icon.png → web/img/public/vendor_icon.png


+ 0 - 0
web/img/vendor/vendor_icon.psd → web/img/public/vendor_icon.psd