81a8a460976bafc57a2df88a99e47431e2258245 kate Fri Jul 31 11:50:52 2020 -0700 Add hg.conf variable 'browser.recTrackSetsDetectChangge' to control whether recommended track sets features attempts to detect changes in the session. refs #25601 diff --git src/hg/hgTracks/recTrackSets.c src/hg/hgTracks/recTrackSets.c index c9d2680..253261e 100644 --- src/hg/hgTracks/recTrackSets.c +++ src/hg/hgTracks/recTrackSets.c @@ -1,24 +1,25 @@ // Code to parse list of recommended track sets from file and print as browser dialog // for client dialog (js) // /* Copyright (C) 2020 The Regents of the University of California * See README in this or parent directory for licensing information. */ #include "common.h" #include "dystring.h" #include "hCommon.h" +#include "hgConfig.h" #include "htmshell.h" #include "hash.h" #include "web.h" #include "ra.h" #include "hgTracks.h" #include "hgFind.h" #include "obscure.h" #include "net.h" /* Recommended track sets are Special 'curated' sessions, created by browser team, e.g. for clinical users * This is expected to be a very limited number (under 10 ?) * The list references sessions in namedSessionDb table, by userName and sessionName * (unfortunately not required to be unique, so depending on curator to * just make one (code willl pick the first one) @@ -43,30 +44,39 @@ * eg, DOCUMENT_ROOT/inc/recTrackSets.hg19.tab */ { char *root = hDocumentRoot(); char buf[200]; safef(buf, sizeof buf, "%s/%s/%s.%s.%s", root, REC_TRACK_SETS_DIR, REC_TRACK_SETS_FILE, database, REC_TRACK_SETS_EXT); return cloneString(buf); } boolean recTrackSetsEnabled() /* Return TRUE if feature is available */ { return fileExists(recTrackSetsFile()); } +boolean recTrackSetsChangeDetectEnabled() +/* Return TRUE if feature is available, in hgConf */ +{ +char *cfgChanges = cfgOption("browser.recTrackSetsDetectChange"); +if (cfgChanges && (sameString(cfgChanges, "on") || sameString(cfgChanges, "true"))) + return TRUE; +return FALSE; +} + struct recTrackSet *loadRecTrackSets() /* Read from tab-sep file. Return list or NULL if no track sets for this database */ { struct recTrackSet *recTrackSet, *recTrackSets = NULL; struct lineFile *lf = lineFileOpen(recTrackSetsFile(), TRUE); if (!lf) return NULL; #define cols 4 char *row[cols]; while (lineFileNextRowTab(lf, row, cols)) { AllocVar(recTrackSet); recTrackSet->label = cloneString(row[0]); recTrackSet->userName = cloneString(row[1]); recTrackSet->sessionName = cloneString(row[2]); @@ -82,30 +92,33 @@ /* Return number of recommended track sets for this database */ { return slCount(loadRecTrackSets()); } void printRecTrackSets() /* Create dialog with list of recommended track sets */ { if (!recTrackSetsEnabled()) return; struct recTrackSet *recTrackSet, *recTrackSets = loadRecTrackSets(); if (!recTrackSets) return; +if (recTrackSetsChangeDetectEnabled()) + jsInline("var recTrackSetsDetectChanges = true;"); + hPrintf("<div style='display:none;' id='recTrackSetsPopup' title='Recommended Track Sets'>\n"); // TODO: Consider moving this to the tab file as a header section hPrintf("<p>These links provide track sets selected and pre-configured for " "specific user scenarios. They are designed to be useful at " "different genomic loci. Clicking a link below will create a browser " "window with these tracks visible, without changing the locus.</p>"); hPrintf("<ul class='indent'>"); for (recTrackSet = recTrackSets; recTrackSet != NULL; recTrackSet = recTrackSet->next) { // TODO: consider libifying hgSession.c:add/getSessionLink() and using that hPrintf("<li><a class='recTrackSetLink' href='./hgTracks?" "pix=%d&textSize=%s" // preserve these user settings "&" hgsOtherUserName "=%s"