Add error notifications for network menu.
This commit is contained in:
@@ -63,6 +63,10 @@ const renderWapStaging = (self, network, staging, connecting) => {
|
|||||||
console.error(
|
console.error(
|
||||||
`Failed to connect to wifi: ${staging.value.ssid}... ${err}`,
|
`Failed to connect to wifi: ${staging.value.ssid}... ${err}`,
|
||||||
);
|
);
|
||||||
|
Utils.notify({
|
||||||
|
summary: "Network",
|
||||||
|
body: err,
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
connecting.value = "";
|
connecting.value = "";
|
||||||
|
|||||||
@@ -39,6 +39,13 @@ const renderWAPs = (self, network, staging, connecting) => {
|
|||||||
return wap.bssid === staging.value.bssid;
|
return wap.bssid === staging.value.bssid;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isDisconnecting = (wap) => {
|
||||||
|
if (wap.ssid === network.wifi.ssid) {
|
||||||
|
return network.wifi.state.toLowerCase() === "deactivating";
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
const filteredWAPs = WAPs.filter(
|
const filteredWAPs = WAPs.filter(
|
||||||
(ap) => ap.ssid !== "Unknown" && !isInStaging(ap),
|
(ap) => ap.ssid !== "Unknown" && !isInStaging(ap),
|
||||||
).sort((a, b) => {
|
).sort((a, b) => {
|
||||||
@@ -83,6 +90,11 @@ const renderWAPs = (self, network, staging, connecting) => {
|
|||||||
.includes("secrets were required, but not provided")
|
.includes("secrets were required, but not provided")
|
||||||
) {
|
) {
|
||||||
staging.value = ap;
|
staging.value = ap;
|
||||||
|
} else {
|
||||||
|
Utils.notify({
|
||||||
|
summary: "Network",
|
||||||
|
body: err,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
connecting.value = "";
|
connecting.value = "";
|
||||||
});
|
});
|
||||||
@@ -128,7 +140,7 @@ const renderWAPs = (self, network, staging, connecting) => {
|
|||||||
Widget.Revealer({
|
Widget.Revealer({
|
||||||
hpack: "end",
|
hpack: "end",
|
||||||
vpack: "start",
|
vpack: "start",
|
||||||
reveal_child: ap.bssid === connecting.value,
|
reveal_child: ap.bssid === connecting.value || isDisconnecting(ap),
|
||||||
child: Widget.Spinner({
|
child: Widget.Spinner({
|
||||||
vpack: "start",
|
vpack: "start",
|
||||||
class_name: "spinner wap",
|
class_name: "spinner wap",
|
||||||
@@ -154,11 +166,14 @@ const renderWAPs = (self, network, staging, connecting) => {
|
|||||||
|
|
||||||
Utils.execAsync(
|
Utils.execAsync(
|
||||||
`nmcli connection delete ${connectionId} "${ap.ssid}"`,
|
`nmcli connection delete ${connectionId} "${ap.ssid}"`,
|
||||||
).catch((err) =>
|
)
|
||||||
|
.then(() => (connecting.value = ""))
|
||||||
|
.catch((err) => {
|
||||||
|
connecting.value = "";
|
||||||
console.error(
|
console.error(
|
||||||
`Error while forgetting "${ap.ssid}": ${err}`,
|
`Error while forgetting "${ap.ssid}": ${err}`,
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -82,8 +82,13 @@ export default () => {
|
|||||||
vertical: true,
|
vertical: true,
|
||||||
setup: (self) => {
|
setup: (self) => {
|
||||||
self.hook(notifs, () => {
|
self.hook(notifs, () => {
|
||||||
|
console.log(JSON.stringify(notifs, null, 2));
|
||||||
|
|
||||||
|
const notifHasImg = (notif) => {
|
||||||
|
return notif.image !== undefined && notif.image.length;
|
||||||
|
};
|
||||||
const imageContainer = (notif) => {
|
const imageContainer = (notif) => {
|
||||||
if (notif.image !== undefined) {
|
if (notifHasImg(notif)) {
|
||||||
return [
|
return [
|
||||||
Widget.Box({
|
Widget.Box({
|
||||||
class_name: "notification-card-image-container menu",
|
class_name: "notification-card-image-container menu",
|
||||||
@@ -138,7 +143,9 @@ export default () => {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return [];
|
return [Widget.Box({
|
||||||
|
class_name: "spacer"
|
||||||
|
})];
|
||||||
};
|
};
|
||||||
|
|
||||||
const NotificationIcon = ({
|
const NotificationIcon = ({
|
||||||
@@ -208,7 +215,7 @@ export default () => {
|
|||||||
vpack: "center",
|
vpack: "center",
|
||||||
vertical: true,
|
vertical: true,
|
||||||
hexpand: true,
|
hexpand: true,
|
||||||
class_name: `notification-card-content ${notif.image === undefined ? "noimg" : " menu"}`,
|
class_name: `notification-card-content ${!notifHasImg(notif) ? "noimg" : " menu"}`,
|
||||||
children: [
|
children: [
|
||||||
Widget.Box({
|
Widget.Box({
|
||||||
vertical: false,
|
vertical: false,
|
||||||
@@ -226,8 +233,9 @@ export default () => {
|
|||||||
hpack: "start",
|
hpack: "start",
|
||||||
hexpand: true,
|
hexpand: true,
|
||||||
vexpand: true,
|
vexpand: true,
|
||||||
max_width_chars:
|
max_width_chars: !notifHasImg(notif)
|
||||||
notif.image === undefined ? 27 : 20,
|
? 27
|
||||||
|
: 20,
|
||||||
truncate: "end",
|
truncate: "end",
|
||||||
wrap: true,
|
wrap: true,
|
||||||
label: notif["summary"],
|
label: notif["summary"],
|
||||||
@@ -255,8 +263,9 @@ export default () => {
|
|||||||
justification: "left",
|
justification: "left",
|
||||||
truncate: "end",
|
truncate: "end",
|
||||||
lines: 2,
|
lines: 2,
|
||||||
max_width_chars:
|
max_width_chars: !notifHasImg(notif)
|
||||||
notif.image === undefined ? 35 : 28,
|
? 35
|
||||||
|
: 28,
|
||||||
wrap: true,
|
wrap: true,
|
||||||
class_name:
|
class_name:
|
||||||
"notification-card-body-label menu",
|
"notification-card-body-label menu",
|
||||||
|
|||||||
@@ -16,8 +16,11 @@ export default () => {
|
|||||||
hexpand: true,
|
hexpand: true,
|
||||||
setup: (self) => {
|
setup: (self) => {
|
||||||
self.hook(notifs, () => {
|
self.hook(notifs, () => {
|
||||||
|
const notifHasImg = (notif) => {
|
||||||
|
return notif.image !== undefined && notif.image.length;
|
||||||
|
};
|
||||||
const imageContainer = (notif) => {
|
const imageContainer = (notif) => {
|
||||||
if (notif.image !== undefined) {
|
if (notifHasImg(notif)) {
|
||||||
return [
|
return [
|
||||||
Widget.Box({
|
Widget.Box({
|
||||||
class_name: "notification-card-image-container",
|
class_name: "notification-card-image-container",
|
||||||
@@ -112,7 +115,7 @@ export default () => {
|
|||||||
vpack: "start",
|
vpack: "start",
|
||||||
vertical: true,
|
vertical: true,
|
||||||
hexpand: true,
|
hexpand: true,
|
||||||
class_name: `notification-card-content ${notif.image === undefined ? "noimg" : ""}`,
|
class_name: `notification-card-content ${!notifHasImg(notif) ? "noimg" : ""}`,
|
||||||
children: [
|
children: [
|
||||||
Widget.Box({
|
Widget.Box({
|
||||||
vertical: false,
|
vertical: false,
|
||||||
@@ -128,8 +131,7 @@ export default () => {
|
|||||||
hpack: "start",
|
hpack: "start",
|
||||||
hexpand: true,
|
hexpand: true,
|
||||||
vexpand: true,
|
vexpand: true,
|
||||||
max_width_chars:
|
max_width_chars: !notifHasImg(notif) ? 27 : 20,
|
||||||
notif.image === undefined ? 27 : 20,
|
|
||||||
truncate: "end",
|
truncate: "end",
|
||||||
wrap: true,
|
wrap: true,
|
||||||
label: notif["summary"],
|
label: notif["summary"],
|
||||||
@@ -156,7 +158,7 @@ export default () => {
|
|||||||
justification: "left",
|
justification: "left",
|
||||||
truncate: "end",
|
truncate: "end",
|
||||||
lines: 2,
|
lines: 2,
|
||||||
max_width_chars: notif.image === undefined ? 35 : 28,
|
max_width_chars: !notifHasImg(notif) ? 35 : 28,
|
||||||
wrap: true,
|
wrap: true,
|
||||||
class_name: "notification-card-body-label",
|
class_name: "notification-card-body-label",
|
||||||
label: notif["body"],
|
label: notif["body"],
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
.notification-card-container.menu {
|
.notification-card-container.menu {
|
||||||
margin: 0em;
|
margin: 0em;
|
||||||
min-width: 26em;
|
min-width: 28.6em;
|
||||||
min-height: 6em;
|
min-height: 6em;
|
||||||
background: $crust;
|
background: $crust;
|
||||||
border: 0.13em solid $surface0;
|
border: 0.13em solid $surface0;
|
||||||
|
|||||||
@@ -20,12 +20,12 @@ window#verification .verification {
|
|||||||
|
|
||||||
.title {
|
.title {
|
||||||
font-size: 1.5em;
|
font-size: 1.5em;
|
||||||
color: $maroon;
|
color: $lavender;
|
||||||
margin-bottom: 0.5em;
|
margin-bottom: 0.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.desc {
|
.desc {
|
||||||
color: $lavender;
|
color: $text;
|
||||||
font-size: 1em;
|
font-size: 1em;
|
||||||
margin-bottom: 0.55em;
|
margin-bottom: 0.55em;
|
||||||
padding: 1em 3em;
|
padding: 1em 3em;
|
||||||
|
|||||||
@@ -99,3 +99,7 @@
|
|||||||
background: $maroon;
|
background: $maroon;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.spacer {
|
||||||
|
margin-bottom: 0.75em;
|
||||||
|
}
|
||||||
|
|||||||
10
style.css
10
style.css
@@ -660,11 +660,11 @@ window#verification .verification .text-box {
|
|||||||
}
|
}
|
||||||
window#verification .verification .text-box .title {
|
window#verification .verification .text-box .title {
|
||||||
font-size: 1.5em;
|
font-size: 1.5em;
|
||||||
color: #eba0ac;
|
color: #b4befe;
|
||||||
margin-bottom: 0.5em;
|
margin-bottom: 0.5em;
|
||||||
}
|
}
|
||||||
window#verification .verification .text-box .desc {
|
window#verification .verification .text-box .desc {
|
||||||
color: #b4befe;
|
color: #cdd6f4;
|
||||||
font-size: 1em;
|
font-size: 1em;
|
||||||
margin-bottom: 0.55em;
|
margin-bottom: 0.55em;
|
||||||
padding: 1em 3em;
|
padding: 1em 3em;
|
||||||
@@ -1044,7 +1044,7 @@ image {
|
|||||||
}
|
}
|
||||||
.notification-card-container.menu {
|
.notification-card-container.menu {
|
||||||
margin: 0em;
|
margin: 0em;
|
||||||
min-width: 26em;
|
min-width: 28.6em;
|
||||||
min-height: 6em;
|
min-height: 6em;
|
||||||
background: #11111b;
|
background: #11111b;
|
||||||
border: 0.13em solid #313244;
|
border: 0.13em solid #313244;
|
||||||
@@ -1354,4 +1354,8 @@ image {
|
|||||||
background: #eba0ac;
|
background: #eba0ac;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.spacer {
|
||||||
|
margin-bottom: 0.75em;
|
||||||
|
}
|
||||||
|
|
||||||
/*# sourceMappingURL=style.css.map */
|
/*# sourceMappingURL=style.css.map */
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user