2929import org .labkey .api .query .FilteredTable ;
3030import org .labkey .api .query .UserSchema ;
3131import org .labkey .api .settings .AppProps ;
32+ import org .labkey .api .util .DOM ;
3233import org .labkey .api .util .FileUtil ;
3334import org .labkey .api .util .HtmlString ;
3435import org .labkey .api .util .LinkBuilder ;
4546import java .util .regex .Matcher ;
4647import java .util .regex .Pattern ;
4748
49+ import static org .labkey .api .util .DOM .Attribute .height ;
50+ import static org .labkey .api .util .DOM .Attribute .src ;
4851import static org .labkey .api .util .DOM .Attribute .style ;
52+ import static org .labkey .api .util .DOM .Attribute .width ;
53+ import static org .labkey .api .util .DOM .IMG ;
4954import static org .labkey .api .util .DOM .SPAN ;
5055import static org .labkey .api .util .DOM .at ;
5156
@@ -278,7 +283,12 @@ public boolean isSortable()
278283 return false ;
279284 }
280285
281- private String getAnalyticsScript (String eventAction , String fileName , boolean addWaitTime )
286+ private HtmlString externalHeatmapViewerLink (String fileName , LincsModule .LincsAssay assayType )
287+ {
288+ return externalHeatmapViewerLink (fileName , assayType , getGctDavUrl (fileName ));
289+ }
290+
291+ private static String getAnalyticsScript (String eventAction , String fileName , boolean addWaitTime )
282292 {
283293 if (!StringUtils .isBlank (AnalyticsService .getTrackingScript ()))
284294 {
@@ -288,31 +298,38 @@ private String getAnalyticsScript(String eventAction, String fileName, boolean a
288298 // request if the download opens on the same page.
289299 String timeout = addWaitTime ? "that=this; setTimeout(function(){location.href=that.href;},400);return false;" : "" ;
290300
291- // Universal Analytics - remove after conversion to GA4 is complete
292- String onClickScript = "try {_gaq.push(['_trackEvent', 'Lincs', " + PageFlowUtil .qh (eventAction ) + ", " + PageFlowUtil .qh (fileName ) + "]); } catch (err) {}" ;
293301 // GA4 variant
294- onClickScript + = "try {gtag('event', 'Lincs', {eventAction: " + PageFlowUtil .qh (eventAction ) + ", fileName: " + PageFlowUtil .qh (fileName ) + "}); } catch(err) {}" ;
302+ String onClickScript = "try {gtag('event', 'Lincs', {eventAction: " + PageFlowUtil .qh (eventAction ) + ", fileName: " + PageFlowUtil .qh (fileName ) + "}); } catch(err) {}" ;
295303 onClickScript += timeout ;
296304 return onClickScript ;
297305 }
298306 return null ;
299307 }
300308
301- private HtmlString externalHeatmapViewerLink (String fileName , LincsModule .LincsAssay assayType )
309+ public static HtmlString externalHeatmapViewerLink (String fileName , LincsModule .LincsAssay assayType , String gctFileDavUrl )
302310 {
303- String gctFileUrl = davUrl + "GCT/" + PageFlowUtil .encodePath (fileName );
304- String morpheusUrl = getMorpheusUrl (gctFileUrl , assayType );
311+ String morpheusUrl = getMorpheusUrl (gctFileDavUrl , assayType );
305312
306313 String analyticsScript = getAnalyticsScript ("Morpheus" , fileName , false );
307- String onclickEvt = StringUtils .isBlank (analyticsScript ) ? "" : "onclick=\" " + analyticsScript + "\" " ;
308314
309315 String imgUrl = AppProps .getInstance ().getContextPath () + "/lincs/GENE-E_icon.png" ;
310316
311- // TODO: Should use a LinkBuilder, etc.
312- return HtmlString .unsafe ("[ <a target=\" _blank\" " + onclickEvt + " href=\" " + morpheusUrl + "\" >View in Morpheus</a> <img src=" + imgUrl + " width=\" 13\" , height=\" 13\" /> ]" );
317+ LinkBuilder viewInMorpheusLink = LinkBuilder .simpleLink ("View in Morpheus" , morpheusUrl ).target ("_blank" );
318+ if (analyticsScript != null )
319+ {
320+ viewInMorpheusLink .onClick (analyticsScript );
321+ }
322+
323+ return HtmlString .of (DOM .SPAN ("[" ,
324+ HtmlString .NBSP ,
325+ viewInMorpheusLink ,
326+ HtmlString .NBSP ,
327+ IMG (at (src , imgUrl ).at (width , 13 ).at (height , 13 )),
328+ HtmlString .NBSP ,
329+ "]" ));
313330 }
314331
315- private String getMorpheusUrl (String gctFileUrl , LincsModule .LincsAssay assayType )
332+ private static String getMorpheusUrl (String gctFileUrl , LincsModule .LincsAssay assayType )
316333 {
317334 String morpheusJson = "{\" dataset\" :\" " + gctFileUrl + "\" ," ;
318335 if (assayType == LincsModule .LincsAssay .P100 )
0 commit comments