diff --git a/pkg/api/check/check.go b/pkg/api/check/check.go index 072cc94..b0e83fb 100644 --- a/pkg/api/check/check.go +++ b/pkg/api/check/check.go @@ -16,10 +16,12 @@ type Handler struct { Client container.Client } +// CheckRequest defines the type for the request data of the Check endpoint type CheckRequest struct { ContainerId string } +// CheckResponse defines the type for the response data of the Check endpoint type CheckResponse struct { ContainerId string HasUpdate bool diff --git a/pkg/api/list/list.go b/pkg/api/list/list.go index 0d29ccf..06d79e1 100644 --- a/pkg/api/list/list.go +++ b/pkg/api/list/list.go @@ -17,6 +17,7 @@ type Handler struct { Client container.Client } +// ContainerListEntry defines the type of each container in the response type ContainerListEntry struct { ContainerId string ContainerName string @@ -25,6 +26,8 @@ type ContainerListEntry struct { ImageVersion string ImageCreatedDate string } + +// ListResponse defines the return type of the List endpoint type ListResponse struct { Containers []ContainerListEntry } diff --git a/web/static/api.js b/web/static/api.js index f140fd4..0640df8 100644 --- a/web/static/api.js +++ b/web/static/api.js @@ -4,23 +4,13 @@ const apiFactory = () => { let token = ""; 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) => { token = password; const response = await fetch(baseUrl + "/list", { - credentials: 'include', + credentials: "include", headers: headers() }); @@ -35,13 +25,23 @@ const apiFactory = () => { return false; }; + const checkLogin = async () => { + const token = localStorage.getItem("token"); + + if (token) { + const isLoggedIn = await logIn(token); + return isLoggedIn; + } + return false; + }; + const logOut = () => { localStorage.clear(); }; const list = async () => { const response = await fetch(baseUrl + "/list", { - credentials: 'include', + credentials: "include", headers: headers() }); const data = await response.json(); @@ -53,11 +53,11 @@ const apiFactory = () => { ContainerId: containerId }; const response = await fetch(baseUrl + "/check", { - method: 'POST', - credentials: 'include', + method: "POST", + credentials: "include", headers: { ...headers(), - 'Content-Type': 'application/json', + "Content-Type": "application/json", }, body: JSON.stringify(requestData) }); @@ -73,7 +73,7 @@ const apiFactory = () => { } const response = await fetch(updateUrl.toString(), { - credentials: 'include', + credentials: "include", headers: headers(), }); diff --git a/web/static/app.css b/web/static/app.css index b6bf420..96697e5 100644 --- a/web/static/app.css +++ b/web/static/app.css @@ -16,7 +16,7 @@ --bs-secondary: #acbfc7 !important; --bs-secondary-rgb: 64, 97, 112; - + --bs-dark: #003343 !important; } @@ -32,8 +32,8 @@ } .btn-outline-primary { - --bs-btn-color:#038C7F; - --bs-btn-disabled-color:#038C7F; + --bs-btn-color: #038C7F; + --bs-btn-disabled-color: #038C7F; --bs-btn-border-color: #038C7F; --bs-btn-hover-bg: #02675d; --bs-btn-hover-border-color: #025a52; @@ -47,5 +47,6 @@ body { } .container-list-entry:hover .container-list-entry-icon .bi-box::before { - content: "\F7D2" /* .bi-box-fill */ + /* .bi-box-fill */ + content: "\F7D2" } \ No newline at end of file diff --git a/web/static/app.jsx b/web/static/app.jsx index 8d75b85..ca20118 100644 --- a/web/static/app.jsx +++ b/web/static/app.jsx @@ -1,3 +1,6 @@ +var React; +var ReactDOM; + const useState = React.useState; const useEffect = React.useEffect;