@kwirthmagnify/kwirth-homepage-matrix 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/front.js +75 -2
- package/package.json +1 -1
package/front.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
(() => {
|
|
2
3
|
var __create = Object.create;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
@@ -192,6 +193,78 @@
|
|
|
192
193
|
return /* @__PURE__ */ import_react.default.createElement(import_material.Box, { key: i, sx: { color: e.type === "Warning" ? "#ff9800" : MATRIX_GREEN, mb: 0.2 } }, /* @__PURE__ */ import_react.default.createElement(import_material.Box, { component: "span", sx: { color: MATRIX_DIM, mr: 0.5 } }, t), /* @__PURE__ */ import_react.default.createElement(import_material.Box, { component: "span", sx: { mr: 0.5 } }, "[", e.reason, "]"), /* @__PURE__ */ import_react.default.createElement(import_material.Box, { component: "span", sx: { color: MATRIX_DIM, mr: 0.5 } }, e.object), e.message);
|
|
193
194
|
}));
|
|
194
195
|
};
|
|
196
|
+
var matrixCardSx = {
|
|
197
|
+
bgcolor: "rgba(0,0,0,0.80)",
|
|
198
|
+
border: `1px solid ${MATRIX_GREEN}`,
|
|
199
|
+
boxShadow: `0 0 10px ${MATRIX_GLOW}, inset 0 0 10px rgba(0,255,65,0.05)`,
|
|
200
|
+
color: MATRIX_GREEN,
|
|
201
|
+
backdropFilter: "blur(2px)"
|
|
202
|
+
};
|
|
203
|
+
var matrixIconBtnSx = {
|
|
204
|
+
color: MATRIX_DIM,
|
|
205
|
+
p: 0.25,
|
|
206
|
+
borderRadius: 0.5,
|
|
207
|
+
fontSize: "0.6rem",
|
|
208
|
+
fontFamily: "monospace",
|
|
209
|
+
lineHeight: 1,
|
|
210
|
+
"&:hover": { color: MATRIX_GREEN, bgcolor: "rgba(0,255,65,0.1)" }
|
|
211
|
+
};
|
|
212
|
+
function QuickColumn({ label, items, getKey, getName, getSub, onLaunch, onDelete }) {
|
|
213
|
+
return /* @__PURE__ */ import_react.default.createElement(import_material.Box, { sx: { flex: 1, minWidth: 0, display: "flex", flexDirection: "column", gap: 0.5, alignSelf: "stretch" } }, /* @__PURE__ */ import_react.default.createElement(import_material.Typography, { sx: { fontFamily: "monospace", fontSize: "0.75rem", color: MATRIX_DIM, letterSpacing: 1, mb: 0.25 } }, "// ", label), /* @__PURE__ */ import_react.default.createElement(import_material.Box, { sx: { borderTop: `1px solid ${MATRIX_DIM}`, mb: 0.5 } }), items.length === 0 ? /* @__PURE__ */ import_react.default.createElement(import_material.Typography, { sx: { fontFamily: "monospace", fontSize: "0.7rem", color: MATRIX_DIM, opacity: 0.5 } }, "// empty") : items.map((item) => /* @__PURE__ */ import_react.default.createElement(import_material.Stack, { key: getKey(item), direction: "row", alignItems: "center", sx: { minWidth: 0, gap: 0.5 } }, /* @__PURE__ */ import_react.default.createElement(import_material.Typography, { sx: { fontFamily: "monospace", fontSize: "0.75rem", flex: 1, minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } }, /* @__PURE__ */ import_react.default.createElement("span", { style: { color: MATRIX_GREEN } }, getName(item)), getSub(item) && /* @__PURE__ */ import_react.default.createElement("span", { style: { color: MATRIX_DIM, paddingLeft: "20px" } }, getSub(item))), /* @__PURE__ */ import_react.default.createElement(import_material.Tooltip, { title: "Launch" }, /* @__PURE__ */ import_react.default.createElement(import_material.IconButton, { size: "small", sx: matrixIconBtnSx, onClick: () => onLaunch(item) }, "\u25B6")), /* @__PURE__ */ import_react.default.createElement(import_material.Tooltip, { title: "Remove" }, /* @__PURE__ */ import_react.default.createElement(import_material.IconButton, { size: "small", sx: matrixIconBtnSx, onClick: () => onDelete(item) }, "\u2715")))));
|
|
214
|
+
}
|
|
215
|
+
var QuickAccessCard = (props) => {
|
|
216
|
+
const delLastTab = (tab) => props.onUpdateTabs(props.lastTabs.filter((t) => t.name !== tab.name || t.channel !== tab.channel), props.favTabs);
|
|
217
|
+
const delFavTab = (tab) => props.onUpdateTabs(props.lastTabs, props.favTabs.filter((t) => t.name !== tab.name || t.channel !== tab.channel));
|
|
218
|
+
const delLastWs = (ws) => props.onUpdateWorkspaces(props.lastWorkspaces.filter((w) => w.name !== ws.name), props.favWorkspaces);
|
|
219
|
+
const delFavWs = (ws) => props.onUpdateWorkspaces(props.lastWorkspaces, props.favWorkspaces.filter((w) => w.name !== ws.name));
|
|
220
|
+
const allEmpty = props.lastTabs.length === 0 && props.favTabs.length === 0 && props.lastWorkspaces.length === 0 && props.favWorkspaces.length === 0;
|
|
221
|
+
if (allEmpty) return null;
|
|
222
|
+
return /* @__PURE__ */ import_react.default.createElement(import_material.Card, { variant: "outlined", sx: { ...matrixCardSx, gridColumn: "1 / -1", minHeight: 160 } }, /* @__PURE__ */ import_react.default.createElement(import_material.CardContent, { sx: { py: 1.5, px: 2, height: "100%", boxSizing: "border-box", "&:last-child": { pb: 1.5 } } }, /* @__PURE__ */ import_react.default.createElement(import_material.Stack, { direction: "row", spacing: 2, alignItems: "flex-start", sx: { minWidth: 0 } }, /* @__PURE__ */ import_react.default.createElement(
|
|
223
|
+
QuickColumn,
|
|
224
|
+
{
|
|
225
|
+
label: "LAST TABS",
|
|
226
|
+
items: props.lastTabs,
|
|
227
|
+
getKey: (t) => `${t.channel}::${t.name}`,
|
|
228
|
+
getName: (t) => t.name,
|
|
229
|
+
getSub: (t) => `${t.channel} \xB7 ${t.channelObject.clusterName}`,
|
|
230
|
+
onLaunch: (t) => props.onHomepageSelectTab(t),
|
|
231
|
+
onDelete: delLastTab
|
|
232
|
+
}
|
|
233
|
+
), /* @__PURE__ */ import_react.default.createElement(import_material.Divider, { orientation: "vertical", flexItem: true, sx: { borderColor: MATRIX_DIM, opacity: 0.4 } }), /* @__PURE__ */ import_react.default.createElement(
|
|
234
|
+
QuickColumn,
|
|
235
|
+
{
|
|
236
|
+
label: "FAV TABS",
|
|
237
|
+
items: props.favTabs,
|
|
238
|
+
getKey: (t) => `${t.channel}::${t.name}`,
|
|
239
|
+
getName: (t) => t.name,
|
|
240
|
+
getSub: (t) => `${t.channel} \xB7 ${t.channelObject.clusterName}`,
|
|
241
|
+
onLaunch: (t) => props.onHomepageSelectTab(t),
|
|
242
|
+
onDelete: delFavTab
|
|
243
|
+
}
|
|
244
|
+
), /* @__PURE__ */ import_react.default.createElement(import_material.Divider, { orientation: "vertical", flexItem: true, sx: { borderColor: MATRIX_DIM, opacity: 0.4 } }), /* @__PURE__ */ import_react.default.createElement(
|
|
245
|
+
QuickColumn,
|
|
246
|
+
{
|
|
247
|
+
label: "LAST WORKSPACES",
|
|
248
|
+
items: props.lastWorkspaces,
|
|
249
|
+
getKey: (w) => w.name,
|
|
250
|
+
getName: (w) => w.name,
|
|
251
|
+
getSub: (w) => w.description,
|
|
252
|
+
onLaunch: (w) => props.onSelectWorkspace(w),
|
|
253
|
+
onDelete: delLastWs
|
|
254
|
+
}
|
|
255
|
+
), /* @__PURE__ */ import_react.default.createElement(import_material.Divider, { orientation: "vertical", flexItem: true, sx: { borderColor: MATRIX_DIM, opacity: 0.4 } }), /* @__PURE__ */ import_react.default.createElement(
|
|
256
|
+
QuickColumn,
|
|
257
|
+
{
|
|
258
|
+
label: "FAV WORKSPACES",
|
|
259
|
+
items: props.favWorkspaces,
|
|
260
|
+
getKey: (w) => w.name,
|
|
261
|
+
getName: (w) => w.name,
|
|
262
|
+
getSub: (w) => w.description,
|
|
263
|
+
onLaunch: (w) => props.onSelectWorkspace(w),
|
|
264
|
+
onDelete: delFavWs
|
|
265
|
+
}
|
|
266
|
+
))));
|
|
267
|
+
};
|
|
195
268
|
var Matrix = (props) => {
|
|
196
269
|
(0, import_react.useEffect)(() => {
|
|
197
270
|
const id = "matrix-keyframes";
|
|
@@ -288,7 +361,7 @@
|
|
|
288
361
|
gridTemplateColumns: "repeat(2, 1fr)",
|
|
289
362
|
gap: 4,
|
|
290
363
|
alignContent: "start"
|
|
291
|
-
} }, props.clusters.map((cluster, idx) => {
|
|
364
|
+
} }, /* @__PURE__ */ import_react.default.createElement(QuickAccessCard, { ...props }), props.clusters.map((cluster, idx) => {
|
|
292
365
|
const clusterChannelIds = new Set((cluster.kwirthData?.channels ?? []).map((ch) => ch.id));
|
|
293
366
|
const clusterHasMagnify = hasMagnify && clusterChannelIds.has("magnify");
|
|
294
367
|
const clusterHasTopology = hasTopology && clusterChannelIds.has("topology");
|
|
@@ -315,7 +388,7 @@
|
|
|
315
388
|
overflow: "hidden",
|
|
316
389
|
textOverflow: "ellipsis",
|
|
317
390
|
whiteSpace: "nowrap"
|
|
318
|
-
} }, cluster.url), clusterMetrics[cluster.name] && /* @__PURE__ */ import_react.default.createElement(import_material.Stack, { direction: "column", spacing: 0.25 }, /* @__PURE__ */ import_react.default.createElement(MetricBar, { label: "CPU", value: clusterMetrics[cluster.name].cpu }), /* @__PURE__ */ import_react.default.createElement(MetricBar, { label: "MEM", value: clusterMetrics[cluster.name].memory }), /* @__PURE__ */ import_react.default.createElement(MetricBar, { label: "POD", value: clusterMetrics[cluster.name].maxPods > 0 ? clusterMetrics[cluster.name].pods / clusterMetrics[cluster.name].maxPods * 100 : 0 }))), clusterMetrics[cluster.name] && /* @__PURE__ */ import_react.default.createElement(import_material.Stack, { direction: "row", spacing: 1.5, sx: { justifyContent: "center" } }, /* @__PURE__ */ import_react.default.createElement(MiniInfoCard, { label: "vCPUs", value: clusterMetrics[cluster.name].vcpus != null ? String(clusterMetrics[cluster.name].vcpus) : "--" }), /* @__PURE__ */ import_react.default.createElement(MiniInfoCard, { label: "RAM", value: clusterMetrics[cluster.name].totalMemoryBytes != null ? `${(clusterMetrics[cluster.name].totalMemoryBytes / 1073741824).toFixed(0)}G` : "--" }), /* @__PURE__ */ import_react.default.createElement(MiniInfoCard, { label: "Pods", value: clusterMetrics[cluster.name].pods ? String(clusterMetrics[cluster.name].pods) : "--" })), /* @__PURE__ */ import_react.default.createElement(import_material.Stack, { direction: "column", spacing: 0.75 }, /* @__PURE__ */ import_react.default.createElement(import_material.Stack, { direction: "row", spacing: 0.5, alignItems: "center" }, (cluster.kwirthData?.channels ?? []).map((ch) => {
|
|
391
|
+
} }, cluster.url), clusterMetrics[cluster.name] && /* @__PURE__ */ import_react.default.createElement(import_material.Stack, { direction: "column", spacing: 0.25 }, /* @__PURE__ */ import_react.default.createElement(MetricBar, { label: "CPU", value: clusterMetrics[cluster.name].cpu }), /* @__PURE__ */ import_react.default.createElement(MetricBar, { label: "MEM", value: clusterMetrics[cluster.name].memory }), /* @__PURE__ */ import_react.default.createElement(MetricBar, { label: "POD", value: clusterMetrics[cluster.name].maxPods > 0 ? clusterMetrics[cluster.name].pods / clusterMetrics[cluster.name].maxPods * 100 : 0 }))), clusterMetrics[cluster.name] && /* @__PURE__ */ import_react.default.createElement(import_material.Stack, { direction: "row", spacing: 1.5, sx: { justifyContent: "center" } }, /* @__PURE__ */ import_react.default.createElement(MiniInfoCard, { label: "vCPUs", value: clusterMetrics[cluster.name].vcpus != null ? String(clusterMetrics[cluster.name].vcpus) : "--" }), /* @__PURE__ */ import_react.default.createElement(MiniInfoCard, { label: "RAM", value: clusterMetrics[cluster.name].totalMemoryBytes != null ? `${(clusterMetrics[cluster.name].totalMemoryBytes / 1073741824).toFixed(0)}G` : "--" }), /* @__PURE__ */ import_react.default.createElement(MiniInfoCard, { label: "Pods", value: clusterMetrics[cluster.name].pods ? String(clusterMetrics[cluster.name].pods) : "--" }), /* @__PURE__ */ import_react.default.createElement(MiniInfoCard, { label: "Nodes", value: cluster.clusterInfo?.nodes?.length != null ? String(cluster.clusterInfo.nodes.length) : "--" })), /* @__PURE__ */ import_react.default.createElement(import_material.Stack, { direction: "column", spacing: 0.75 }, /* @__PURE__ */ import_react.default.createElement(import_material.Stack, { direction: "row", spacing: 0.5, alignItems: "center" }, (cluster.kwirthData?.channels ?? []).map((ch) => {
|
|
319
392
|
const channelClass = props.frontChannels.get(ch.id);
|
|
320
393
|
if (!channelClass) return null;
|
|
321
394
|
const icon = new channelClass().getChannelIcon();
|