Skip to content

Commit

Permalink
Refactoring sort variable and order. Addresses #684
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsielicki committed Mar 29, 2017
1 parent affa9f2 commit 9407cd3
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions web-server/plugins/slycat-timeseries-model/js/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ var selected_column_min = null; // This holds the min value of the currently sel
var selected_column_max = null; // This holds the max value of the currently selected column
var selected_simulations = null; // This hold the currently selected rows

var sort_variable = null; // This holds the sorted variable
var sort_order = null; // This holds the sort order

var controls_ready = false;
var colorswitcher_ready = false;
var dendrogram_ready = false;
Expand Down Expand Up @@ -249,6 +252,10 @@ function setup_page()
// Set state of colormap
colormap = bookmark["colormap"] !== undefined ? bookmark["colormap"] : "night";

// Set sort variable and order
sort_variable = bookmark["sort-variable"] !== undefined ? bookmark["sort-variable"] : undefined;
sort_order = bookmark["sort-order"] !== undefined ? bookmark["sort-order"] : undefined;

setup_controls();
setup_widgets();
setup_waveforms();
Expand Down Expand Up @@ -501,6 +508,7 @@ function setup_widgets()
if(
!table_ready && bookmark && table_metadata && cluster_index !== null && selected_simulations !== null && colormap !== null
&& selected_column !== null && selected_column_type !== null && selected_column_min !== null && selected_column_max !== null
&& sort_variable !== null && sort_order !== null
)
{
table_ready = true;
Expand All @@ -517,14 +525,10 @@ function setup_widgets()
colormap : colormap,
"variable-selection" : [selected_column[cluster_index]],
"row-selection" : selected_simulations,
"sort-variable" : sort_variable,
"sort-order" : sort_order,
};

if("sort-variable" in bookmark && "sort-order" in bookmark)
{
table_options["sort-variable"] = bookmark["sort-variable"];
table_options["sort-order"] = bookmark["sort-order"];
}

if(selected_column_type[cluster_index] != "string")
{
colorscale = $("#color-switcher").colorswitcher("get_color_scale", undefined, selected_column_min[cluster_index], selected_column_max[cluster_index]);
Expand Down Expand Up @@ -590,6 +594,7 @@ function setup_widgets()
// Setup the dendrogram ...
if(!dendrogram_ready && bookmark && s_to_a(clusters) && cluster_index !== null && clusters_data[cluster_index] !== undefined
&& color_array !== null && selected_simulations !== null && colormap !== null && selected_column_min !== null && selected_column_max !== null
&& sort_variable !== null
)
{
dendrogram_ready = true;
Expand All @@ -610,7 +615,7 @@ function setup_widgets()
dendrogram_options.color_scale = color_scale;
dendrogram_options.color_array = color_array;

if(bookmark["sort-variable"] != undefined) {
if(sort_variable != undefined) {
dendrogram_options.dendrogram_sort_order = false;
}

Expand Down Expand Up @@ -872,12 +877,15 @@ function update_waveform_dendrogram_legend_on_selected_variable_changed(variable

function variable_sort_changed(variable, order)
{
sort_variable = variable;
sort_order = order;

$.ajax(
{
type : "POST",
url : server_root + "events/models/" + model._id + "/select/sort-order/" + variable + "/" + order
});
bookmarker.updateState( {"sort-variable" : variable, "sort-order" : order} );
bookmarker.updateState( {"sort-variable" : sort_variable, "sort-order" : sort_order} );
}

function expanded_collapsed_nodes_changed(nodes){
Expand Down

0 comments on commit 9407cd3

Please sign in to comment.