Skip to content

Commit

Permalink
Add a getDrivesList request and a createDrivesList in index.ts to get…
Browse files Browse the repository at this point in the history
… the informations about the list of drives and create the corresponding new Drive instances with faked contents at thi stage.
  • Loading branch information
HaudinFlorence committed Dec 21, 2023
1 parent f25ec49 commit b6fd1fc
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
45 changes: 44 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import {
/*FilenameSearcher, IScore, */ SidePanel
} from '@jupyterlab/ui-components';

import { IBucket } from './s3requests';

/**
* The class name added to the filebrowser filterbox node.
*/
Expand All @@ -48,6 +50,46 @@ namespace CommandIDs {
console.log('JupyterLab extension @jupyter/drives is activated!');
}
};*/

async function createDrivesList(manager: IDocumentManager) {
/*const s3BucketsList: IBucket[] = await getDrivesList();*/
const s3BucketsList: IBucket[] = [
{
creation_date: '2023-12-15T13:27:57.000Z',
name: 'jupyter-drive-bucket1',
provider: 'S3',
region: 'us-east-1',
status: 'active'
},
{
creation_date: '2023-12-19T08:57:29.000Z',
name: 'jupyter-drive-bucket2',
provider: 'S3',
region: 'us-east-1',
status: 'inactive'
},
{
creation_date: '2023-12-19T09:07:29.000Z',
name: 'jupyter-drive-bucket3',
provider: 'S3',
region: 'us-east-1',
status: 'active'
}
];

const availableS3Buckets: Drive[] = [];
s3BucketsList.forEach(item => {
const drive = new Drive();
drive.name = item.name;
drive.baseUrl = '';
drive.region = item.region;
drive.status = item.status;
drive.provider = item.provider;
manager.services.contents.addDrive(drive);
availableS3Buckets.push(drive);
});
return availableS3Buckets;
}
const AddDrivesPlugin: JupyterFrontEndPlugin<void> = {
id: '@jupyter/drives:add-drives',
description: 'Open a dialog to select drives to be added in the filebrowser.',
Expand Down Expand Up @@ -112,7 +154,8 @@ export async function activateAddDrivesPlugin(
}

app.commands.addCommand(CommandIDs.addDriveBrowser, {
execute: args => {
execute: async args => {
const driveList = await createDrivesList(manager);
function createSidePanel(driveName: string) {
const panel = new SidePanel();
panel.title.icon = DriveIcon;
Expand Down
15 changes: 15 additions & 0 deletions src/s3requests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { requestAPI } from './handler';

export interface IBucket {
name: string;
region: string;
provider: string;
creation_date: string;
status: string;
}

export async function getDrivesList() {
return await requestAPI<Array<IBucket>>('drives', {
method: 'GET'
});
}

0 comments on commit b6fd1fc

Please sign in to comment.