diff --git a/src/frontend/src/components/headerComponent/index.tsx b/src/frontend/src/components/headerComponent/index.tsx index b112cc743..c74cdaa76 100644 --- a/src/frontend/src/components/headerComponent/index.tsx +++ b/src/frontend/src/components/headerComponent/index.tsx @@ -32,29 +32,38 @@ export default function Header(): JSX.Element { )} {!autoLogin && location.pathname !== `/flow/${tabId}` && ( - + Home + )} {isAdmin && !autoLogin && location.pathname !== "/admin" && location.pathname !== `/flow/${tabId}` && ( - + navigate("/admin")} + > + Admin page + )}
diff --git a/src/frontend/src/pages/ApiKeysPage/index.tsx b/src/frontend/src/pages/ApiKeysPage/index.tsx index 48e8574c8..d1c91593a 100644 --- a/src/frontend/src/pages/ApiKeysPage/index.tsx +++ b/src/frontend/src/pages/ApiKeysPage/index.tsx @@ -156,6 +156,7 @@ export default function ApiKeysPage() {
+ Total Uses @@ -167,7 +168,7 @@ export default function ApiKeysPage() { - {api_keys.name} + {api_keys.name ? api_keys.name : "-"} @@ -177,18 +178,45 @@ export default function ApiKeysPage() { - {moment(api_keys.created_at).format( - "YYYY-MM-DD HH:mm" - )} - - - {moment(api_keys.last_used_at).format( - "YYYY-MM-DD HH:mm" - ) === "Invalid date" - ? "Never" - : moment(api_keys.last_used_at).format( + +
+ {moment(api_keys.created_at).format( "YYYY-MM-DD HH:mm" )} +
+
+
+ + +
+ {moment(api_keys.last_used_at).format( + "YYYY-MM-DD HH:mm" + ) === "Invalid date" + ? "Never" + : moment( + api_keys.last_used_at + ).format("YYYY-MM-DD HH:mm")} +
+
+
+ + {api_keys.total_uses}
diff --git a/src/frontend/src/pages/loginPage/index.tsx b/src/frontend/src/pages/loginPage/index.tsx index 5fcbe366f..14e04708b 100644 --- a/src/frontend/src/pages/loginPage/index.tsx +++ b/src/frontend/src/pages/loginPage/index.tsx @@ -19,7 +19,7 @@ export default function LoginPage(): JSX.Element { useState(CONTROL_LOGIN_STATE); const { password, username } = inputState; - const { login, getAuthentication, setUserData } = useContext(AuthContext); + const { login, getAuthentication, setUserData, setIsAdmin } = useContext(AuthContext); const navigate = useNavigate(); const { setErrorData } = useContext(alertContext); @@ -53,10 +53,12 @@ export default function LoginPage(): JSX.Element { setTimeout(() => { getLoggedUser() .then((user) => { + const isSuperUser = user.is_superuser; + setIsAdmin(isSuperUser); setUserData(user); }) .catch((error) => {}); - }, 1000); + }, 500); } } diff --git a/src/frontend/src/types/components/index.ts b/src/frontend/src/types/components/index.ts index 9a0108e70..3f8096618 100644 --- a/src/frontend/src/types/components/index.ts +++ b/src/frontend/src/types/components/index.ts @@ -538,6 +538,7 @@ export type ApiKey = { name: string; created_at: string; last_used_at: string; + total_uses: number; }; export type fetchErrorComponentType = { message: string;