@@ -59,7 +59,7 @@ class Page extends Component {
5959
6060 { /* Add a hidden span tag containing chars used in HSPs */ }
6161 < pre className = "pre-reset hsp-lines" ref = { this . hspChars } hidden >
62- ABCDEFGHIJKLMNOPQRSTUVWXYZ +-
62+ ABCDEFGHIJKLMNOPQRSTUVWXYZ +-
6363 </ pre >
6464
6565 { /* Required by Grapher for SVG and PNG download */ }
@@ -85,6 +85,10 @@ class Report extends Component {
8585 constructor ( props ) {
8686 super ( props ) ;
8787 this . fetchResults ( ) ;
88+ this . getDatabaseListString = this . getDatabaseListString . bind ( this ) ;
89+ this . toggleShowDatabases = this . toggleShowDatabases . bind ( this ) ;
90+ this . renderToggleDatabasesList = this . renderToggleDatabasesList . bind ( this ) ;
91+ this . maxDatabasesStringLength = 200 ;
8892
8993 // Properties below are internal state used to render results in small
9094 // slices (see updateState).
@@ -104,6 +108,8 @@ class Report extends Component {
104108 querydb : [ ] ,
105109 params : [ ] ,
106110 stats : [ ] ,
111+ databasesList : '' ,
112+ showMore : false
107113 } ;
108114 }
109115 /**
@@ -153,8 +159,8 @@ class Report extends Component {
153159 * bound to the window, document, or body.
154160 */
155161 componentDidMount ( ) {
156- // This sets up an event handler which enables users to select text from
157- // hit header without collapsing the hit.
162+ // This sets up an event handler which enables users to select text from
163+ // hit header without collapsing the hit.
158164 this . preventCollapseOnSelection ( ) ;
159165 this . toggleTable ( ) ;
160166 }
@@ -165,8 +171,11 @@ class Report extends Component {
165171 * and circos would have been rendered at this point. At this stage we kick
166172 * start iteratively adding 1 HSP to the page every 25 milli-seconds.
167173 */
168- componentDidUpdate ( ) {
169- // Log to console how long the last update take?
174+ componentDidUpdate ( props , state ) {
175+ if ( this . getDatabaseListString ( ) !== this . getDatabaseListString ( state . querydb ) ) {
176+ this . setState ( { databasesList : this . getDatabaseListString ( ) . substring ( 0 , this . maxDatabasesStringLength ) + '...' } ) ;
177+ }
178+ // Log to console how long the last update take?
170179 console . log ( ( Date . now ( ) - this . lastTimeStamp ) / 1000 ) ;
171180
172181 // Lock sidebar in its position on the first update.
@@ -242,11 +251,11 @@ class Report extends Component {
242251 < HSP
243252 key = {
244253 'Query_' +
245- query . number +
246- '_Hit_' +
247- hit . number +
248- '_HSP_' +
249- hsp . number
254+ query . number +
255+ '_Hit_' +
256+ hit . number +
257+ '_HSP_' +
258+ hsp . number
250259 }
251260 query = { query }
252261 hit = { hit }
@@ -305,12 +314,12 @@ class Report extends Component {
305314 </ h1 >
306315 < p >
307316 < br />
308- This can take some time depending on the size of your query and
309- database(s). The page will update automatically when BLAST is done.
317+ This can take some time depending on the size of your query and
318+ database(s). The page will update automatically when BLAST is done.
310319 < br />
311320 < br />
312- You can bookmark the page and come back to it later or share the
313- link with someone.
321+ You can bookmark the page and come back to it later or share the
322+ link with someone.
314323 </ p >
315324 </ div >
316325 </ div >
@@ -338,7 +347,20 @@ class Report extends Component {
338347 </ div >
339348 ) ;
340349 }
341-
350+ getDatabaseListString ( querydb = this . state . querydb ) {
351+ return querydb
352+ . map ( ( db ) => {
353+ return db . title ;
354+ } )
355+ . join ( ', ' ) ;
356+ }
357+ toggleShowDatabases ( ) {
358+ const databases = this . state . showMore ? `${ this . getDatabaseListString ( ) . substring ( 0 , this . maxDatabasesStringLength ) } ...` : `${ this . getDatabaseListString ( ) } ` ;
359+ this . setState ( { databasesList : databases , showMore : ! this . state . showMore } ) ;
360+ }
361+ renderToggleDatabasesList ( ) {
362+ return < span onClick = { this . toggleShowDatabases } > { this . state . databasesList } < span style = { { cursor : 'pointer' } } className = "btn-link hover-bold" > { this . state . showMore ? 'Show Less' : 'Show More' } </ span > </ span > ;
363+ }
342364 /**
343365 * Renders report overview.
344366 */
@@ -349,16 +371,12 @@ class Report extends Component {
349371 < strong > SequenceServer { this . state . seqserv_version } </ strong > using{ ' ' }
350372 < strong > { this . state . program_version } </ strong >
351373 { this . state . submitted_at &&
352- `, query submitted on ${ this . state . submitted_at } ` }
374+ `, query submitted on ${ this . state . submitted_at } ` }
353375 </ p >
354376 < p >
355377 < strong > Databases: </ strong >
356- { this . state . querydb
357- . map ( ( db ) => {
358- return db . title ;
359- } )
360- . join ( ', ' ) } { ' ' }
361- ({ this . state . stats . nsequences } sequences,
378+ { this . getDatabaseListString ( ) . length <= this . maxDatabasesStringLength ? this . getDatabaseListString ( ) : this . renderToggleDatabasesList ( ) } { ' ' }
379+ ({ this . state . stats . nsequences } sequences,
362380 { this . state . stats . ncharacters } characters)
363381 </ p >
364382 < p >
@@ -368,9 +386,9 @@ class Report extends Component {
368386 } ) . join ( ', ' ) }
369387 </ p >
370388 < p >
371- Please cite:{ ' ' }
389+ Please cite:{ ' ' }
372390 < a href = "https://doi.org/10.1093/molbev/msz185" >
373- https://doi.org/10.1093/molbev/msz185
391+ https://doi.org/10.1093/molbev/msz185
374392 </ a >
375393 </ p >
376394 </ div >
0 commit comments