Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
C-D-Lewis committed Oct 18, 2024
1 parent 4c17b11 commit 33bd06a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
3 changes: 2 additions & 1 deletion dashboard2/src/components/AppArea.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ const NoDeviceLabel = () => fabricate('Text')
const AppCardList = () => fabricate('Row')
.setStyles({
flexWrap: 'wrap',
padding: '15px',
padding: '0px 15px',
})
.setNarrowStyles({ padding: '0px' })
.onUpdate((el, state) => {
el.setChildren(state.selectedDeviceApps.map((p) => AppCard({ app: p })));
}, [fabricate.StateKeys.Created, 'selectedDeviceApps']);
Expand Down
2 changes: 1 addition & 1 deletion dashboard2/src/components/AppCard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const AppControls = ({ app }: { app: DeviceApp }) => fabricate('Column')

})
.setChildren([
fabricate('Text').setText('Controls here'),
// fabricate('Text').setText('Controls here'),
]);

/**
Expand Down
32 changes: 21 additions & 11 deletions dashboard2/src/components/DeviceMetrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@ declare const fabricate: Fabricate<AppState>;

/** Plot point label offset */
const LABEL_OFFSET = 3;

/** Graph width based on length of a day */
const GRAPH_WIDTH = Math.round(1440 / BUCKET_SIZE);
/** Map of friendly metric names */
const METRIC_NAME_MAP = {
cpu: 'CPU',
memoryPerc: 'Memory (%)',
tempRaw: 'Temperature',
freqPerc: 'CPU Frequency (%)',
};

/**
* NoDeviceLabel component.
Expand Down Expand Up @@ -72,9 +78,9 @@ const MetricGraph = ({ name } : { name: MetricName }) => {
ctx.fillRect(0, 0, width, height);

if (!buckets.length) {
ctx.font = '18px Arial';
ctx.font = '12px Arial';
ctx.fillStyle = 'white';
ctx.fillText('No data', 15, 15);
ctx.fillText('No data', 25, 25);
return;
}

Expand Down Expand Up @@ -111,18 +117,22 @@ const MetricGraph = ({ name } : { name: MetricName }) => {
};

return fabricate('div')
.setStyles(() => ({ width: '100%', height: '100%' }))
.setStyles(() => ({
width: '100%',
height: '100%',
overflow: 'hidden',
}))
.setChildren([canvas as unknown as FabricateComponent<AppState>])
.onUpdate(async (el, state, keys) => {
canvas.width = el.offsetWidth - 1;
canvas.height = el.offsetHeight - 1;

if (keys.includes(fabricate.StateKeys.Created)) {
fetchMetric(state, name);
return;
}

if (keys.includes(dataKey)) {
canvas.width = el.offsetWidth - 1;
canvas.height = el.offsetHeight;

draw(state);
}
}, [fabricate.StateKeys.Created, dataKey]);
Expand Down Expand Up @@ -151,12 +161,12 @@ const MetricContainer = ({ name } : { name: MetricName }) => fabricate('Column')
.setStyles(({ fonts, palette }) => ({
color: 'white',
fontSize: '0.9rem',
fontFamily: fonts.code,
margin: '5px 0px 0px 0px',
padding: '0px 5px',
fontFamily: fonts.body,
margin: '0px',
padding: '5px',
borderBottom: `solid 2px ${palette.grey6}`,
}))
.setText(name),
.setText(METRIC_NAME_MAP[name]),
MetricGraph({ name }),
]);

Expand Down
2 changes: 1 addition & 1 deletion dashboard2/src/components/StatRow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ const StatRow = ({ device }: { device: Device }) => {
}),
StatView({
iconSrc: 'assets/images/uptime.png',
text: `${uptimeDays || '-'} days`,
text: `${typeof uptimeDays === 'undefined' ? '-' : uptimeDays} days`,
fontFamily: Theme.fonts.body,
}),
Toolbar({ device }),
Expand Down

0 comments on commit 33bd06a

Please sign in to comment.