Prechádzať zdrojové kódy

More context implementation

Steven Silvester 8 rokov pred
rodič
commit
ba04eafdbf
2 zmenil súbory, kde vykonal 16 pridanie a 28 odobranie
  1. 14 9
      src/docmanager/context.ts
  2. 2 19
      src/docmanager/index.ts

+ 14 - 9
src/docmanager/context.ts

@@ -4,7 +4,7 @@
 
 import {
   IKernelId, IKernel, IKernelSpecIds, IContentsManager,
-  INotebookSessionManager, INotebookSession
+  INotebookSessionManager, INotebookSession, ISessionId
 } from 'jupyter-js-services';
 
 import {
@@ -32,7 +32,7 @@ import {
 } from '../filebrowser/browser';
 
 import {
-  IDocumentContext, IDocumentModel, ISessionInfo
+  IDocumentContext, IDocumentModel
 } from './index';
 
 
@@ -127,7 +127,7 @@ class Context implements IDocumentContext {
   /**
    * Get the list of running sessions.
    */
-  listSessions(): Promise<ISessionInfo[]> {
+  listSessions(): Promise<ISessionId[]> {
     return this._manager.listSessions();
   }
 
@@ -178,7 +178,9 @@ namespace Private {
 }
 
 
-
+/**
+ * An object which manages the active contexts.
+ */
 export
 class ContextManager {
   /**
@@ -188,7 +190,10 @@ class ContextManager {
     this._contentsManager = contentsManager;
     this._sessionManager = sessionManager;
     this._opener = opener;
-    // TODO: fetch the kernelspecids.
+    // Fetch and store the kernelspecids.
+    sessionManager.getSpecs().then(specs => {
+      this._kernelspecids = specs;
+    });
   }
 
   /**
@@ -295,10 +300,8 @@ class ContextManager {
   /**
    * Get the list of running sessions.
    */
-  listSessions(): Promise<ISessionInfo[]> {
-    // TODO filter the running session info.
-    //return this._sessionManager.listRunning();
-    return void 0;
+  listSessions(): Promise<ISessionId[]> {
+    return this._sessionManager.listRunning();
   }
 
   /**
@@ -306,6 +309,8 @@ class ContextManager {
    */
   addSibling(path: string, widget: Widget): IDisposable {
    // TODO: Add the widget to the list of siblings
+   // This needs to go back to the document manager to set the
+   // context and factory properties.
    this._opener.open(widget);
    // TODO: return a disposable
    return void 0;

+ 2 - 19
src/docmanager/index.ts

@@ -5,7 +5,7 @@
 import {
   IContentsModel, IKernelId, IKernelSpecId, IContentsOpts, IKernel,
   INotebookSession, IContentsManager, INotebookSessionManager,
-  IKernelSpecIds
+  IKernelSpecIds, ISessionId
 } from 'jupyter-js-services';
 
 import {
@@ -100,23 +100,6 @@ interface IDocumentModel {
 }
 
 
-/**
- * A session info object for a running session.
- */
-export
-interface ISessionInfo {
-  /**
-   * The list of file paths associated with the running sessions.
-   */
-  path: string;
-
-  /**
-   * The kernel instance associated with the session.
-   */
-  kernel: IKernel;
-}
-
-
 /**
  * The document context object.
  */
@@ -172,7 +155,7 @@ export interface IDocumentContext {
   /**
    * Get the list of running sessions.
    */
-  listSessions(): Promise<ISessionInfo[]>;
+  listSessions(): Promise<ISessionId[]>;
 
   /**
    * Add a sibling widget to the document manager.