Skip to content

Commit fc53892

Browse files
committed
feat: fix some issues
1 parent 62c1487 commit fc53892

File tree

11 files changed

+88
-47
lines changed

11 files changed

+88
-47
lines changed

.eslintrc.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module.exports = {
2+
env: {
3+
node: true, // Add this line to specify the Node.js environment
4+
},
5+
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
6+
extends: [
7+
'eslint:recommended', // Use the recommended rules from ESLint
8+
'plugin:@typescript-eslint/recommended', // Use the recommended rules from the @typescript-eslint/eslint-plugin
9+
],
10+
parserOptions: {
11+
ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features
12+
sourceType: 'module', // Allows for the use of imports
13+
},
14+
rules: {
15+
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
16+
// e.g. "@typescript-eslint/explicit-function-return-type": "off",
17+
},
18+
overrides: [
19+
{
20+
files: ['*.ts', '*.tsx'], // Ensure ESLint checks TypeScript files
21+
rules: {
22+
// Add TypeScript-specific rules here if needed
23+
},
24+
},
25+
],
26+
};

next-env.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/// <reference types="next" />
22
/// <reference types="next/image-types/global" />
3+
/// <reference types="next/navigation-types/compat/navigation" />
34

45
// NOTE: This file should not be edited
5-
// see https://nextjs.org/docs/basic-features/typescript for more information.
6+
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.

src/components/dashboard/widgets/external-integrations/argocd-integration/argocd-integration.module.css

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
.applications {
22
display: flex;
3-
flex-direction: column;
3+
flex-direction: row;
44
gap: 0.5rem;
55
}
66

77
.application {
88
background-color: var(--integration-bg-color);
9-
padding: 0.125rem;
9+
padding: 0.5rem;
1010
border-radius: 0.125rem;
1111

12-
width: 100%;
1312
text-align: center;
1413

1514
display: flex;

src/components/dashboard/widgets/external-integrations/argocd-integration/argocd-integration.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ const Applications = ({ applications }: { applications: ArgoCDData[] }) => {
2727
<span className={classes.applicationName}>{application.name}</span>
2828
<span
2929
className={clsx("circle", {
30-
[classes.synced]: application.status.toLowerCase() === "synced",
31-
[classes.outOfSync]:
30+
[classes.synced as string]:
31+
application.status.toLowerCase() === "synced",
32+
[classes.outOfSync as string]:
3233
application.status.toLowerCase() === "outofsync",
3334
})}
3435
></span>

src/components/dashboard/widgets/external-integrations/uptime-kuma-integration/uptime-kuma-integration.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ export const UptimeKumaIntegration = ({
2121
<Tooltip title={key} placement="top" key={key}>
2222
<div
2323
className={clsx(classes.uptime, {
24-
[classes.up]: data.uptime[key].msg.includes("200"),
25-
[classes.down]: !data.uptime[key].msg.includes("200"),
24+
[classes.up as string]:
25+
data.uptime[key as string]?.msg.includes("200"),
26+
[classes.down as string]:
27+
!data.uptime[key as string]?.msg.includes("200"),
2628
})}
2729
>
2830
<div className={classes.circle}></div>
29-
<Typography>{data.uptime[key].ping}ms</Typography>
31+
<Typography>{data.uptime[key as string]?.ping}ms</Typography>
3032
</div>
3133
</Tooltip>
3234
))}
@@ -35,11 +37,7 @@ export const UptimeKumaIntegration = ({
3537
};
3638

3739
return (
38-
<Integration
39-
title="uptime-kuma"
40-
icon="/icons/kuma.png"
41-
link={url}
42-
>
40+
<Integration title="uptime-kuma" icon="/icons/kuma.png" link={url}>
4341
<Uptimes />
4442
</Integration>
4543
);

src/components/dashboard/widgets/running-containers/running-containers.tsx

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,22 @@ export const RunningContainers = ({
3232
return null;
3333
}
3434

35+
if (!containerCount) {
36+
return null;
37+
}
38+
3539
return (
36-
containerCount && (
37-
<div className={`${classes.runningContainers} ${className}`}>
38-
<Typography
39-
variant="body2"
40-
color="text.secondary"
41-
component="p"
42-
className={classes.containerCount}
43-
display="inline"
44-
>
45-
<DirectionsBoatIcon fontSize="inherit" className={classes.shipIcon} />
46-
{containerCount.stdout}
47-
</Typography>
48-
</div>
49-
)
40+
<div className={`${classes.runningContainers} ${className}`}>
41+
<Typography
42+
variant="body2"
43+
color="text.secondary"
44+
component="p"
45+
className={classes.containerCount}
46+
display="inline"
47+
>
48+
<DirectionsBoatIcon fontSize="inherit" className={classes.shipIcon} />
49+
{containerCount.stdout}
50+
</Typography>
51+
</div>
5052
);
5153
};

src/components/host/command-queue/command-queue.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export const CommandQueue = ({
4545
""
4646
);
4747

48-
combinedOutput = `$ ${command.commands[0].command}\n${combinedOutput}`;
48+
combinedOutput = `$ ${command.commands[0]?.command}\n${combinedOutput}`;
4949
setViewedResult(combinedOutput);
5050
setOpen();
5151
};
@@ -89,6 +89,8 @@ export const CommandQueue = ({
8989

9090
return () => clearInterval(intervalId);
9191
}
92+
93+
return;
9294
}, [host]);
9395

9496
if (loading && commands.length === 0) {
@@ -108,7 +110,7 @@ export const CommandQueue = ({
108110
{commands.map((command, index) => (
109111
<CursorTooltip
110112
title="View Output"
111-
key={`${command.commands[0].name}-${index}`}
113+
key={`${command.commands[0]?.name}-${index}`}
112114
>
113115
<TableRow
114116
key={index}

src/components/shared/integration/integration.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const Integration = ({
3535

3636
return (
3737
<Paper
38-
className={clsx(classes.integration, { [classes.link]: link })}
38+
className={clsx(classes.integration, { [classes.link as string]: link })}
3939
onClick={handleNavigate}
4040
style={{
4141
backgroundColor: isHovered ? hoverCardColor : cardColor,

src/lib/utils.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,19 @@ export const fetchAndSet = async (
1414
setter: (arg: any) => void,
1515
axios?: AxiosCacheInstance
1616
) => {
17-
if (axios) {
18-
const response = await axios.get(url);
19-
setter(response.data);
20-
return;
21-
}
17+
try {
18+
if (axios) {
19+
const response = await axios.get(url);
20+
setter(response.data);
21+
return;
22+
}
2223

23-
const response = await fetch(url);
24-
const json = await response.json();
25-
setter(json);
24+
const response = await fetch(url);
25+
const json = await response.json();
26+
setter(json);
27+
} catch (error) {
28+
console.error(error);
29+
}
2630
};
2731

2832
export const fetchAndSetWithPayload = async (

src/pages/api/[host_name]/stats.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default async function handler(
2727
}
2828
}
2929

30-
let storage: object[] = [];
30+
const storage: object[] = [];
3131

3232
paths.forEach((path: string) => {
3333
const storageSizeRegex = new RegExp(
@@ -44,7 +44,7 @@ export default async function handler(
4444
size: match[2],
4545
used: match[3],
4646
available: match[4],
47-
usePercent: Number(match[5].replace("%", "")),
47+
usePercent: Number(match[5]?.replace("%", "")),
4848
};
4949

5050
storage.push(storageParts);

tsconfig.json

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
2929
"baseUrl": ".",
3030
"paths": {
31-
"@/*": ["src/*"]
31+
"@/*": [
32+
"src/*"
33+
]
3234
},
3335
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
3436
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
@@ -80,7 +82,7 @@
8082
/* Type Checking */
8183
"strict": true /* Enable all strict type-checking options. */,
8284
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
83-
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
85+
"strictNullChecks": true /* When type checking, take into account 'null' and 'undefined'. */,
8486
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
8587
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
8688
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
@@ -90,9 +92,9 @@
9092
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
9193
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
9294
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
93-
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
95+
"noImplicitReturns": true /* Enable error reporting for codepaths that do not explicitly return in a function. */,
9496
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
95-
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
97+
"noUncheckedIndexedAccess": true /* Add 'undefined' to a type when accessed using an index. */,
9698
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
9799
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
98100
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
@@ -110,11 +112,17 @@
110112
"incremental": true,
111113
"moduleResolution": "node",
112114
"resolveJsonModule": true,
113-
"isolatedModules": true
115+
"isolatedModules": true,
116+
"plugins": [
117+
{
118+
"name": "next"
119+
}
120+
]
114121
},
115122
"include": [
116123
"src",
117-
"src/declaration.d.ts"
124+
"src/declaration.d.ts",
125+
"./dist/types/**/*.ts"
118126
],
119127
"exclude": [
120128
"node_modules"

0 commit comments

Comments
 (0)