##// END OF EJS Templates
generate `ipython console` config file...
generate `ipython console` config file when populating a profile

File last commit:

r17358:4aea6271
r18845:f3cedfd8
Show More
clusterlist.js
193 lines | 6.5 KiB | application/javascript | JavascriptLexer
Jonathan Frederic
Finished making tree.html requirejs friendly
r17190 // Copyright (c) IPython Development Team.
// Distributed under the terms of the Modified BSD License.
define([
'base/js/namespace',
Jonathan Frederic
MWE,...
r17200 'jquery',
Jonathan Frederic
Finished making tree.html requirejs friendly
r17190 'base/js/utils',
Jonathan Frederic
Almost done!...
r17198 ], function(IPython, $, utils) {
MinRK
add utils.url_path_join...
r13063 "use strict";
Brian Granger
Draft of the cluster list UI....
r6195
MinRK
various unicode fixes...
r15234 var ClusterList = function (selector, options) {
Brian Granger
Draft of the cluster list UI....
r6195 this.selector = selector;
if (this.selector !== undefined) {
this.element = $(selector);
this.style();
this.bind_events();
}
MinRK
various unicode fixes...
r15234 options = options || {};
this.options = options;
Jonathan Frederic
Almost done!...
r17198 this.base_url = options.base_url || utils.get_body_data("baseUrl");
this.notebook_path = options.notebook_path || utils.get_body_data("notebookPath");
Bussonnier Matthias
change more baseurl
r9503 };
Brian Granger
Draft of the cluster list UI....
r6195 ClusterList.prototype.style = function () {
MinRK
use row-fluid for cluster list
r10920 $('#cluster_list').addClass('list_container');
Brian Granger
Draft of the cluster list UI....
r6195 $('#cluster_toolbar').addClass('list_toolbar');
$('#cluster_list_info').addClass('toolbar_info');
$('#cluster_buttons').addClass('toolbar_buttons');
};
ClusterList.prototype.bind_events = function () {
var that = this;
$('#refresh_cluster_list').click(function () {
that.load_list();
});
};
ClusterList.prototype.load_list = function () {
var settings = {
processData : false,
cache : false,
type : "GET",
dataType : "json",
MinRK
log all failed ajax API requests
r16445 success : $.proxy(this.load_list_success, this),
Jonathan Frederic
Almost done!...
r17198 error : utils.log_ajax_error,
Brian Granger
Draft of the cluster list UI....
r6195 };
Jonathan Frederic
Almost done!...
r17198 var url = utils.url_join_encode(this.base_url, 'clusters');
Brian Granger
Draft of the cluster list UI....
r6195 $.ajax(url, settings);
};
ClusterList.prototype.clear_list = function () {
MinRK
use row-fluid for cluster list
r10920 this.element.children('.list_item').remove();
MinRK
add utils.url_path_join...
r13063 };
Brian Granger
Draft of the cluster list UI....
r6195
ClusterList.prototype.load_list_success = function (data, status, xhr) {
this.clear_list();
var len = data.length;
for (var i=0; i<len; i++) {
MinRK
use row-fluid for cluster list
r10920 var element = $('<div/>');
MinRK
various unicode fixes...
r15234 var item = new ClusterItem(element, this.options);
Brian Granger
Draft of the cluster list UI....
r6195 item.update_state(data[i]);
MinRK
fight with bootstrap a little less in tree view
r10911 element.data('item', item);
this.element.append(element);
MinRK
add utils.url_path_join...
r13063 }
Brian Granger
Draft of the cluster list UI....
r6195 };
MinRK
various unicode fixes...
r15234 var ClusterItem = function (element, options) {
Brian Granger
Draft of the cluster list UI....
r6195 this.element = $(element);
Jonathan Frederic
Almost done!...
r17198 this.base_url = options.base_url || utils.get_body_data("baseUrl");
this.notebook_path = options.notebook_path || utils.get_body_data("notebookPath");
Brian Granger
Draft of the cluster list UI....
r6195 this.data = null;
Brian Granger
Cluster management is now working....
r6197 this.style();
Brian Granger
Draft of the cluster list UI....
r6195 };
Brian Granger
Cluster management is now working....
r6197 ClusterItem.prototype.style = function () {
Jonathan Frederic
Ran jdfreder/bootstrap2to3
r16913 this.element.addClass('list_item').addClass("row");
MinRK
add utils.url_path_join...
r13063 };
Brian Granger
Cluster management is now working....
r6197
Brian Granger
Draft of the cluster list UI....
r6195 ClusterItem.prototype.update_state = function (data) {
this.data = data;
if (data.status === 'running') {
this.state_running();
} else if (data.status === 'stopped') {
this.state_stopped();
MinRK
add utils.url_path_join...
r13063 }
};
Brian Granger
Draft of the cluster list UI....
r6195
ClusterItem.prototype.state_stopped = function () {
Brian Granger
Cluster management is now working....
r6197 var that = this;
MinRK
move some responsive bootstrap transitions...
r17358 var profile_col = $('<div/>').addClass('profile_col col-xs-4').text(this.data.profile);
var status_col = $('<div/>').addClass('status_col col-xs-3').text('stopped');
var engines_col = $('<div/>').addClass('engine_col col-xs-3');
Matthias BUSSONNIER
min and default for engine number
r9289 var input = $('<input/>').attr('type','number')
.attr('min',1)
.attr('size',3)
Jonathan Frederic
Fixes to make spinners in cluster list display correctly.
r16922 .addClass('engine_num_input form-control');
Brian Granger
Chaging # of engines format in cluster list.
r6201 engines_col.append(input);
Jonathan Frederic
Ran jdfreder/bootstrap2to3
r16913 var start_button = $('<button/>').addClass("btn btn-default btn-xs").text("Start");
MinRK
move some responsive bootstrap transitions...
r17358 var action_col = $('<div/>').addClass('action_col col-xs-2').append(
MinRK
use row-fluid for cluster list
r10920 $("<span/>").addClass("item_buttons btn-group").append(
MinRK
bootstrap tree
r10891 start_button
)
);
MinRK
use row-fluid for cluster list
r10920 this.element.empty()
MinRK
fight with bootstrap a little less in tree view
r10911 .append(profile_col)
MinRK
use row-fluid for cluster list
r10920 .append(status_col)
MinRK
fight with bootstrap a little less in tree view
r10911 .append(engines_col)
MinRK
use row-fluid for cluster list
r10920 .append(action_col);
Brian Granger
Draft of the cluster list UI....
r6195 start_button.click(function (e) {
Brian Granger
Cluster management is now working....
r6197 var n = that.element.find('.engine_num_input').val();
Brian Granger
Notebook cluster manager now uses proper launchers.
r6199 if (!/^\d+$/.test(n) && n.length>0) {
Matthias BUSSONNIER
some $.html( -> $.text(...
r14634 status_col.text('invalid engine #');
Brian Granger
Cluster management is now working....
r6197 } else {
var settings = {
cache : false,
data : {n:n},
type : "POST",
dataType : "json",
success : function (data, status, xhr) {
that.update_state(data);
},
MinRK
log all failed ajax API requests
r16445 error : function (xhr, status, error) {
Matthias BUSSONNIER
some $.html( -> $.text(...
r14634 status_col.text("error starting cluster");
Jonathan Frederic
Almost done!...
r17198 utils.log_ajax_error(xhr, status, error);
Brian Granger
Cluster management is now working....
r6197 }
};
Matthias BUSSONNIER
some $.html( -> $.text(...
r14634 status_col.text('starting');
Jonathan Frederic
Almost done!...
r17198 var url = utils.url_join_encode(
MinRK
s/base_project_url/base_url/...
r15238 that.base_url,
MinRK
add utils.url_path_join...
r13063 'clusters',
that.data.profile,
'start'
);
Brian Granger
Cluster management is now working....
r6197 $.ajax(url, settings);
MinRK
add utils.url_path_join...
r13063 }
Brian Granger
Draft of the cluster list UI....
r6195 });
};
Brian Granger
Cluster management is now working....
r6197
Brian Granger
Draft of the cluster list UI....
r6195 ClusterItem.prototype.state_running = function () {
Brian Granger
Cluster management is now working....
r6197 var that = this;
MinRK
move some responsive bootstrap transitions...
r17358 var profile_col = $('<div/>').addClass('profile_col col-xs-4').text(this.data.profile);
var status_col = $('<div/>').addClass('status_col col-xs-3').text('running');
var engines_col = $('<div/>').addClass('engines_col col-xs-3').text(this.data.n);
Jonathan Frederic
Ran jdfreder/bootstrap2to3
r16913 var stop_button = $('<button/>').addClass("btn btn-default btn-xs").text("Stop");
MinRK
move some responsive bootstrap transitions...
r17358 var action_col = $('<div/>').addClass('action_col col-xs-2').append(
MinRK
use row-fluid for cluster list
r10920 $("<span/>").addClass("item_buttons btn-group").append(
MinRK
bootstrap tree
r10891 stop_button
)
);
MinRK
use row-fluid for cluster list
r10920 this.element.empty()
MinRK
fight with bootstrap a little less in tree view
r10911 .append(profile_col)
MinRK
use row-fluid for cluster list
r10920 .append(status_col)
MinRK
fight with bootstrap a little less in tree view
r10911 .append(engines_col)
MinRK
use row-fluid for cluster list
r10920 .append(action_col);
Brian Granger
Cluster management is now working....
r6197 stop_button.click(function (e) {
var settings = {
cache : false,
type : "POST",
dataType : "json",
success : function (data, status, xhr) {
that.update_state(data);
},
MinRK
log all failed ajax API requests
r16445 error : function (xhr, status, error) {
utils.log_ajax_error(xhr, status, error),
Matthias BUSSONNIER
some $.html( -> $.text(...
r14634 status_col.text("error stopping cluster");
Brian Granger
Cluster management is now working....
r6197 }
};
Matthias BUSSONNIER
some $.html( -> $.text(...
r14634 status_col.text('stopping');
MinRK
make sure to encode URL components for API requests...
r13693 var url = utils.url_join_encode(
MinRK
s/base_project_url/base_url/...
r15238 that.base_url,
MinRK
add utils.url_path_join...
r13063 'clusters',
that.data.profile,
'stop'
);
Brian Granger
Cluster management is now working....
r6197 $.ajax(url, settings);
Brian Granger
Draft of the cluster list UI....
r6195 });
};
Jonathan Frederic
Finished making tree.html requirejs friendly
r17190 // For backwards compatability.
Brian Granger
Draft of the cluster list UI....
r6195 IPython.ClusterList = ClusterList;
IPython.ClusterItem = ClusterItem;
Jonathan Frederic
Return dicts instead of classes,...
r17201 return {
'ClusterList': ClusterList,
'ClusterItem': ClusterItem,
};
Jonathan Frederic
Finished making tree.html requirejs friendly
r17190 });