-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Creates document session * Uses translator * Update jupyter_collaboration/handlers.py * Create a new endpoint for document sessions, changes tranlator property and deprecates old endpoints --------- Co-authored-by: David Brochart <[email protected]>
- Loading branch information
1 parent
d8481ce
commit 9d57e8b
Showing
6 changed files
with
179 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* ----------------------------------------------------------------------------- | ||
| Copyright (c) Jupyter Development Team. | ||
| Distributed under the terms of the Modified BSD License. | ||
|----------------------------------------------------------------------------*/ | ||
|
||
import { URLExt } from '@jupyterlab/coreutils'; | ||
import { ServerConnection, Contents } from '@jupyterlab/services'; | ||
|
||
/** | ||
* Document session endpoint provided by `jupyter_collaboration` | ||
* See https://github.com/jupyterlab/jupyter_collaboration | ||
*/ | ||
const DOC_SESSION_URL = 'api/collaboration/session'; | ||
|
||
export interface ISessionModel { | ||
format: Contents.FileFormat; | ||
type: Contents.ContentType; | ||
fileId: string; | ||
sessionId: string; | ||
} | ||
|
||
export async function requestDocSession( | ||
format: string, | ||
type: string, | ||
path: string | ||
): Promise<ISessionModel> { | ||
const { makeSettings, makeRequest, ResponseError } = ServerConnection; | ||
|
||
const settings = makeSettings(); | ||
const url = URLExt.join( | ||
settings.baseUrl, | ||
DOC_SESSION_URL, | ||
encodeURIComponent(path) | ||
); | ||
const data = { | ||
method: 'PUT', | ||
body: JSON.stringify({ format, type }) | ||
}; | ||
|
||
const response = await makeRequest(url, data, settings); | ||
|
||
if (response.status !== 200 && response.status !== 201) { | ||
throw new ResponseError(response); | ||
} | ||
|
||
return response.json(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.