Skip to content

Commit

Permalink
Improve Device Stats card
Browse files Browse the repository at this point in the history
Improve Device stats card to show Total Bytes/Messages value instead of NaN.

Closes astarte-platform#384

Signed-off-by: Ismet Softic <ismet.softic@secomind.com>
  • Loading branch information
Hibe7 committed Aug 2, 2023
1 parent a8e2eff commit 1a19428
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
([#375](https://github.com/astarte-platform/astarte-dashboard/issues/375))
- Improve history navigation by replacing the browser's location.
([#385](https://github.com/astarte-platform/astarte-dashboard/issues/385))
- Improve Device stats card to show Total Bytes/Messages value instead of NaN.
([#384](https://github.com/astarte-platform/astarte-dashboard/issues/384))

## [1.1.0] - 2023-06-20

Expand Down
10 changes: 6 additions & 4 deletions src/DeviceStatusPage/ExchangedBytesCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,20 @@ const ExchangedBytesCard = ({ astarte, device }: ExchangedBytesCardProps): React
computedStats.push({
name: `${interfaceStats.name} v${interfaceStats.major}.${interfaceStats.minor}`,
bytes: interfaceStats.exchangedBytes,
bytesPercent: (interfaceStats.exchangedBytes * 100) / totalBytes,
bytesPercent: interfaceBytes !== 0 ? (interfaceStats.exchangedBytes * 100) / totalBytes : 0,
messages: interfaceStats.exchangedMessages,
messagesPercent: (interfaceStats.exchangedMessages * 100) / totalMessages,
messagesPercent:
interfaceMessages !== 0 ? (interfaceStats.exchangedMessages * 100) / totalMessages : 0,
});
});

computedStats.push({
name: 'Other',
bytes: totalBytes - interfaceBytes,
bytesPercent: ((totalBytes - interfaceBytes) * 100) / totalBytes,
bytesPercent: interfaceBytes !== 0 ? ((totalBytes - interfaceBytes) * 100) / totalBytes : 0,
messages: totalMessages - interfaceMessages,
messagesPercent: ((totalMessages - interfaceMessages) * 100) / totalMessages,
messagesPercent:
interfaceMessages !== 0 ? ((totalMessages - interfaceMessages) * 100) / totalMessages : 0,
});

computedStats.push({
Expand Down

0 comments on commit 1a19428

Please sign in to comment.