Skip to content

Commit

Permalink
feat: allow adjusting of items per page in multi-drive storage widget
Browse files Browse the repository at this point in the history
  • Loading branch information
MauriceNino committed Apr 29, 2023
1 parent 213b73e commit 54be449
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
2 changes: 2 additions & 0 deletions apps/api/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ export const CONFIG: Config = {
cpu_shown_datapoints: numNull(penv('CPU_SHOWN_DATAPOINTS')) ?? 20,
cpu_poll_interval: numNull(penv('CPU_POLL_INTERVAL')) ?? 1000,

storage_widget_items_per_page:
numNull(penv('STORAGE_WIDGET_ITEMS_PER_PAGE')) ?? 3,
storage_widget_grow: numNull(penv('STORAGE_WIDGET_GROW')) ?? 3.5,
storage_widget_min_width: numNull(penv('STORAGE_WIDGET_MIN_WIDTH')) ?? 500,
storage_poll_interval: numNull(penv('STORAGE_POLL_INTERVAL')) ?? 60000,
Expand Down
8 changes: 8 additions & 0 deletions apps/docs/docs/config/widget-specific/storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ title: Storage

<!-- markdownlint-enable -->

## `DASHDOT_STORAGE_ITEMS_PER_PAGE`

To adjust the number of items per page in the Storage view, when multiple disks are
present.

- type: `number`
- default: `3`

## `DASHDOT_STORAGE_WIDGET_GROW`

To adjust the relative size of the Storage widget.
Expand Down
10 changes: 8 additions & 2 deletions apps/view/src/widgets/storage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,11 @@ export const StorageChart: FC<StorageChartProps> = ({
height={size.height}
data={
index != null
? usageArr.slice(index * 3, index * 3 + 3)
? usageArr.slice(
index * config.storage_widget_items_per_page,
index * config.storage_widget_items_per_page +
config.storage_widget_items_per_page
)
: usageArr
}
tooltipRenderer={x => {
Expand Down Expand Up @@ -340,7 +344,9 @@ export const StorageWidget: FC<StorageWidgetProps> = ({
color={theme.colors.storagePrimary}
heading='Storage'
infos={infos}
infosPerPage={shownData.length > 1 ? 3 : 7}
infosPerPage={
shownData.length > 1 ? config.storage_widget_items_per_page : 7
}
icon={faHdd}
extraContent={
canHaveSplitView ? (
Expand Down
1 change: 1 addition & 0 deletions libs/common/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export type Config = {
cpu_poll_interval: number;

// Storage Widget
storage_widget_items_per_page: number;
storage_widget_grow: number;
storage_widget_min_width: number;
storage_poll_interval: number;
Expand Down

0 comments on commit 54be449

Please sign in to comment.