diff --git a/core/app/api/v2/command.go b/core/app/api/v2/command.go index 33906d11bae2..900a29c66ed4 100644 --- a/core/app/api/v2/command.go +++ b/core/app/api/v2/command.go @@ -137,11 +137,7 @@ func (b *BaseApi) UpdateCommand(c *gin.Context) { return } - upMap := make(map[string]interface{}) - upMap["name"] = req.Name - upMap["group_id"] = req.GroupID - upMap["command"] = req.Command - if err := commandService.Update(req.ID, upMap); err != nil { + if err := commandService.Update(req); err != nil { helper.InternalServer(c, err) return } diff --git a/core/app/dto/logs.go b/core/app/dto/logs.go index 8831801db34d..16a71ef84444 100644 --- a/core/app/dto/logs.go +++ b/core/app/dto/logs.go @@ -5,9 +5,9 @@ import ( ) type OperationLog struct { - ID uint `json:"id"` - Source string `json:"source"` - + ID uint `json:"id"` + Source string `json:"source"` + Node string `json:"node"` IP string `json:"ip"` Path string `json:"path"` Method string `json:"method"` @@ -26,6 +26,7 @@ type SearchOpLogWithPage struct { PageInfo Source string `json:"source"` Status string `json:"status"` + Node string `json:"node"` Operation string `json:"operation"` } diff --git a/core/app/model/logs.go b/core/app/model/logs.go index 490b6a48cbc4..99e26c43f3bd 100644 --- a/core/app/model/logs.go +++ b/core/app/model/logs.go @@ -8,6 +8,7 @@ type OperationLog struct { BaseModel Source string `json:"source"` IP string `json:"ip"` + Node string `json:"node"` Path string `json:"path"` Method string `json:"method"` UserAgent string `json:"userAgent"` diff --git a/core/app/repo/common.go b/core/app/repo/common.go index 627da80dd034..0b30466099e5 100644 --- a/core/app/repo/common.go +++ b/core/app/repo/common.go @@ -55,6 +55,11 @@ func WithByStatus(status string) global.DBOption { return g.Where("status = ?", status) } } +func WithByNode(node string) global.DBOption { + return func(g *gorm.DB) *gorm.DB { + return g.Where("node = ?", node) + } +} func WithByGroupBelong(group string) global.DBOption { return func(g *gorm.DB) *gorm.DB { return g.Where("group_belong = ?", group) diff --git a/core/app/service/command.go b/core/app/service/command.go index d99d28e5acfa..09bbaeb4fdcb 100644 --- a/core/app/service/command.go +++ b/core/app/service/command.go @@ -15,7 +15,7 @@ type ICommandService interface { SearchForTree(req dto.OperateByType) ([]dto.CommandTree, error) SearchWithPage(search dto.SearchCommandWithPage) (int64, interface{}, error) Create(req dto.CommandOperate) error - Update(id uint, upMap map[string]interface{}) error + Update(req dto.CommandOperate) error Delete(ids []uint) error } @@ -123,6 +123,14 @@ func (u *CommandService) Delete(ids []uint) error { return commandRepo.Delete(repo.WithByIDs(ids)) } -func (u *CommandService) Update(id uint, upMap map[string]interface{}) error { - return commandRepo.Update(id, upMap) +func (u *CommandService) Update(req dto.CommandOperate) error { + command, _ := commandRepo.Get(repo.WithByName(req.Name), repo.WithByType(req.Type)) + if command.ID != req.ID { + return buserr.New("ErrRecordExist") + } + upMap := make(map[string]interface{}) + upMap["name"] = req.Name + upMap["group_id"] = req.GroupID + upMap["command"] = req.Command + return commandRepo.Update(req.ID, upMap) } diff --git a/core/app/service/logs.go b/core/app/service/logs.go index 48a432424b81..8e233f6a6222 100644 --- a/core/app/service/logs.go +++ b/core/app/service/logs.go @@ -122,6 +122,9 @@ func (u *LogService) PageOperationLog(req dto.SearchOpLogWithPage) (int64, inter if len(req.Status) != 0 { options = append(options, repo.WithByStatus(req.Status)) } + if len(req.Node) != 0 { + options = append(options, repo.WithByNode(req.Node)) + } total, ops, err := logRepo.PageOperationLog( req.Page, diff --git a/core/i18n/i18n.go b/core/i18n/i18n.go index e85019643d3f..dcbff8f384e3 100644 --- a/core/i18n/i18n.go +++ b/core/i18n/i18n.go @@ -2,7 +2,6 @@ package i18n import ( "embed" - "fmt" "strings" "github.com/1Panel-dev/1Panel/core/global" @@ -65,10 +64,9 @@ func GetErrMsg(key string, maps map[string]interface{}) string { } func GetMsgByKey(key string) string { - content, err := global.I18n.Localize(&i18n.LocalizeConfig{ + content, _ := global.I18n.Localize(&i18n.LocalizeConfig{ MessageID: key, }) - fmt.Println(err) return content } diff --git a/core/init/migration/migrate.go b/core/init/migration/migrate.go index 3d6a98395158..d5301f0f23fe 100644 --- a/core/init/migration/migrate.go +++ b/core/init/migration/migrate.go @@ -24,6 +24,7 @@ func Init() { migrations.UpdateXpackHideMemu, migrations.AddSystemIP, migrations.InitScriptLibrary, + migrations.AddOperationNode, }) if err := m.Migrate(); err != nil { global.LOG.Error(err) diff --git a/core/init/migration/migrations/init.go b/core/init/migration/migrations/init.go index fdbfa05c2f74..10f3acf24eb9 100644 --- a/core/init/migration/migrations/init.go +++ b/core/init/migration/migrations/init.go @@ -339,3 +339,13 @@ var InitScriptLibrary = &gormigrate.Migration{ return nil }, } + +var AddOperationNode = &gormigrate.Migration{ + ID: "20250321-add-operation-node", + Migrate: func(tx *gorm.DB) error { + if err := tx.AutoMigrate(&model.OperationLog{}); err != nil { + return err + } + return nil + }, +} diff --git a/core/middleware/operation.go b/core/middleware/operation.go index b1fccf5077d6..dabbbaad31a5 100644 --- a/core/middleware/operation.go +++ b/core/middleware/operation.go @@ -32,8 +32,10 @@ func OperationLog() gin.HandlerFunc { source := loadLogInfo(c.Request.URL.Path) pathItem := strings.TrimPrefix(c.Request.URL.Path, "/api/v2") pathItem = strings.TrimPrefix(pathItem, "/api/v2/core") + currentNode := c.Request.Header.Get("CurrentNode") record := &model.OperationLog{ Source: source, + Node: currentNode, IP: c.ClientIP(), Method: strings.ToLower(c.Request.Method), Path: pathItem, diff --git a/frontend/src/components/log/custom-hightlight/index.vue b/frontend/src/components/log/custom-hightlight/index.vue index 4a90d03a4c88..f51eb2ec20ed 100644 --- a/frontend/src/components/log/custom-hightlight/index.vue +++ b/frontend/src/components/log/custom-hightlight/index.vue @@ -89,7 +89,7 @@ const systemRules: TokenRule[] = [ const taskRules: TokenRule[] = [ { type: 'bracket-text', - pattern: /\[([^\]]+)\]/g, + pattern: /\[([^\,]]+)\]/g, color: '#B87A2B', }, ]; diff --git a/frontend/src/components/system-upgrade/index.vue b/frontend/src/components/system-upgrade/index.vue index 8b97934521c4..4635b1ee8134 100644 --- a/frontend/src/components/system-upgrade/index.vue +++ b/frontend/src/components/system-upgrade/index.vue @@ -31,11 +31,12 @@ v-if="version !== 'Waiting' && !globalStore.hasNewVersion" type="primary" :underline="false" + class="ml-2" @click="onLoadUpgradeInfo" > {{ $t('commons.button.update') }} - + {{ $t('setting.upgrading') }} diff --git a/frontend/src/layout/index.vue b/frontend/src/layout/index.vue index 7b65ddd682a0..655a6f9735ed 100644 --- a/frontend/src/layout/index.vue +++ b/frontend/src/layout/index.vue @@ -7,15 +7,19 @@ @mouseenter="collapseButtonShow = true" @mouseleave="collapseButtonShow = false" > - - + + + + diff --git a/frontend/src/views/cronjob/cronjob/index.vue b/frontend/src/views/cronjob/cronjob/index.vue index 6e494f47f93a..d8aa073a6138 100644 --- a/frontend/src/views/cronjob/cronjob/index.vue +++ b/frontend/src/views/cronjob/cronjob/index.vue @@ -29,6 +29,7 @@ @sort-change="search" @search="search" :data="data" + :heightDiff="300" > { }; const loadRecord = async (row: Cronjob.Record) => { currentRecord.value = row; - console.log(currentRecord.value); if (row.records) { const res = await getRecordLog(row.id); let log = res.data.replace(/\x1B\[[0-?]*[ -/]*[@-~]/g, ''); diff --git a/frontend/src/views/cronjob/library/index.vue b/frontend/src/views/cronjob/library/index.vue index 85a1a89d4b7f..0dabdd40e1dc 100644 --- a/frontend/src/views/cronjob/library/index.vue +++ b/frontend/src/views/cronjob/library/index.vue @@ -29,7 +29,7 @@ :pagination-config="paginationConfig" :data="data" @search="search" - :heightDiff="370" + :heightDiff="300" > diff --git a/frontend/src/views/cronjob/library/operate/index.vue b/frontend/src/views/cronjob/library/operate/index.vue index 1f4785906503..5bcfb8fab8fd 100644 --- a/frontend/src/views/cronjob/library/operate/index.vue +++ b/frontend/src/views/cronjob/library/operate/index.vue @@ -87,6 +87,7 @@ const onSubmit = async (formEl: FormInstance | undefined) => { formEl.validate(async (valid) => { if (!valid) return; loading.value = true; + dialogData.value.rowData.groupList = dialogData.value.rowData.groupList || []; dialogData.value.rowData.groups = dialogData.value.rowData.groupList.join(','); if (dialogData.value.title === 'create') { await addScript(dialogData.value.rowData) diff --git a/frontend/src/views/database/postgresql/setting/index.vue b/frontend/src/views/database/postgresql/setting/index.vue index 39258d3cde23..9262343437d1 100644 --- a/frontend/src/views/database/postgresql/setting/index.vue +++ b/frontend/src/views/database/postgresql/setting/index.vue @@ -1,7 +1,11 @@