Skip to content

Commit

Permalink
Done server page
Browse files Browse the repository at this point in the history
  • Loading branch information
trungleduc committed Jan 18, 2024
1 parent 27cdb7f commit 7a45b00
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 12 deletions.
1 change: 0 additions & 1 deletion frontend/src/environments/EnvironmentList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ function _EnvironmentList(props: IEnvironmentListProps) {
return newItem;
});
}, [props]);

return (
<Box sx={{ padding: 1 }}>
<DataGrid
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/servers/NewServerDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,17 @@ function _NewServerDialog(props: INewServerDialogProps) {
const imageName = props.images[rowSelectionModel[0] as number].image_name;
const data = new FormData();
data.append('image', imageName);
let path = '';
if (serverName.length > 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();
Expand Down
30 changes: 22 additions & 8 deletions frontend/src/servers/RemoveServerButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -33,12 +39,20 @@ function _RemoveServerButton(props: IRemoveServerButton) {
buttonLabel="Stop Server"
dialogTitle="Stop Server"
dialogBody={
<Box>
<Typography>
Are you sure you want to stop the following server?
</Typography>
<pre>{props.server}</pre>
</Box>
props.server.length > 0 ? (
<Box>
<Typography>
Are you sure you want to stop the following server?
</Typography>
<pre>{props.server}</pre>
</Box>
) : (
<Box>
<Typography>
Are you sure you want to stop the default server?
</Typography>
</Box>
)
}
action={removeEnv}
/>
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/servers/ServersList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
1 change: 0 additions & 1 deletion tljh_repo2docker/templates/page.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{% extends "templates/page.html" %}

{% block nav_bar_left_items %}
<li><a href="{{base_url}}home">Home</a></li>
<li><a href="{{base_url}}servers">Servers</a></li>
<li><a href="{{base_url}}token">Token</a></li>
{% if user.admin %}
Expand Down

0 comments on commit 7a45b00

Please sign in to comment.