33
44import { Signal , ISignal } from '@lumino/signaling' ;
55import { Contents , ServerConnection } from '@jupyterlab/services' ;
6+ import { PathExt } from '@jupyterlab/coreutils' ;
7+ import { IDrivesList } from './token' ;
68
7- const data : Contents . IModel = {
9+ let data : Contents . IModel = {
810 name : '' ,
911 path : '' ,
1012 last_modified : '' ,
@@ -26,8 +28,24 @@ export class Drive implements Contents.IDrive {
2628 constructor ( options : Drive . IOptions = { } ) {
2729 this . _serverSettings = ServerConnection . makeSettings ( ) ;
2830 this . _name = options . name ?? '' ;
31+ this . _drivesList = options . drivesList ?? { names : [ ] } ;
2932 //this._apiEndpoint = options.apiEndpoint ?? SERVICE_DRIVE_URL;
3033 }
34+
35+ /**
36+ * The drives list getter.
37+ */
38+ get drivesList ( ) : IDrivesList {
39+ return this . _drivesList ;
40+ }
41+
42+ /**
43+ * The drives list setter.
44+ * */
45+ set drivesList ( list : IDrivesList ) {
46+ this . _drivesList = list ;
47+ }
48+
3149 /**
3250 * The Drive base URL
3351 */
@@ -41,6 +59,7 @@ export class Drive implements Contents.IDrive {
4159 set baseUrl ( url : string ) {
4260 this . _baseUrl = url ;
4361 }
62+
4463 /**
4564 * The Drive name getter
4665 */
@@ -170,6 +189,48 @@ export class Drive implements Contents.IDrive {
170189 } else {
171190 relativePath = localPath ;
172191 }
192+
193+ data = {
194+ name : PathExt . basename ( localPath ) ,
195+ path : PathExt . basename ( localPath ) ,
196+ last_modified : '' ,
197+ created : '' ,
198+ content : [ ] ,
199+ format : 'json' ,
200+ mimetype : '' ,
201+ size : undefined ,
202+ writable : true ,
203+ type : 'directory'
204+ } ;
205+ } else {
206+ const drivesList : Contents . IModel [ ] = [ ] ;
207+ for ( const drive of this . _drivesList . names ) {
208+ drivesList . push ( {
209+ name : drive ,
210+ path : drive ,
211+ last_modified : '' ,
212+ created : '' ,
213+ content : [ ] ,
214+ format : 'json' ,
215+ mimetype : '' ,
216+ size : undefined ,
217+ writable : true ,
218+ type : 'directory'
219+ } ) ;
220+ }
221+
222+ data = {
223+ name : this . _name ,
224+ path : this . _name ,
225+ last_modified : '' ,
226+ created : '' ,
227+ content : drivesList ,
228+ format : 'json' ,
229+ mimetype : '' ,
230+ size : undefined ,
231+ writable : true ,
232+ type : 'directory'
233+ } ;
173234 }
174235 console . log ( 'GET: ' , relativePath ) ;
175236
@@ -532,6 +593,7 @@ export class Drive implements Contents.IDrive {
532593 }*/
533594
534595 // private _apiEndpoint: string;
596+ private _drivesList : IDrivesList = { names : [ ] } ;
535597 private _serverSettings : ServerConnection . ISettings ;
536598 private _name : string = '' ;
537599 private _provider : string = '' ;
@@ -548,6 +610,11 @@ export namespace Drive {
548610 * The options used to initialize a `Drive`.
549611 */
550612 export interface IOptions {
613+ /**
614+ * List of available drives.
615+ */
616+ drivesList ?: IDrivesList ;
617+
551618 /**
552619 * The name for the `Drive`, which is used in file
553620 * paths to disambiguate it from other drives.
0 commit comments