mirror of https://github.com/jetkvm/kvm.git
Compare commits
1 Commits
e927fb94e9
...
502fd538f7
Author | SHA1 | Date |
---|---|---|
|
502fd538f7 |
18
web.go
18
web.go
|
@ -97,6 +97,9 @@ func setupRouter() *gin.Engine {
|
|||
// We use this to determine if the device is setup
|
||||
r.GET("/device/status", handleDeviceStatus)
|
||||
|
||||
// We use this to provide the UI with the device configuration
|
||||
r.GET("/device/ui-config.js", handleDeviceUIConfig)
|
||||
|
||||
// We use this to setup the device in the welcome page
|
||||
r.POST("/device/setup", handleSetup)
|
||||
|
||||
|
@ -691,6 +694,21 @@ func handleCloudState(c *gin.Context) {
|
|||
c.JSON(http.StatusOK, response)
|
||||
}
|
||||
|
||||
func handleDeviceUIConfig(c *gin.Context) {
|
||||
config, _ := json.Marshal(gin.H{
|
||||
"CLOUD_API": config.CloudURL,
|
||||
"DEVICE_VERSION": builtAppVersion,
|
||||
})
|
||||
if config == nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to marshal config"})
|
||||
return
|
||||
}
|
||||
|
||||
response := fmt.Sprintf("window.JETKVM_CONFIG = %s;", config)
|
||||
|
||||
c.Data(http.StatusOK, "text/javascript; charset=utf-8", []byte(response))
|
||||
}
|
||||
|
||||
func handleSetup(c *gin.Context) {
|
||||
// Check if the device is already set up
|
||||
if config.LocalAuthMode != "" || config.HashedPassword != "" {
|
||||
|
|
Loading…
Reference in New Issue