e00cb63405632c064e4228a97139b56d05274c82 braney Wed Nov 14 16:50:09 2012 -0800 fix bug in keeping track of error message introduced last cycle (#9609). Also fix bug in unlisted hubs where assembly was listed incorrectly. diff --git src/hg/hgHubConnect/hgHubConnect.c src/hg/hgHubConnect/hgHubConnect.c index dd0ff6a..4cf21fc 100644 --- src/hg/hgHubConnect/hgHubConnect.c +++ src/hg/hgHubConnect/hgHubConnect.c @@ -55,101 +55,80 @@ ourCellEnd(); } static char *removeLastComma(char *string) { if (string != NULL) { int len = strlen(string); if ( string[len - 1] == ',') string[len - 1] = 0; } return string; } -static void addGenomesToHash(struct hubConnectStatus *hub, struct hash *hash) -/* add supported assembly names from trackHub to hash */ -{ -if (hub == NULL) - return; - -struct trackHub *thub = hub->trackHub; -if (thub != NULL) +static void printGenomes(struct trackHub *thub) +/* print supported assembly names from trackHub */ { /* List of associated genomes. */ struct trackHubGenome *genomes = thub->genomeList; +struct dyString *dy = newDyString(100); for(; genomes; genomes = genomes->next) - hashStore(hash, genomes->name); - } + dyStringPrintf(dy,"%s,", genomes->name); +ourPrintCell(removeLastComma( dyStringCannibalize(&dy))); } 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\"" "type=\"text\" size=\"65\"> \n" "<input name=\"hubAddButton\"" "onClick=\"hubText.value=$.trim(hubText.value);if(validateUrl($('#hubUrl').val())) { document.addHubForm.elements['hubUrl'].value=hubText.value;" "document.addHubForm.submit();return true;} else { return false;}\" " "class=\"hubField\" type=\"button\" value=\"Add Hub\">\n" "</th> \n" "</tr> \n"); // count up the number of unlisted hubs we currently have int unlistedHubCount = 0; struct hubConnectStatus *unlistedHubList = NULL; struct hubConnectStatus *hub, *nextHub; -struct hash *assHash = newHash(5); for(hub = hubList; hub; hub = nextHub) { nextHub = hub->next; // if url is not in publicHash, it's unlisted */ if (!((publicHash != NULL) && hashLookup(publicHash, hub->hubUrl))) { - addGenomesToHash(hub, assHash); unlistedHubCount++; slAddHead(&unlistedHubList, hub); } } hubList = NULL; // hubList no longer valid -struct hashCookie cookie = hashFirst(assHash); -struct dyString *dy = newDyString(100); -struct hashEl *hel; -int numAssemblies = 0; -while ((hel = hashNext(&cookie)) != NULL) - { - dyStringPrintf(dy,"%s,", hel->name); - numAssemblies++; - } - -char *dbList = NULL; -if (numAssemblies) - dbList = dyStringCannibalize(&dy); - if (unlistedHubCount == 0) { // nothing to see here printf("<tr><td>No Unlisted Track Hubs</td></tr>"); printf("</thead></table></div>"); return; } // time to output the big table. First the header printf( "<tr> " "<th>Display</th> " "<th>Hub Name</th> " "<th>Description</th> " "<th>Assemblies</th> " @@ -191,31 +170,34 @@ } if (hub->trackHub != NULL) ourPrintCell(hub->trackHub->shortLabel); else ourPrintCell(""); if (!isEmpty(hub->errorMessage)) printf("<TD><span class=\"hubError\">ERROR: %s </span>" "<a href=\"../goldenPath/help/hgTrackHubHelp.html#Debug\">Debug</a></TD>\n", hub->errorMessage); else if (hub->trackHub != NULL) ourPrintCell(hub->trackHub->longLabel); else ourPrintCell(""); - ourPrintCell(removeLastComma(dbList)); + if (hub->trackHub != NULL) + printGenomes(hub->trackHub); + else + ourPrintCell(""); ourPrintCell(hub->hubUrl); ourCellStart(); printf( "<input name=\"hubDisconnectButton\"" "onClick=\"document.disconnectHubForm.elements['hubId'].value='%d';" "document.disconnectHubForm.submit();return true;\" " "class=\"hubField\" type=\"button\" value=\"X\">\n" , hub->id); ourCellEnd(); } printf("</TR></tbody></TABLE>\n"); printf("</div>"); }