078fcca1d679a770b100f71cfcd514b412f1e88d kent Thu Jan 28 17:50:06 2021 -0800 Commenting and cleaning up code. Making it only show 10 things in a facet by default. diff --git src/hg/hgFacetedBars/hgFacetedBars.c src/hg/hgFacetedBars/hgFacetedBars.c index 9509be2..613821d 100644 --- src/hg/hgFacetedBars/hgFacetedBars.c +++ src/hg/hgFacetedBars/hgFacetedBars.c @@ -13,108 +13,111 @@ #include "udc.h" #include "knetUdc.h" #include "genbank.h" #include "tablesTables.h" /* Global Variables */ struct cart *cart; /* CGI and other variables */ struct hash *oldVars = NULL; char *database = NULL; char *genome = NULL; void doBody() { struct sqlConnection *conn = sqlConnect(database); struct hash *emptyHash = hashNew(0); + +/* Write out html to pull in the other files we use. */ webIncludeResourceFile("facets.css"); printf("\t\t"); printf("\t\t\n" "\n" "\t\t\n" "\t\t\n" "\n" "\t\t\n" "\t\t\n" ); - +/* Working within a form we save context */ printf("
\n"); cartSaveSession(cart); + +/* Fake up a 'track' for development */ +char *trackName = "cellFacetsJk1"; + +/* Set up url that has enough context to get back to us. This is very much a work in + * progress. */ char returnUrl[PATH_LEN*2]; -safef(returnUrl, sizeof(returnUrl), "../cgi-bin/hgFacetedBars?cellFacetsJk1=pack&%s", +safef(returnUrl, sizeof(returnUrl), "../cgi-bin/hgFacetedBars?%s", cartSidUrlString(cart) ); +/* If we got called by a click on a facet deal with that */ char *selOp = cartOptionalString(cart, "browseFiles_facet_op"); if (selOp) { char *selFieldName = cartOptionalString(cart, "browseFiles_facet_fieldName"); char *selFieldVal = cartOptionalString(cart, "browseFiles_facet_fieldVal"); if (selFieldName && selFieldVal) { char *selectedFacetValues=cartUsualString(cart, "cdwSelectedFieldValues", ""); - //warn("selectedFacetValues=[%s] selFieldName=%s selFieldVal=%s selOp=%s", - //selectedFacetValues, selFieldName, selFieldVal, selOp); // DEBUG REMOVE struct facetField *selList = deLinearizeFacetValString(selectedFacetValues); selectedListFacetValUpdate(&selList, selFieldName, selFieldVal, selOp); char *newSelectedFacetValues = linearizeFacetVals(selList); - //warn("newSelectedFacetValues=[%s]", newSelectedFacetValues); // DEBUG REMOVE cartSetString(cart, "cdwSelectedFieldValues", newSelectedFacetValues); cartRemove(cart, "browseFiles_facet_op"); cartRemove(cart, "browseFiles_facet_fieldName"); cartRemove(cart, "browseFiles_facet_fieldVal"); } } - +/* Put up the big faceted search table */ webFilteredSqlTable(cart, conn, - "organ,stage,cell_class,cell_type,id,shortLabel", "cellFacetsJk1", "", - returnUrl, "cellFacetsJk1", 40, + "cell_count,organ,cell_type", trackName, "", + returnUrl, trackName, 32, emptyHash, NULL, - FALSE, "bars", 100, emptyHash, "organ,stage,cell_class,cell_type", + FALSE, NULL, 100, 10, emptyHash, "organ,cell_class,stage,cell_type", NULL); + +/* Clean up and go home. */ printf("
\n"); hashFree(&emptyHash); sqlDisconnect(&conn); } void doMiddle(struct cart *theCart) /* Set up globals and make web page */ { +/* Set some major global variable and attach us to current genome and DB. */ cart = theCart; getDbAndGenome(cart, &database, &genome, oldVars); initGenbankTableNames(database); +/* Set udcTimeout from cart */ int timeout = cartUsualInt(cart, "udcTimeout", 300); if (udcCacheTimeout() < timeout) udcSetCacheTimeout(timeout); knetUdcInstall(); +/* Wrap http/html text around main routine */ htmStart(stdout, "hgFacetedBars"); - doBody(); - htmEnd(stdout); - -#ifdef OLD -cartWebStart(cart, database, "A stand alone to show a faceted barchart selection."); -printf("Your code goes here...."); -cartWebEnd(); -#endif /* OLD */ } /* Null terminated list of CGI Variables we don't want to save * permanently. */ char *excludeVars[] = {"Submit", "submit", NULL,}; int main(int argc, char *argv[]) /* Process command line. */ { cgiSpoof(&argc, argv); cartEmptyShell(doMiddle, hUserCookie(), excludeVars, oldVars); return 0; }