diff --git a/IPython/html/static/tree/js/main.js b/IPython/html/static/tree/js/main.js
index cbf14d3c3..5f388618b 100644
--- a/IPython/html/static/tree/js/main.js
+++ b/IPython/html/static/tree/js/main.js
@@ -13,9 +13,17 @@
$(document).ready(function () {
IPython.page = new IPython.Page();
- $('#new_notebook').click(function (e) {
- window.open($('body').data('baseProjectUrl')+'new');
- });
+
+ if ($('body').data('notebookPath') == "") {
+ $('#new_notebook').button().click(function (e) {
+ window.open($('body').data('baseProjectUrl')+'notebooks/'+'new');
+ });
+ }
+ else {
+ $('#new_notebook').button().click(function (e) {
+ window.open($('body').data('baseProjectUrl')+'notebooks/'+$('body').data('notebookPath') + '/new');
+ });
+ }
IPython.notebook_list = new IPython.NotebookList('#notebook_list');
IPython.cluster_list = new IPython.ClusterList('#cluster_list');
@@ -30,14 +38,14 @@ $(document).ready(function () {
//refresh immediately , then start interval
if($('.upload_button').length == 0)
{
- IPython.notebook_list.load_list();
+ IPython.notebook_list.load_sessions();
IPython.cluster_list.load_list();
}
if (!interval_id){
interval_id = setInterval(function(){
if($('.upload_button').length == 0)
{
- IPython.notebook_list.load_list();
+ IPython.notebook_list.load_sessions();
IPython.cluster_list.load_list();
}
}, time_refresh*1000);
diff --git a/IPython/html/static/tree/js/notebooklist.js b/IPython/html/static/tree/js/notebooklist.js
index a0b88405b..b52a7fd1f 100644
--- a/IPython/html/static/tree/js/notebooklist.js
+++ b/IPython/html/static/tree/js/notebooklist.js
@@ -18,10 +18,28 @@ var IPython = (function (IPython) {
this.style();
this.bind_events();
}
+ this.notebooks_list = new Array();
+ this.sessions = new Object();
};
NotebookList.prototype.baseProjectUrl = function () {
- return $('body').data('baseProjectUrl')
+ return $('body').data('baseProjectUrl');
+ };
+
+ NotebookList.prototype.notebookPath = function() {
+ var path = $('body').data('notebookPath');
+ if (path != "") {
+ if (path[path.length-1] != '/') {
+ path = path.substring(0,path.length);
+ };
+ return path;
+ } else {
+ return path;
+ };
+ };
+
+ NotebookList.prototype.url_name = function(name){
+ return encodeURIComponent(name);
};
NotebookList.prototype.style = function () {
@@ -84,6 +102,35 @@ var IPython = (function (IPython) {
this.element.children('.list_item').remove();
};
+ NotebookList.prototype.load_sessions = function(){
+ var settings = {
+ processData : false,
+ cache : false,
+ type : "GET",
+ dataType : "json",
+ success : $.proxy(this.sessions_loaded, this)
+ };
+ var url = this.baseProjectUrl() + 'api/sessions';
+ $.ajax(url,settings);
+ };
+
+
+ NotebookList.prototype.sessions_loaded = function(data){
+ this.sessions=new Object();
+ var len = data.length;
+ if (len != 0) {
+ for (var i=0; i").text("Shutdown").addClass("btn btn-mini").
click(function (e) {
@@ -194,10 +239,10 @@ var IPython = (function (IPython) {
type : "DELETE",
dataType : "json",
success : function (data, status, xhr) {
- that.load_list();
+ that.load_sessions();
}
};
- var url = that.baseProjectUrl() + 'kernels/'+kernel;
+ var url = that.baseProjectUrl() + 'api/sessions/' + session;
$.ajax(url, settings);
return false;
});
@@ -216,7 +261,6 @@ var IPython = (function (IPython) {
// data because the outer scopes values change as we iterate through the loop.
var parent_item = that.parents('div.list_item');
var nbname = parent_item.data('nbname');
- var notebook_id = parent_item.data('notebook_id');
var message = 'Are you sure you want to permanently delete the notebook: ' + nbname + '?';
IPython.dialog.modal({
title : "Delete notebook",
@@ -234,7 +278,12 @@ var IPython = (function (IPython) {
parent_item.remove();
}
};
- var url = notebooklist.baseProjectUrl() + 'notebooks/' + notebook_id;
+ if (notebooklist.notebookPath() == "") {
+ var url = notebooklist.baseProjectUrl() + 'api/notebooks/' + nbname;
+ }
+ else {
+ var url = notebooklist.baseProjectUrl() + 'api/notebooks/' + notebooklist.notebookPath() + nbname;
+ }
$.ajax(url, settings);
}
},