Convert all remaining files to typescript.

This commit is contained in:
Jas Singh
2024-07-26 23:11:33 -07:00
parent ca5dcc629b
commit b511d76e11
84 changed files with 2075 additions and 1987 deletions

View File

@@ -1,133 +0,0 @@
import GLib from "gi://GLib";
import options from "options";
const { left, right } = options.menus.dashboard.directories;
const Directories = () => {
return Widget.Box({
class_name: "dashboard-card directories-container",
vpack: "fill",
hpack: "fill",
expand: true,
children: [
Widget.Box({
vertical: true,
expand: true,
class_name: "section right",
children: [
Widget.Button({
hpack: "start",
expand: true,
class_name: "directory-link left top",
on_primary_click: left.directory1.command
.bind("value")
.as((cmd) => {
return () => {
App.closeWindow("dashboardmenu");
Utils.execAsync(cmd);
};
}),
child: Widget.Label({
hpack: "start",
label: left.directory1.label.bind("value"),
}),
}),
Widget.Button({
expand: true,
hpack: "start",
class_name: "directory-link left middle",
on_primary_click: left.directory2.command
.bind("value")
.as((cmd) => {
return () => {
App.closeWindow("dashboardmenu");
Utils.execAsync(cmd);
};
}),
child: Widget.Label({
hpack: "start",
label: left.directory2.label.bind("value"),
}),
}),
Widget.Button({
expand: true,
hpack: "start",
class_name: "directory-link left bottom",
on_primary_click: left.directory3.command
.bind("value")
.as((cmd) => {
return () => {
App.closeWindow("dashboardmenu");
Utils.execAsync(cmd);
};
}),
child: Widget.Label({
hpack: "start",
label: left.directory3.label.bind("value"),
}),
}),
],
}),
Widget.Box({
vertical: true,
expand: true,
class_name: "section left",
children: [
Widget.Button({
hpack: "start",
expand: true,
class_name: "directory-link right top",
on_primary_click: right.directory1.command
.bind("value")
.as((cmd) => {
return () => {
App.closeWindow("dashboardmenu");
Utils.execAsync(cmd);
};
}),
child: Widget.Label({
hpack: "start",
label: right.directory1.label.bind("value"),
}),
}),
Widget.Button({
expand: true,
hpack: "start",
class_name: "directory-link right middle",
on_primary_click: right.directory2.command
.bind("value")
.as((cmd) => {
return () => {
App.closeWindow("dashboardmenu");
Utils.execAsync(cmd);
};
}),
child: Widget.Label({
hpack: "start",
label: right.directory2.label.bind("value"),
}),
}),
Widget.Button({
expand: true,
hpack: "start",
class_name: "directory-link right bottom",
on_primary_click: right.directory3.command
.bind("value")
.as((cmd) => {
return () => {
App.closeWindow("dashboardmenu");
Utils.execAsync(cmd);
};
}),
child: Widget.Label({
hpack: "start",
label: right.directory3.label.bind("value"),
}),
}),
],
}),
],
});
};
export { Directories };

View File

@@ -0,0 +1,132 @@
import options from "options";
const { left, right } = options.menus.dashboard.directories;
const Directories = () => {
return Widget.Box({
class_name: "dashboard-card directories-container",
vpack: "fill",
hpack: "fill",
expand: true,
children: [
Widget.Box({
vertical: true,
expand: true,
class_name: "section right",
children: [
Widget.Button({
hpack: "start",
expand: true,
class_name: "directory-link left top",
on_primary_click: left.directory1.command
.bind("value")
.as((cmd) => {
return () => {
App.closeWindow("dashboardmenu");
Utils.execAsync(cmd);
};
}),
child: Widget.Label({
hpack: "start",
label: left.directory1.label.bind("value"),
}),
}),
Widget.Button({
expand: true,
hpack: "start",
class_name: "directory-link left middle",
on_primary_click: left.directory2.command
.bind("value")
.as((cmd) => {
return () => {
App.closeWindow("dashboardmenu");
Utils.execAsync(cmd);
};
}),
child: Widget.Label({
hpack: "start",
label: left.directory2.label.bind("value"),
}),
}),
Widget.Button({
expand: true,
hpack: "start",
class_name: "directory-link left bottom",
on_primary_click: left.directory3.command
.bind("value")
.as((cmd) => {
return () => {
App.closeWindow("dashboardmenu");
Utils.execAsync(cmd);
};
}),
child: Widget.Label({
hpack: "start",
label: left.directory3.label.bind("value"),
}),
}),
],
}),
Widget.Box({
vertical: true,
expand: true,
class_name: "section left",
children: [
Widget.Button({
hpack: "start",
expand: true,
class_name: "directory-link right top",
on_primary_click: right.directory1.command
.bind("value")
.as((cmd) => {
return () => {
App.closeWindow("dashboardmenu");
Utils.execAsync(cmd);
};
}),
child: Widget.Label({
hpack: "start",
label: right.directory1.label.bind("value"),
}),
}),
Widget.Button({
expand: true,
hpack: "start",
class_name: "directory-link right middle",
on_primary_click: right.directory2.command
.bind("value")
.as((cmd) => {
return () => {
App.closeWindow("dashboardmenu");
Utils.execAsync(cmd);
};
}),
child: Widget.Label({
hpack: "start",
label: right.directory2.label.bind("value"),
}),
}),
Widget.Button({
expand: true,
hpack: "start",
class_name: "directory-link right bottom",
on_primary_click: right.directory3.command
.bind("value")
.as((cmd) => {
return () => {
App.closeWindow("dashboardmenu");
Utils.execAsync(cmd);
};
}),
child: Widget.Label({
hpack: "start",
label: right.directory3.label.bind("value"),
}),
}),
],
}),
],
});
};
export { Directories };

View File

@@ -1,79 +0,0 @@
import icons from "../../../icons/index.js";
import powermenu from "../../power/helpers/actions.js";
import options from "options";
const { image, name } = options.menus.dashboard.powermenu.avatar;
const Profile = () => {
const handleClick = (action) => {
App.closeWindow("dashboardmenu");
return powermenu.action(action);
};
return Widget.Box({
class_name: "profiles-container",
hpack: "fill",
hexpand: true,
children: [
Widget.Box({
class_name: "profile-picture-container dashboard-card",
hexpand: true,
vertical: true,
children: [
Widget.Icon({
hpack: "center",
class_name: "profile-picture",
icon: image.bind("value"),
}),
Widget.Label({
hpack: "center",
class_name: "profile-name",
label: name.bind("value").as((v) => {
if (v === "system") {
return Utils.exec("bash -c whoami");
}
return v;
}),
}),
],
}),
Widget.Box({
class_name: "power-menu-container dashboard-card",
vertical: true,
vexpand: true,
children: [
Widget.Button({
class_name: "dashboard-button shutdown",
on_clicked: () => handleClick("shutdown"),
tooltip_text: "Shut Down",
vexpand: true,
child: Widget.Icon(icons.powermenu.shutdown),
}),
Widget.Button({
class_name: "dashboard-button restart",
on_clicked: () => handleClick("reboot"),
tooltip_text: "Restart",
vexpand: true,
child: Widget.Icon(icons.powermenu.reboot),
}),
Widget.Button({
class_name: "dashboard-button lock",
on_clicked: () => handleClick("logout"),
tooltip_text: "Log Out",
vexpand: true,
child: Widget.Icon(icons.powermenu.logout),
}),
Widget.Button({
class_name: "dashboard-button sleep",
on_clicked: () => handleClick("sleep"),
tooltip_text: "Sleep",
vexpand: true,
child: Widget.Icon(icons.powermenu.sleep),
}),
],
}),
],
});
};
export { Profile };

View File

@@ -0,0 +1,80 @@
import icons from "../../../icons/index.js";
import powermenu from "../../power/helpers/actions.js";
import { PowerOptions } from "lib/types/options.js";
import options from "options";
const { image, name } = options.menus.dashboard.powermenu.avatar;
const Profile = () => {
const handleClick = (action: PowerOptions) => {
App.closeWindow("dashboardmenu");
return powermenu.action(action);
};
return Widget.Box({
class_name: "profiles-container",
hpack: "fill",
hexpand: true,
children: [
Widget.Box({
class_name: "profile-picture-container dashboard-card",
hexpand: true,
vertical: true,
children: [
Widget.Icon({
hpack: "center",
class_name: "profile-picture",
icon: image.bind("value"),
}),
Widget.Label({
hpack: "center",
class_name: "profile-name",
label: name.bind("value").as((v) => {
if (v === "system") {
return Utils.exec("bash -c whoami");
}
return v;
}),
}),
],
}),
Widget.Box({
class_name: "power-menu-container dashboard-card",
vertical: true,
vexpand: true,
children: [
Widget.Button({
class_name: "dashboard-button shutdown",
on_clicked: () => handleClick("shutdown"),
tooltip_text: "Shut Down",
vexpand: true,
child: Widget.Icon(icons.powermenu.shutdown),
}),
Widget.Button({
class_name: "dashboard-button restart",
on_clicked: () => handleClick("reboot"),
tooltip_text: "Restart",
vexpand: true,
child: Widget.Icon(icons.powermenu.reboot),
}),
Widget.Button({
class_name: "dashboard-button lock",
on_clicked: () => handleClick("logout"),
tooltip_text: "Log Out",
vexpand: true,
child: Widget.Icon(icons.powermenu.logout),
}),
Widget.Button({
class_name: "dashboard-button sleep",
on_clicked: () => handleClick("sleep"),
tooltip_text: "Sleep",
vexpand: true,
child: Widget.Icon(icons.powermenu.sleep),
}),
],
}),
],
});
};
export { Profile };

View File

@@ -16,16 +16,12 @@ const Shortcuts = () => {
},
],
});
const handleClick = (action, resolver, tOut = 250) => {
const handleClick = (action: any, tOut: number = 250) => {
App.closeWindow("dashboardmenu");
setTimeout(() => {
Utils.execAsync(action)
.then((res) => {
if (typeof resolver === "function") {
return resolver(res);
}
return res;
})
.catch((err) => err);

View File

@@ -1,11 +1,12 @@
import options from "options";
import { GPU_Stat } from "lib/types/gpustat";
const { terminal } = options;
const Stats = () => {
const divide = ([total, free]) => free / total;
const formatSizeInGB = (sizeInKB) =>
const formatSizeInGB = (sizeInKB: number) =>
Number((sizeInKB / 1024 ** 2).toFixed(2));
const cpu = Variable(0, {
@@ -73,8 +74,10 @@ const Stats = () => {
const totalGpu = 100;
const usedGpu =
data.gpus.reduce((acc, gpu) => acc + gpu["utilization.gpu"], 0) /
data.gpus.length;
data.gpus.reduce((acc: number, gpu: GPU_Stat) => {
return acc + gpu["utilization.gpu"]
}, 0) / data.gpus.length;
return divide([totalGpu, usedGpu]);
} catch (e) {