Skip to content

Commit 5f07fce

Browse files
committed
improvement(upgraded-nodes): show subheaders for each version
1 parent 5609590 commit 5f07fce

File tree

9 files changed

+123
-31
lines changed

9 files changed

+123
-31
lines changed

i18n/generic.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@
104104
"network_nodes_4368eb67": "Network Nodes",
105105
"no_network_found_try_realigning_your_node_and_resc_176a9b3e": "No network found, try realigning your node and rescanning.",
106106
"node_configuration_7342e6f5": "Node Configuration",
107+
"not_upgraded_howmany_5ed230c3": "Not Upgraded (%{howMany})",
108+
"not_upgraded_nodes_9e67db38": "Not Upgraded Nodes",
107109
"notes_c42e0fd5": "Notes",
108110
"notes_of_a44a4158": "Notes of",
109111
"ok_ff1b646a": "Ok",
@@ -170,8 +172,10 @@
170172
"there_s_an_active_remote_support_session_4a40a8bb": "There's an active remote support session",
171173
"there_s_no_open_session_for_remote_support_click_a_efd0d415": "There's no open session for remote support. Click at Create Session to begin one",
172174
"these_are_the_nodes_associated_on_this_radio_3d302167": "These are the nodes associated on this radio",
175+
"these_are_the_nodes_running_the_last_version_of_th_5165bdfe": "These are the nodes running the last version of the Firmware",
173176
"these_are_the_nodes_that_can_be_reached_from_your__4c524abe": "These are the nodes that can be reached from your node, i.e. there is a working path from your node to each of them.",
174177
"these_are_the_nodes_that_can_t_be_reached_from_you_dbbf9032": "These are the nodes that can't be reached from your node, it is possible that they are not turned on or a link to reach them is down.",
178+
"these_are_the_nodes_that_need_to_be_upgraded_to_th_d09d104": "These are the nodes that need to be upgraded to the last version of the Firmware",
175179
"this_device_does_not_support_secure_rollback_to_pr_1c167a2c": "This device does not support secure rollback to previous version if something goes wrong",
176180
"this_device_supports_secure_rollback_to_previous_v_a60ddbcb": "This device supports secure rollback to previous version if something goes wrong",
177181
"this_information_is_synced_periodically_and_can_be_8b74cb8c": "This information is synced periodically and can be outdated by some minutes",
@@ -188,6 +192,8 @@
188192
"upgrade_now_f300d697": "Upgrade Now",
189193
"upgrade_to_lastest_firmware_version_9b159910": "Upgrade to lastest firmware version",
190194
"upgrade_to_versionname_621a0b6a": "Upgrade to %{versionName}",
195+
"upgraded_howmany_e439d4b1": "Upgraded (%{howMany})",
196+
"upgraded_nodes_dfc85207": "Upgraded Nodes",
191197
"upload_firmware_image_from_your_device_57327bee": "Upload firmware image from your device",
192198
"uptime_c1d2415d": "Uptime",
193199
"versionname_is_now_available_a6fbbb63": "%{versionName} is now available",

i18n/translations/es.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,12 @@
210210
"these_are_the_nodes_that_can_t_be_reached_from_you_dbbf9032": "Son los nodos con los que tienes conectividad, es decir que hay un camino funcionando entre tu nodo y cada uno de ellos.",
211211
"this_information_is_synced_periodically_and_can_be_8b74cb8c": "Esta información se sincroniza periódicamente, puede estar desactualizada algunos minutos.",
212212
"unreachable_howmany_e5c8f844": "No Alcanzables (%{howMany})",
213-
"unreachable_nodes_e6785f10": "Nodos No Alcanzables"
213+
"unreachable_nodes_e6785f10": "Nodos No Alcanzables",
214+
"not_upgraded_howmany_5ed230c3": "No Actualizados (%{howMany})",
215+
"not_upgraded_nodes_9e67db38": "Nodos No Actualizados",
216+
"these_are_the_nodes_running_the_last_version_of_th_5165bdfe": "Estos son los nodos que están actualizados a la última versión del Firmware",
217+
"these_are_the_nodes_that_need_to_be_upgraded_to_th_d09d104": "Estos son los nodos que necesitan actualizarse a la última versión del Firmware",
218+
"upgraded_howmany_e439d4b1": "Actualizados (%{howMany})",
219+
"upgraded_nodes_dfc85207": "Nodos Actualizados"
214220
}
215221

File renamed without changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.stickySubheader {
2+
position: sticky;
3+
top: 0;
4+
background-color: #325850;
5+
padding: 0.2rem;
6+
text-align: center;
7+
color:white;
8+
}

plugins/lime-plugin-upgradedNodes/src/upgradedNodesMenu.js renamed to plugins/lime-plugin-upgraded-nodes/src/upgradedNodesMenu.js

File renamed without changes.

plugins/lime-plugin-upgradedNodes/src/upgradedNodesPage.js renamed to plugins/lime-plugin-upgraded-nodes/src/upgradedNodesPage.js

Lines changed: 47 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { h } from "preact";
1+
import { h, Fragment } from "preact";
2+
import style from "./style.less";
23
import { useEffect, useState } from "preact/hooks";
34
import Tabs from "components/tabs";
45
import Loading from "components/loading";
@@ -9,6 +10,19 @@ import { useNewVersion } from "plugins/lime-plugin-firmware/src/firmwareQueries"
910
import Help from "components/help";
1011
import I18n from 'i18n-js';
1112

13+
function groupBy(xs, key) {
14+
return xs.reduce(function (rv, x) {
15+
let v = key instanceof Function ? key(x) : x[key];
16+
let el = rv.find((r) => r && r.key === v);
17+
if (el) {
18+
el.values.push(x);
19+
} else {
20+
rv.push({ key: v, values: [x] });
21+
}
22+
return rv;
23+
}, []);
24+
};
25+
1226
const PageHelp = () => (
1327
<div>
1428
<p>
@@ -33,8 +47,8 @@ const PageTabs = ({ nodes, ...props }) => {
3347
}
3448

3549
export const UpgradedNodesPage_ = ({ nodes }) => {
36-
const [ selectedGroup, setselectedGroup ] = useState('upgraded');
37-
const [ unfoldedNode, setunfoldedNode ] = useState(null);
50+
const [selectedGroup, setselectedGroup] = useState('upgraded');
51+
const [unfoldedNode, setunfoldedNode] = useState(null);
3852

3953
function changeUnfolded(hostname) {
4054
if (unfoldedNode == hostname) {
@@ -44,6 +58,13 @@ export const UpgradedNodesPage_ = ({ nodes }) => {
4458
setunfoldedNode(hostname);
4559
}
4660

61+
const groupNodes = nodes
62+
.filter(n => n.status !== 'gone')
63+
.filter(n => n.group === selectedGroup);
64+
65+
const grouppedByVersion = groupBy(groupNodes, 'fw_version')
66+
.sort((a, b) => a.key > b.key);
67+
4768
return (
4869
<div class="d-flex flex-column flex-grow-1 overflow-auto">
4970
<div class="d-flex">
@@ -53,32 +74,40 @@ export const UpgradedNodesPage_ = ({ nodes }) => {
5374
</div>
5475
</div>
5576
<List>
56-
{nodes
57-
.filter(n => n.status !== 'gone')
58-
.filter(n => n.group === selectedGroup)
59-
.sort((a, b) => a.hostname > b.hostname)
60-
.map(
61-
node =>
62-
<ExpandableNode key={node.hostname} node={node}
63-
showMore={unfoldedNode === node.hostname}
64-
onClick={() => changeUnfolded(node.hostname)}/>
65-
)}
77+
{grouppedByVersion
78+
.map((versionGroup, index) => (
79+
<Fragment>
80+
{selectedGroup === 'not_upgraded' &&
81+
<div class={style.stickySubheader} style={{ zIndex: 990 + index }}>
82+
{versionGroup.key}
83+
</div>
84+
}
85+
{versionGroup.values
86+
.map(node =>
87+
<ExpandableNode key={node.hostname} node={node}
88+
showMore={unfoldedNode === node.hostname}
89+
onClick={() => changeUnfolded(node.hostname)} />
90+
)}
91+
</Fragment>
92+
))
93+
}
6694
</List>
6795
</div>
6896
)
6997
}
7098

7199
const UpgradedNodesPage = () => {
72100
const { data: nodes, isLoading: isLoadingNodes } = useNetworkNodes();
73-
const { data: newVersion, isLoading: isLoadingVersion} = useNewVersion();
101+
const { data: newVersion, isLoading: isLoadingVersion } = useNewVersion();
74102
const [taggedNodes, setTaggedNodes] = useState(undefined);
75103

76104
useEffect(() => {
77-
if (nodes && newVersion){
105+
if (nodes && newVersion) {
78106
const taggedNodes = [...nodes].map(
79-
n => ({ ...n,
80-
group: n.fw_version === newVersion.version ? 'upgraded' : 'not_upgraded'
81-
}));
107+
n => ({
108+
...n,
109+
group: n.fw_version === newVersion.version ? 'upgraded' : 'not_upgraded'
110+
}));
82111
setTaggedNodes(taggedNodes);
83112
}
84113
}, [nodes, newVersion])

plugins/lime-plugin-upgradedNodes/upgradedNodes.spec.js renamed to plugins/lime-plugin-upgraded-nodes/upgradedNodes.spec.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// Here you define tests that closely resemble how your component is used
2-
// Using the testing-library: https://testing-library.com
3-
41
import { h } from 'preact';
52
import { fireEvent, screen, cleanup, act } from '@testing-library/preact';
63
import '@testing-library/jest-dom';
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { UpgradedNodesPage_ } from './src/upgradedNodesPage';
2+
3+
export default {
4+
title: 'Containers/Upgraded Nodes'
5+
}
6+
7+
const nodes = [
8+
{ hostname: "ql-czuk", status: "recently_reachable",
9+
ipv4:'10.5.0.3', ipv6: 'fd0d:fe46:8ce8::8bbf:7500',
10+
board: 'LibreRouter v1', fw_version: 'LibreRouterOS 1.3',
11+
group: 'not_upgraded'
12+
},
13+
{ hostname: "ql-czuk-bbone", status: "recently_reachable",
14+
ipv4:'10.5.0.9', ipv6: 'fd0d:fe46:8ce8::8bbf:7500',
15+
board: 'LibreRouter v1', fw_version: 'LibreRouterOS 1.3',
16+
group: 'not_upgraded'
17+
},
18+
{ hostname: "si-soniam", status: "recently_reachable",
19+
ipv4:'10.5.0.16', ipv6: 'fd0d:fe46:8ce8::8bbf:7500',
20+
board: 'LibreRouter v1', fw_version: 'LibreRouterOS 1.4',
21+
group: 'upgraded'
22+
},
23+
{ hostname: "ql-berta", status: "recently_reachable",
24+
ipv4:'10.5.0.9', ipv6: 'fd0d:fe46:8ce8::8bbf:7500',
25+
board: 'LibreRouter v1', fw_version: 'LibreRouterOS 1.4',
26+
group: 'upgraded'
27+
},
28+
{ hostname: "ql-nelson", status: "recently_reachable",
29+
ipv4:'10.5.0.9', ipv6: 'fd0d:fe46:8ce8::8bbf:7500',
30+
board: 'LibreRouter v1', fw_version: 'LibreRouterOS 1.3',
31+
group: 'not_upgraded'
32+
},
33+
{ hostname: "ql-irene", status: "recently_reachable",
34+
ipv4:'10.5.0.9', ipv6: 'fd0d:fe46:8ce8::8bbf:7500',
35+
board: 'LibreRouter v1', fw_version: 'LibreRouterOS 1.3',
36+
group: 'not_upgraded'
37+
},
38+
{ hostname: "ql-guillermina", status: "recently_reachable",
39+
ipv4:'10.5.0.9', ipv6: 'fd0d:fe46:8ce8::8bbf:7500',
40+
board: 'LibreRouter v1', fw_version: 'LibreRouterOS 1.3',
41+
group: 'not_upgraded'
42+
},
43+
{ hostname: "ql-silviak", status: "recently_reachable",
44+
ipv4:'10.5.0.9', ipv6: 'fd0d:fe46:8ce8::8bbf:7500',
45+
board: 'LibreRouter v1', fw_version: 'LibreRouterOS 1.3',
46+
group: 'not_upgraded'
47+
},
48+
{ hostname: "ql-oncelotes", status: "recently_reachable",
49+
ipv4:'10.5.0.9', ipv6: 'fd0d:fe46:8ce8::8bbf:7500',
50+
board: 'LibreRouter v1', fw_version: 'LibreRouterOS 1.2',
51+
group: 'not_upgraded'
52+
},
53+
];
54+
55+
export const upgradedNodesPage = () => <UpgradedNodesPage_ nodes={nodes} />

plugins/lime-plugin-upgradedNodes/upgradedNodes.stories.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)