Skip to content

Commit 668095d

Browse files
committed
fix types
1 parent 9fd6feb commit 668095d

File tree

11 files changed

+45
-28
lines changed

11 files changed

+45
-28
lines changed

backend/src/routes/layout.route.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import fs from 'fs/promises';
44
import StatusCodes from 'http-status-codes';
55
import path from 'path';
66

7+
import { Config } from '../types';
78
export const layoutRoute = Router();
89

910
const CONFIG_FILE = path.join(__dirname, '../config/config.json');
@@ -36,7 +37,7 @@ layoutRoute.post('/', async (req: Request, res: Response): Promise<void> => {
3637
console.log('saving layout body', req.body);
3738

3839
const { desktop, mobile } = req.body;
39-
const config = loadConfig();
40+
const config: Config = loadConfig();
4041

4142
console.log('config', config);
4243
config.layout.desktop = desktop && desktop.length > 0 ? desktop : config.layout.desktop;
Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { DashboardItem } from './dashboard-item'
2-
31
export type Config = {
42
layout: {
53
desktop: DashboardItem[];
@@ -11,3 +9,13 @@ export type DashboardLayout = {
119
desktop: DashboardItem[];
1210
mobile: DashboardItem[];
1311
}
12+
13+
export type DashboardItem = {
14+
id: string;
15+
label: string;
16+
type: string;
17+
url?: string;
18+
icon?: { path: string; name: string; source?: string; };
19+
showName?: boolean;
20+
};
21+

backend/tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
},
1313
"include": [
1414
"index.ts",
15-
"./src/config/config.json",
16-
"../shared"
15+
"./src/config/config.json"
1716
]
1817
}

frontend/src/api/dash-api.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import axios from 'axios';
22
import { StatusCodes } from 'http-status-codes';
33

4-
import { DashboardLayout } from '../../../shared/types/config';
5-
import { DashboardItem } from '../../../shared/types/dashboard-item';
64
import { BACKEND_URL } from '../constants/constants';
7-
import { Icon } from '../types';
5+
import { DashboardItem, DashboardLayout, Icon } from '../types';
86

97

108
export class DashApi {

frontend/src/components/dnd/DashboardGrid.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ import { SortableAppShortcut } from './SortableAppShortcut';
1919
import { SortableDateTimeWidget } from './SortableDateTime';
2020
import { SortableSystemMonitorWidget } from './SortableSystemMonitor';
2121
import { SortableWeatherWidget } from './SortableWeather';
22-
import { DashboardItem } from '../../../../shared/types/dashboard-item';
2322
import { useAppContext } from '../../context/useAppContext';
24-
import { ITEM_TYPE } from '../../types';
23+
import { DashboardItem, ITEM_TYPE } from '../../types';
2524
import { AddEditForm } from '../forms/AddEditForm';
2625
import { CenteredModal } from '../modals/CenteredModal';
2726
import { ConfirmationOptions, PopupManager } from '../modals/PopupManager';

frontend/src/components/forms/AddEditForm.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import { useEffect, useState } from 'react';
33
import { useForm } from 'react-hook-form';
44
import { CheckboxElement, FormContainer, SelectElement, TextFieldElement } from 'react-hook-form-mui';
55

6-
import { DashboardItem } from '../../../../shared/types/dashboard-item';
6+
77
import { DashApi } from '../../api/dash-api';
88
import { useAppContext } from '../../context/useAppContext';
99
import { useIsMobile } from '../../hooks/useIsMobile';
1010
import { COLORS, styles } from '../../theme/styles';
1111
import { theme } from '../../theme/theme';
12-
import { Icon, ITEM_TYPE, NewItem } from '../../types';
12+
import { DashboardItem, Icon, ITEM_TYPE, NewItem } from '../../types';
1313
import { IconSearch } from '../IconSearch';
1414

1515
type Props = {

frontend/src/context/AppContext.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { createContext, Dispatch, SetStateAction } from 'react';
22

3-
import { DashboardItem } from '../../../shared/types/dashboard-item';
4-
import { NewItem } from '../types';
3+
import { DashboardItem, NewItem } from '../types';
54

65
export interface IAppContext {
76
dashboardLayout: DashboardItem[];

frontend/src/context/AppContextProvider.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@ import { ReactNode, useState } from 'react';
33
import shortid from 'shortid';
44

55
import { AppContext } from './AppContext';
6-
import { DashboardLayout } from '../../../shared/types/config';
7-
import { DashboardItem } from '../../../shared/types/dashboard-item';
86
import { DashApi } from '../api/dash-api';
97
import { initialItems } from '../constants/constants';
108
import { theme } from '../theme/theme';
11-
import { NewItem } from '../types';
9+
import { DashboardItem, DashboardLayout, NewItem } from '../types';
1210

1311
type Props = {
1412
children: ReactNode
@@ -25,7 +23,9 @@ export const AppContextProvider = ({ children }: Props) => {
2523

2624
if (res) {
2725
const selectedLayout = isMobile ? res.mobile : res.desktop;
28-
setDashboardLayout(selectedLayout);
26+
if (selectedLayout.length > 0) {
27+
setDashboardLayout(selectedLayout);
28+
}
2929
return selectedLayout;
3030
}
3131
return [];

frontend/src/types/index.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,25 @@ export type Icon = {
2222
source?: string;
2323
guidelines?: string;
2424
}
25+
26+
export type Config = {
27+
layout: {
28+
desktop: DashboardItem[];
29+
mobile: DashboardItem[];
30+
}
31+
}
32+
33+
export type DashboardLayout = {
34+
desktop: DashboardItem[];
35+
mobile: DashboardItem[];
36+
}
37+
38+
export type DashboardItem = {
39+
id: string;
40+
label: string;
41+
type: string;
42+
url?: string;
43+
icon?: { path: string; name: string; source?: string; };
44+
showName?: boolean;
45+
};
46+

frontend/tsconfig.app.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"compilerOptions": {
3-
"tsBuildInfoFile": "./frontend/node_modules/.tmp/tsconfig.app.tsbuildinfo",
3+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
44
"target": "ES2020",
55
"useDefineForClassFields": true,
66
"lib": [
@@ -26,6 +26,5 @@
2626
},
2727
"include": [
2828
"./src",
29-
"../shared"
3029
]
3130
}

0 commit comments

Comments
 (0)