##// END OF EJS Templates
Merge pull request #4823 from adamatus/parallel-doc-fixes...
Merge pull request #4823 from adamatus/parallel-doc-fixes Minor fixes for typos/inconsistencies in parallel docs

File last commit:

r13693:4daff2b9
r14632:744eaf4e merge
Show More
clusterlist.js
199 lines | 6.5 KiB | application/javascript | JavascriptLexer
Brian Granger
Draft of the cluster list UI....
r6195 //----------------------------------------------------------------------------
MinRK
add utils.url_path_join...
r13063 // Copyright (C) 2011 The IPython Development Team
Brian Granger
Draft of the cluster list UI....
r6195 //
// Distributed under the terms of the BSD License. The full license is in
// the file COPYING, distributed as part of this software.
//----------------------------------------------------------------------------
//============================================================================
// NotebookList
//============================================================================
var IPython = (function (IPython) {
MinRK
add utils.url_path_join...
r13063 "use strict";
var utils = IPython.utils;
Brian Granger
Draft of the cluster list UI....
r6195
var ClusterList = function (selector) {
this.selector = selector;
if (this.selector !== undefined) {
this.element = $(selector);
this.style();
this.bind_events();
}
};
Bussonnier Matthias
change more baseurl
r9503 ClusterList.prototype.baseProjectUrl = function(){
return this._baseProjectUrl || $('body').data('baseProjectUrl');
};
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",
success : $.proxy(this.load_list_success, this)
};
MinRK
make sure to encode URL components for API requests...
r13693 var url = utils.url_join_encode(this.baseProjectUrl(), '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
fight with bootstrap a little less in tree view
r10911 var item = new ClusterItem(element);
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 };
var ClusterItem = function (element) {
this.element = $(element);
this.data = null;
Brian Granger
Cluster management is now working....
r6197 this.style();
Brian Granger
Draft of the cluster list UI....
r6195 };
Matthias BUSSONNIER
fix baseUrl
r9699 ClusterItem.prototype.baseProjectUrl = function(){
return this._baseProjectUrl || $('body').data('baseProjectUrl');
};
Brian Granger
Cluster management is now working....
r6197 ClusterItem.prototype.style = function () {
MinRK
use row-fluid for cluster list
r10920 this.element.addClass('list_item').addClass("row-fluid");
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
use row-fluid for cluster list
r10920 var profile_col = $('<span/>').addClass('profile_col span4').text(this.data.profile);
var status_col = $('<span/>').addClass('status_col span3').html('stopped');
var engines_col = $('<span/>').addClass('engine_col span3');
Matthias BUSSONNIER
min and default for engine number
r9289 var input = $('<input/>').attr('type','number')
.attr('min',1)
.attr('size',3)
.addClass('engine_num_input');
Brian Granger
Chaging # of engines format in cluster list.
r6201 engines_col.append(input);
MinRK
bootstrap tree
r10891 var start_button = $('<button/>').addClass("btn btn-mini").text("Start");
MinRK
use row-fluid for cluster list
r10920 var action_col = $('<span/>').addClass('action_col span2').append(
$("<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) {
Brian Granger
Cluster management is now working....
r6197 status_col.html('invalid engine #');
} else {
var settings = {
cache : false,
data : {n:n},
type : "POST",
dataType : "json",
success : function (data, status, xhr) {
that.update_state(data);
},
error : function (data, status, xhr) {
MinRK
add utils.url_path_join...
r13063 status_col.html("error starting cluster");
Brian Granger
Cluster management is now working....
r6197 }
};
status_col.html('starting');
MinRK
make sure to encode URL components for API requests...
r13693 var url = utils.url_join_encode(
MinRK
add utils.url_path_join...
r13063 that.baseProjectUrl(),
'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
use row-fluid for cluster list
r10920 var profile_col = $('<span/>').addClass('profile_col span4').text(this.data.profile);
var status_col = $('<span/>').addClass('status_col span3').html('running');
var engines_col = $('<span/>').addClass('engines_col span3').html(this.data.n);
MinRK
bootstrap tree
r10891 var stop_button = $('<button/>').addClass("btn btn-mini").text("Stop");
MinRK
use row-fluid for cluster list
r10920 var action_col = $('<span/>').addClass('action_col span2').append(
$("<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);
},
error : function (data, status, xhr) {
console.log('error',data);
MinRK
add utils.url_path_join...
r13063 status_col.html("error stopping cluster");
Brian Granger
Cluster management is now working....
r6197 }
};
MinRK
add utils.url_path_join...
r13063 status_col.html('stopping');
MinRK
make sure to encode URL components for API requests...
r13693 var url = utils.url_join_encode(
MinRK
add utils.url_path_join...
r13063 that.baseProjectUrl(),
'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 });
};
IPython.ClusterList = ClusterList;
IPython.ClusterItem = ClusterItem;
return IPython;
}(IPython));