Skip to content

Commit

Permalink
docs: allow enable/disable item only through widget list
Browse files Browse the repository at this point in the history
Items should disappear/reappear if they are in this list or not

BREAKING CHANGE: The old config options for disabling specific widgets are now obsolete
for #64
  • Loading branch information
MauriceNino committed Jun 4, 2022
1 parent 869a228 commit b6c0c41
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 49 deletions.
49 changes: 22 additions & 27 deletions CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ If you don't know how to set them, look up the section for your type of installm

<!-- markdownlint-disable -->

| Variable | Description | Type | Default Value |
| ---------------------- | ---------------------------------------------------------------------------------------------------------------- | ------ | ---------------------------- |
| `DASHDOT_PORT` | The port where the express backend is running (the backend serves the frontend, so it is the same port for both) | number | `3001` |
| `DASHDOT_WIDGET_ORDER` | Change the order of the elements in the list, to change the position on the page | string | `os,cpu,storage,ram,network` |
| Variable | Description | Type | Default Value |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ | ---------------------------- |
| `DASHDOT_PORT` | The port where the express backend is running (the backend serves the frontend, so it is the same port for both) | number | `3001` |
| `DASHDOT_WIDGET_LIST` | Change the order of the elements in the list, to change the position on the page, or remove an item from the list, to remove it from the page (The available options are: `os`, `cpu`, `storage`, `ram`, `network`) | string | `os,cpu,storage,ram,network` |

<!-- markdownlint-enable -->

Expand All @@ -23,7 +23,6 @@ If you don't know how to set them, look up the section for your type of installm
| Variable | Description | Type | Default Value |
| ----------------------------- | --------------------------------------------------------------------------------------- | ------- | ------------- |
| `DASHDOT_DISABLE_HOST` | If you want to hide the host part in the server widget (e.g. `dash.mauz.io` -> `dash.`) | boolean | `false` |
| `DASHDOT_OS_WIDGET_ENABLE` | To show/hide the OS widget | boolean | `true` |
| `DASHDOT_OS_WIDGET_GROW` | To adjust the relative size of the OS widget | number | `1.5` |
| `DASHDOT_OS_WIDGET_MIN_WIDTH` | To adjust the minimum width of the OS widget (in px) | number | `300` |

Expand All @@ -36,7 +35,6 @@ If you don't know how to set them, look up the section for your type of installm
| Variable | Description | Type | Default Value |
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | ------------- |
| `DASHDOT_ENABLE_CPU_TEMPS` | If you want to show the CPU temperature in the graph. This will probably not work on a VPS, so you need to try it on your own if this works. For home servers it might work just fine | boolean | `false` |
| `DASHDOT_CPU_WIDGET_ENABLE` | To show/hide the Processor widget | boolean | `true` |
| `DASHDOT_CPU_WIDGET_GROW` | To adjust the relative size of the Processor widget | number | `4` |
| `DASHDOT_CPU_WIDGET_MIN_WIDTH` | To adjust the minimum width of the Processor widget (in px) | number | `500` |
| `DASHDOT_CPU_DATAPOINTS` | The amount of datapoints in the Processor graph | number | `20` |
Expand All @@ -48,41 +46,38 @@ If you don't know how to set them, look up the section for your type of installm

<!-- markdownlint-disable -->

| Variable | Description | Type | Default Value |
| ---------------------------------- | --------------------------------------------------------- | ------- | ------------- |
| `DASHDOT_STORAGE_WIDGET_ENABLE` | To show/hide the Storage widget | boolean | `true` |
| `DASHDOT_STORAGE_WIDGET_GROW` | To adjust the relative size of the Storage widget | number | `3.5` |
| `DASHDOT_STORAGE_WIDGET_MIN_WIDTH` | To adjust the minimum width of the Storage widget (in px) | number | `500` |
| `DASHDOT_STORAGE_POLL_INTERVAL` | Read the Storage load every x milliseconds | number | `60000` |
| Variable | Description | Type | Default Value |
| ---------------------------------- | --------------------------------------------------------- | ------ | ------------- |
| `DASHDOT_STORAGE_WIDGET_GROW` | To adjust the relative size of the Storage widget | number | `3.5` |
| `DASHDOT_STORAGE_WIDGET_MIN_WIDTH` | To adjust the minimum width of the Storage widget (in px) | number | `500` |
| `DASHDOT_STORAGE_POLL_INTERVAL` | Read the Storage load every x milliseconds | number | `60000` |

<!-- markdownlint-enable -->

## RAM Widget

<!-- markdownlint-disable -->

| Variable | Description | Type | Default Value |
| ------------------------------ | -------------------------------------------------------- | ------- | ------------- |
| `DASHDOT_RAM_WIDGET_ENABLE` | To show/hide the Memory widget | boolean | `true` |
| `DASHDOT_RAM_WIDGET_GROW` | To adjust the relative size of the Memory widget | number | `4` |
| `DASHDOT_RAM_WIDGET_MIN_WIDTH` | To adjust the minimum width of the Memory widget (in px) | number | `500` |
| `DASHDOT_RAM_DATAPOINTS` | The amount of datapoints in the Memory graph | number | `20` |
| `DASHDOT_RAM_POLL_INTERVAL` | Read the Memory load every x milliseconds | number | `1000` |
| Variable | Description | Type | Default Value |
| ------------------------------ | -------------------------------------------------------- | ------ | ------------- |
| `DASHDOT_RAM_WIDGET_GROW` | To adjust the relative size of the Memory widget | number | `4` |
| `DASHDOT_RAM_WIDGET_MIN_WIDTH` | To adjust the minimum width of the Memory widget (in px) | number | `500` |
| `DASHDOT_RAM_DATAPOINTS` | The amount of datapoints in the Memory graph | number | `20` |
| `DASHDOT_RAM_POLL_INTERVAL` | Read the Memory load every x milliseconds | number | `1000` |

<!-- markdownlint-enable -->

## Network Widget

<!-- markdownlint-disable -->

| Variable | Description | Type | Default Value |
| ---------------------------------- | --------------------------------------------------------------------- | ------- | ------------- |
| `DASHDOT_SPEED_TEST_INTERVAL` | At which interval the network speed-test should be rerun (in minutes) | number | `60` |
| `DASHDOT_NETWORK_WIDGET_ENABLE` | To show/hide the Network widget | boolean | `true` |
| `DASHDOT_NETWORK_WIDGET_GROW` | To adjust the relative size of the Network widget | number | `6` |
| `DASHDOT_NETWORK_WIDGET_MIN_WIDTH` | To adjust the minimum width of the Network widget (in px) | number | `500` |
| `DASHDOT_NETWORK_DATAPOINTS` | The amount of datapoints in each of the Network graphs | number | `20` |
| `DASHDOT_NETWORK_POLL_INTERVAL` | Read the Network load every x milliseconds | number | `1000` |
| Variable | Description | Type | Default Value |
| ---------------------------------- | --------------------------------------------------------------------- | ------ | ------------- |
| `DASHDOT_SPEED_TEST_INTERVAL` | At which interval the network speed-test should be rerun (in minutes) | number | `60` |
| `DASHDOT_NETWORK_WIDGET_GROW` | To adjust the relative size of the Network widget | number | `6` |
| `DASHDOT_NETWORK_WIDGET_MIN_WIDTH` | To adjust the minimum width of the Network widget (in px) | number | `500` |
| `DASHDOT_NETWORK_DATAPOINTS` | The amount of datapoints in each of the Network graphs | number | `20` |
| `DASHDOT_NETWORK_POLL_INTERVAL` | Read the Network load every x milliseconds | number | `1000` |

<!-- markdownlint-enable -->

Expand Down
8 changes: 2 additions & 6 deletions apps/api/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,33 @@ const numNull = (val: string | undefined): number | undefined => {
};

const penv = (key: string): string | undefined => process.env[`DASHDOT_${key}`];
const lst = (item: string): any[] => item.split(',');

export const CONFIG: Config = {
port: numNull(penv('PORT')) ?? 3001,
enable_tilt: penv('ENABLE_TILT') === 'true',
widget_order: penv('WIDGET_ORDER') ?? 'os,cpu,storage,ram,network',
widget_list: lst(penv('WIDGET_LIST') ?? 'os,cpu,storage,ram,network'),

disable_host: penv('DISABLE_HOST') === 'true',
os_widget_enable: penv('OS_WIDGET_ENABLE') !== 'false',
os_widget_grow: numNull(penv('OS_WIDGET_GROW')) ?? 1.5,
os_widget_min_width: numNull(penv('OS_WIDGET_MIN_WIDTH')) ?? 300,

enable_cpu_temps: penv('ENABLE_CPU_TEMPS') === 'true',
cpu_widget_enable: penv('CPU_WIDGET_ENABLE') !== 'false',
cpu_widget_grow: numNull(penv('CPU_WIDGET_GROW')) ?? 4,
cpu_widget_min_width: numNull(penv('CPU_WIDGET_MIN_WIDTH')) ?? 500,
cpu_shown_datapoints: numNull(penv('CPU_SHOWN_DATAPOINTS')) ?? 20,
cpu_poll_interval: numNull(penv('CPU_POLL_INTERVAL')) ?? 1000,

storage_widget_enable: penv('STORAGE_WIDGET_ENABLE') !== 'false',
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,

ram_widget_enable: penv('RAM_WIDGET_ENABLE') !== 'false',
ram_widget_grow: numNull(penv('RAM_WIDGET_GROW')) ?? 4,
ram_widget_min_width: numNull(penv('RAM_WIDGET_MIN_WIDTH')) ?? 500,
ram_shown_datapoints: numNull(penv('RAM_SHOWN_DATAPOINTS')) ?? 20,
ram_poll_interval: numNull(penv('RAM_POLL_INTERVAL')) ?? 1000,

speed_test_interval: numNull(penv('SPEED_TEST_INTERVAL')) ?? 60,
network_widget_enable: penv('NETWORK_WIDGET_ENABLE') !== 'false',
network_widget_grow: numNull(penv('NETWORK_WIDGET_GROW')) ?? 6,
network_widget_min_width: numNull(penv('NETWORK_WIDGET_MIN_WIDTH')) ?? 500,
network_shown_datapoints: numNull(penv('NETWORK_SHOWN_DATAPOINTS')) ?? 20,
Expand Down
11 changes: 1 addition & 10 deletions apps/view/src/components/main-widget-container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,48 +112,39 @@ export const MainWidgetContainer: FC = () => {
os: {
grow: config.os_widget_grow,
minWidth: config.os_widget_min_width,
enabled: config.os_widget_enable,
Widget: ServerWidget,
data: osData,
},
cpu: {
grow: config.cpu_widget_grow,
minWidth: config.cpu_widget_min_width,
enabled: config.cpu_widget_enable,
Widget: CpuWidget,
data: cpuData,
load: cpuLoad,
},
storage: {
grow: config.storage_widget_grow,
minWidth: config.storage_widget_min_width,
enabled: config.storage_widget_enable,
Widget: StorageWidget,
data: storageData,
load: storageLoad,
},
ram: {
grow: config.ram_widget_grow,
minWidth: config.ram_widget_min_width,
enabled: config.ram_widget_enable,
Widget: RamWidget,
data: ramData,
load: ramLoad,
},
network: {
grow: config.network_widget_grow,
minWidth: config.network_widget_min_width,
enabled: config.network_widget_enable,
Widget: NetworkWidget,
data: networkData,
load: networkLoad,
},
};

const widgetOrderArr = (
config.widget_order.split(',') as (keyof typeof configs)[]
).filter(widget => configs[widget].enabled);

return (
<FlexContainer
mobile={isMobile}
Expand All @@ -162,7 +153,7 @@ export const MainWidgetContainer: FC = () => {
animate='animate'
exit='exit'
>
{widgetOrderArr.map(widget => {
{config.widget_list.map(widget => {
const currentConfig = configs[widget];

return (
Expand Down
7 changes: 1 addition & 6 deletions libs/common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,38 +62,33 @@ export type Config = {
// General
port: number;
enable_tilt: boolean;
widget_order: string;
widget_list: ('os' | 'cpu' | 'storage' | 'ram' | 'network')[];

// OS Widget
disable_host: boolean;
os_widget_enable: boolean;
os_widget_grow: number;
os_widget_min_width: number;

// CPU Widget
enable_cpu_temps: boolean;
cpu_widget_enable: boolean;
cpu_widget_grow: number;
cpu_widget_min_width: number;
cpu_shown_datapoints: number;
cpu_poll_interval: number;

// Storage Widget
storage_widget_enable: boolean;
storage_widget_grow: number;
storage_widget_min_width: number;
storage_poll_interval: number;

// RAM Widget
ram_widget_enable: boolean;
ram_widget_grow: number;
ram_widget_min_width: number;
ram_shown_datapoints: number;
ram_poll_interval: number;

// Network Widget
speed_test_interval: number;
network_widget_enable: boolean;
network_widget_grow: number;
network_widget_min_width: number;
network_shown_datapoints: number;
Expand Down

0 comments on commit b6c0c41

Please sign in to comment.