-
Notifications
You must be signed in to change notification settings - Fork 9
/
AppModel.ts
150 lines (138 loc) · 4.44 KB
/
AppModel.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*
* This file belongs to Hoist, an application development toolkit
* developed by Extremely Heavy Industries (www.xh.io | [email protected])
*
* Copyright © 2024 Extremely Heavy Industries Inc.
*/
import {clusterTab} from '@xh/hoist/admin/tabs/cluster/ClusterTab';
import {GridModel} from '@xh/hoist/cmp/grid';
import {TabConfig, TabContainerModel} from '@xh/hoist/cmp/tab';
import {HoistAppModel, managed, XH} from '@xh/hoist/core';
import {Icon} from '@xh/hoist/icon';
import {without} from 'lodash';
import {Route} from 'router5';
import {activityTab} from './tabs/activity/ActivityTab';
import {generalTab} from './tabs/general/GeneralTab';
import {monitorTab} from './tabs/monitor/MonitorTab';
import {userDataTab} from './tabs/userData/UserDataTab';
export class AppModel extends HoistAppModel {
static instance: AppModel;
@managed
tabModel: TabContainerModel;
static get readonly() {
return !XH.getUser().isHoistAdmin;
}
constructor() {
super();
this.tabModel = new TabContainerModel({
route: 'default',
switcher: false,
tabs: this.createTabs()
});
// Enable managed autosize mode across Hoist Admin console grids.
GridModel.DEFAULT_AUTOSIZE_MODE = 'managed';
}
override getRoutes(): Route[] {
return [
{
name: 'default',
path: '/admin',
children: this.getTabRoutes()
}
];
}
//------------------------
// For override / extension
//------------------------
getAppMenuButtonExtraItems() {
return [];
}
getTabRoutes(): Route[] {
return [
{
name: 'general',
path: '/general',
children: [
{name: 'about', path: '/about'},
{name: 'config', path: '/config'},
{name: 'alertBanner', path: '/alertBanner'}
]
},
{
name: 'cluster',
path: '/cluster',
children: [
{name: 'logs', path: '/logs'},
{name: 'memory', path: '/memory'},
{name: 'jdbcPool', path: '/jdbcPool'},
{name: 'environment', path: '/environment'},
{name: 'services', path: '/services'},
{name: 'objects', path: '/objects'},
{name: 'hibernate', path: '/hibernate'},
{name: 'webSockets', path: '/webSockets'}
]
},
{
name: 'monitors',
path: '/monitors'
},
{
name: 'activity',
path: '/activity',
children: [
{name: 'tracking', path: '/tracking'},
{name: 'clientErrors', path: '/clientErrors'},
{name: 'feedback', path: '/feedback'}
]
},
{
name: 'userData',
path: '/userData',
children: [
{name: 'users', path: '/users'},
{name: 'roles', path: '/roles'},
{name: 'prefs', path: '/prefs'},
{name: 'jsonBlobs', path: '/jsonBlobs'}
]
}
];
}
createTabs(): TabConfig[] {
return [
{
id: 'general',
icon: Icon.info(),
content: generalTab
},
{
id: 'cluster',
icon: Icon.server(),
content: clusterTab
},
{
id: 'monitors',
icon: Icon.shieldCheck(),
content: monitorTab
},
{
id: 'userData',
icon: Icon.users(),
content: userDataTab
},
{
id: 'activity',
title: 'User Activity',
icon: Icon.analytics(),
content: activityTab
}
];
}
/** Open the primary business-facing application, typically 'app'. */
openPrimaryApp() {
window.open(`/${this.getPrimaryAppCode()}`);
}
getPrimaryAppCode() {
const appCodes = without(XH.clientApps, XH.clientAppCode, 'mobile');
return appCodes.find(it => it === 'app') ?? appCodes[0];
}
}