diff --git a/agent/app/dto/response/website.go b/agent/app/dto/response/website.go index 725ca42f6..449bd23d8 100644 --- a/agent/app/dto/response/website.go +++ b/agent/app/dto/response/website.go @@ -111,8 +111,9 @@ type Resource struct { } type Database struct { - Name string `json:"name"` - Type string `json:"type"` - From string `json:"from"` - ID uint `json:"id"` + Name string `json:"name"` + DatabaseName string `json:"databaseName"` + Type string `json:"type"` + From string `json:"from"` + ID uint `json:"id"` } diff --git a/agent/app/service/app.go b/agent/app/service/app.go index a03ac72b8..b43da0607 100644 --- a/agent/app/service/app.go +++ b/agent/app/service/app.go @@ -192,16 +192,18 @@ func (a AppService) GetApp(ctx *gin.Context, key string) (*response.AppDTO, erro } var versionsRaw []string hasLatest := false + latestVersion := "" for _, detail := range details { if strings.Contains(detail.Version, "latest") { hasLatest = true + latestVersion = detail.Version continue } versionsRaw = append(versionsRaw, detail.Version) } appDTO.Versions = common.GetSortedVersions(versionsRaw) if hasLatest { - appDTO.Versions = append([]string{"latest"}, appDTO.Versions...) + appDTO.Versions = append([]string{latestVersion}, appDTO.Versions...) } tags, err := getAppTags(app.ID, strings.ToLower(common.GetLang(ctx))) if err != nil { diff --git a/agent/app/service/app_utils.go b/agent/app/service/app_utils.go index f27934ae8..8724a1a08 100644 --- a/agent/app/service/app_utils.go +++ b/agent/app/service/app_utils.go @@ -1834,19 +1834,18 @@ func handleOpenrestyFile(appInstall *model.AppInstall) error { break } } - if !hasDefaultWebsite { - return nil + if hasDefaultWebsite { + installDir := appInstall.GetPath() + defaultConfigPath := path.Join(installDir, "conf", "default", "00.default.conf") + fileOp := files.NewFileOp() + content, err := fileOp.GetContent(defaultConfigPath) + if err != nil { + return err + } + newContent := strings.ReplaceAll(string(content), "default_server", "") + if err := fileOp.WriteFile(defaultConfigPath, strings.NewReader(newContent), constant.FilePerm); err != nil { + return err + } } - installDir := appInstall.GetPath() - defaultConfigPath := path.Join(installDir, "conf", "default", "00.default.conf") - fileOp := files.NewFileOp() - content, err := fileOp.GetContent(defaultConfigPath) - if err != nil { - return err - } - newContent := strings.ReplaceAll(string(content), "default_server", "") - if err := fileOp.WriteFile(defaultConfigPath, strings.NewReader(newContent), constant.FilePerm); err != nil { - return err - } - return createAllWebsitesWAFConfig() + return createAllWebsitesWAFConfig(websites) } diff --git a/agent/app/service/website.go b/agent/app/service/website.go index d4311fb31..4dfc25703 100644 --- a/agent/app/service/website.go +++ b/agent/app/service/website.go @@ -3210,10 +3210,11 @@ func (w WebsiteService) ListDatabases() ([]response.Database, error) { database, _ := databaseRepo.Get(repo.WithByName(db.MysqlName)) if database.ID > 0 { res = append(res, response.Database{ - ID: db.ID, - Name: db.Name, - Type: database.Type, - From: database.From, + ID: db.ID, + Name: db.Name, + Type: database.Type, + From: database.From, + DatabaseName: database.Name, }) } } @@ -3222,10 +3223,11 @@ func (w WebsiteService) ListDatabases() ([]response.Database, error) { database, _ := databaseRepo.Get(repo.WithByName(db.PostgresqlName)) if database.ID > 0 { res = append(res, response.Database{ - ID: db.ID, - Name: db.Name, - Type: database.Type, - From: database.From, + ID: db.ID, + Name: db.Name, + Type: database.Type, + From: database.From, + DatabaseName: database.Name, }) } } diff --git a/agent/app/service/website_utils.go b/agent/app/service/website_utils.go index 20fa0a3fe..a63320744 100644 --- a/agent/app/service/website_utils.go +++ b/agent/app/service/website_utils.go @@ -297,11 +297,7 @@ func moveDefaultWafConfig(websiteDir string, defaultConfigContent []byte, defaul return nil } -func createAllWebsitesWAFConfig() error { - websites, _ := websiteRepo.List() - if len(websites) == 0 { - return nil - } +func createAllWebsitesWAFConfig(websites []model.Website) error { nginxInstall, err := getAppInstallByKey(constant.AppOpenresty) if err != nil { return err diff --git a/agent/utils/docker/docker.go b/agent/utils/docker/docker.go index d30504e5c..3f4aadf5a 100644 --- a/agent/utils/docker/docker.go +++ b/agent/utils/docker/docker.go @@ -196,7 +196,6 @@ func (c Client) PullImageWithProcessAndOptions(task *task.Task, imageName string } return err } - timeStr := time.Now().Format("2006/01/02 15:04:05") status, _ := progress["status"].(string) if status == "Downloading" || status == "Extracting" { id, _ := progress["id"].(string) @@ -204,16 +203,17 @@ func (c Client) PullImageWithProcessAndOptions(task *task.Task, imageName string current, _ := progressDetail["current"].(float64) progressStr := "" total, ok := progressDetail["total"].(float64) + timeStr := time.Now().Format("2006/01/02 15:04:05") if ok { progressStr = fmt.Sprintf("%s %s [%s] --- %.2f%%", timeStr, status, id, (current/total)*100) } else { progressStr = fmt.Sprintf("%s %s [%s] --- %.2f%%", timeStr, status, id, current) } - _ = setLog(id, progressStr, task) } if status == "Pull complete" || status == "Download complete" { id, _ := progress["id"].(string) + timeStr := time.Now().Format("2006/01/02 15:04:05") progressStr := fmt.Sprintf("%s %s [%s] --- %.2f%%", timeStr, status, id, 100.0) _ = setLog(id, progressStr, task) } @@ -312,7 +312,6 @@ func (c Client) BuildImageWithProcessAndOptions(task *task.Task, tar io.ReadClos } else { progressStr = fmt.Sprintf("%s %s [%s] --- %.2f%%", timeStr, status, id, current) } - _ = setLog(id, progressStr, task) case "Pull complete", "Download complete", "Verifying Checksum": id, _ := progress["id"].(string) diff --git a/frontend/src/api/interface/website.ts b/frontend/src/api/interface/website.ts index d4b72e82f..94f9f5b5a 100644 --- a/frontend/src/api/interface/website.ts +++ b/frontend/src/api/interface/website.ts @@ -629,6 +629,7 @@ export namespace Website { databaseID: number; websiteID: number; from: string; + databaseName: number; } export interface ChangeDatabase { diff --git a/frontend/src/components/log/task/index.vue b/frontend/src/components/log/task/index.vue index edca31335..e8cc3da66 100644 --- a/frontend/src/components/log/task/index.vue +++ b/frontend/src/components/log/task/index.vue @@ -1,11 +1,10 @@