[manager,webapp]新增监控大类别,支持自定义监控页面菜单自动渲染

This commit is contained in:
tomsun28
2022-03-05 15:17:52 +08:00
parent 326cc35199
commit 36926f0fa2
15 changed files with 65 additions and 45 deletions

View File

@@ -3,7 +3,7 @@ import { Injectable, Inject } from '@angular/core';
import { Router } from '@angular/router';
import { ACLService } from '@delon/acl';
import { DA_SERVICE_TOKEN, ITokenService } from '@delon/auth';
import { ALAIN_I18N_TOKEN, MenuService, SettingsService, TitleService } from '@delon/theme';
import { ALAIN_I18N_TOKEN, Menu, MenuService, SettingsService, TitleService } from '@delon/theme';
import type { NzSafeAny } from 'ng-zorro-antd/core/types';
import { NzIconService } from 'ng-zorro-antd/icon';
import { Observable, zip, of } from 'rxjs';
@@ -37,13 +37,17 @@ export class StartupService {
private viaHttp(): Observable<void> {
const defaultLang = this.i18n.defaultLang;
return zip(this.i18n.loadLangData(defaultLang), this.httpClient.get('./assets/app-data.json')).pipe(
return zip(
this.i18n.loadLangData(defaultLang),
this.httpClient.get('./assets/app-data.json'),
this.httpClient.get('/apps/hierarchy')
).pipe(
catchError((res: NzSafeAny) => {
console.warn(`StartupService.load: Network request failed`, res);
setTimeout(() => this.router.navigateByUrl(`/exception/500`));
return [];
}),
map(([langData, appData]: [Record<string, string>, NzSafeAny]) => {
map(([langData, appData, menuData]: [Record<string, string>, NzSafeAny, NzSafeAny]) => {
// setting language data
this.i18n.use(defaultLang, langData);
@@ -56,6 +60,20 @@ export class StartupService {
this.aclService.setFull(true);
// Menu data, https://ng-alain.com/theme/menu
this.menuService.add(appData.menu);
menuData.data.forEach((item: { category: string; value: string }) => {
let category = item.category;
let app = item.value;
let menu: Menu | null = this.menuService.getItem(category);
if (menu != null) {
menu.children?.push({
text: app,
link: `/monitors?app=${app}`,
i18n: `monitor.app.${app}`
});
}
});
// 刷新菜单
this.menuService.resume();
// Can be set page suffix title, https://ng-alain.com/theme/title
this.titleService.suffix = appData.app.name;
})

View File

@@ -30,48 +30,29 @@
"hideInBreadcrumb": true,
"children": [
{
"key": "service",
"text": "应用服务",
"i18n": "menu.monitor.service",
"icon": "anticon-cloud",
"children": [
{
"text": "website",
"link": "/monitors?app=website",
"i18n": "monitor.app.website"
},
{
"text": "api",
"link": "/monitors?app=api",
"i18n": "monitor.app.api"
},
{
"text": "ping",
"link": "/monitors?app=ping",
"i18n": "monitor.app.ping"
},
{
"text": "port",
"link": "/monitors?app=port",
"i18n": "monitor.app.port"
},
{
"text": "fullsite",
"link": "/monitors?app=fullsite",
"i18n": "monitor.app.fullsite"
}
]
"icon": "anticon-cloud"
},
{
"key": "db",
"text": "数据库",
"i18n": "menu.monitor.db",
"icon": "anticon-database",
"children": [
{
"text": "Mysql",
"link": "/monitors?app=mysql",
"i18n": "monitor.app.mysql"
}
]
"icon": "anticon-database"
},
{
"key": "os",
"text": "操作系统",
"hide": true,
"i18n": "menu.monitor.os",
"icon": "anticon-windows"
},
{
"key": "custom",
"text": "自定义",
"i18n": "menu.monitor.custom",
"icon": "anticon-skin"
}
]
},

View File

@@ -12,7 +12,8 @@
"service": "应用服务监控",
"db": "数据库监控",
"os": "操作系统监控",
"mid": "中间件监控"
"mid": "中间件监控",
"custom": "自定义监控"
},
"account": {
"": "个人页",