6cbe668f98ab263238542b8fd6bbf860db113930 angie Wed Jan 28 09:55:13 2015 -0800 Several major changes in the way data sources are represented: 1. Instead of the CGI sending menus for group, track and table, make it send the whole tree of groups, tracks, views, subtracks -- "groupedTrackDb". Now the client-side model can make menus that reflect the tree structure. This also gives us flexibility to tweak labels easily. 2. Instead of hardcoding group, track and table into elements of hgai_querySpec.dataSources, make each data source a proper object with a trackPath (path through groupedTrackDb), and for the UI, other attributes like label and URL for hgTables schema page. When the CGI unpacks hgai_querySpec.dataSources, it now uses trackPath and gets table from the leaf track or subtrack (the last item in trackPath). Note: this doesn't work for old Conservation tracks that don't have views/subtracks -- need to figure out how to fudge subtracks for those. 3. Limit the number of data sources to 5, don't let the user add the same data source twice, and remember which track the user most recently selected in the "Add Data Source" section. Also, in hgAi.jsx, I separated out a bunch of things that were rendered in the top-level AppComponent into subcomponents to add some granularity to "Loading..." sections (instead of making the whole page saying "Loading..." until everything is in place). diff --git src/inc/jsonWrite.h src/inc/jsonWrite.h index a0873d1..8f12bf2 100644 --- src/inc/jsonWrite.h +++ src/inc/jsonWrite.h @@ -1,68 +1,71 @@ /* jsonWrite - Helper routines for writing out JSON. */ #ifndef JSONWRITE_H #define JSONWRITE_H struct jsonWrite /* Object to help output JSON */ { struct jsonWrite *next; struct dyString *dy; /* Most of this module is building json text in here */ bool objStack[128]; /* We need stack deep enough to handle nested objects and lists */ int stackIx; /* Current index in stack */ }; struct jsonWrite *jsonWriteNew(); /* Return new empty jsonWrite struct. */ void jsonWriteFree(struct jsonWrite **pJw); /* Free up a jsonWrite object. */ void jsonWriteTag(struct jsonWrite *jw, char *var); /* Print out quoted tag followed by colon. Print out preceding comma if need be. */ void jsonWriteEndLine(struct jsonWrite *jw); /* Write comma if in middle, and then newline regardless. */ void jsonWriteString(struct jsonWrite *jw, char *var, char *string); /* Print out "var": "val". If var is NULL, print val only. If string is NULL, "var": null . */ void jsonWriteDateFromUnix(struct jsonWrite *jw, char *var, long long unixTimeVal); /* Add "var": YYYY-MM-DDT-HH:MM:SSZ given a Unix time stamp. Var may be NULL. */ void jsonWriteNumber(struct jsonWrite *jw, char *var, long long val); /* print out "var": val as number. Var may be NULL. */ +void jsonWriteDouble(struct jsonWrite *jw, char *var, double val); +/* print out "var": val as number. Var may be NULL. */ + void jsonWriteLink(struct jsonWrite *jw, char *var, char *objRoot, char *name); /* Print out the jsony type link to another object. objRoot will start and end with a '/' * and may have additional slashes in this usage. Var may be NULL. */ void jsonWriteLinkNum(struct jsonWrite *jw, char *var, char *objRoot, long long id); /* Print out the jsony type link to another object with a numerical id. objRoot will start * and end with a '/' and may have additional slashes in this usage. Var may be NULL */ void jsonWriteListStart(struct jsonWrite *jw, char *var); /* Start an array in JSON. Var may be NULL */ void jsonWriteListEnd(struct jsonWrite *jw); /* End an array in JSON */ void jsonWriteObjectStart(struct jsonWrite *jw, char *var); /* Print start of object, preceded by tag if var is non-NULL. */ void jsonWriteObjectEnd(struct jsonWrite *jw); /* End object in JSON */ void jsonWriteStringf(struct jsonWrite *jw, char *var, char *format, ...); /* Write "var": "val" where val is jsonStringEscape'd formatted string. */ void jsonWriteBoolean(struct jsonWrite *jw, char *var, boolean val); /* Write out "var": true or "var": false depending on val (no quotes around true/false). */ void jsonWriteValueLabelList(struct jsonWrite *jw, char *var, struct slPair *pairList); /* Print out a named list of {"value": "<pair->name>", "label": "<pair->val>"} objects. */ void jsonWriteSlNameList(struct jsonWrite *jw, char *var, struct slName *slnList); /* Print out a named list of strings from slnList. */ #endif /* JSONWRITE_H */