Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shear UI #505

Merged
merged 75 commits into from
Jul 17, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
cbf4060
bp shear
kwcantrell Mar 1, 2021
227ec29
style fix
kwcantrell Mar 1, 2021
66c2e56
checkpoint
kwcantrell Mar 6, 2021
1183aa7
checkpoint
kwcantrell Mar 9, 2021
eafbea3
Finished TreeController
kwcantrell Mar 10, 2021
7301e82
tree-controller
kwcantrell Mar 17, 2021
888cf72
merged with master
kwcantrell Mar 17, 2021
f4f668f
fix doc issue
kwcantrell Mar 17, 2021
a408326
style fix
kwcantrell Mar 17, 2021
b043826
Apply suggestions from code review
kwcantrell Mar 19, 2021
caa916e
Merge branch 'master' of https://github.com/biocore/empress into tree…
kwcantrell Mar 19, 2021
f598928
fix style
kwcantrell Mar 19, 2021
5ca5809
addressed comments
kwcantrell Mar 23, 2021
89a4326
removed shear
kwcantrell Mar 23, 2021
654df69
start ui
kwcantrell Mar 24, 2021
d6aa515
finished basic shear ui
kwcantrell Mar 25, 2021
de01d93
fixed test issue
kwcantrell Mar 25, 2021
fcb6b5b
removed old comments
kwcantrell Mar 25, 2021
55f6f7e
merged master
kwcantrell Mar 25, 2021
b3acbd1
Apply suggestions from code review
kwcantrell Mar 30, 2021
263dd6a
started addressing PR suggestions
kwcantrell Mar 30, 2021
5bb8729
Merge branch 'shear-ui' of https://github.com/kwcantrell/empress into…
kwcantrell Mar 30, 2021
68d0d63
fixed style
kwcantrell Mar 30, 2021
603bf97
still addressing comments
kwcantrell Apr 1, 2021
31b5af3
fixed style
kwcantrell Apr 1, 2021
7f56e68
fix unselect all
kwcantrell Apr 1, 2021
9a9bb75
Fixed unselect all for circ layout
kwcantrell Apr 1, 2021
9dc26bc
fixed issue were tree disappears if all tips sheared
kwcantrell Apr 1, 2021
4445ebd
check point
kwcantrell Apr 1, 2021
15f81ab
fixed clade collapse
kwcantrell Apr 1, 2021
4630689
fixed style
kwcantrell Apr 1, 2021
73892fd
fixed test
kwcantrell Apr 1, 2021
3ca595e
fixed no biom error
kwcantrell Apr 2, 2021
66e5ded
checkpoint
kwcantrell Apr 6, 2021
9eb4243
performance improvemens
kwcantrell Apr 7, 2021
e3d128f
merged master
kwcantrell Apr 8, 2021
4b4d8e3
finished documenting
kwcantrell Apr 9, 2021
3d05f17
style fix
kwcantrell Apr 9, 2021
d909e83
added warning to shear
kwcantrell Apr 9, 2021
3b6d854
Major performance increase!
kwcantrell Apr 11, 2021
0803dc0
Apply suggestions from code review
kwcantrell Apr 12, 2021
cc754e9
fix style
kwcantrell Apr 12, 2021
3a2eede
Add warning message to shear panel
kwcantrell Apr 13, 2021
95392a5
starting addressing @fedarko's comments
kwcantrell May 4, 2021
45e2d49
addressed @fedarko's comments
kwcantrell May 4, 2021
3570a19
Merge branch 'master' of https://github.com/biocore/empress into shea…
kwcantrell May 4, 2021
e78ecd1
fix test
kwcantrell May 4, 2021
c95adf8
Apply suggestions from code review
kwcantrell May 17, 2021
af71569
added more @fedarko's suggestions + stle fix
kwcantrell May 17, 2021
35a2aa9
Merge branch 'master' of https://github.com/biocore/empress into shea…
kwcantrell May 28, 2021
928a2ce
address @fedarko's PR comments
kwcantrell May 28, 2021
6d4571a
Merge branch 'master' of https://github.com/biocore/empress into shea…
kwcantrell Jun 6, 2021
6074e5d
fixed collapse issue
kwcantrell Jun 10, 2021
0b081ca
Merge branch 'master' of https://github.com/biocore/empress into shea…
kwcantrell Jun 10, 2021
0bd1160
Apply suggestions from code review
kwcantrell Jun 10, 2021
d3c2a61
fixed callback for emperor selections
kwcantrell Jun 10, 2021
ac544fb
fixed style
kwcantrell Jun 10, 2021
55ca475
modified node circle text
kwcantrell Jun 10, 2021
aedb860
merged with master
kwcantrell Jun 11, 2021
90571be
disabled tabs during animation
kwcantrell Jun 11, 2021
149ecb5
fixed tests/lint issues
kwcantrell Jun 11, 2021
288a140
Apply suggestions from code review
kwcantrell Jun 29, 2021
7faa70a
modified message
kwcantrell Jun 29, 2021
cb085ba
addressed comments
kwcantrell Jun 29, 2021
8af9b93
fixed python test
kwcantrell Jun 29, 2021
c0fbd57
Merge branch 'master' of https://github.com/biocore/empress into pr50…
fedarko Jul 17, 2021
0505705
Remove extra " in side panel disabled message
fedarko Jul 17, 2021
924b938
rm another extra "
fedarko Jul 17, 2021
0bae2ce
space after "
fedarko Jul 17, 2021
953abd8
fix problem i introduced in the last commit ._.
fedarko Jul 17, 2021
8767132
MNT: RM \t chars, make e-d-*.js docs consistent
fedarko Jul 17, 2021
01d7022
DOC: Adjust tab-disabled prefix using isEmpirePlot
fedarko Jul 17, 2021
c57a5d2
DOC: Make uses of bold fonts consistent
fedarko Jul 17, 2021
00b7dee
STY: prettify
fedarko Jul 17, 2021
b664bfd
Cleaner toast msg for no-FM-b/c-shearing case
fedarko Jul 17, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion empress/support_files/js/animation-panel-handler.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
define(["Colorer", "util"], function (Colorer, util) {
define(["Colorer", "util", "EnableDisableAnimationTab"], function (Colorer, util, EnableDisableAnimationTab) {
/**
*
* @class AnimationPanel
Expand All @@ -11,6 +11,9 @@ define(["Colorer", "util"], function (Colorer, util) {
* construct AnimationPanel
*/
function AnimationPanel(animator) {
this.container = new EnableDisableAnimationTab(
document.getElementById("animation-div")
);
// used in event triggers
this.animator = animator;

Expand Down Expand Up @@ -45,6 +48,23 @@ define(["Colorer", "util"], function (Colorer, util) {
this._onAnimationStopped = null;
}

/*
* Enables the Animation tab. This will result in the Animation tab
* containing its original content.
*/
AnimationPanel.prototype.enableTab = function() {
this.container.enableTab();
}

/*
* Disables the Animation tab. This will result in the Animation tab
* containing a message describing why the tab has been disabled and how to
* re-enable it.
*/
AnimationPanel.prototype.disableTab = function() {
this.container.disableTab();
}

/**
* Makes the play button visible. This is the menu shown before user has
* started the animation.
Expand Down
36 changes: 35 additions & 1 deletion empress/support_files/js/animator.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ define(["Colorer", "util"], function (Colorer, util) {
*
* @param{Empress} empress The core class. Entry point for all metadata and
* tree operations.
* @param{Array} sidePanelTabs An array of EnableDisableSidePanelTab
* for the side-panel tabs. These tabs will be
* disabled while the animator is active and
* enabled otherwise.
*
* @returns{Animator}
* @constructs Animator
*/
function Animator(empress) {
function Animator(empress, sidePanelTabs) {
/**
* @type {Empress}
* The Empress state machine
Expand Down Expand Up @@ -109,6 +113,34 @@ define(["Colorer", "util"], function (Colorer, util) {
* Extra width for branches.
*/
this.lWidth = 0;

/**
* @type {Array}
* Stores the side-panel tabs. These tabs will be disabled
* while the animator is active and enabled otherwise.
* Each element of this array is an EnableDisableSidePanelTab object
*/
this.sidePanelTabs = sidePanelTabs;
}
/*
* Enables the side panel tabs. This will result in the side panel tabs
* containing their original content.
*/
Animator.prototype.disableSidePanelTabs = function() {
_.each(this.sidePanelTabs, function(tab) {
tab.disableTab();
});
}

/*
* Disables the side panel tabs. This will result in the side panel tabs
* containing a message describing why the tabs have been disabled and how
* to re-enable them.
*/
Animator.prototype.enableSidePanelTabs = function() {
_.each(this.sidePanelTabs, function(tab) {
tab.enableTab();
});
}

/**
Expand Down Expand Up @@ -310,6 +342,7 @@ define(["Colorer", "util"], function (Colorer, util) {
* start the animation loop.
*/
Animator.prototype.startAnimation = function () {
this.disableSidePanelTabs();
this.initAnimation();

// start animation loop
Expand Down Expand Up @@ -338,6 +371,7 @@ define(["Colorer", "util"], function (Colorer, util) {
* Stops the animation and clears state machine parameters
*/
Animator.prototype.stopAnimation = function () {
this.enableSidePanelTabs();
this.__resetParams();
this.empress.clearLegend();
this.empress.resetTree();
Expand Down
49 changes: 30 additions & 19 deletions empress/support_files/js/emperor-callbacks.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,30 @@
/**
* helper function that will color the empress tree according to
* colorSampleGroups.
*
* @param {object} colorSampleGroups An object whose property names are html
* hex color stings and associated values are
* arrays of sample ids.
* example:
* {
* #008000: ['s1', 's2', 's3']
* #000080: ['s1', 's3', 's4']
* }
*/
var emperorCallbackColorEmpress = function(colorSampleGroups) {
// if there's any coloring setup remove it, and re-enable the update button
sPanel.sUpdateBtn.classList.remove("hidden");
sPanel.fUpdateBtn.classList.remove("hidden");
empress.clearLegend();
empress.resetTree();
empress.colorSampleGroups(colorSampleGroups);
}

/*
* This file is intended to be used only with Emperor. For more information
* about these and other events see this document:
* https://github.com/biocore/emperor/blob/master/doc/source/js_integration.rst
*/

empress.setOnNodeMenuVisibleCallback(function (samples) {
// reset scale settings for all samples
ec.decViews.scatter.setScale(1);
Expand Down Expand Up @@ -64,7 +85,7 @@ plotView.on("click", function (name, object) {
});

plotView.on("select", function (samples, view) {
// remove any strangling observers
// remove any ongoing observers
shearer.unregisterObserver("emperor-select");

// cancel any ongoing timers
Expand All @@ -81,14 +102,8 @@ plotView.on("select", function (samples, view) {
});
}

var colorEmpress = () => {
// if there's any coloring setup remove it, and re-enable the update button
sPanel.sUpdateBtn.classList.remove("hidden");
sPanel.fUpdateBtn.classList.remove("hidden");
empress.clearLegend();
empress.resetTree();
empress.colorSampleGroups(namesOnly);
};
// color the tree using the samples
var colorEmpress = () => {emperorCallbackColorEmpress(namesOnly);};
colorEmpress();

// 4 seconds before resetting
Expand Down Expand Up @@ -139,6 +154,7 @@ ec.controllers.animations.addEventListener("animation-started", function (
// animation starts
animationPanel.startOptions();
animationPanel.setEnabled(false);
animationPanel.disableTab();

animator.setAnimationParameters(
payload.message.trajectory,
Expand All @@ -148,6 +164,7 @@ ec.controllers.animations.addEventListener("animation-started", function (
animator.lWidth
);
animator.initAnimation();
animator.disableSidePanelTabs();
});

ec.controllers.animations.addEventListener(
Expand All @@ -162,6 +179,7 @@ ec.controllers.animations.addEventListener("animation-cancelled", function (
) {
// if the animation is cancelled enable the animation controls
animationPanel.setEnabled(true);
animationPanel.enableTab();
animator.stopAnimation();
});

Expand All @@ -181,7 +199,7 @@ ec.controllers.animations.addEventListener("animation-ended", function (
ec.controllers.color.addEventListener("value-double-clicked", function (
payload
) {
// remove any strangling observers
// remove any ongoing observers
shearer.unregisterObserver("emperor-value-double-clicked");

// when dealing with a biplot ignore arrow-emitted events
Expand All @@ -203,14 +221,7 @@ ec.controllers.color.addEventListener("value-double-clicked", function (
var container = {};
container[payload.message.attribute] = names;

var colorEmpress = () => {
// if there's any coloring setup remove it, and re-enable the update button
sPanel.sUpdateBtn.classList.remove("hidden");
sPanel.fUpdateBtn.classList.remove("hidden");
empress.clearLegend();
empress.resetTree();
empress.colorSampleGroups(container);
};
var colorEmpress = () => {emperorCallbackColorEmpress(container);};
colorEmpress();

// 4 seconds before resetting
Expand Down
52 changes: 52 additions & 0 deletions empress/support_files/js/enable-disable-animation-tab.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
define(["EnableDisableTab"], function (EnableDisableTab) {
/**
* @class EnableDisableAnimationTab
*
* Adds the the ability to enable and disable the Animation tab by
* encapsulating it in an enabled/disabled container.
* Two new containers will be created:
* - an enable container that holds the original content of tab
* - a disable container that will display a message describing why the
* tab has been disabled an how to re-enable it.
*
* @param{object} tab The div container to encapsulate
*
* @returns{EnableDisableAnimationTab}
* @constructs EnableDisableAnimationTab
*/
function EnableDisableAnimationTab(tab) {
// call EnableDisableTab constructor
EnableDisableTab.call(this, tab);


// add disable text message
this.disableContainer.innerHTML =
'<p class="side-panel-notes">' +
'<span style="font-weight: bold;">This tab</span> ' +
'has been disabled while the animation is active from within ' +
'the Emperor interface.' +
'</p>'

// add instructions to re-enable the tab
this.disableContainer.innerHTML +=
'<p class="side-panel-notes">' +
'<span style="font-weight: bold;">To re-enable</span> ' +
'this tab please click on the ' +
'<span style="font-style: italic;">Reset the animation</span>' +
' button located within the ' +
'<span style="font-style: italic;">Animations</span> ' +
'tab of Emperor.' +
'</p>'
}

// inherit EnableDisableTab functions
EnableDisableAnimationTab.prototype = Object.create(
EnableDisableTab.prototype
);

// set EnableDisableAnimationTab's constructor
EnableDisableAnimationTab.prototype.constructor =
EnableDisableAnimationTab;

return EnableDisableAnimationTab;
});
68 changes: 68 additions & 0 deletions empress/support_files/js/enable-disable-side-panel-tab.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
define(["EnableDisableTab"], function (EnableDisableTab) {
/**
* @class EnableDisableSidePanelTab
*
* Adds the the ability to enable and disable a side panel tab by
* encapsulates a side-panel tab in an enabled/disabled container.
* Two new containers will be created:
* - an enable container that holds the original content of tab
* - a disable container that will display a message describing why the
* tab has been disabled an how to re-enable it.
*
* @param{String} tabName The name of the tab
* @param{object} tab The div container to encapsulate
*
* @returns{EnableDisableSidePanelTab}
* @constructs EnableDisableSidePanelTab
*/
function EnableDisableSidePanelTab(tabName, tab) {
// call EnableDisableTab constructor
EnableDisableTab.call(this, tab);


// add disable text message
this.disableContainer.innerHTML =
'<p class="side-panel-notes">'+
'<span style="font-weight: bold;">' + tabName +
'</span> is currently disabled while an ' +
'<span style="font-style: italic;">animation is active</span>. ' +
'To enable <span style="font-style: italic;">' + tabName +
'</span>, manually stop the animation.'+
'</p>';

// add instructions to manually disable animations from empress
this.disableContainer.innerHTML +=
'<p class="side-panel-notes">' +
'<span style="font-weight: bold;">To manually stop</span> ' +
'the animation go to the ' +
'<span style="font-style: italic;">Animation</span> ' +
'tab and click on the ' +
'<span style="font-style: italic;">Stop Animation</span> ' +
'button.' +
'</p>';

// add instructions to manually disable animations from emperor
this.disableContainer.innerHTML +=
'<p class="side-panel-notes">' +
'<span style="font-weight: bold;">Note</span> ' +
'if the animation was triggered using the ' +
'<span style="font-style: italic;">Emperor</span> ' +
'interface of an Empire plot, it can be stop by clicking ' +
'on the <span style="font-style: italic;">Restart the ' +
'animation</span> button located within the ' +
'<span style="font-style: italic;">Animations</span> ' +
'tab of Emperor.' +
'</p>';
}

// inherit EnableDisableTab functions
EnableDisableSidePanelTab.prototype = Object.create(
EnableDisableTab.prototype
);

// set EnableDisableSidePanelTab's constructor
EnableDisableSidePanelTab.prototype.constructor =
EnableDisableSidePanelTab;

return EnableDisableSidePanelTab;
});
Loading