Skip to content

Commit 7ef06fe

Browse files
authored
[explorer] fix: remove database field in node status with non API roles
problem: non-API roles display Data Base status in node status, API node status is confuse user. solution: `Data Base` only displays nodes API roles, Display `Light Node` when light node config.
1 parent 88bac7d commit 7ef06fe

File tree

13 files changed

+70
-18
lines changed

13 files changed

+70
-18
lines changed

__tests__/infrastructure/NodeService.spec.js

+31
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,37 @@ describe('Node Service', () => {
238238
});
239239
});
240240

241+
const runLightRestNodeTests = roles => {
242+
it(`returns roles ${roles} node status and light rest status`, async () => {
243+
// Arrange:
244+
const lightNodeResponse = {
245+
roles,
246+
peerStatus: generateNodePeerStatus(true),
247+
apiStatus: {
248+
...generateNodeApiStatus(true),
249+
nodeStatus: undefined
250+
},
251+
...nodeCommonField
252+
};
253+
254+
const expectedLightAPIStatus = {
255+
...expectedAPIStatus,
256+
lightNodeStatus: true,
257+
connectionStatus: true
258+
};
259+
delete expectedLightAPIStatus.databaseStatus;
260+
delete expectedLightAPIStatus.apiNodeStatus;
261+
262+
await assertNodeStatus(lightNodeResponse, {
263+
peerStatus: expectedPeerStatus,
264+
apiStatus: expectedLightAPIStatus,
265+
chainInfo: expectedChainInfoStatus
266+
});
267+
});
268+
};
269+
270+
[1, 4, 5].forEach(roles => runLightRestNodeTests(roles));
271+
241272
runStatisticServiceFailResponseTests('getNode', 'getNodeInfo');
242273
});
243274
});

package-lock.json

+13-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/tables/TableView.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,8 @@ export default {
233233
'apiNodeStatus' === key ||
234234
'databaseStatus' === key ||
235235
'isHttpsEnabled' === key ||
236-
'isAvailable' === key
236+
'isAvailable' === key ||
237+
'lightNodeStatus' === key
237238
);
238239
},
239240

src/config/i18n/en-us.json

+1
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@
350350
"connectionStatus": "Connection",
351351
"databaseStatus": "Data Base",
352352
"apiNodeStatus": "API Node",
353+
"lightNodeStatus": "Light Node",
353354
"isAvailable": "Available",
354355
"lastStatusCheck": "Last Status Check",
355356
"nodeChainInfoTitle": "Node Chain Info",

src/config/i18n/es.json

+1
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@
346346
"connectionStatus": "Connection",
347347
"databaseStatus": "Data Base",
348348
"apiNodeStatus": "API Node",
349+
"lightNodeStatus": "Light Node",
349350
"isAvailable": "Available",
350351
"lastStatusCheck": "Last Status Check",
351352
"nodeChainInfoTitle": "Node Chain Info",

src/config/i18n/ja.json

+1
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@
350350
"connectionStatus": "接続",
351351
"databaseStatus": "データベース",
352352
"apiNodeStatus": "API ノード",
353+
"lightNodeStatus": "Light ノード",
353354
"isAvailable": "有効",
354355
"lastStatusCheck": "最終チェック",
355356
"nodeChainInfoTitle": "ノードチェーン情報",

src/config/i18n/ko.json

+1
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@
350350
"connectionStatus": "연결",
351351
"databaseStatus": "데이터베이스",
352352
"apiNodeStatus": "API 노드",
353+
"lightNodeStatus": "Light 노드",
353354
"isAvailable": "활성",
354355
"lastStatusCheck": "마지막 상태 확인",
355356
"nodeChainInfoTitle": "노드 체인 정보",

src/config/i18n/pt.json

+1
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@
347347
"connectionStatus": "Connection",
348348
"databaseStatus": "Data Base",
349349
"apiNodeStatus": "API Node",
350+
"lightNodeStatus": "Light Node",
350351
"isAvailable": "Available",
351352
"lastStatusCheck": "Last Status Check",
352353
"nodeChainInfoTitle": "Node Chain Info",

src/config/i18n/ru.json

+1
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@
350350
"connectionStatus": "Соединение",
351351
"databaseStatus": "База данных",
352352
"apiNodeStatus": "API Ноды",
353+
"lightNodeStatus": "Light Ноды",
353354
"isAvailable": "Доступные",
354355
"lastStatusCheck": "Последняя проверка статуса",
355356
"nodeChainInfoTitle": "Информация о цепочке нод",

src/config/i18n/ua.json

+1
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@
346346
"connectionStatus": "Connection",
347347
"databaseStatus": "Data Base",
348348
"apiNodeStatus": "API Node",
349+
"lightNodeStatus": "Light Node",
349350
"isAvailable": "Available",
350351
"lastStatusCheck": "Last Status Check",
351352
"nodeChainInfoTitle": "Node Chain Info",

src/config/i18n/zh.json

+1
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@
346346
"connectionStatus": "Connection",
347347
"databaseStatus": "Data Base",
348348
"apiNodeStatus": "API Node",
349+
"lightNodeStatus": "Light Node",
349350
"isAvailable": "Available",
350351
"lastStatusCheck": "Last Status Check",
351352
"nodeChainInfoTitle": "Node Chain Info",

src/config/pages/node-detail.json

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
"connectionStatus",
7979
"databaseStatus",
8080
"apiNodeStatus",
81+
"lightNodeStatus",
8182
"isHttpsEnabled",
8283
"restVersion",
8384
"lastStatusCheck"

src/infrastructure/NodeService.js

+15-4
Original file line numberDiff line numberDiff line change
@@ -183,17 +183,28 @@ class NodeService {
183183
// Api status
184184
formattedNode.apiStatus = {
185185
connectionStatus: isAvailable,
186-
databaseStatus:
187-
'up' === nodeStatus?.db || Constants.Message.UNAVAILABLE,
188-
apiNodeStatus:
189-
'up' === nodeStatus?.apiNode || Constants.Message.UNAVAILABLE,
190186
isHttpsEnabled,
191187
restVersion,
192188
lastStatusCheck: moment
193189
.utc(lastStatusCheck)
194190
.format('YYYY-MM-DD HH:mm:ss')
195191
};
196192

193+
// Only API nodes have database status
194+
if ([2, 3, 6, 7].includes(node.roles)) {
195+
formattedNode.apiStatus = {
196+
...formattedNode.apiStatus,
197+
apiNodeStatus:
198+
'up' === nodeStatus?.apiNode || Constants.Message.UNAVAILABLE,
199+
databaseStatus: 'up' === nodeStatus?.db || Constants.Message.UNAVAILABLE
200+
};
201+
} else {
202+
formattedNode.apiStatus = {
203+
...formattedNode.apiStatus,
204+
lightNodeStatus: isAvailable || Constants.Message.UNAVAILABLE
205+
};
206+
};
207+
197208
// Chain info
198209
formattedNode.chainInfo = {
199210
height: chainHeight,

0 commit comments

Comments
 (0)