Skip to content
This repository has been archived by the owner on Sep 3, 2022. It is now read-only.

Commit

Permalink
Merge pull request #353 from GoogleCloudPlatform/feature/kernel-resta…
Browse files Browse the repository at this point in the history
…rt-button

Adds a kernel restart button to the notebook toolbar
  • Loading branch information
drewbryant committed May 27, 2015
2 parents 638560e + d65d5f9 commit 7178e0d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
/// <reference path="../../../../../../../../externs/ts/angularjs/angular.d.ts" />
/// <amd-dependency path="app/components/sessions/ClientNotebook" />
/// <amd-dependency path="app/services/SessionService" />
import logging = require('app/common/Logging');
import constants = require('app/common/Constants');
import _app = require('app/App');
Expand All @@ -27,28 +28,31 @@ var log = logging.getLogger(constants.scopes.notebookToolbar);

interface NotebookToolbarScope extends ng.IScope {
notebook: app.IClientNotebook;
session: app.ISessionService;
}

class NotebookToolbarController {

_clientNotebook: app.IClientNotebook;
_scope: NotebookToolbarScope;

static $inject = ['$scope', constants.clientNotebook.name];
static $inject = ['$scope', constants.clientNotebook.name, constants.sessionService.name];

/**
* Constructor.
*
* @param scope The directive scope.
* @param clientNotebook The client's notebook session.
* @param notebook The client's notebook session.
* @param session The session API service.
*/
constructor(
scope: NotebookToolbarScope,
clientNotebook: app.IClientNotebook) {
notebook: app.IClientNotebook,
session: app.ISessionService) {

this._scope = scope;

this._scope.notebook = clientNotebook
this._scope.notebook = notebook
this._scope.session = session
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,9 @@
ng-click="notebook.clearOutputs()">
</i>

<!-- Reset the session (kernel) state -->
<i class="datalab-toolbar-button fa-power-off fa"
ng-click="session.reset(notebook.notebookPath)">
</i>

</div>
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ class ClientNotebook implements app.IClientNotebook {
// the current notebook path.this notebook path reference should be preferred for referencing
// by other components that require access to the current notebook path (e.g., notebook title
// component).
this.notebookPath = route.current.params.notebookPath;
//
// Note that a slash is prepended because all notebook paths are rooted.
this.notebookPath = '/' + route.current.params.notebookPath;

this._registerEventHandlers();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ var log = logging.getLogger(constants.scopes.sessionConnection);
function sessionConnectionFactory(
rootScope: ng.IRootScopeService,
location: ng.ILocationService,
route: ng.route.IRouteService
route: ng.route.IRouteService,
notebook: app.IClientNotebook
): app.ISessionConnection {

var socket: Socket = socketio(location.host(), {
// Note: slash is prepended because all content storage paths are rooted.
query: 'notebookPath=/' + route.current.params.notebookPath
query: 'notebookPath=' + notebook.notebookPath
});

return {
Expand All @@ -66,7 +66,7 @@ function sessionConnectionFactory(
}
};
}
sessionConnectionFactory.$inject = ['$rootScope', '$location', '$route'];
sessionConnectionFactory.$inject = ['$rootScope', '$location', '$route', constants.clientNotebook.name];


_app.registrar.factory(constants.sessionConnection.name, sessionConnectionFactory);
Expand Down

0 comments on commit 7178e0d

Please sign in to comment.