diff --git a/agent/app/api/v2/dashboard.go b/agent/app/api/v2/dashboard.go index be7390aed963..ea7d3f06c09c 100644 --- a/agent/app/api/v2/dashboard.go +++ b/agent/app/api/v2/dashboard.go @@ -61,6 +61,19 @@ func (b *BaseApi) LoadAppLauncherOption(c *gin.Context) { helper.SuccessWithData(c, data) } +func (b *BaseApi) SyncAppLauncher(c *gin.Context) { + var req dto.SyncFromMaster + if err := helper.CheckBindAndValidate(&req, c); err != nil { + return + } + if err := dashboardService.Sync(req); err != nil { + helper.BadRequest(c, err) + return + } + + helper.SuccessWithOutData(c) +} + // @Tags Dashboard // @Summary Load dashboard base info // @Accept json diff --git a/agent/app/service/cronjob.go b/agent/app/service/cronjob.go index f14a1aae6611..ee11cf27dc25 100644 --- a/agent/app/service/cronjob.go +++ b/agent/app/service/cronjob.go @@ -96,16 +96,27 @@ func (u *CronjobService) SearchRecords(search dto.SearchRecord) (int64, interfac func (u *CronjobService) LoadNextHandle(specStr string) ([]string, error) { spec := cron.NewParser(cron.Minute | cron.Hour | cron.Dom | cron.Month | cron.Dow) + now := time.Now() + var nexts [5]string + if strings.HasPrefix(specStr, "@every ") { + duration := time.Minute + if strings.HasSuffix(specStr, "s") { + duration = time.Second + } + for i := 0; i < 5; i++ { + nextTime := now.Add(duration) + nexts[i] = nextTime.Format(constant.DateTimeLayout) + now = nextTime + } + return nexts[:], nil + } sched, err := spec.Parse(specStr) if err != nil { return nil, err } - now := time.Now() - var nexts [5]string for i := 0; i < 5; i++ { nextTime := sched.Next(now) - nexts[i] = nextTime.Format("2006-01-02 15:04:05") - fmt.Println(nextTime) + nexts[i] = nextTime.Format(constant.DateTimeLayout) now = nextTime } return nexts[:], nil diff --git a/agent/router/ro_dashboard.go b/agent/router/ro_dashboard.go index 125290e4db92..828a32a6e242 100644 --- a/agent/router/ro_dashboard.go +++ b/agent/router/ro_dashboard.go @@ -13,6 +13,7 @@ func (s *DashboardRouter) InitRouter(Router *gin.RouterGroup) { { cmdRouter.GET("/base/os", baseApi.LoadDashboardOsInfo) cmdRouter.GET("/app/launcher", baseApi.LoadAppLauncher) + cmdRouter.POST("/app/launcher/sync", baseApi.SyncAppLauncher) cmdRouter.POST("/app/launcher/option", baseApi.LoadAppLauncherOption) cmdRouter.GET("/base/:ioOption/:netOption", baseApi.LoadDashboardBaseInfo) cmdRouter.GET("/current/node", baseApi.LoadCurrentInfoForNode) diff --git a/core/app/service/app_launcher.go b/core/app/service/app_launcher.go index 166b58c9c6b7..881d58f52f24 100644 --- a/core/app/service/app_launcher.go +++ b/core/app/service/app_launcher.go @@ -39,6 +39,7 @@ func (u *LauncherService) ChangeShow(req dto.SettingUpdate) error { launcher, _ := launcherRepo.Get(repo.WithByKey(req.Key)) if req.Value == constant.StatusEnable { if launcher.ID != 0 { + go syncLauncherToAgent(launcher, "create") return nil } launcher.Key = req.Key @@ -49,6 +50,7 @@ func (u *LauncherService) ChangeShow(req dto.SettingUpdate) error { return nil } if launcher.ID == 0 { + go syncLauncherToAgent(launcher, "delete") return nil } if err := launcherRepo.Delete(repo.WithByKey(req.Key)); err != nil { diff --git a/frontend/src/components/dialog-pro/index.vue b/frontend/src/components/dialog-pro/index.vue index 6ddf6f86db29..0267fc14eb2e 100644 --- a/frontend/src/components/dialog-pro/index.vue +++ b/frontend/src/components/dialog-pro/index.vue @@ -84,6 +84,7 @@ const dialogVisible = computed({ const handleBeforeClose = () => { emit('close'); + dialogVisible.value = false; }; const open = () => { emit('open'); diff --git a/frontend/src/views/home/app/index.vue b/frontend/src/views/home/app/index.vue index 6fef232e7629..d1dca0e59d7d 100644 --- a/frontend/src/views/home/app/index.vue +++ b/frontend/src/views/home/app/index.vue @@ -23,7 +23,7 @@