50f54e54cab29400300ce108dc134d1645c9481b max Thu Sep 6 02:27:25 2018 -0700 suppressing clickable links for hubs that have errors in hgHubConnect, refs #22012 diff --git src/hg/hgHubConnect/hgHubConnect.c src/hg/hgHubConnect/hgHubConnect.c index 679c23e..265a318 100644 --- src/hg/hgHubConnect/hgHubConnect.c +++ src/hg/hgHubConnect/hgHubConnect.c @@ -135,60 +135,64 @@ static char *removeLastComma(char *string) { if (string != NULL) { int len = strlen(string); if ( string[len - 1] == ',') string[len - 1] = 0; else if (len > 2 && endsWith(string,", ")) string[len - 2] = 0; } return string; } #define GENLISTWIDTH 40 -static void printGenomeList(char *hubUrl, struct slName *genomes, int row) +static void printGenomeList(char *hubUrl, struct slName *genomes, int row, boolean withLink) /* print supported assembly names from sl list */ { /* List of associated genomes. */ struct dyString *dy = newDyString(100); struct dyString *dyShort = newDyString(100); char *trimmedName = NULL; int charCount = 0; struct slName *genome = genomes; for(; genome; genome = genome->next) { trimmedName = trackHubSkipHubName(genome->name); dyStringPrintf(dy,"%s, ", trimmedName); if (dyShort->stringSize == 0 || (dyShort->stringSize+strlen(trimmedName)<=GENLISTWIDTH)) dyStringPrintf(dyShort,"%s, ", trimmedName); charCount += strlen(trimmedName); } char *genomesString = removeLastComma( dyStringCannibalize(&dy)); char *genomesShort = removeLastComma( dyStringCannibalize(&dyShort)); char tempHtml[1024+strlen(genomesString)+strlen(genomesShort)]; if (strlen(genomesShort) > GENLISTWIDTH) // If even the first element is too long, truncate it. genomesShort[GENLISTWIDTH] = 0; if (strlen(genomesShort)==strlen(genomesString)) { struct dyString *tempHtmlSrc = newDyString(1000); genome = genomes; for(; genome; genome = genome->next) { trimmedName = trackHubSkipHubName(genome->name); + if (withLink) dyStringPrintf(tempHtmlSrc,"<a href='hgTracks?hubUrl=%s&genome=%s'>%s</a>" , hubUrl, genome->name, trimmedName); + else + dyStringPrintf(tempHtmlSrc,"%s" , trimmedName); + if (genome->next) dyStringPrintf(tempHtmlSrc,", "); } safef(tempHtml, sizeof tempHtml, "%s", dyStringCannibalize(&tempHtmlSrc)); } else { char id[256]; safef(tempHtml, sizeof tempHtml, "<span id=Short%d>[+] %s...</span>" "<span id=Full%d style=\"display:none\">[-]<br>%s</span>" , row, genomesShort , row, genomesString); @@ -198,43 +202,43 @@ "document.getElementById('Full%d').style.display='inline';" "return false;" , row, row); safef(id, sizeof id, "Full%d", row); jsOnEventByIdF("click", id, "document.getElementById('Full%d').style.display='none';" "document.getElementById('Short%d').style.display='inline';" "return false;" , row, row); } ourPrintCell(tempHtml); } -static void printGenomes(struct trackHub *thub, int row) +static void printGenomes(struct trackHub *thub, int row, boolean withLink) /* print supported assembly names from trackHub */ { /* List of associated genomes. */ struct trackHubGenome *genomes = thub->genomeList; struct slName *list = NULL, *el; for(; genomes; genomes = genomes->next) { el = slNameNew(genomes->name); slAddHead(&list, el); } slReverse(&list); -printGenomeList(thub->url, list, row); +printGenomeList(thub->url, list, row, withLink); } static void hgHubConnectUnlisted(struct hubConnectStatus *hubList, struct hash *publicHash) /* Put up the list of unlisted hubs and other controls for the page. */ /* uses publicHash to distingusih public hubs from unlisted ones */ /* NOTE: Destroys hubList */ { // put out the top of our page printf("<div id=\"unlistedHubs\" class=\"hubList\"> \n" "<table id=\"unlistedHubsTable\"> \n" "<thead><tr> \n" "<th colspan=\"6\" id=\"addHubBar\"><label for=\"hubUrl\">URL:</label> \n" "<input name=\"hubText\" id=\"hubUrl\" class=\"hubField\" " @@ -310,59 +314,61 @@ safef(id, sizeof id, "hubDisconnectButtonU%d", count); printf("<input name=\"hubDisconnectButton\" id='%s' " "class=\"hubDisconnectButton\" type=\"button\" value=\"Disconnect\">\n", id); jsOnEventByIdF("click", id, "document.disconnectHubForm.elements['hubId'].value='%d';" "document.disconnectHubForm.submit(); return true;", hub->id); ourCellEnd(); if (hub->trackHub != NULL) { ourPrintCellLink(hub->trackHub->shortLabel, hub->hubUrl); } else ourPrintCell(""); - if (!isEmpty(hub->errorMessage)) + boolean hubHasError = (!isEmpty(hub->errorMessage)); + if (hubHasError) { ourCellStart(); printf("<span class=\"hubError\">ERROR: %s </span>" "<a TARGET=_BLANK href=\"../goldenPath/help/hgTrackHubHelp.html#Debug\">Debug Help</a>\n", hub->errorMessage); safef(id, sizeof id, "hubClearButton%d", count); // give people a chance to clear the error printf("<input name=\"hubClearButton\" id='%s' " "class=\"hubButton\" type=\"button\" value=\"Retry Hub\">" , id); jsOnEventByIdF("click", id, "document.resetHubForm.elements['hubCheckUrl'].value='%s';" "document.resetHubForm.submit(); return true;", hub->hubUrl); ourCellEnd(); } else if (hub->trackHub != NULL) { if (hub->trackHub->descriptionUrl != NULL) ourPrintCellLink(hub->trackHub->longLabel, hub->trackHub->descriptionUrl); else ourPrintCell(hub->trackHub->longLabel); } else ourPrintCell(""); + if (hub->trackHub != NULL) - printGenomes(hub->trackHub, count); + printGenomes(hub->trackHub, count, !hubHasError); else ourPrintCell(""); puts("</tr>"); } printf("</tbody></TABLE>\n"); printf("</div>"); } static void addPublicHubsToHubStatus(struct sqlConnection *conn, char *publicTable, char *statusTable) /* Add urls in the hubPublic table to the hubStatus table if they aren't there already */ { char query[1024]; @@ -627,55 +633,56 @@ printf("<input name=\"hubConnectButton\" id='%s' " "class=\"hubButton\" type=\"button\" value=\"Connect\">\n", jsId); jsOnEventByIdF("click", jsId, "document.connectHubForm.elements['hubUrl'].value= '%s';" "document.connectHubForm.elements['db'].value= '%s';" "document.connectHubForm.submit();return true;", hubInfo->hubUrl,name); } ourCellEnd(); } else errAbort("cannot get id for hub with url %s\n", hubInfo->hubUrl); ourPrintCellLink(hubInfo->shortLabel, hubInfo->hubUrl); -if (isEmpty(hubInfo->errorMessage)) +boolean hubHasNoError = isEmpty(hubInfo->errorMessage); +if (hubHasNoError) { if (hubInfo->tableHasDescriptionField && !isEmpty(hubInfo->descriptionUrl)) ourPrintCellLink(hubInfo->longLabel, hubInfo->descriptionUrl); else ourPrintCell(hubInfo->longLabel); } else { ourCellStart(); printf("<span class=\"hubError\">ERROR: %s </span>" "<a href=\"../goldenPath/help/hgTrackHubHelp.html#Debug\">Debug Help</a>", hubInfo->errorMessage); safef(jsId, sizeof jsId, "hubClearButton%d", count); printf( "<input name=\"hubClearButton\" id='%s' " "class=\"hubButton\" type=\"button\" value=\"Retry Hub\">" , jsId); jsOnEventByIdF("click", jsId, "document.resetHubForm.elements['hubCheckUrl'].value='%s';" "document.resetHubForm.submit();return true;", hubInfo->hubUrl); ourCellEnd(); } -printGenomeList(hubInfo->hubUrl, dbListNames, count); +printGenomeList(hubInfo->hubUrl, dbListNames, count, hubHasNoError); printf("</tr>\n"); } void printSearchOutputForTrack(struct tdbOutputStructure *tdbOut) /* Write out a <li> entry for a search hit on a track, along with a nested * <ul> for any included hits to subtracks */ { printf("<li configLink='%s' nodeType='track'>\n", dyStringContents(tdbOut->configUrl)); printf("%s", dyStringContents(tdbOut->shortLabel)); if (tdbOut->childCount > 0) printf(" (%d subtrack%s)", tdbOut->childCount, tdbOut->childCount==1?"":"s"); if (isNotEmpty(dyStringContents(tdbOut->metaTags))) { printf("<br><span class='descriptionMatch'><em>Metadata: %s</em></span>\n", dyStringContents(tdbOut->metaTags));