(WIP) Code orginazation/refactoring and beging nework refactoring...

This commit is contained in:
Jas Singh
2024-06-29 03:36:57 -07:00
parent 78496ae98a
commit 5ddf5c240d
18 changed files with 1109 additions and 984 deletions

View File

@@ -0,0 +1,61 @@
const renderWAPs = (self, network) => {
self.hook(network, () => {
const WAPs = network.wifi.access_points;
console.log("WAPs");
console.log(JSON.stringify(WAPs, null, 2));
const filteredWAPs = WAPs.filter((ap) => ap.ssid !== "Unknown").sort(
(a, b) => {
return b.strength - a.strength;
},
);
if (filteredWAPs.length <= 0) {
return (self.child = Widget.Label({
class_name: "waps-not-found dim",
expand: true,
hpack: "center",
vpack: "center",
label: "No Wi-Fi Networks Found",
}));
}
return (self.children = filteredWAPs.map((ap) => {
return Widget.Button({
class_name: "network-element-item",
child: Widget.Box({
hpack: "start",
children: [
Widget.Icon({
class_name: "network-ethernet-icon",
icon: `${ap["iconName"]}`,
}),
Widget.Box({
class_name: "connection-container",
vertical: true,
children: [
Widget.Label({
class_name: "active-connection",
hpack: "start",
truncate: "end",
wrap: true,
label: ap.ssid,
}),
Widget.Revealer({
revealChild: ap.active,
child: Widget.Label({
hpack: "start",
class_name: "connection-status dim",
label: "Connected",
}),
}),
],
}),
],
}),
});
}));
});
};
export { renderWAPs };