mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-18 08:00:14 +01:00
Additional Codacy fixes
This commit is contained in:
parent
741f315f14
commit
73f7e105e8
4 changed files with 33 additions and 34 deletions
|
|
@ -7,7 +7,7 @@ interface LoginProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
const Login = (props: LoginProps) => {
|
const Login = (props: LoginProps) => {
|
||||||
const [password, setPassword] = useState("");
|
const [value, setValue] = useState("");
|
||||||
const [remember, setRemember] = useState(false);
|
const [remember, setRemember] = useState(false);
|
||||||
const [error, setError] = useState("");
|
const [error, setError] = useState("");
|
||||||
|
|
||||||
|
|
@ -15,7 +15,7 @@ const Login = (props: LoginProps) => {
|
||||||
if (event.target.type === "checkbox") {
|
if (event.target.type === "checkbox") {
|
||||||
setRemember(event.target.checked);
|
setRemember(event.target.checked);
|
||||||
} else {
|
} else {
|
||||||
setPassword(event.target.value);
|
setValue(event.target.value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -23,11 +23,11 @@ const Login = (props: LoginProps) => {
|
||||||
setError("");
|
setError("");
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
if (password === "") {
|
if (value === "") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const loggedIn = await logIn(password, remember);
|
const loggedIn = await logIn(value, remember);
|
||||||
if (loggedIn) {
|
if (loggedIn) {
|
||||||
props.onLogin();
|
props.onLogin();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -42,7 +42,7 @@ const Login = (props: LoginProps) => {
|
||||||
<h1 className="h3 mb-3 fw-normal">Please log in</h1>
|
<h1 className="h3 mb-3 fw-normal">Please log in</h1>
|
||||||
|
|
||||||
<div className="form-floating mb-3">
|
<div className="form-floating mb-3">
|
||||||
<input type="password" value={password} onChange={handleChange} className={"form-control" + (error ? " is-invalid" : "")} id="floatingPassword" placeholder="Password" required />
|
<input type="password" value={value} onChange={handleChange} className={"form-control" + (error ? " is-invalid" : "")} id="floatingPassword" placeholder="Password" required />
|
||||||
<label htmlFor="floatingPassword" className="user-select-none">Password</label>
|
<label htmlFor="floatingPassword" className="user-select-none">Password</label>
|
||||||
{error &&
|
{error &&
|
||||||
<div className="invalid-feedback">
|
<div className="invalid-feedback">
|
||||||
|
|
|
||||||
|
|
@ -3,4 +3,4 @@ import { CheckResponse, ContainerListEntry } from "../services/Api";
|
||||||
export default interface ContainerModel extends ContainerListEntry, CheckResponse {
|
export default interface ContainerModel extends ContainerListEntry, CheckResponse {
|
||||||
Selected: boolean;
|
Selected: boolean;
|
||||||
IsChecking: boolean;
|
IsChecking: boolean;
|
||||||
}
|
};
|
||||||
|
|
@ -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 getEmbeddedVariable = (variableName: string) => {
|
||||||
const value = document.body.getAttribute(`data-${variableName}`);
|
const value = document.body.getAttribute(`data-${variableName}`);
|
||||||
|
|
@ -83,28 +106,4 @@ export const update = async (images?: string[]): Promise<boolean> => {
|
||||||
});
|
});
|
||||||
|
|
||||||
return response.ok;
|
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;
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { defineConfig, loadEnv } from "vite"
|
import { defineConfig, loadEnv } from "vite";
|
||||||
import react from "@vitejs/plugin-react"
|
import react from "@vitejs/plugin-react";
|
||||||
|
|
||||||
const htmlPlugin = (mode: string) => {
|
const htmlPlugin = (mode: string) => {
|
||||||
const env = loadEnv(mode, ".");
|
const env = loadEnv(mode, ".");
|
||||||
|
|
@ -8,7 +8,7 @@ const htmlPlugin = (mode: string) => {
|
||||||
name: "html-transform",
|
name: "html-transform",
|
||||||
transformIndexHtml(html: string) {
|
transformIndexHtml(html: string) {
|
||||||
return html.replace(/%(.*?)%/g, function (match, p1) {
|
return html.replace(/%(.*?)%/g, function (match, p1) {
|
||||||
return env[p1];
|
return env[String(p1)];
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue