Browse Source

Merge pull request #37 from IceWhaleTech/dev

fixed bug
link 3 years ago
parent
commit
14175bc438
9 changed files with 35 additions and 11 deletions
  1. 1 1
      UI
  2. 4 3
      model/sys_common.go
  3. 2 0
      pkg/utils/oasis_err/e.go
  4. 5 1
      route/init.go
  5. 1 0
      route/route.go
  6. 11 1
      route/v1/docker.go
  7. 8 0
      route/v1/user.go
  8. 1 3
      service/docker.go
  9. 2 2
      types/system.go

+ 1 - 1
UI

@@ -1 +1 @@
-Subproject commit a74be104eb5173eb1933d5e7e7a2364f6f1890de
+Subproject commit f7c46d7379ab31bc70a35900ef6a50f7f3c2ef4f

+ 4 - 3
model/sys_common.go

@@ -20,9 +20,10 @@ type UserModel struct {
 
 
 //服务配置
 //服务配置
 type ServerModel struct {
 type ServerModel struct {
-	HttpPort  string
-	RunMode   string
-	ServerApi string
+	HttpPort    string
+	RunMode     string
+	ServerApi   string
+	LockAccount bool
 }
 }
 
 
 //服务配置
 //服务配置

+ 2 - 0
pkg/utils/oasis_err/e.go

@@ -11,6 +11,7 @@ const (
 	PWD_IS_EMPTY = 10002
 	PWD_IS_EMPTY = 10002
 
 
 	PWD_INVALID_OLD = 10003
 	PWD_INVALID_OLD = 10003
+	ACCOUNT_LOCK    = 10004
 	//system
 	//system
 	DIR_ALREADY_EXISTS  = 20001
 	DIR_ALREADY_EXISTS  = 20001
 	FILE_ALREADY_EXISTS = 20002
 	FILE_ALREADY_EXISTS = 20002
@@ -42,6 +43,7 @@ var MsgFlags = map[int]string{
 	PWD_INVALID:     "Password invalid",
 	PWD_INVALID:     "Password invalid",
 	PWD_IS_EMPTY:    "Password is empty",
 	PWD_IS_EMPTY:    "Password is empty",
 	PWD_INVALID_OLD: "Old Password invalid",
 	PWD_INVALID_OLD: "Old Password invalid",
+	ACCOUNT_LOCK:    "Account Lock",
 
 
 	//system
 	//system
 	DIR_ALREADY_EXISTS:  "Directory already exists",
 	DIR_ALREADY_EXISTS:  "Directory already exists",

+ 5 - 1
route/init.go

@@ -96,7 +96,7 @@ func installSyncthing(appId string) {
 	m.Origin = "system"
 	m.Origin = "system"
 	m.PortMap = appInfo.PortMap
 	m.PortMap = appInfo.PortMap
 	m.Ports = appInfo.Ports
 	m.Ports = appInfo.Ports
-	m.Restart = ""
+	m.Restart = "always"
 	m.Volumes = appInfo.Volumes
 	m.Volumes = appInfo.Volumes
 
 
 	containerId, err := service.MyService.Docker().DockerContainerCreate(dockerImage+":"+dockerImageVersion, id, m, appInfo.NetworkModel)
 	containerId, err := service.MyService.Docker().DockerContainerCreate(dockerImage+":"+dockerImageVersion, id, m, appInfo.NetworkModel)
@@ -156,6 +156,10 @@ func checkSystemApp() {
 	list := service.MyService.App().GetSystemAppList()
 	list := service.MyService.App().GetSystemAppList()
 	for _, v := range *list {
 	for _, v := range *list {
 		if v.Image == "linuxserver/syncthing" {
 		if v.Image == "linuxserver/syncthing" {
+			if v.State != "running" {
+				//step:start container
+				service.MyService.Docker().DockerContainerStart(v.CustomId)
+			}
 			syncIsExistence = true
 			syncIsExistence = true
 			if config.SystemConfigInfo.SyncPort != v.Port {
 			if config.SystemConfigInfo.SyncPort != v.Port {
 				config.SystemConfigInfo.SyncPort = v.Port
 				config.SystemConfigInfo.SyncPort = v.Port

+ 1 - 0
route/route.go

@@ -12,6 +12,7 @@ import (
 )
 )
 
 
 var swagHandler gin.HandlerFunc
 var swagHandler gin.HandlerFunc
+var OnlineDemo bool = false
 
 
 func InitRouter() *gin.Engine {
 func InitRouter() *gin.Engine {
 
 

+ 11 - 1
route/v1/docker.go

@@ -2,6 +2,7 @@ package v1
 
 
 import (
 import (
 	"bytes"
 	"bytes"
+	"encoding/json"
 	json2 "encoding/json"
 	json2 "encoding/json"
 	"net/http"
 	"net/http"
 	"reflect"
 	"reflect"
@@ -420,6 +421,9 @@ func InstallApp(c *gin.Context) {
 		rely := model.MapStrings{}
 		rely := model.MapStrings{}
 
 
 		copier.Copy(&rely, &relyMap)
 		copier.Copy(&rely, &relyMap)
+		for i := 0; i < len(m.Volumes); i++ {
+			m.Volumes[i].Path = docker.GetDir(id, m.Volumes[i].ContainerPath)
+		}
 		portsStr, _ := json2.Marshal(m.Ports)
 		portsStr, _ := json2.Marshal(m.Ports)
 		envsStr, _ := json2.Marshal(m.Envs)
 		envsStr, _ := json2.Marshal(m.Envs)
 		volumesStr, _ := json2.Marshal(m.Volumes)
 		volumesStr, _ := json2.Marshal(m.Volumes)
@@ -904,10 +908,16 @@ func UpdateSetting(c *gin.Context) {
 	//如果容器端口均未修改,这不进行处理
 	//如果容器端口均未修改,这不进行处理
 	portsStr, _ := json2.Marshal(m.Ports)
 	portsStr, _ := json2.Marshal(m.Ports)
 
 
+	list := []model.PathMap{}
+	json.Unmarshal([]byte(appInfo.Volumes), &list)
+	for i := 0; i < len(list); i++ {
+		list[i].Path = docker.GetDir(id, list[i].ContainerPath)
+	}
 	envsStr, _ := json2.Marshal(m.Envs)
 	envsStr, _ := json2.Marshal(m.Envs)
 	volumesStr, _ := json2.Marshal(m.Volumes)
 	volumesStr, _ := json2.Marshal(m.Volumes)
 	devicesStr, _ := json2.Marshal(m.Devices)
 	devicesStr, _ := json2.Marshal(m.Devices)
-	if !reflect.DeepEqual(string(portsStr), appInfo.Ports) || !reflect.DeepEqual(string(envsStr), appInfo.Envs) || !reflect.DeepEqual(string(volumesStr), appInfo.Volumes) || m.PortMap != appInfo.PortMap || m.NetworkModel != appInfo.NetModel {
+	listStr, _ := json2.Marshal(list)
+	if !reflect.DeepEqual(string(portsStr), appInfo.Ports) || !reflect.DeepEqual(string(envsStr), appInfo.Envs) || !reflect.DeepEqual(volumesStr, listStr) || m.PortMap != appInfo.PortMap || m.NetworkModel != appInfo.NetModel {
 
 
 		var newUUid = uuid.NewV4().String()
 		var newUUid = uuid.NewV4().String()
 		var err error
 		var err error

+ 8 - 0
route/v1/user.go

@@ -123,6 +123,10 @@ func Up_Load_Head(c *gin.Context) {
 // @Success 200 {string} string "ok"
 // @Success 200 {string} string "ok"
 // @Router /user/changusername [put]
 // @Router /user/changusername [put]
 func Chang_User_Name(c *gin.Context) {
 func Chang_User_Name(c *gin.Context) {
+	if config.ServerInfo.LockAccount {
+		c.JSON(http.StatusOK, model.Result{Success: oasis_err2.ACCOUNT_LOCK, Message: oasis_err2.GetMsg(oasis_err2.ACCOUNT_LOCK)})
+		return
+	}
 	oldname := c.PostForm("oldname")
 	oldname := c.PostForm("oldname")
 	username := c.PostForm("username")
 	username := c.PostForm("username")
 	if len(username) == 0 || config.UserInfo.UserName != oldname {
 	if len(username) == 0 || config.UserInfo.UserName != oldname {
@@ -149,6 +153,10 @@ func Chang_User_Pwd(c *gin.Context) {
 		c.JSON(http.StatusOK, model.Result{Success: oasis_err2.PWD_INVALID_OLD, Message: oasis_err2.GetMsg(oasis_err2.PWD_INVALID_OLD)})
 		c.JSON(http.StatusOK, model.Result{Success: oasis_err2.PWD_INVALID_OLD, Message: oasis_err2.GetMsg(oasis_err2.PWD_INVALID_OLD)})
 		return
 		return
 	}
 	}
+	if config.ServerInfo.LockAccount {
+		c.JSON(http.StatusOK, model.Result{Success: oasis_err2.ACCOUNT_LOCK, Message: oasis_err2.GetMsg(oasis_err2.ACCOUNT_LOCK)})
+		return
+	}
 	if len(pwd) == 0 {
 	if len(pwd) == 0 {
 		c.JSON(http.StatusOK, model.Result{Success: oasis_err2.PWD_IS_EMPTY, Message: oasis_err2.GetMsg(oasis_err2.PWD_IS_EMPTY)})
 		c.JSON(http.StatusOK, model.Result{Success: oasis_err2.PWD_IS_EMPTY, Message: oasis_err2.GetMsg(oasis_err2.PWD_IS_EMPTY)})
 		return
 		return

+ 1 - 3
service/docker.go

@@ -479,15 +479,13 @@ func (ds *dockerService) DockerContainerCreate(imageName string, containerDbId s
 	if len(m.Restart) > 0 {
 	if len(m.Restart) > 0 {
 		rp.Name = m.Restart
 		rp.Name = m.Restart
 	}
 	}
-	//fmt.Print(port)
 	healthTest := []string{}
 	healthTest := []string{}
 	if len(port) > 0 {
 	if len(port) > 0 {
 		healthTest = []string{"CMD-SHELL", "curl -f http://localhost:" + port + m.Index + " || exit 1"}
 		healthTest = []string{"CMD-SHELL", "curl -f http://localhost:" + port + m.Index + " || exit 1"}
 	}
 	}
 
 
 	health := &container.HealthConfig{
 	health := &container.HealthConfig{
-		Test: healthTest,
-		//Test:        []string{},
+		Test:        healthTest,
 		StartPeriod: 0,
 		StartPeriod: 0,
 		Retries:     1000,
 		Retries:     1000,
 	}
 	}

+ 2 - 2
types/system.go

@@ -1,4 +1,4 @@
 package types
 package types
 
 
-const CURRENTVERSION = "0.2.1"
-const BODY = "<li>fixed path error</li>"
+const CURRENTVERSION = "0.2.2"
+const BODY = "<li>ui adjustment</li><li>fixed bugs</li>"