Skip to content

Commit

Permalink
feat(view): add option to set page title
Browse files Browse the repository at this point in the history
fixes #189
  • Loading branch information
MauriceNino committed Jul 8, 2022
1 parent d26c451 commit e42fb84
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions apps/api/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const CONFIG: Config = {
disable_integrations: penv('DISABLE_INTEGRATIONS') === 'true',

show_host: penv('SHOW_HOST') === 'true',
page_title: penv('PAGE_TITLE') ?? 'dash.',
use_imperial: penv('USE_IMPERIAL') === 'true',
enable_storage_split_view: penv('ENABLE_STORAGE_SPLIT_VIEW') === 'true',
always_show_percentages: penv('ALWAYS_SHOW_PERCENTAGES') === 'true',
Expand Down
7 changes: 7 additions & 0 deletions apps/docs/docs/config/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ they will only be shown on lower resolution devices (mobile phones).
| ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ |
| <img src="/img/screenshot_darkmode.png" alt="Dashboard iwith no percentages" style={{maxHeight: "250px"}} /> | <img src="/img/screenshot_darkmode_with_perc.png" alt="Dashboard with percentages" style={{maxHeight: "250px"}} /> |

### `DASHDOT_PAGE_TITLE`

If you want to show a custom string in the browser page title.

- type: `string`
- default: `dash.`

## General

### `DASHDOT_PORT`
Expand Down
8 changes: 7 additions & 1 deletion apps/view/src/components/main-widget-container.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { motion, Variants } from 'framer-motion';
import { FC } from 'react';
import { FC, useEffect } from 'react';
import { default as styled } from 'styled-components';
import { GlassPane } from '../components/glass-pane';
import { useIsMobile } from '../services/mobile';
Expand Down Expand Up @@ -80,6 +80,12 @@ export const MainWidgetContainer: FC = () => {
const storageData = serverInfo?.storage;
const gpuData = serverInfo?.gpu;

useEffect(() => {
if (config?.page_title) {
document.title = config.page_title;
}
}, [config?.page_title]);

if (error) {
return (
<ErrorContainer
Expand Down
1 change: 1 addition & 0 deletions libs/common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export type Config = {
disable_integrations: boolean;

show_host: boolean;
page_title: string;
use_imperial: boolean;
enable_cpu_temps: boolean;
enable_storage_split_view: boolean;
Expand Down

0 comments on commit e42fb84

Please sign in to comment.