From 73f7e105e86ea92a1b64fc80d18a8c2ace5b4d2f Mon Sep 17 00:00:00 2001 From: Anders Roos Date: Tue, 15 Nov 2022 14:54:00 +0100 Subject: [PATCH] Additional Codacy fixes --- web/src/components/Login.tsx | 10 +++---- web/src/models/ContainerModel.ts | 2 +- web/src/services/Api.ts | 49 ++++++++++++++++---------------- web/vite.config.ts | 6 ++-- 4 files changed, 33 insertions(+), 34 deletions(-) diff --git a/web/src/components/Login.tsx b/web/src/components/Login.tsx index 72e2823..07ae5a7 100644 --- a/web/src/components/Login.tsx +++ b/web/src/components/Login.tsx @@ -7,7 +7,7 @@ interface LoginProps { } const Login = (props: LoginProps) => { - const [password, setPassword] = useState(""); + const [value, setValue] = useState(""); const [remember, setRemember] = useState(false); const [error, setError] = useState(""); @@ -15,7 +15,7 @@ const Login = (props: LoginProps) => { if (event.target.type === "checkbox") { setRemember(event.target.checked); } else { - setPassword(event.target.value); + setValue(event.target.value); } }; @@ -23,11 +23,11 @@ const Login = (props: LoginProps) => { setError(""); event.preventDefault(); - if (password === "") { + if (value === "") { return; } - const loggedIn = await logIn(password, remember); + const loggedIn = await logIn(value, remember); if (loggedIn) { props.onLogin(); } else { @@ -42,7 +42,7 @@ const Login = (props: LoginProps) => {

Please log in

- + {error &&
diff --git a/web/src/models/ContainerModel.ts b/web/src/models/ContainerModel.ts index 9bc36f1..b1ae976 100644 --- a/web/src/models/ContainerModel.ts +++ b/web/src/models/ContainerModel.ts @@ -3,4 +3,4 @@ import { CheckResponse, ContainerListEntry } from "../services/Api"; export default interface ContainerModel extends ContainerListEntry, CheckResponse { Selected: boolean; IsChecking: boolean; -} \ No newline at end of file +}; \ No newline at end of file diff --git a/web/src/services/Api.ts b/web/src/services/Api.ts index fd601d9..1586411 100644 --- a/web/src/services/Api.ts +++ b/web/src/services/Api.ts @@ -1,3 +1,26 @@ +export interface ListResponse { + Containers: ContainerListEntry[]; +} + +export interface ContainerListEntry { + ContainerID: string; + ContainerName: string; + ImageName: string; + ImageNameShort: string; + ImageVersion: string; + ImageCreatedDate: string; +} + +export interface CheckRequest { + ContainerID: string; +} + +export interface CheckResponse { + ContainerID: string; + HasUpdate: boolean; + NewVersion: string; + NewVersionCreated: string; +} const getEmbeddedVariable = (variableName: string) => { const value = document.body.getAttribute(`data-${variableName}`); @@ -83,28 +106,4 @@ export const update = async (images?: string[]): Promise => { }); return response.ok; -}; - -export interface ListResponse { - Containers: ContainerListEntry[]; -} - -export interface ContainerListEntry { - ContainerID: string; - ContainerName: string; - ImageName: string; - ImageNameShort: string; - ImageVersion: string; - ImageCreatedDate: string; -} - -export interface CheckRequest { - ContainerID: string; -} - -export interface CheckResponse { - ContainerID: string; - HasUpdate: boolean; - NewVersion: string; - NewVersionCreated: string; -} \ No newline at end of file +}; \ No newline at end of file diff --git a/web/vite.config.ts b/web/vite.config.ts index 3fca177..1f54021 100644 --- a/web/vite.config.ts +++ b/web/vite.config.ts @@ -1,5 +1,5 @@ -import { defineConfig, loadEnv } from "vite" -import react from "@vitejs/plugin-react" +import { defineConfig, loadEnv } from "vite"; +import react from "@vitejs/plugin-react"; const htmlPlugin = (mode: string) => { const env = loadEnv(mode, "."); @@ -8,7 +8,7 @@ const htmlPlugin = (mode: string) => { name: "html-transform", transformIndexHtml(html: string) { return html.replace(/%(.*?)%/g, function (match, p1) { - return env[p1]; + return env[String(p1)]; }); }, };