|
1 | 1 | import { URLExt } from "@jupyterlab/coreutils"; |
| 2 | +import { showDialog, Dialog } from '@jupyterlab/apputils'; |
2 | 3 | import { ServerConnection } from "@jupyterlab/services"; |
| 4 | +import { TranslationBundle } from '@jupyterlab/translation'; |
3 | 5 | import { IModel } from "./serverproxy"; |
4 | 6 |
|
5 | 7 | /** |
6 | 8 | * The url for the server proxy service. |
7 | 9 | */ |
8 | | -const SERVER_PROXY_SERVICE_URL = "api/server-proxy"; |
| 10 | +const SERVER_PROXY_SERVICE_URL = "server-proxy/api/servers/"; |
9 | 11 |
|
10 | 12 | /** |
11 | 13 | * List the running server proxy apps. |
@@ -43,13 +45,24 @@ export async function listRunning( |
43 | 45 | */ |
44 | 46 | export async function shutdown( |
45 | 47 | name: string, |
| 48 | + trans: TranslationBundle, |
46 | 49 | settings: ServerConnection.ISettings = ServerConnection.makeSettings(), |
47 | 50 | ): Promise<void> { |
48 | 51 | const url = URLExt.join(settings.baseUrl, SERVER_PROXY_SERVICE_URL, name); |
49 | 52 | const init = { method: "DELETE" }; |
50 | 53 | const response = await ServerConnection.makeRequest(url, init, settings); |
51 | 54 | if (response.status === 404) { |
52 | | - const msg = `Server proxy "${name}" does not exist. Are you sure "${name}" is started by jupyter-server-proxy?`; |
| 55 | + const msg = trans.__(`Server proxy "${name}" is not running anymore. It will be removed from this list shortly`); |
| 56 | + console.warn(msg); |
| 57 | + void showDialog({ |
| 58 | + title: trans.__('Warning'), |
| 59 | + body: msg, |
| 60 | + buttons: [Dialog.okButton({ label : 'Dismiss'})], |
| 61 | + }); |
| 62 | + } else if (response.status === 403) { |
| 63 | + // This request cannot be made via JupyterLab UI and hence we just throw |
| 64 | + // console log |
| 65 | + const msg = trans.__(`Provide a running server proxy name to terminate`); |
53 | 66 | console.warn(msg); |
54 | 67 | } else if (response.status !== 204) { |
55 | 68 | const err = await ServerConnection.ResponseError.create(response); |
|
0 commit comments