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

SCT-3097 - fix clustering viewer pop ups, timeouts, tab crash with large clusters #2385

Open
wants to merge 73 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
ff113f2
Merge pull request #2247 from kbase/narrative_version_debug
briehl Apr 21, 2021
3b09924
Merge pull request #2289 from kbase/develop
briehl May 18, 2021
80766a3
remove console logging
eapearson Jul 15, 2021
fe61c0a
minor code cleanup
eapearson Jul 15, 2021
d91670d
fix tab removal behavior; remove commented out code
eapearson Jul 15, 2021
98394da
disable focus outline for close button; it just looks weird given its…
eapearson Jul 15, 2021
d1a9a56
improve layout; use "-" for missing name or function (rather than emp…
eapearson Jul 15, 2021
271ba29
improve layout spacing; disable explore cluster for > 200 genes; hand…
eapearson Jul 15, 2021
2231a2b
don't convert stats to fixed decimal strings, that is already handled…
eapearson Jul 15, 2021
8efb24f
disabled explore cluster button aligned with non-disabled.
eapearson Jul 15, 2021
d65549e
prettification
eapearson Jul 15, 2021
7f67f84
ignore _temp dir
eapearson Jul 15, 2021
1cf849f
fix order of ops in init
eapearson Jul 15, 2021
ef17db7
fix typo in getSubmatrixParams; add improved error handling based on …
eapearson Jul 23, 2021
f1cffbc
use get_objects2 rather than deprecated ws methods; use upas.cluster…
eapearson Jul 23, 2021
6b8ca67
add roles for testing; other minor improvements.
eapearson Jul 23, 2021
2001bf9
remove unused variable
eapearson Jul 23, 2021
a995a83
remove unused variable (set twice.)
eapearson Jul 23, 2021
a26f7d2
remove unused featureValueClient property and dependency
eapearson Jul 23, 2021
ad15040
Add testing of pairwise clusters widget, with test data; refactor to …
eapearson Jul 25, 2021
b2e6be2
Merge remote-tracking branch 'origin/develop' into SCT-3097_clusterin…
eapearson Jul 25, 2021
1c4edc9
add release note
eapearson Jul 25, 2021
cefcd5d
remove commented out code, use actual uuid.
eapearson Jul 26, 2021
f56e850
hoist more hardcoded values into constants to clarify code;
eapearson Jul 26, 2021
2ca0bd6
remove nonfunctional testing code
eapearson Jul 26, 2021
adc05a2
remove unused modules references
eapearson Jul 26, 2021
c42680d
fix spacing
eapearson Jul 26, 2021
e9abb88
fix for code quality tool, removes unnecessary variables
eapearson Jul 26, 2021
0b1614e
fix typo, remove unnecessary lines, commented out code
eapearson Jul 26, 2021
dd75ed7
simplify code, refactor for loop.
eapearson Jul 26, 2021
30b6e9f
remove unnecessary comments, commented out code.
eapearson Jul 26, 2021
a55be38
make code quality tool happy by removing shadowed variables
eapearson Jul 26, 2021
456ff4a
remove default for duration
eapearson Jul 26, 2021
c749f0f
refactor a repeated pattern into a function
eapearson Jul 26, 2021
bf6c0ba
rename variables to avoid triggering warning in cq tools
eapearson Jul 26, 2021
7dc2136
center message
eapearson Jul 26, 2021
cd7edd8
remove button disabling with > 200 genes
eapearson Jul 26, 2021
d0a1843
fix data table not displaying table controls (sort, pagination, info)
eapearson Jul 26, 2021
c14cf4f
fix hide/show of selected features table
eapearson Jul 26, 2021
f88ecb9
adjust test for button
eapearson Jul 26, 2021
f151891
Merge pull request #2425 from kbase/develop
briehl Aug 20, 2021
3e39acd
Merge remote-tracking branch 'origin/develop' into SCT-3097_clusterin…
eapearson Aug 20, 2021
0201fec
restore sample service to config
eapearson Aug 20, 2021
6d3adaa
restore CHROME_BIN to karma unit testing config
eapearson Aug 20, 2021
3e7e66f
Fix loading message (probably merge error)
eapearson Aug 20, 2021
4f9f757
minor updates to integratin-test doc
eapearson Aug 20, 2021
f6e2e46
add "whenShown" callback; useful for doing rendering fixup (e.g. data…
eapearson Aug 20, 2021
4d34618
move some styles into stylesheet; fix some table styling issues
eapearson Aug 20, 2021
eddc302
Merge remote-tracking branch 'origin/develop' into SCT-3097_clusterin…
eapearson Sep 29, 2021
bb3d0e2
remove todo comment and unused argument
eapearson Sep 30, 2021
f841f4b
tabs 4 -> 2 and other formatting fixes
eapearson Sep 30, 2021
0bf6036
remove unused args
eapearson Sep 30, 2021
2bc384f
replace regex constructor with regex literals
eapearson Sep 30, 2021
c3cb5e4
fix css for styleelint, add stylelint dependency, stylelint settings
eapearson Sep 30, 2021
52de0e2
Merge pull request #2538 from kbase/develop
briehl Oct 28, 2021
41162f6
Merge remote-tracking branch 'origin/master' into SCT-3097_clustering…
eapearson Nov 22, 2021
1d13e8f
Merge remote-tracking branch 'origin/develop' into SCT-3097_clusterin…
eapearson Nov 22, 2021
39610a3
Merge remote-tracking branch 'origin/develop' into SCT-3097_clusterin…
eapearson Mar 9, 2022
3f17586
Merge remote-tracking branch 'origin/develop' into SCT-3097_clusterin…
eapearson May 24, 2022
d976bfe
Add !important to force full width table; some change in datatables c…
eapearson May 24, 2022
90d49f4
fix usage caught by DeepScan (which actually pointed to the wrong pro…
eapearson May 24, 2022
e829eef
remove unnecessary import of jquery into test (sonarcloud) [SCT-3097]
eapearson May 24, 2022
4bd485a
move direct styles into stylesheet [SCT-3097]
eapearson May 24, 2022
6208aa3
improve styling [SCT-3097]
eapearson May 25, 2022
f66d4fc
add support for component demos [SCT-3097]
eapearson May 25, 2022
3b99f35
fix default type for alert [SCT-3097]
eapearson May 25, 2022
426221a
move css stylesheet to scss [SCT-3097]
eapearson May 25, 2022
d3a6aac
move stylesheet to scss [SCT-3097]
eapearson May 25, 2022
c8917e4
replace more inline styles with scss [SCT-3097]
eapearson May 25, 2022
2d96cdb
fix tabbing for codacy [SCT-3097]
eapearson May 25, 2022
5367b26
format with "remark", as per codacy [SCT-3097]
eapearson May 25, 2022
6c03a4c
more markdown formatting tweaks, how silly [SCT-3097]
eapearson May 25, 2022
a0a0166
last markdown tweak, yuck [SCT-3097]
eapearson May 25, 2022
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
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ kbase-extension/static/ext_packages
kbase-extension/static/kbase/js/patched-components
venv
cover
/_temp
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ This is built on the Jupyter Notebook v6.0.2 (more notes will follow).

### Unreleased

- SCT-3097 - Fix pop-ups and long timeouts & browser tab crash for expression feature clustering viewer
- SCT-3084 - Fixed broken (non-functional) search in the data panel
- SCT-3602 - refseq public data tool now searches by lineage as well; for all public data tools: automatically focus the search input; fix paging bug.
- No ticket - migrate from `nosetests` to `pytest` for testing the Python stack.
Expand Down
122 changes: 122 additions & 0 deletions kbase-extension/static/kbase/js/widgets/common/ErrorView.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
/**
* errorView - A widget which displays common error types, including
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We invented this wheel in the truss branch -- perhaps that file can be pulled over as it's quite similar to this.

* strings, exception objects descended from Error, and plain objects which
* follow the KBase SDK JSON-RPC error form:
* {name, code, message, error}
* name - string - always JSONRPCError
* code - number - JSONRPC compatible error code
* message - string - canonical message
* error - string - captures trace
*/
define([
'jquery',
'kb_common/jsonRpc/exceptions',
'widgets/common/RenderIn',
'widgets/common/JSONView',
], ($, jsonRPCExceptions, RenderIn, $JSONView) => {
'use strict';

const { $TextIn, $HTMLIn } = RenderIn;
const UNKNOWN_ERROR_TEXT = 'Unknown error';

function $renderJSONRPCException(err) {
const $errorTable = $('<table>').addClass('table');

const $tbody = $('<tbody>');
$errorTable.append($tbody);

const $renderRow = (label, value) => {
return $('<tr>')
.css('background-color', 'transparent')
.append(
$('<th>').css('border', 'none').text(label),
$('<td>').css('border', 'none').text(value)
);
};

$tbody.append($renderRow('Type', err.type));
$tbody.append($renderRow('Code', err.code));
$tbody.append($renderRow('Module', err.module));
$tbody.append($renderRow('Function', err.func));
$tbody.append($renderRow('Message', err.message));

return $errorTable;
}

function $renderError(err) {
if (typeof err === 'string') {
return $TextIn(err);
}

// This may be a KBase service error, which are somewhat uniform.
// We display some common fields at top, and then dump the
// entire error info as nested tables.

if (err instanceof jsonRPCExceptions.RpcError) {
return $renderJSONRPCException(err);
}

// Some other error
if (err instanceof Error) {
return $HTMLIn([
$TextIn(err.name, 'span'),
$TextIn(': ', 'span'),
$TextIn(err.message, 'span'),
]);
}

// Some other object
if (typeof err === 'object') {
// Note that order is important.

if (err === null) {
return $TextIn(UNKNOWN_ERROR_TEXT);
}

if ('message' in err && typeof err.message === 'string') {
return $TextIn(err.message);
}

if (err.constructor === {}.constructor) {
return $JSONView(err);
}

if ('toString' in err && typeof err.toString === 'function') {
return $TextIn(`Unknown error: ${err.toString()}`);
}
}

// Don't try to do anything fancy if the error value is outside what we are prepared
// to handle.
return $TextIn(UNKNOWN_ERROR_TEXT);
}

function $renderContactInfo() {
return $('<div>')
.css('margin-top', '20px')
.append($TextIn('You may', 'span'))
.append(' ')
.append(
$('<a>')
.attr('href', 'https://www.kbase.us/support')
.attr('target', '_blank')
.text('contact the KBase team')
)
.append(' ')
.append($TextIn('with the information above.', 'span'));
}

function $renderTitle() {
return $('<div>').css('font-weight', 'bold').text('Error');
}

function $ErrorView(err) {
return $('<div>')
.addClass('alert alert-danger')
.append($renderTitle())
.append($renderError(err))
.append($renderContactInfo());
}

return $ErrorView;
});
63 changes: 63 additions & 0 deletions kbase-extension/static/kbase/js/widgets/common/JSONView.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
define(['jquery', 'widgets/common/RenderIn'], ($, RenderIn) => {
'use strict';

const { $TextIn } = RenderIn;

function $RenderJSONArray(data) {
const $rows = data.map((value, index) => {
return $('<tr>').append(
$('<th>').css('color', 'rgba(150, 150, 150, 1)').text(String(index)),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you move all the css declarations be moved out of these JS files and into the appropriate css file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure it is worth the added complexity, but sure. Added css file and created some associated classes.
I realize the Narrative has moved most css into scss - should this as well?

$('<td>').addClass('fa fa-arrow-right'),
$('<td>').html($JSONView(value))
);
});
return $('<table>').addClass('table table-striped').html($('<tbody>').append($rows));
}

function $RenderJSONObject(data) {
const $rows = Object.entries(data).map(([key, value]) => {
return $('<tr>').append(
$('<th>').css('color', 'rgba(150, 150, 150, 1)').text(key),
$('<td>').addClass('fa fa-arrow-right'),
$('<td>').html($JSONView(value))
);
});
return $('<table>').addClass('table table-striped').html($('<tbody>').append($rows));
}

function $RenderNonJSON(data) {
if (typeof data === 'object') {
return $TextIn(`Not representable: ${typeof data} (${data.constructor.name})`);
} else {
return $TextIn(`Not representable: ${typeof data}`);
}
}

function $JSONView(data) {
switch (typeof data) {
case 'string':
return $TextIn(data);
case 'number':
return $TextIn(String(data));
case 'boolean':
return $TextIn(String(data));
case 'object':
if (data === null) {
return $TextIn('NULL');
}
if (Array.isArray(data)) {
return $RenderJSONArray(data);
} else {
if (data.constructor === {}.constructor) {
return $RenderJSONObject(data);
} else {
return $RenderNonJSON(data);
}
}
default:
return $RenderNonJSON(data);
}
}

return $JSONView;
});
24 changes: 24 additions & 0 deletions kbase-extension/static/kbase/js/widgets/common/LoadingMessage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
define(['jquery'], ($) => {
'use strict';
function $LoadingMessage(message) {
const $message = (() => {
if (typeof message === 'string') {
return $('<span>').text(message);
} else {
return message;
}
})();
return $('<div>')
.addClass('alert alert-info')
.css('display', 'flex')
.css('flex-direction', 'row')
.css('align-items', 'center')
.css('justify-content', 'center')
.css('margin', '10px auto')
.css('max-width', '30em')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move to CSS file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to a stylesheet in this and other cases.
I resisted (I have of course done this dozens of times, so I'm quite familiar with this practice!) in this case I considered the risk of css class collision or interference not unlikely in a large codebase without some sort of namespacing solution. When individual components have associated class files, the stylesheet proliferation is be significant. It is just so easy to invent a new component, an associated class named after it, and have it collide with a same-named component either at present or in the future. There are ways to fix this, like css modules, or namespacing class names.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this and other css move into scss?

.append($message)
.append('&nbsp;')
.append($('<i>').addClass('fa fa-spinner fa-spin fa-2x'));
}
return $LoadingMessage;
});
13 changes: 13 additions & 0 deletions kbase-extension/static/kbase/js/widgets/common/RenderIn.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
define(['jquery'], ($) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noted in #2378 also, but this seems to be some module duplication / factorization with what's in the common/errorView (or something like that) module.

Is there a plan to unify those?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, yes. In this case, I simply wanted some convenience functions for working with jQuery.

'use strict';

function $TextIn(text, tag = 'div') {
return $(document.createElement(tag)).text(text);
}

function $HTMLIn(html, tag = 'div') {
return $(document.createElement(tag)).append(html);
}

return { $TextIn, $HTMLIn };
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Base class for viewers visualizaing expression of a set of conditions from various aspects
*
* The descendant classes should override:
* 1. getSubmtrixParams - to set params for get_submatrix_stat method from the KBaseFeatureValues service
* 1. getSubmatrixParams - to set params for get_submatrix_stat method from the KBaseFeatureValues service
* 2. buildWidget - to create a custom visuzualization
*
*
Expand All @@ -17,13 +17,11 @@ define([
'narrativeConfig',
'kbwidget',
'kbaseAuthenticatedWidget',
'kbaseTabs',
'kb_common/jsonRpc/dynamicServiceClient',
// For effect
'bootstrap',
'jquery-dataTables',
'kbaseFeatureValues-client-api',
], ($, Config, KBWidget, kbaseAuthenticatedWidget, kbaseTabs, DynamicServiceClient) => {
], ($, Config, KBWidget, kbaseAuthenticatedWidget, DynamicServiceClient) => {
'use strict';

return KBWidget({
Expand All @@ -42,9 +40,6 @@ define([
// Prefix for all div ids
pref: null,

// KBaseFeatureValue client
featureValueClient: null,

// Matrix set stat
submatrixStat: null,

Expand Down Expand Up @@ -84,7 +79,7 @@ define([
},

// To be overriden to specify additional parameters
getSubmtrixParams: function () {
getSubmatrixParams: function () {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😁

const self = this;
self.setTestParameters();
let conditions = [];
Expand All @@ -104,7 +99,7 @@ define([
self.loading(true);

const getSubmatrixStatsAndRender = function () {
const smParams = self.getSubmtrixParams();
const smParams = self.getSubmatrixParams();

// some parameter checking
if (!smParams.column_ids || smParams.column_ids.length === 0) {
Expand Down
Loading