Compare commits

...
Author SHA1 Message Date
aias00 c51236318e Merge branch 'master' into bugfix-app-hide 2025-02-13 10:20:14 +08:00
aias00 decc6598e4 Merge branch 'master' into bugfix-app-hide 2025-02-13 10:19:43 +08:00
Logic 11ae95bd2f refactor(web-app): update app menu visibility on monitor creation
- Add updateLocalAppState method to update app menu visibility
- Call updateLocalAppState when creating a new monitor
- Move success notification and routing inside configuration update subscription
2025-02-12 22:28:42 +08:00
2 changed files with 26 additions and 5 deletions
@@ -19,7 +19,7 @@
import { Component, Inject, OnInit } from '@angular/core';
import { ActivatedRoute, ParamMap, Router } from '@angular/router';
import { I18NService } from '@core';
import { I18NService, StartupService } from '@core';
import { ALAIN_I18N_TOKEN, TitleService } from '@delon/theme';
import { NzNotificationService } from 'ng-zorro-antd/notification';
import { switchMap } from 'rxjs/operators';
@@ -32,6 +32,7 @@ import { Param } from '../../../pojo/Param';
import { ParamDefine } from '../../../pojo/ParamDefine';
import { AppDefineService } from '../../../service/app-define.service';
import { CollectorService } from '../../../service/collector.service';
import { GeneralConfigService } from '../../../service/general-config.service';
import { MonitorService } from '../../../service/monitor.service';
import { generateReadableRandomString } from '../../../shared/utils/common-util';
@@ -59,6 +60,8 @@ export class MonitorNewComponent implements OnInit {
private route: ActivatedRoute,
private router: Router,
private notifySvc: NzNotificationService,
private configService: GeneralConfigService,
private startUpSvc: StartupService,
@Inject(ALAIN_I18N_TOKEN) private i18nSvc: I18NService,
private titleSvc: TitleService,
private collectorSvc: CollectorService
@@ -168,13 +171,19 @@ export class MonitorNewComponent implements OnInit {
};
this.spinningTip = 'Loading...';
this.isSpinning = true;
this.monitorSvc.newMonitor(addMonitor).subscribe(
message => {
this.isSpinning = false;
if (message.code === 0) {
this.notifySvc.success(this.i18nSvc.fanyi('monitor.new.success'), '');
this.router.navigateByUrl(`/monitors?app=${info.monitor.app}`);
this.configService.updateAppTemplateConfig({ hide: false }, info.monitor.app).subscribe(() => {
this.startUpSvc.loadConfigResourceViaHttp().subscribe(() => {
this.isSpinning = false;
this.notifySvc.success(this.i18nSvc.fanyi('monitor.new.success'), '');
this.router.navigateByUrl(`/monitors?app=${info.monitor.app}`);
});
});
} else {
this.isSpinning = false;
this.notifySvc.error(this.i18nSvc.fanyi('monitor.new.failed'), message.msg);
}
},
@@ -266,7 +266,7 @@ export class DefineComponent implements OnInit {
.subscribe(
message => {
if (message.code === 0) {
this.loadMenus();
this.updateLocalAppState(app, hide);
this.startUpSvc.loadConfigResourceViaHttp().subscribe(() => {});
this.notifySvc.success(this.i18nSvc.fanyi('common.notify.apply-success'), '');
} else {
@@ -279,6 +279,18 @@ export class DefineComponent implements OnInit {
);
}
private updateLocalAppState(app: string, hide: boolean): void {
this.appMenusArr.forEach(([category, menuData]) => {
if (menuData.child) {
menuData.child.forEach((item: any) => {
if (item.value === app) {
item.hide = hide;
}
});
}
});
}
renderCategoryName(category: string): string {
let label = this.i18nSvc.fanyi(`menu.monitor.${category}`);
if (label == `menu.monitor.${category}`) {