-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathconstants.ts
More file actions
234 lines (223 loc) · 5.8 KB
/
constants.ts
File metadata and controls
234 lines (223 loc) · 5.8 KB
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
import type {NodesGroupByField, NodesRequiredField, NodesSortValue} from '../../types/api/nodes';
import type {ValueOf} from '../../types/common';
import i18n from './i18n';
export const NODES_COLUMNS_WIDTH_LS_KEY = 'nodesTableColumnsWidth';
export const NODES_COLUMNS_IDS = {
NodeId: 'NodeId',
Host: 'Host',
Database: 'Database',
NodeName: 'NodeName',
DC: 'DC',
Rack: 'Rack',
Version: 'Version',
Uptime: 'Uptime',
Memory: 'Memory',
RAM: 'RAM',
CPU: 'CPU',
Pools: 'Pools',
LoadAverage: 'LoadAverage',
Load: 'Load',
DiskSpaceUsage: 'DiskSpaceUsage',
TotalSessions: 'TotalSessions',
Connections: 'Connections',
NetworkUtilization: 'NetworkUtilization',
SendThroughput: 'SendThroughput',
ReceiveThroughput: 'ReceiveThroughput',
PingTime: 'PingTime',
ClockSkew: 'ClockSkew',
Missing: 'Missing',
Tablets: 'Tablets',
PDisks: 'PDisks',
} as const;
export type NodesColumnId = ValueOf<typeof NODES_COLUMNS_IDS>;
// This code is running when module is initialized and correct language may not be set yet
// get functions guarantee that i18n fields will be inited on render with current render language
export const NODES_COLUMNS_TITLES = {
get NodeId() {
return i18n('node-id');
},
get Host() {
return i18n('host');
},
get Database() {
return i18n('database');
},
get NodeName() {
return i18n('node-name');
},
get DC() {
return i18n('dc');
},
get Rack() {
return i18n('rack');
},
get Version() {
return i18n('version');
},
get Uptime() {
return i18n('uptime');
},
get Memory() {
return i18n('memory');
},
get RAM() {
return i18n('ram');
},
get Pools() {
return i18n('pools');
},
get CPU() {
return i18n('cpu');
},
get LoadAverage() {
return i18n('load-average');
},
get Load() {
return i18n('load');
},
get DiskSpaceUsage() {
return i18n('disk-usage');
},
get TotalSessions() {
return i18n('sessions');
},
get Connections() {
return i18n('connections');
},
get NetworkUtilization() {
return i18n('utilization');
},
get SendThroughput() {
return i18n('send');
},
get ReceiveThroughput() {
return i18n('receive');
},
get PingTime() {
return i18n('ping');
},
get ClockSkew() {
return i18n('skew');
},
get Missing() {
return i18n('missing');
},
get Tablets() {
return i18n('tablets');
},
get PDisks() {
return i18n('pdisks');
},
} as const satisfies Record<NodesColumnId, string>;
const NODES_COLUMNS_GROUP_BY_TITLES = {
get NodeId() {
return i18n('node-id');
},
get Host() {
return i18n('host');
},
get NodeName() {
return i18n('node-name');
},
get Database() {
return i18n('database');
},
get DiskSpaceUsage() {
return i18n('disk-usage');
},
get DC() {
return i18n('dc');
},
get Rack() {
return i18n('rack');
},
get Missing() {
return i18n('missing');
},
get Uptime() {
return i18n('uptime');
},
get Version() {
return i18n('version');
},
get SystemState() {
return i18n('system-state');
},
get ConnectStatus() {
return i18n('connect-status');
},
get NetworkUtilization() {
return i18n('network-utilization');
},
get ClockSkew() {
return i18n('clock-skew');
},
get PingTime() {
return i18n('ping-time');
},
} as const satisfies Record<NodesGroupByField, string>;
export function getNodesGroupByFieldTitle(groupByField: NodesGroupByField) {
return NODES_COLUMNS_GROUP_BY_TITLES[groupByField];
}
// Although columns ids mostly similar to backend fields, there might be some difference
// Also for some columns we may use more than one field
export const NODES_COLUMNS_TO_DATA_FIELDS: Record<NodesColumnId, NodesRequiredField[]> = {
NodeId: ['NodeId'],
Host: ['Host', 'Rack', 'Database', 'SystemState'],
Database: ['Database'],
NodeName: ['NodeName'],
DC: ['DC'],
Rack: ['Rack'],
Version: ['Version'],
Uptime: ['Uptime'],
Memory: ['Memory', 'MemoryDetailed'],
RAM: ['Memory'],
Pools: ['CPU'],
CPU: ['CPU'],
LoadAverage: ['LoadAverage'],
Load: ['LoadAverage'],
DiskSpaceUsage: ['DiskSpaceUsage'],
TotalSessions: ['SystemState'],
Connections: ['Connections'],
NetworkUtilization: ['NetworkUtilization'],
SendThroughput: ['SendThroughput'],
ReceiveThroughput: ['ReceiveThroughput'],
PingTime: ['PingTime'],
ClockSkew: ['ClockSkew'],
Missing: ['Missing'],
Tablets: ['Tablets', 'Database'],
PDisks: ['PDisks'],
};
const NODES_COLUMNS_TO_SORT_FIELDS: Record<NodesColumnId, NodesSortValue | undefined> = {
NodeId: 'NodeId',
Host: 'Host',
Database: 'Database',
NodeName: 'NodeName',
DC: 'DC',
Rack: 'Rack',
Version: 'Version',
Uptime: 'Uptime',
Memory: 'Memory',
RAM: 'Memory',
CPU: 'CPU',
Pools: 'CPU',
LoadAverage: 'LoadAverage',
Load: 'LoadAverage',
DiskSpaceUsage: 'DiskSpaceUsage',
TotalSessions: undefined,
Connections: 'Connections',
NetworkUtilization: 'NetworkUtilization',
SendThroughput: 'SendThroughput',
ReceiveThroughput: 'ReceiveThroughput',
PingTime: 'PingTime',
ClockSkew: 'ClockSkew',
Missing: 'Missing',
Tablets: undefined,
PDisks: undefined,
};
export function getNodesColumnSortField(columnId?: string) {
return NODES_COLUMNS_TO_SORT_FIELDS[columnId as NodesColumnId];
}
export function isSortableNodesColumn(columnId: string) {
return Boolean(getNodesColumnSortField(columnId));
}