09f396b33776cf8466273dfd05ce3d386febb799 braney Thu Jun 5 08:25:27 2014 -0700 some hgHubConnect clean ups diff --git src/hg/hgHubConnect/hgHubConnect.c src/hg/hgHubConnect/hgHubConnect.c index 5cc6245..952a3b1 100644 --- src/hg/hgHubConnect/hgHubConnect.c +++ src/hg/hgHubConnect/hgHubConnect.c @@ -215,33 +215,33 @@ safef(hubName, sizeof(hubName), "%s%u", hgHubConnectHubVarPrefix, hub->id); if (cartUsualBoolean(cart, hubName, FALSE)) printf("<input name=\"hubDisconnectButton\"" "onClick=" "\" document.disconnectHubForm.elements['hubId'].value= '%d';" "document.disconnectHubForm.submit();return true;\" " "class=\"hubDisconnectButton\" type=\"button\" value=\"Disconnect\">\n", hub->id); ourCellEnd(); } else { // give people a chance to clear the error ourCellStart(); printf( "<input name=\"hubClearButton\"" - "onClick=\"document.resetHubForm.elements['hubUrl'].value='%s';" + "onClick=\"document.resetHubForm.elements['hubCheckUrl'].value='%s';" "document.resetHubForm.submit();return true;\" " - "class=\"hubField\" type=\"button\" value=\"check hub\">\n" + "class=\"hubButton\" type=\"button\" value=\"Check Hub\">\n" , hub->hubUrl); ourCellEnd(); } if (hub->trackHub != NULL) { ourPrintCellLink(hub->trackHub->shortLabel, hub->hubUrl); } 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) @@ -290,114 +290,113 @@ char *trixWords[trixWordCount]; trixWordCount = chopString(hubSearchTerms, " ", trixWords, trixWordCount); struct trixSearchResult *tsList = trixSearch(trix, trixWordCount, trixWords, TRUE); for ( ; tsList != NULL; tsList = tsList->next) hashStore(urlSearchHash, tsList->itemId); return urlSearchHash; } static struct hash *outputPublicTable(struct sqlConnection *conn, char *publicTable, char *statusTable) /* Put up the list of public hubs and other controls for the page. */ { char *trixFile = cfgOptionEnvDefault("HUBSEARCHTRIXFILE", "hubSearchTrixFile", "/gbdb/hubs/public.ix"); char *hubSearchTerms = cartOptionalString(cart, hgHubSearchTerms); +char *cleanSearchTerms = cloneString(hubSearchTerms); boolean haveTrixFile = fileExists(trixFile); struct hash *urlSearchHash = NULL; printf("<div id=\"publicHubs\" class=\"hubList\"> \n"); -if (haveTrixFile && !isEmpty(hubSearchTerms)) +// if we have a trix file, draw the search box +if (haveTrixFile) { - strLower(hubSearchTerms); - urlSearchHash = getUrlSearchHash(trixFile, hubSearchTerms); + puts("Enter search terms to find in public track hub description pages:<BR>" + "<input name=\"hubSearchTerms\" id=\"hubSearchTerms\" class=\"hubField\"" + "type=\"text\" size=\"65\"> \n" + "<input name=\"hubSearchButton\"" + "onClick=" + "\" document.searchHubForm.elements['hubSearchTerms'].value=hubSearchTerms.value;" + "document.searchHubForm.submit();return true;\" " + "class=\"hubField\" type=\"button\" value=\"Search Public Hubs\">\n"); + puts("<BR><BR>\n"); } // if we have search terms, put out the line telling the user so -if (!isEmpty(hubSearchTerms)) +if (haveTrixFile && !isEmpty(hubSearchTerms)) { - printf("<BR>List restricted by search terms : %s\n", hubSearchTerms); + printf("List restricted by search terms : %s\n", hubSearchTerms); puts("<input name=\"hubDeleteSearchButton\"" "onClick=" "\" document.searchHubForm.elements['hubSearchTerms'].value=\'\';" "document.searchHubForm.submit();return true;\" " "class=\"hubField\" type=\"button\" value=\"Show All Hubs\">\n"); - printf("<BR>\n"); - } + puts("<BR><BR>\n"); -// if we have a trix file, draw the search box -if (haveTrixFile) - { - puts("<input name=\"hubSearchTerms\" id=\"hubSearchTerms\" class=\"hubField\"" - "type=\"text\" size=\"65\"> \n" - "<input name=\"hubSearchButton\"" - "onClick=" - "\" document.searchHubForm.elements['hubSearchTerms'].value=hubSearchTerms.value;" - "document.searchHubForm.submit();return true;\" " - "class=\"hubField\" type=\"button\" value=\"Search Public Hubs\">\n"); + strLower(cleanSearchTerms); + urlSearchHash = getUrlSearchHash(trixFile, cleanSearchTerms); } +puts("<I>Pressing Connect button will take you to the gateway page with the default assembly for that hub selected.</I><BR>"); // make sure all the public hubs are in the hubStatus table. addPublicHubsToHubStatus(conn, publicTable, statusTable); -struct hash *publicHash = NULL; +struct hash *publicHash = newHash(5); char query[512]; bool hasDescription = sqlColumnExists(conn, publicTable, "descriptionUrl"); if (hasDescription) sqlSafef(query, sizeof(query), "select p.hubUrl,p.shortLabel,p.longLabel,p.dbList,s.errorMessage,s.id,p.descriptionUrl from %s p,%s s where p.hubUrl = s.hubUrl", publicTable, statusTable); else sqlSafef(query, sizeof(query), "select p.hubUrl,p.shortLabel,p.longLabel,p.dbList,s.errorMessage,s.id from %s p,%s s where p.hubUrl = s.hubUrl", publicTable, statusTable); struct sqlResult *sr = sqlGetResult(conn, query); char **row; int count = 0; boolean gotAnyRows = FALSE; while ((row = sqlNextRow(sr)) != NULL) { ++count; char *url = row[0], *shortLabel = row[1], *longLabel = row[2], *dbList = row[3], *errorMessage = row[4], *descriptionUrl = row[6]; int id = atoi(row[5]); + hashStore(publicHash, url); if ((urlSearchHash != NULL) && (hashLookup(urlSearchHash, url) == NULL)) continue; struct slName *dbListNames = slNameListFromComma(dbList); if (gotAnyRows) webPrintLinkTableNewRow(); else { /* output header */ printf("<table id=\"publicHubsTable\"> " "<thead><tr> " "<th>Display</th> " "<th>Hub Name</th> " "<th>Description</th> " "<th>Assemblies</th> " "</tr></thead>\n"); // start first row printf("<tbody> <tr>"); gotAnyRows = TRUE; - - // allocate the hash to store hubUrl's - publicHash = newHash(5); } if ((id != 0) && isEmpty(errorMessage)) { ourCellStart(); char hubName[32]; safef(hubName, sizeof(hubName), "%s%u", hgHubConnectHubVarPrefix, id); if (cartUsualBoolean(cart, hubName, FALSE)) printf("<input name=\"hubDisconnectButton\"" "onClick=" "\" document.disconnectHubForm.elements['hubId'].value= '%d';" "document.disconnectHubForm.submit();return true;\" " "class=\"hubDisconnectButton\" type=\"button\" value=\"Disconnect\">\n", id); else { @@ -406,67 +405,65 @@ // if the name isn't currently loaded, we assume it's a hub if (!hDbExists(name)) { char buffer[512]; safef(buffer, sizeof buffer, "hub_%d_%s", id, name); name = cloneString(buffer); } printf("<input name=\"hubConnectButton\"" "onClick=" "\" document.connectHubForm.elements['hubUrl'].value= '%s';" "document.connectHubForm.elements['db'].value= '%s';" "document.connectHubForm.submit();return true;\" " - "class=\"hubConnectButton\" type=\"button\" value=\"Connect\">\n", url,name); + "class=\"hubButton\" type=\"button\" value=\"Connect\">\n", url,name); } ourCellEnd(); } else if (!isEmpty(errorMessage)) { // give user a chance to clear the error ourCellStart(); printf( "<input name=\"hubClearButton\"" - "onClick=\"document.resetHubForm.elements['hubUrl'].value='%s';" + "onClick=\"document.resetHubForm.elements['hubCheckUrl'].value='%s';" "document.resetHubForm.submit();return true;\" " - "class=\"hubField\" type=\"button\" value=\"check hub\">" + "class=\"hubButton\" type=\"button\" value=\"Check Hub\">" , url); ourCellEnd(); } else errAbort("cannot get id for hub with url %s\n", url); ourPrintCellLink(shortLabel, url); if (isEmpty(errorMessage)) { if (hasDescription && !isEmpty(descriptionUrl)) ourPrintCellLink(longLabel, descriptionUrl); else ourPrintCell(longLabel); } else printf("<TD><span class=\"hubError\">ERROR: %s </span>" "<a href=\"../goldenPath/help/hgTrackHubHelp.html#Debug\">Debug</a></TD>", errorMessage); printGenomeList(dbListNames, count); - - hashStore(publicHash, url); } sqlFreeResult(&sr); if (gotAnyRows) printf("</TR></tbody></TABLE>\n"); printf("</div>"); return publicHash; } struct hash *hgHubConnectPublic() /* Put up the list of public hubs and other controls for the page. */ { struct hash *retHash = NULL; @@ -497,34 +494,35 @@ if (errCatchStart(errCatch)) hub = hubConnectStatusForId(conn, id); errCatchEnd(errCatch); if (errCatch->gotError) hubUpdateStatus( errCatch->message->string, NULL); else hubUpdateStatus(NULL, hub); errCatchFree(&errCatch); hDisconnectCentral(&conn); } static void doResetHub(struct cart *theCart) { -char *url = cartOptionalString(cart, hgHubDataText); +char *url = cartOptionalString(cart, hgHubCheckUrl); if (url != NULL) { + udcSetCacheTimeout(1); unsigned id = hubResetError(url); tryHubOpen(id); } else errAbort("must specify url in %s\n", hgHubDataText); } static void doClearHub(struct cart *theCart) { char *url = cartOptionalString(cart, hgHubDataText); printf("<pre>clearing hub %s\n",url); if (url != NULL) hubClearStatus(url); else @@ -555,31 +553,31 @@ } } void doMiddle(struct cart *theCart) /* Write header and body of html page. */ { cart = theCart; if (cartVarExists(cart, hgHubDoClear)) { doClearHub(cart); cartWebEnd(); return; } -if (cartVarExists(cart, hgHubDoReset)) +if (cartVarExists(cart, hgHubCheckUrl)) { doResetHub(cart); } cartWebStart(cart, NULL, "%s", pageTitle); jsIncludeFile("jquery.js", NULL); jsIncludeFile("utils.js", NULL); jsIncludeFile("jquery-ui.js", NULL); webIncludeResourceFile("jquery-ui.css"); jsIncludeFile("ajax.js", NULL); jsIncludeFile("hgHubConnect.js", NULL); jsIncludeFile("jquery.cookie.js", NULL); @@ -624,33 +622,31 @@ cgiMakeHiddenVar("hubUrl", ""); cgiMakeHiddenVar("db", ""); cgiMakeHiddenVar(hgHubConnectRemakeTrackHub, "on"); puts("</FORM>"); // this is the form for the disconnect hub button printf("<FORM ACTION=\"%s\" NAME=\"disconnectHubForm\">\n", "../cgi-bin/hgGateway"); cgiMakeHiddenVar("db", "hg19"); cgiMakeHiddenVar("hubId", ""); cgiMakeHiddenVar(hgHubDoDisconnect, "on"); cgiMakeHiddenVar(hgHubConnectRemakeTrackHub, "on"); puts("</FORM>"); // this is the form for the reset hub button printf("<FORM ACTION=\"%s\" NAME=\"resetHubForm\">\n", "../cgi-bin/hgHubConnect"); -cgiMakeHiddenVar("hubUrl", ""); -cgiMakeHiddenVar(hgHubDoReset, "on"); -cgiMakeHiddenVar(hgHubConnectRemakeTrackHub, "on"); +cgiMakeHiddenVar(hgHubCheckUrl, ""); puts("</FORM>"); // this is the form for the search hub button printf("<FORM ACTION=\"%s\" NAME=\"searchHubForm\">\n", "../cgi-bin/hgHubConnect"); cgiMakeHiddenVar(hgHubSearchTerms, ""); cgiMakeHiddenVar(hgHubDoSearch, "on"); puts("</FORM>"); // ... and now the main form printf("<FORM ACTION=\"%s\" METHOD=\"POST\" NAME=\"mainForm\">\n", "../cgi-bin/hgGateway"); cartSaveSession(cart); // we have two tabs for the public and unlisted hubs printf("<div id=\"tabs\">" "<ul> <li><a href=\"#publicHubs\">Public Hubs</a></li>" @@ -665,30 +661,30 @@ char *emailAddress = cfgOptionDefault("hub.emailAddress","genome@soe.ucsc.edu"); printf("<span class=\"small\">" "Contact <A HREF=\"mailto:%s\">%s</A> to add a public hub." "</span>\n", emailAddress,emailAddress); printf("</div>"); cgiMakeHiddenVar(hgHubConnectRemakeTrackHub, "on"); printf("</div>\n"); puts("</FORM>"); cartWebEnd(); } char *excludeVars[] = {"Submit", "submit", "hc_one_url", - hgHubDoReset, hgHubDoClear, hgHubDoDisconnect, hgHubDataText, + hgHubCheckUrl, hgHubDoClear, hgHubDoDisconnect, hgHubDataText, hgHubConnectRemakeTrackHub, NULL}; int main(int argc, char *argv[]) /* Process command line. */ { long enteredMainTime = clock1000(); oldVars = hashNew(10); setUdcCacheDir(); cgiSpoof(&argc, argv); cartEmptyShell(doMiddle, hUserCookie(), excludeVars, oldVars); cgiExitTime("hgHubConnect", enteredMainTime); return 0; }