19e6e03d64ce54f9db60a93734cd3b573eb0446b kent Fri Jan 29 09:07:37 2021 -0800 I believe I got all the faceted variables using the varPrefix. Tested this by having two faceted tables on the same page and it worked. Looks clean by cartDump too. diff --git src/hg/cirm/cdw/cdwWebBrowse/cdwWebBrowse.c src/hg/cirm/cdw/cdwWebBrowse/cdwWebBrowse.c index db1072a..aff6340 100644 --- src/hg/cirm/cdw/cdwWebBrowse/cdwWebBrowse.c +++ src/hg/cirm/cdw/cdwWebBrowse/cdwWebBrowse.c @@ -137,31 +137,31 @@ { printf("", val, cartSidUrlString(cart)); printf("%s", shortVal); } void wrapTagValueInFiles(struct fieldedTable *table, struct fieldedRow *row, char *field, char *val, char *shortVal, void *context) /* Write out wrapper that links us to something nice */ { printf("%s", shortVal); } void wrapFileSize(struct fieldedTable *table, struct fieldedRow *row, char * field, char *val, char *shortVal, void *context) /* Write out wrapper that displays file sizes in human-readable format */ { if (!isdigit(val[0])) warn("Warning: expected a number for file_size, but got %s", val); double fVal = atof(val); char* valQual = ""; int intVal = 0; if (fVal>=1E12) { @@ -895,31 +895,31 @@ { // get query of files that match and where we have access struct cdwFile *efList = NULL; struct dyString *accWhere; char *fields; searchFilesWithAccess(conn, searchString, fileTableFields, initialWhere, &efList, &accWhere, &fields, FALSE); // reduce query to those that match our filters struct dyString *dummy; struct dyString *filteredWhere; char *table = isEmpty(initialWhere) ? getCdwTableSetting("cdwFileFacets") : getCdwTableSetting("cdwFileTags"); webTableBuildQuery(cart, table, accWhere->string, "cdwBrowseFiles", fileTableFields, FALSE, &dummy, &filteredWhere); // Selected Facet Values Filtering -char *selectedFacetValues=cartUsualString(cart, "cdwSelectedFieldValues", ""); +char *selectedFacetValues=cartUsualString(cart, "cdwBrowseFiles_facet_selList", ""); struct facetField *selectedList = deLinearizeFacetValString(selectedFacetValues); struct facetField *sff = NULL; struct dyString *facetedWhere = dyStringNew(1024); for (sff = selectedList; sff; sff=sff->next) { if (slCount(sff->valList)>0) { sqlDyStringPrintfFrag(facetedWhere, " and "); // use Frag to prevent NOSQLINJ tag sqlDyStringPrintf(facetedWhere, "ifnull(%s,'n/a') in (", sff->fieldName); struct facetVal *el; for (el=sff->valList; el; el=el->next) { sqlDyStringPrintf(facetedWhere, "'%s'", el->val); if (el->next) sqlDyStringPrintf(facetedWhere, ","); @@ -953,31 +953,31 @@ char varName[1024]; safef(varName, sizeof(varName), "cdwBrowseFiles_f_%s", fieldNames[i]); cgiContinueHiddenVar(varName); } } void makeDownloadAllButtonForm(int count) /* The "download all" button cannot be a form at this place, nested forms are * not allowed in html. So create a link instead. */ { if (count<0) errAbort("Error: Search results in a negative number of files found"); printf("Download %d File%s", count, count>1?"s":""); printf("

\n"); } char *createTokenForUser() /* create a random token and add it to the cdwDownloadToken table with the current username. * Returns token, should be freed.*/ { struct sqlConnection *conn = hConnectCentral(); // r/w access -> has to be in hgcentral char query[4096]; if (!sqlTableExists(conn, "cdwDownloadToken")) { sqlSafef(query, sizeof(query), "CREATE TABLE cdwDownloadToken (token varchar(255) NOT NULL PRIMARY KEY, " "userId int NOT NULL, createTime datetime DEFAULT NOW())"); @@ -1073,31 +1073,31 @@ } // if we recreate the submission dir structure, we need to create a shell script boolean createSubdirs = FALSE; if (sameOk(cgiOptionalString("cdwDownloadName"), "subAndDir")) createSubdirs = TRUE; cart = cartAndCookieWithHtml(hUserCookie(), excludeVars, oldVars, FALSE); if (createSubdirs) puts("Content-disposition: attachment; filename=downloadCirm.sh\n"); else puts("Content-disposition: attachment; filename=fileUrls.txt\n"); char *searchString = unquotedCartString(cart, "cdwFileSearch"); -char *initialWhere = cartUsualString(cart, "cdwFile_filter", ""); +char *initialWhere = cartUsualString(cart, "cdwBrowseFiles_filter", ""); struct cdwFile *efList = findDownloadableFiles(conn, cart, initialWhere, searchString); char *host = hHttpHost(); // user may want to download with original submitted filename, not with format . char *optArg = ""; if (sameOk(cgiOptionalString("cdwDownloadName"), "sub")) optArg = "&useSubmitFname=1"; struct cdwFile *ef; for (ef = efList; ef != NULL; ef = ef->next) { struct cdwValidFile *vf = cdwValidFileFromFileId(conn, ef->id); @@ -1135,31 +1135,31 @@ /* show overview page of download files */ { if (user==NULL && !isPublicSite) { printf("Sorry, you have to log in before you can download files."); return; } printf("
\n"); cartSaveSession(cart); cgiMakeHiddenVar("cdwCommand", "downloadUrls"); continueSearchVars(); char *searchString = unquotedCartString(cart, "cdwFileSearch"); -char *initialWhere = cartUsualString(cart, "cdwFile_filter", ""); +char *initialWhere = cartUsualString(cart, "cdwBrowseFiles_filter", ""); struct cdwFile *efList = findDownloadableFiles(conn, cart, initialWhere, searchString); // get total size struct cdwFile *ef; long long size = 0; for (ef = efList; ef != NULL; ef = ef->next) size += ef->size; int fCount = slCount(efList); char sizeStr[4096]; sprintWithGreekByte(sizeStr, sizeof(sizeStr), size); printf("

Data Download Options

\n"); printf("Number of files: %d
\n", fCount); @@ -1224,31 +1224,31 @@ puts("
\n"); cdwFileFreeList(&efList); } void doBrowseFiles(struct sqlConnection *conn) /* Print list of files */ { printf("\n"); cartSaveSession(cart); cgiMakeHiddenVar("cdwCommand", "browseFiles"); cgiMakeHiddenVar("clearRestriction", "0"); char *clearRestriction = cartOptionalString(cart, "clearRestriction"); if (clearRestriction && sameString(clearRestriction,"1")) { - cartSetString(cart, "cdwFile_filter", ""); // reset file filter to empty string + cartSetString(cart, "cdwBrowseFiles_filter", ""); // reset file filter to empty string cartRemove(cart, "clearRestriction"); } // DEBUG REMOVE //char *varName = "cdwSelectedFieldValues"; //char *varVal = cartUsualString(cart, varName, ""); //warn("varName=[%s] varVal=[%s]", varName, varVal); // DEBUG REMOVE //warn("getCdwTableSetting(cdwFileFacets)=%s", getCdwTableSetting("cdwFileFacets")); // DEBUG REMOVE char *selOp = cartOptionalString(cart, "cdwBrowseFiles_facet_op"); if (selOp) { char *selFieldName = cartOptionalString(cart, "cdwBrowseFiles_facet_fieldName"); char *selFieldVal = cartOptionalString(cart, "cdwBrowseFiles_facet_fieldVal"); @@ -1264,31 +1264,31 @@ cartSetString(cart, "cdwSelectedFieldValues", newSelectedFacetValues); cartRemove(cart, "cdwBrowseFiles_facet_op"); cartRemove(cart, "cdwBrowseFiles_facet_fieldName"); cartRemove(cart, "cdwBrowseFiles_facet_fieldVal"); } } printf("Click on file's name to see full metadata."); printf(" Links in ucsc_db go to the Genome Browser.
\n"); char *searchString = showSearchControl("cdwFileSearch", "files"); /* Put up big filtered table of files */ char returnUrl[PATH_LEN*2]; safef(returnUrl, sizeof(returnUrl), "../cgi-bin/cdwWebBrowse?cdwCommand=browseFiles&%s", cartSidUrlString(cart) ); -char *where = cartUsualString(cart, "cdwFile_filter", ""); +char *where = cartUsualString(cart, "cdwBrowseFiles_filter", ""); struct hash *wrappers = hashNew(0); hashAdd(wrappers, "file_name", wrapFileName); hashAdd(wrappers, "ucsc_db", wrapTrackNearFileName); hashAdd(wrappers, "format", wrapFormat); hashAdd(wrappers, "file_size", wrapFileSize); accessibleFilesTable(cart, conn, searchString, fileTableFields, isEmpty(where) ? getCdwTableSetting("cdwFileFacets") : getCdwTableSetting("cdwFileTags"), where, returnUrl, "cdwBrowseFiles", 18, wrappers, conn, FALSE, "files", 100, visibleFacetFields, TRUE); printf("\n"); } @@ -1398,35 +1398,35 @@ sqlSafef(query, sizeof(query), "select id from cdwSubmitDir where url='/data/cirm/wrangle/%s'", datasetId); int submitDirId = sqlQuickNum(conn, query); // If the ID exists and the user has access print a link to the page. int fileId = getRecentSubmitFileId(conn, submitDirId, "summary/index.html"); boolean haveAccess = ((fileId > 0) && cdwCheckFileAccess(conn, fileId, user)); if (haveAccess) { printf("
  • %s (%s)
    \n", datasetId, label, datasetId); // Print out file count and descriptions. sqlSafef(query, sizeof(query), "select count(*) from %s where data_set_id='%s'", getCdwTableSetting("cdwFileTags"), datasetId); long long fileCount = sqlQuickLongLong(conn, query); -// printf("%s (%lld files)",fileCount); int fileId = getRecentSubmitFileId(conn, submitDirId, "meta.txt"); if ((fileId > 0) && cdwCheckFileAccess(conn, fileId, user)) { printf(" (metadata: html"); doServeTagStorm(conn, datasetId); } } else // Otherwise print a label and description. { printf("
  • %s (%s)
    \n", label, datasetId);