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 this

 stage.
  • Loading branch information
HaudinFlorence committed Dec 21, 2023
1 parent f25ec49 commit d2124b1
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 18 deletions.
64 changes: 46 additions & 18 deletions 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 All @@ -74,21 +116,7 @@ export async function activateAddDrivesPlugin(
) {
console.log('AddDrives plugin is activated!');
const trans = translator.load('jupyter-drives');
const cocoDrive = new Drive();
cocoDrive.name = 'coconutDrive';
cocoDrive.baseUrl = '/coconut/url';
cocoDrive.region = '';
cocoDrive.status = 'active';
cocoDrive.provider = '';
manager.services.contents.addDrive(cocoDrive);
const bananaDrive = new Drive();
bananaDrive.name = 'bananaDrive';
bananaDrive.baseUrl = '/banana/url';
bananaDrive.region = '';
bananaDrive.status = 'active';
bananaDrive.provider = '';
manager.services.contents.addDrive(bananaDrive);
const driveList: Drive[] = [cocoDrive, bananaDrive];
const driveList: Drive[] = await createDrivesList(manager);

function camelCaseToDashedCase(name: string) {
if (name !== name.toLowerCase()) {
Expand All @@ -112,7 +140,7 @@ export async function activateAddDrivesPlugin(
}

app.commands.addCommand(CommandIDs.addDriveBrowser, {
execute: args => {
execute: async args => {
function createSidePanel(driveName: string) {
const panel = new SidePanel();
panel.title.icon = DriveIcon;
Expand Down Expand Up @@ -158,9 +186,9 @@ export async function activateAddDrivesPlugin(
);
}

driveList.forEach(drive => {
/*driveList.forEach(drive => {
addDriveToPanel(drive, factory);
});
});*/
},
caption: trans.__('Add drive filebrowser.'),
label: trans.__('Add Drive Filebrowser')
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 d2124b1

Please sign in to comment.