repositories / dotfiles
dotfiles
bugabingas dorkfiles
owned by admin
quickshell/nuguland/features/system/fixtures/services/Resources.qml
Rawimport QtQuick
Item {
property var powerProfiles: null
property bool liveRates: false
property bool popupOpen: false
property int opens: 0
property int closes: 0
onPopupOpenChanged: {
if (popupOpen)
opens++;
else
closes++;
}
property var identity: ({
host: "fixture-host",
model: "synthetic machine",
distro: "fixture linux",
kernel: "test kernel",
wm: "nested niri",
packages: 123,
shell: "fixture",
uptime: "2 hours"
})
property var failedUnits: ["fixture.service"]
property var incidents: []
property var extraIssues: []
property string incidentStatus: "ready"
property string agentIssueId: ""
property bool agentPending: false
property string agentError: ""
property int agentActions: 0
signal agentDispatched
property real cpuTemperatureC: 52
property var diskUsage: []
property int updateCount: 0
property real memoryUsage: 0.4
property bool swapGrowing: false
property real loadOne: 0.5
property real loadFive: 0.3
property real loadFifteen: 0.2
property int cores: 4
property var healthPercentage: 95
property bool isLaptopBattery: true
property var batteryPercent: 80
property string batteryStatus: "charging"
property real cpuUsage: 0.25
property real memTotal: 8000000000
property real memAvailable: 4800000000
property real swapTotal: 0
property real swapFree: 0
property real swapUsage: 0
property real fanRpm: 1200
property real tempHighC: 90
property real networkRxRate: 1024
property real networkTxRate: 512
property real diskReadRate: 2048
property real diskWriteRate: 1024
property var cpuRing: [0.1, 0.4, 0.2, 0.25]
property var memRing: [0.2, 0.3, 0.4]
property var tempRing: [40, 48, 52]
property var netTxRing: [100, 800, 512]
property var netRxRing: [900, 1200, 1024]
property var diskReadRing: [500, 3000, 2048]
property var diskWriteRing: [500, 1000, 1024]
property var processes: [
{
name: "fixture-worker",
cpu: 25
}
]
property int actions: 0
property string lastAction: ""
// Plain, not readonly: the reactivity test derives them with the production bindings.
property var conditions: (failedUnits.length ? [
{
id: "fixture-unit",
severity: "error",
label: "fixture service failed",
detail: "synthetic issue action",
action: true
}
] : []).concat(extraIssues)
property var incidentGroups: incidents
// The bar chip's emphasis, as production derives it from current conditions;
// plain, so the reactivity test can bind the production derivation.
property string attention: conditions.some(issue => issue.severity === "error") ? "error" : (conditions.some(issue => issue.severity === "warning") ? "warning" : "")
// Only a warning: the chip shows its dot, without strong emphasis.
function showWarning() {
failedUnits = [];
extraIssues = [
{
id: "battery-health",
severity: "warning",
label: "battery wear",
detail: "72% health",
action: null
}
];
}
function runIssueAgent(id) {
if (agentPending)
return;
agentIssueId = id;
agentPending = true;
agentError = "";
agentActions++;
}
function agentResult(success) {
agentPending = false;
if (success)
agentDispatched();
else
agentError = "pi not found · install pi or add it to the session path, then retry";
}
function showIncidents() {
const latest = {
source: "crash",
bootId: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
cursor: "s=fixture-crash",
timestamp: new Date(Date.now() - 720000).toISOString(),
metadata: {
comm: "fixture editor",
executable: "/usr/bin/fixture-editor",
uid: "1000",
signal: "SIGSEGV",
pid: "123",
// The scope uwsm started the app in, with its generated suffix.
userUnit: "app-dev.fixture.Editor@e7f0a3c1b2d44f2a9c8b7d6e5f4a3b2c.service"
}
};
const earlier = Object.assign({}, latest, {
cursor: "s=fixture-earlier",
timestamp: new Date(Date.now() - 1440000).toISOString(),
metadata: Object.assign({}, latest.metadata, {
signal: "SIGABRT",
pid: "100"
})
});
const oldest = Object.assign({}, earlier, {
cursor: "s=fixture-oldest",
timestamp: new Date(Date.now() - 1800000).toISOString()
});
incidents = [
{
id: "crashes:[\"1000\",\"/usr/bin/fixture-editor\"]",
severity: "warning",
label: "app crashed",
detail: "synthetic crash",
context: latest,
events: [latest, earlier, oldest],
action: {
kind: "journal-event"
}
},
{
id: "fixture-oom",
severity: "warning",
label: "app ran out of memory",
detail: "synthetic oom",
context: {
source: "kernel-oom",
timestamp: new Date(Date.now() - 960000).toISOString(),
metadata: {
comm: "fixture worker with a very long process name <b>literal markup</b> and additional identifying text",
signal: "SIGKILL",
pid: "456"
}
},
action: {
kind: "journal-event"
}
}
];
extraIssues = [
{
id: "battery-health",
severity: "warning",
label: "battery wear",
detail: "72% health",
action: null
},
{
id: "updates",
severity: "info",
label: "3 updates available",
detail: "pending packages",
action: {
kind: "update"
}
}
];
// Touch an existing dependency just as production metrics do.
failedUnits = failedUnits.slice();
}
// Recorded crashes and an oom kill, without any current condition.
function showHistoryOnly() {
showIncidents();
failedUnits = [];
extraIssues = [];
}
function addCrash() {
const group = incidents[0];
const latest = Object.assign({}, group.context, {
cursor: "s=fixture-new",
timestamp: new Date().toISOString(),
metadata: Object.assign({}, group.context.metadata, {
pid: "200"
})
});
incidents = [Object.assign({}, group, {
context: latest,
events: [latest].concat(group.events)
})].concat(incidents.slice(1));
}
function runIssueAction(id) {
actions++;
lastAction = id;
}
function setIncidentStatus(status) {
incidentStatus = String(status);
}
// The panel's retry: production reads the journal again at once.
property int incidentRetries: 0
function retryIncidents() {
incidentRetries++;
incidentStatus = "not checked";
}
// Two minutes of samples: enough history for every sparkline.
function fillHistory() {
const wave = (base, swing) => Array.from({
length: 60
}, (_, i) => base + swing * Math.sin(i / 4));
cpuRing = wave(0.25, 0.15);
memRing = wave(0.4, 0.02);
tempRing = wave(50, 4);
netTxRing = wave(600, 400);
netRxRing = wave(1000, 600);
diskReadRing = wave(2000, 1500);
diskWriteRing = wave(1000, 800);
}
// `snapshot().features.system.service` in the system suite.
function fixtureState() {
return {
popupOpen: popupOpen,
opens: opens,
closes: closes,
actions: actions,
lastAction: lastAction,
agentActions: agentActions,
agentPending: agentPending,
agentIssueId: agentIssueId,
agentError: agentError,
incidentStatus: incidentStatus,
incidentRetries: incidentRetries,
attention: attention,
crashGroupId: incidents.length ? incidents[0].id : ""
};
}
function clear() {
failedUnits = [];
incidents = [];
extraIssues = [];
processes = [];
}
}