##// END OF EJS Templates
store current kernel selection in frontend config...
Min RK -
Show More
@@ -8,6 +8,7 b' require(['
8 'base/js/events',
8 'base/js/events',
9 'base/js/page',
9 'base/js/page',
10 'base/js/utils',
10 'base/js/utils',
11 'services/config',
11 'contents',
12 'contents',
12 'tree/js/notebooklist',
13 'tree/js/notebooklist',
13 'tree/js/clusterlist',
14 'tree/js/clusterlist',
@@ -27,6 +28,7 b' require(['
27 events,
28 events,
28 page,
29 page,
29 utils,
30 utils,
31 config,
30 contents_service,
32 contents_service,
31 notebooklist,
33 notebooklist,
32 clusterlist,
34 clusterlist,
@@ -43,6 +45,10 b' require(['
43 base_url: utils.get_body_data("baseUrl"),
45 base_url: utils.get_body_data("baseUrl"),
44 notebook_path: utils.get_body_data("notebookPath"),
46 notebook_path: utils.get_body_data("notebookPath"),
45 };
47 };
48 var cfg = new config.ConfigSection('tree', common_options);
49 cfg.load();
50 common_options.config = cfg;
51
46 var session_list = new sesssionlist.SesssionList($.extend({
52 var session_list = new sesssionlist.SesssionList($.extend({
47 events: events},
53 events: events},
48 common_options));
54 common_options));
@@ -15,6 +15,7 b' define(['
15 this.notebook_path = options.notebook_path;
15 this.notebook_path = options.notebook_path;
16 this.contents = options.contents;
16 this.contents = options.contents;
17 this.current_selection = null;
17 this.current_selection = null;
18 this.config = options.config;
18 this.kernelspecs = {};
19 this.kernelspecs = {};
19 if (this.selector !== undefined) {
20 if (this.selector !== undefined) {
20 this.element = $(selector);
21 this.element = $(selector);
@@ -38,6 +39,7 b' define(['
38
39
39 NewNotebookWidget.prototype._load_kernelspecs = function (data) {
40 NewNotebookWidget.prototype._load_kernelspecs = function (data) {
40 /** load kernelspec list */
41 /** load kernelspec list */
42 var that = this;
41 this.kernelspecs = data.kernelspecs;
43 this.kernelspecs = data.kernelspecs;
42 var menu = this.element.find("#new-notebook-menu");
44 var menu = this.element.find("#new-notebook-menu");
43 var keys = Object.keys(data.kernelspecs).sort(function (a, b) {
45 var keys = Object.keys(data.kernelspecs).sort(function (a, b) {
@@ -69,17 +71,30 b' define(['
69 );
71 );
70 menu.append(li);
72 menu.append(li);
71 }
73 }
72 this._load_default_kernelspec(data['default']);
74 this.config.loaded.then(function () {
75 that._load_default_kernelspec(data['default']);
76 });
73 };
77 };
74
78
75 NewNotebookWidget.prototype._load_default_kernelspec = function (default_name) {
79 NewNotebookWidget.prototype._load_default_kernelspec = function (default_name) {
76 /** load default kernelspec name from localStorage, if defined */
80 /** load default kernelspec name from localStorage, if defined */
77 this.select_kernel(localStorage.default_kernel_name || default_name);
81 if (this.config.data.NewNotebookWidget &&
82 this.config.data.NewNotebookWidget.current_selection &&
83 this.kernelspecs[this.config.data.NewNotebookWidget.current_selection] !== undefined
84 ) {
85 default_name = this.config.data.NewNotebookWidget.current_selection;
86 }
87 this.select_kernel(default_name);
78 };
88 };
79
89
80 NewNotebookWidget.prototype.select_kernel = function (kernel_name) {
90 NewNotebookWidget.prototype.select_kernel = function (kernel_name) {
81 /** select the current default kernel */
91 /** select the current default kernel */
82 this.current_selection = kernel_name;
92 this.current_selection = kernel_name;
93 this.config.update({
94 NewNotebookWidget: {
95 current_selection: kernel_name
96 }
97 });
83 var spec = this.kernelspecs[kernel_name];
98 var spec = this.kernelspecs[kernel_name];
84 var display_name;
99 var display_name;
85 if (spec) {
100 if (spec) {
General Comments 0
You need to be logged in to leave comments. Login now