Skip to content

Commit 736200b

Browse files
authored
fix: Fix the issue of abnormal display of recommended applications on… (#7914)
1 parent 33e2365 commit 736200b

File tree

6 files changed

+58
-17
lines changed

6 files changed

+58
-17
lines changed

agent/app/api/v2/dashboard.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,19 @@ func (b *BaseApi) LoadAppLauncherOption(c *gin.Context) {
6161
helper.SuccessWithData(c, data)
6262
}
6363

64+
func (b *BaseApi) SyncAppLauncher(c *gin.Context) {
65+
var req dto.SyncFromMaster
66+
if err := helper.CheckBindAndValidate(&req, c); err != nil {
67+
return
68+
}
69+
if err := dashboardService.Sync(req); err != nil {
70+
helper.BadRequest(c, err)
71+
return
72+
}
73+
74+
helper.SuccessWithOutData(c)
75+
}
76+
6477
// @Tags Dashboard
6578
// @Summary Load dashboard base info
6679
// @Accept json

agent/app/service/cronjob.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,27 @@ func (u *CronjobService) SearchRecords(search dto.SearchRecord) (int64, interfac
9696

9797
func (u *CronjobService) LoadNextHandle(specStr string) ([]string, error) {
9898
spec := cron.NewParser(cron.Minute | cron.Hour | cron.Dom | cron.Month | cron.Dow)
99+
now := time.Now()
100+
var nexts [5]string
101+
if strings.HasPrefix(specStr, "@every ") {
102+
duration := time.Minute
103+
if strings.HasSuffix(specStr, "s") {
104+
duration = time.Second
105+
}
106+
for i := 0; i < 5; i++ {
107+
nextTime := now.Add(duration)
108+
nexts[i] = nextTime.Format(constant.DateTimeLayout)
109+
now = nextTime
110+
}
111+
return nexts[:], nil
112+
}
99113
sched, err := spec.Parse(specStr)
100114
if err != nil {
101115
return nil, err
102116
}
103-
now := time.Now()
104-
var nexts [5]string
105117
for i := 0; i < 5; i++ {
106118
nextTime := sched.Next(now)
107-
nexts[i] = nextTime.Format("2006-01-02 15:04:05")
108-
fmt.Println(nextTime)
119+
nexts[i] = nextTime.Format(constant.DateTimeLayout)
109120
now = nextTime
110121
}
111122
return nexts[:], nil

agent/router/ro_dashboard.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ func (s *DashboardRouter) InitRouter(Router *gin.RouterGroup) {
1313
{
1414
cmdRouter.GET("/base/os", baseApi.LoadDashboardOsInfo)
1515
cmdRouter.GET("/app/launcher", baseApi.LoadAppLauncher)
16+
cmdRouter.POST("/app/launcher/sync", baseApi.SyncAppLauncher)
1617
cmdRouter.POST("/app/launcher/option", baseApi.LoadAppLauncherOption)
1718
cmdRouter.GET("/base/:ioOption/:netOption", baseApi.LoadDashboardBaseInfo)
1819
cmdRouter.GET("/current/node", baseApi.LoadCurrentInfoForNode)

core/app/service/app_launcher.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ func (u *LauncherService) ChangeShow(req dto.SettingUpdate) error {
3939
launcher, _ := launcherRepo.Get(repo.WithByKey(req.Key))
4040
if req.Value == constant.StatusEnable {
4141
if launcher.ID != 0 {
42+
go syncLauncherToAgent(launcher, "create")
4243
return nil
4344
}
4445
launcher.Key = req.Key
@@ -49,6 +50,7 @@ func (u *LauncherService) ChangeShow(req dto.SettingUpdate) error {
4950
return nil
5051
}
5152
if launcher.ID == 0 {
53+
go syncLauncherToAgent(launcher, "delete")
5254
return nil
5355
}
5456
if err := launcherRepo.Delete(repo.WithByKey(req.Key)); err != nil {

frontend/src/components/dialog-pro/index.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ const dialogVisible = computed({
8484
8585
const handleBeforeClose = () => {
8686
emit('close');
87+
dialogVisible.value = false;
8788
};
8889
const open = () => {
8990
emit('open');

frontend/src/views/home/app/index.vue

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</el-popover>
2424
</template>
2525
<template #body>
26-
<el-scrollbar height="525px" class="moz-height">
26+
<el-scrollbar height="545px" class="moz-height">
2727
<div class="h-app-card" v-for="(app, index) in apps" :key="index">
2828
<el-row :gutter="5">
2929
<el-col :span="5">
@@ -64,16 +64,17 @@
6464
<div class="h-app-content" v-else>
6565
<div>
6666
<el-dropdown trigger="hover">
67-
<el-button plain size="small" link class="h-app-dropdown">
67+
<el-button type="primary" plain size="small" link class="h-app-dropdown">
6868
{{ app.currentRow.name }}
6969
<el-icon class="el-icon--right"><ArrowDown /></el-icon>
7070
</el-button>
7171
<template #dropdown>
72-
<el-dropdown-menu
73-
v-for="(detailItem, index2) in app.detail"
74-
:key="index2"
75-
>
76-
<el-dropdown-item @click="app.currentRow = detailItem">
72+
<el-dropdown-menu>
73+
<el-dropdown-item
74+
v-for="(detailItem, index2) in app.detail"
75+
:key="index2"
76+
@click="app.currentRow = detailItem"
77+
>
7778
{{ detailItem.name + ' - ' + detailItem.version }}
7879
</el-dropdown-item>
7980
</el-dropdown-menu>
@@ -90,7 +91,8 @@
9091
size="small"
9192
type="primary"
9293
link
93-
@click="onOperate('stop', app.currentRow)"
94+
v-if="app.currentRow.status !== 'Running'"
95+
@click="onOperate('start', app.currentRow)"
9496
>
9597
{{ $t('commons.button.start') }}
9698
</el-button>
@@ -99,10 +101,20 @@
99101
size="small"
100102
type="primary"
101103
link
104+
v-else
102105
@click="onOperate('stop', app.currentRow)"
103106
>
104107
{{ $t('commons.button.stop') }}
105108
</el-button>
109+
<el-button
110+
:style="mobile ? 'margin-left: -1px' : ''"
111+
size="small"
112+
type="primary"
113+
link
114+
@click="onOperate('restart', app.currentRow)"
115+
>
116+
{{ $t('commons.button.restart') }}
117+
</el-button>
106118
<el-button
107119
:style="mobile ? 'margin-left: -1px' : ''"
108120
size="small"
@@ -244,6 +256,7 @@ const onChangeStatus = async (row: any) => {
244256
await changeLauncherStatus(row.key, row.isShow ? 'Enable' : 'Disable')
245257
.then(() => {
246258
loading.value = false;
259+
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
247260
search();
248261
})
249262
.catch(() => {
@@ -266,8 +279,8 @@ const getConfig = async () => {
266279
267280
const onOperate = async (operation: string, row: any) => {
268281
ElMessageBox.confirm(
269-
i18n.global.t('app.operatorHelper', [i18n.global.t('app.' + operation)]),
270-
i18n.global.t('app.' + operation),
282+
i18n.global.t('app.operatorHelper', [i18n.global.t('commons.button.' + operation)]),
283+
i18n.global.t('commons.button.' + operation),
271284
{
272285
confirmButtonText: i18n.global.t('commons.button.confirm'),
273286
cancelButtonText: i18n.global.t('commons.button.cancel'),
@@ -276,9 +289,9 @@ const onOperate = async (operation: string, row: any) => {
276289
).then(async () => {
277290
loading.value = true;
278291
let params = {
279-
installId: row.installId,
292+
installId: row.installID,
280293
operate: operation,
281-
detailId: row.detailId,
294+
detailId: row.detailID,
282295
};
283296
await installedOp(params)
284297
.then(() => {
@@ -353,7 +366,7 @@ defineExpose({
353366
.h-app-dropdown {
354367
font-weight: 600;
355368
font-size: 16px;
356-
color: #1f2329;
369+
color: var(--panel-text-color);
357370
}
358371
359372
.h-app-margin {

0 commit comments

Comments
 (0)