/* configure - Do configuration page. */ #include "common.h" #include "jksql.h" #include "cart.h" #include "hPrint.h" #include "hgColors.h" #include "gisaidTable.h" char *configVarName(struct column *col, char *varName) /* Return variable name for configuration. */ { static char name[64]; safef(name, sizeof(name), "%s%s.%s", colConfigPrefix, col->name, varName); return name; } char *configVarVal(struct column *col, char *varName) /* Return value for configuration variable. Return NULL if it * doesn't exist or if it is "" */ { char *name = configVarName(col, varName); return cartNonemptyString(cart, name); } static void configTable(struct column *colList, struct sqlConnection *conn) /* Write out configuration table */ { struct column *col; char varName[128]; boolean isVis; hPrintf("
"); hPrintf("\n"); /* Write out first row - labels. */ hPrintf(""); hPrintf(""); hPrintf(""); //hPrintf(""); hPrintf(""); //hPrintf(""); /* Print out configuration controls. */ hPrintf(""); /* Write out other rows. */ for (col = colList; col != NULL; col = col->next) { hPrintf(""); /* Do small label. */ hPrintf("", col->shortLabel); /* Do on/off dropdown. */ hPrintf(""); ///* Do left/right button */ //hPrintf(""); /* Do long label. */ hPrintf("", col->longLabel); ///* Do configuration controls. */ //if (col->configControls != NULL) // col->configControls(col); //else // hPrintf(""); hPrintf("\n"); } hPrintf("
NameOnPositionDescriptionConfiguration
%s"); safef(varName, sizeof(varName), "%s%s.vis", colConfigPrefix, col->name); isVis = cartUsualBoolean(cart, varName, col->on); cgiMakeCheckBox(varName, isVis); hPrintf(""); //safef(varName, sizeof(varName), "gisaidTable.do.up.%s", col->name); //if (col != colList) // { // hPrintf(""); // } //safef(varName, sizeof(varName), "gisaidTable.do.down.%s", col->name); //if (col->next != NULL) // { // hPrintf(""); // } //hPrintf("%sn/a
\n"); hPrintf("
"); } // NOTE: this only needed if we start letting user change column order // //static void savePriorities(struct column *colList) ///* Save priority list. */ //{ //struct dyString *dy = dyStringNew(4*1024); //struct column *col; // //for (col = colList; col != NULL; col = col->next) // dyStringPrintf(dy, "%s %f ", col->name, col->priority); //cartSetString(cart, colOrderVar, dy->string); //dyStringFree(&dy); //} static void configControlPanel() /* Put up configuration control panel. */ { //struct userSettings *us = colUserSettings(); controlPanelStart(); hPrintf("\n"); hPrintf("
"); cgiMakeButton("submit", "submit"); hPrintf(" "); hPrintf(" "); hPrintf(""); hPrintf("Columns:"); hPrintf(" "); cgiMakeButton(hideAllConfName, "hide all"); hPrintf(""); cgiMakeButton(showAllConfName, "show all"); hPrintf(""); cgiMakeButton(defaultConfName, "default"); hPrintf(""); //hPrintf("Settings:"); //hPrintf(""); //cgiMakeButton(saveCurrentConfName, "save"); //hPrintf(""); //cgiMakeOptionalButton(useSavedConfName, "load", !userSettingsAnySaved(us)); hPrintf("
"); //hPrintf("\n"); //hPrintf("
"); //hPrintf("Expression ratio colors: "); //hgExpColorDropDown(cart, expRatioColorVarName); //hPrintf(""); //hPrintf("Show all splicing variants: "); //cgiMakeCheckBox(showAllSpliceVarName, // cartUsualBoolean(cart, showAllSpliceVarName, FALSE)); //hPrintf(""); //cgiMakeButton(customPageDoName, "custom columns"); //hPrintf("
"); controlPanelEnd(); } void doConfigure(struct sqlConnection *conn, struct column *colList) //, char *bumpVar) /* Generate configuration page. */ { //if (bumpVar) // bumpColList(bumpVar, &colList); hPrintf("
\n"); //makeTitle("Configure Table View", "gisaidTableHelp.html#Configure"); hotLinks(); configControlPanel(); cartSaveSession(cart); configTable(colList, conn); hPrintf("
"); } // only needed if we allow the order to be changed // //static void restoreDefaultOrder(struct column **pColList) ///* Restore order of columns to default using priority settings. */ //{ //struct column *col; //for (col = *pColList; col != NULL; col = col->next) // { // char *priority = columnSetting(col, "priority", NULL); // if (priority != NULL) // col->priority = atof(priority); // } //slSort(pColList, columnCmpPriority); //} void doDefaultConfigure(struct sqlConnection *conn, struct column *colList) /* Do configuration starting with defaults. */ { struct column *col; for (col=colList; col != NULL; col = col->next) col->on = col->defaultOn; cartRemovePrefix(cart, colConfigPrefix); cartRemove(cart, colOrderVar); //restoreDefaultOrder(&colList); doConfigure(conn, colList); //, NULL); } static void configAllVis(struct sqlConnection *conn, struct column *colList, boolean how) /* Respond to hide all button in configuration page. */ { char varName[64]; struct column *col; for (col = colList; col != NULL; col = col->next) { safef(varName, sizeof(varName), "%s%s.vis", colConfigPrefix, col->name); cartSetBoolean(cart, varName, how); } doConfigure(conn, colList); //, NULL); } void doConfigHideAll(struct sqlConnection *conn, struct column *colList) /* Respond to hide all button in configuration page. */ { configAllVis(conn, colList, 0); } void doConfigShowAll(struct sqlConnection *conn, struct column *colList) /* Respond to hide all button in configuration page. */ { configAllVis(conn, colList, 1); }