From 7a45b00c5ee4a132740042251fceaf01626edbcf Mon Sep 17 00:00:00 2001 From: trungleduc Date: Thu, 18 Jan 2024 19:26:14 +0100 Subject: [PATCH] Done server page --- frontend/src/environments/EnvironmentList.tsx | 1 - frontend/src/servers/NewServerDialog.tsx | 8 ++++- frontend/src/servers/RemoveServerButton.tsx | 30 ++++++++++++++----- frontend/src/servers/ServersList.tsx | 8 ++++- tljh_repo2docker/templates/page.html | 1 - 5 files changed, 36 insertions(+), 12 deletions(-) diff --git a/frontend/src/environments/EnvironmentList.tsx b/frontend/src/environments/EnvironmentList.tsx index 10541e0..7d2251f 100644 --- a/frontend/src/environments/EnvironmentList.tsx +++ b/frontend/src/environments/EnvironmentList.tsx @@ -108,7 +108,6 @@ function _EnvironmentList(props: IEnvironmentListProps) { return newItem; }); }, [props]); - return ( 0) { + path = `${jhData.user}/${serverName}`; + } else { + path = jhData.user; + } try { await axios.request({ method: 'post', prefix: SPAWN_PREFIX, - path: `${jhData.user}/${serverName}`, + path, data }); window.location.reload(); diff --git a/frontend/src/servers/RemoveServerButton.tsx b/frontend/src/servers/RemoveServerButton.tsx index 50013f9..8fbea96 100644 --- a/frontend/src/servers/RemoveServerButton.tsx +++ b/frontend/src/servers/RemoveServerButton.tsx @@ -15,12 +15,18 @@ function _RemoveServerButton(props: IRemoveServerButton) { const axios = useAxios(); const jhData = useJupyterhub(); const removeEnv = useCallback(async () => { + let path = ''; + if (props.server.length > 0) { + path = `users/${jhData.user}/servers/${props.server}`; + } else { + path = `users/${jhData.user}/server`; + } try { await axios.request({ method: 'delete', prefix: API_PREFIX, - path: `users/${jhData.user}/servers/${props.server}`, - data: { remove: true } + path, + data: { remove: props.server.length > 0 } }); window.location.reload(); } catch (e: any) { @@ -33,12 +39,20 @@ function _RemoveServerButton(props: IRemoveServerButton) { buttonLabel="Stop Server" dialogTitle="Stop Server" dialogBody={ - - - Are you sure you want to stop the following server? - -
{props.server}
-
+ props.server.length > 0 ? ( + + + Are you sure you want to stop the following server? + +
{props.server}
+
+ ) : ( + + + Are you sure you want to stop the default server? + + + ) } action={removeEnv} /> diff --git a/frontend/src/servers/ServersList.tsx b/frontend/src/servers/ServersList.tsx index 282c0c3..733ce86 100644 --- a/frontend/src/servers/ServersList.tsx +++ b/frontend/src/servers/ServersList.tsx @@ -80,12 +80,18 @@ export interface IServerListProps { function _ServerList(props: IServerListProps) { const rows = useMemo(() => { - return props.servers.map((it, id) => { + let servers = [...props.servers]; + if (props.defaultServer.active) { + servers = [props.defaultServer, ...servers]; + } + const allServers = servers.map((it, id) => { const newItem: any = { ...it, id }; newItem.image = it.user_options.image ?? ''; newItem.last_activity = formatTime(newItem.last_activity); return newItem; }); + + return allServers; }, [props]); return ( diff --git a/tljh_repo2docker/templates/page.html b/tljh_repo2docker/templates/page.html index 5863acb..7553763 100644 --- a/tljh_repo2docker/templates/page.html +++ b/tljh_repo2docker/templates/page.html @@ -1,7 +1,6 @@ {% extends "templates/page.html" %} {% block nav_bar_left_items %} -
  • Home
  • Servers
  • Token
  • {% if user.admin %}