mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-17 07:30:13 +01:00
Fix some Codacy warnings
This commit is contained in:
parent
41ce5a3b32
commit
ad12b483ff
5 changed files with 30 additions and 21 deletions
|
|
@ -16,10 +16,12 @@ type Handler struct {
|
||||||
Client container.Client
|
Client container.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CheckRequest defines the type for the request data of the Check endpoint
|
||||||
type CheckRequest struct {
|
type CheckRequest struct {
|
||||||
ContainerId string
|
ContainerId string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CheckResponse defines the type for the response data of the Check endpoint
|
||||||
type CheckResponse struct {
|
type CheckResponse struct {
|
||||||
ContainerId string
|
ContainerId string
|
||||||
HasUpdate bool
|
HasUpdate bool
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ type Handler struct {
|
||||||
Client container.Client
|
Client container.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ContainerListEntry defines the type of each container in the response
|
||||||
type ContainerListEntry struct {
|
type ContainerListEntry struct {
|
||||||
ContainerId string
|
ContainerId string
|
||||||
ContainerName string
|
ContainerName string
|
||||||
|
|
@ -25,6 +26,8 @@ type ContainerListEntry struct {
|
||||||
ImageVersion string
|
ImageVersion string
|
||||||
ImageCreatedDate string
|
ImageCreatedDate string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListResponse defines the return type of the List endpoint
|
||||||
type ListResponse struct {
|
type ListResponse struct {
|
||||||
Containers []ContainerListEntry
|
Containers []ContainerListEntry
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,23 +4,13 @@ const apiFactory = () => {
|
||||||
let token = "";
|
let token = "";
|
||||||
|
|
||||||
const headers = () => ({
|
const headers = () => ({
|
||||||
'Authorization': 'Bearer ' + token
|
"Authorization": "Bearer " + token
|
||||||
});
|
});
|
||||||
|
|
||||||
const checkLogin = async () => {
|
|
||||||
const token = localStorage.getItem("token");
|
|
||||||
|
|
||||||
if (token) {
|
|
||||||
const isLoggedIn = await logIn(token);
|
|
||||||
return isLoggedIn;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
const logIn = async (password, remember) => {
|
const logIn = async (password, remember) => {
|
||||||
token = password;
|
token = password;
|
||||||
const response = await fetch(baseUrl + "/list", {
|
const response = await fetch(baseUrl + "/list", {
|
||||||
credentials: 'include',
|
credentials: "include",
|
||||||
headers: headers()
|
headers: headers()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -35,13 +25,23 @@ const apiFactory = () => {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const checkLogin = async () => {
|
||||||
|
const token = localStorage.getItem("token");
|
||||||
|
|
||||||
|
if (token) {
|
||||||
|
const isLoggedIn = await logIn(token);
|
||||||
|
return isLoggedIn;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
const logOut = () => {
|
const logOut = () => {
|
||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
};
|
};
|
||||||
|
|
||||||
const list = async () => {
|
const list = async () => {
|
||||||
const response = await fetch(baseUrl + "/list", {
|
const response = await fetch(baseUrl + "/list", {
|
||||||
credentials: 'include',
|
credentials: "include",
|
||||||
headers: headers()
|
headers: headers()
|
||||||
});
|
});
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|
@ -53,11 +53,11 @@ const apiFactory = () => {
|
||||||
ContainerId: containerId
|
ContainerId: containerId
|
||||||
};
|
};
|
||||||
const response = await fetch(baseUrl + "/check", {
|
const response = await fetch(baseUrl + "/check", {
|
||||||
method: 'POST',
|
method: "POST",
|
||||||
credentials: 'include',
|
credentials: "include",
|
||||||
headers: {
|
headers: {
|
||||||
...headers(),
|
...headers(),
|
||||||
'Content-Type': 'application/json',
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
body: JSON.stringify(requestData)
|
body: JSON.stringify(requestData)
|
||||||
});
|
});
|
||||||
|
|
@ -73,7 +73,7 @@ const apiFactory = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await fetch(updateUrl.toString(), {
|
const response = await fetch(updateUrl.toString(), {
|
||||||
credentials: 'include',
|
credentials: "include",
|
||||||
headers: headers(),
|
headers: headers(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,5 +47,6 @@ body {
|
||||||
}
|
}
|
||||||
|
|
||||||
.container-list-entry:hover .container-list-entry-icon .bi-box::before {
|
.container-list-entry:hover .container-list-entry-icon .bi-box::before {
|
||||||
content: "\F7D2" /* .bi-box-fill */
|
/* .bi-box-fill */
|
||||||
|
content: "\F7D2"
|
||||||
}
|
}
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
|
var React;
|
||||||
|
var ReactDOM;
|
||||||
|
|
||||||
const useState = React.useState;
|
const useState = React.useState;
|
||||||
const useEffect = React.useEffect;
|
const useEffect = React.useEffect;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue