Skip to content

Commit

Permalink
improvement(network-nodes): filter gones and sort
Browse files Browse the repository at this point in the history
  • Loading branch information
germanferrero committed Oct 14, 2021
1 parent 699f108 commit 6f4834e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
1 change: 1 addition & 0 deletions bkp/src/networkFirmwaresStyle.less
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Here you define the css for this plugin
21 changes: 18 additions & 3 deletions plugins/lime-plugin-network-nodes/networkNodes.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,22 @@ describe('networkNodes', () => {
ipv4: '10.5.0.16',
ipv6: 'fd0d:fe46:8ce8::8bbf:7500',
board: 'LibreRouter v1',
fw_version: 'LibreRouterOS 1.4'
fw_version: 'LibreRouterOS 1.4',
status: 'recently_connected'
},
"ql-nelson": {
ipv4: '10.5.0.17',
ipv6: 'fd0d:fe46:8ce8::8bbf:75bf',
board: 'LibreRouter v1',
fw_version: 'LibreRouterOS 1.4'
fw_version: 'LibreRouterOS 1.4',
status: 'disconnected'
},
"ql-gone-node": {
ipv4: '10.5.0.18',
ipv6: 'fd0d:fe46:8ce8::8bbf:75be',
board: 'LibreRouter v1',
fw_version: 'LibreRouterOS 1.4',
status: 'gone'
}
}));
});
Expand All @@ -35,7 +44,7 @@ describe('networkNodes', () => {
act(() => queryCache.clear());
});

it('test that nodes are shown', async () => {
it('test that nodes recently_connected and connected nodes are shown', async () => {
render(<NetworkNodes />);
expect(await screen.findByText('ql-nelson')).toBeInTheDocument();
expect(await screen.findByText('ql-berta')).toBeInTheDocument();
Expand All @@ -49,6 +58,12 @@ describe('networkNodes', () => {
expect(await screen.findByText('IPv6: fd0d:fe46:8ce8::8bbf:75bf')).toBeInTheDocument();
expect(await screen.findByText('Device: LibreRouter v1')).toBeInTheDocument();
expect(await screen.findByText('Firmware: LibreRouterOS 1.4')).toBeInTheDocument();
});

it('test that gone nodes are not shown', async () => {
render(<NetworkNodes />);
await screen.findByText('ql-nelson');
expect(screen.queryByText('ql-gone-node')).toBeNull();
})

});
3 changes: 2 additions & 1 deletion plugins/lime-plugin-network-nodes/src/networkNodesPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ const NetworkNodes = () => {
const sortedNodes = (networkNodes &&
Object.entries(networkNodes)
.map(([k, v]) => ({ ...v, hostname: k }))
.sort((a, b) => a.hostname > b.hostname ? -1 : 1));
.filter(n => n.status !== 'gone')
.sort((a, b) => a.hostname > b.hostname));

function changeUnfolded(hostname) {
if (unfoldedNode == hostname) {
Expand Down

0 comments on commit 6f4834e

Please sign in to comment.