Commit 087f8fb21c3934f226d485880456fa7db4966c83
1 parent
a205e8f40d
Exists in
master
and in
1 other branch
expanded list config with live graph
Showing
2 changed files
with
55 additions
and
21 deletions
Show diff stats
json_utility.go
... | ... | @@ -243,16 +243,16 @@ func UpdateEntityModels(command string) (total, upd, add int, err error) { |
243 | 243 | |
244 | 244 | total = len(updateQue) |
245 | 245 | |
246 | - forUpdate := make([]string, 0) | |
247 | - forAdd := make([]string, 0) | |
246 | + toUpdate := make([]string, 0) | |
247 | + toAdd := make([]string, 0) | |
248 | 248 | |
249 | 249 | for k, _ := range updateQue { |
250 | 250 | if _, exists := metadata[k]; exists { |
251 | 251 | if command == "force" { |
252 | - forUpdate = append(forUpdate, k) | |
252 | + toUpdate = append(toUpdate, k) | |
253 | 253 | } |
254 | 254 | } else { |
255 | - forAdd = append(forAdd, k) | |
255 | + toAdd = append(toAdd, k) | |
256 | 256 | } |
257 | 257 | } |
258 | 258 | |
... | ... | @@ -268,7 +268,9 @@ func UpdateEntityModels(command string) (total, upd, add int, err error) { |
268 | 268 | return |
269 | 269 | } |
270 | 270 | } |
271 | - for _, k := range forUpdate { | |
271 | + for _, k := range toUpdate { | |
272 | + //fmt.Printf("Updating: %s\n", k) | |
273 | + //fmt.Printf("New model: %s\n", updateQue[k]) | |
272 | 274 | _, err = uStmt.Exec(string(updateQue[k]), k) |
273 | 275 | if err != nil { |
274 | 276 | logger.Log("webutility: %v\n", err) |
... | ... | @@ -290,7 +292,7 @@ func UpdateEntityModels(command string) (total, upd, add int, err error) { |
290 | 292 | return |
291 | 293 | } |
292 | 294 | } |
293 | - for _, k := range forAdd { | |
295 | + for _, k := range toAdd { | |
294 | 296 | _, err = iStmt.Exec(activeProject, string(blankPayload), k, string(updateQue[k])) |
295 | 297 | if err != nil { |
296 | 298 | logger.Log("webutility: %v\n", err) | ... | ... |
list_config.go
... | ... | @@ -42,12 +42,13 @@ type ListGraph struct { |
42 | 42 | } |
43 | 43 | |
44 | 44 | type ListActions struct { |
45 | - Create bool `json:"create"` | |
46 | - Update bool `json:"update"` | |
47 | - Delete bool `json:"delete"` | |
48 | - Export bool `json:"export"` | |
49 | - Print bool `json:"print"` | |
50 | - Graph bool `json:"graph"` | |
45 | + Create bool `json:"create"` | |
46 | + Update bool `json:"update"` | |
47 | + Delete bool `json:"delete"` | |
48 | + Export bool `json:"export"` | |
49 | + Print bool `json:"print"` | |
50 | + Graph bool `json:"graph"` | |
51 | + LiveGraph bool `json:"liveGraph"` | |
51 | 52 | } |
52 | 53 | |
53 | 54 | type ListNavNode struct { |
... | ... | @@ -79,6 +80,12 @@ type ListDetails struct { |
79 | 80 | SingleDetail bool `json:"singleDetail"` |
80 | 81 | } |
81 | 82 | |
83 | +type ListLiveGraph struct { | |
84 | + ObjectType string `json:"objectType"` | |
85 | + ValueFields string `json:"valueFields"` | |
86 | + LabelFields string `json:"labelFields"` | |
87 | +} | |
88 | + | |
82 | 89 | type ListConfig struct { |
83 | 90 | ObjectType string `json:"objectType"` |
84 | 91 | Title string `json:"title"` |
... | ... | @@ -92,6 +99,7 @@ type ListConfig struct { |
92 | 99 | Navigation []ListNavNode `json:"navigation"` |
93 | 100 | Pivots []ListPivot `json:"pivots"` |
94 | 101 | Details ListDetails `json:"details"` |
102 | + LiveGraph ListLiveGraph `json:"liveGraphs"` | |
95 | 103 | } |
96 | 104 | |
97 | 105 | // GetListConfig returns list configuration for the provided object type for the front-end application |
... | ... | @@ -109,6 +117,7 @@ func GetListConfig(db *sql.DB, objType string) (ListConfig, error) { |
109 | 117 | resp.Graphs, err = getListGraph(db, objType) |
110 | 118 | resp.Pivots, err = getListPivot(db, objType) |
111 | 119 | resp.Details, err = getListDetails(db, objType) |
120 | + resp.LiveGraph, err = getListLiveGraph(db, objType) | |
112 | 121 | |
113 | 122 | if err != nil { |
114 | 123 | return ListConfig{}, err |
... | ... | @@ -157,12 +166,13 @@ func newDefaultList(objType string) ListConfig { |
157 | 166 | }, |
158 | 167 | Filters: nil, |
159 | 168 | Actions: ListActions{ |
160 | - Create: false, | |
161 | - Update: false, | |
162 | - Delete: false, | |
163 | - Export: false, | |
164 | - Print: false, | |
165 | - Graph: false, | |
169 | + Create: false, | |
170 | + Update: false, | |
171 | + Delete: false, | |
172 | + Export: false, | |
173 | + Print: false, | |
174 | + Graph: false, | |
175 | + LiveGraph: false, | |
166 | 176 | }, |
167 | 177 | Parent: nil, |
168 | 178 | Navigation: nil, |
... | ... | @@ -233,7 +243,7 @@ func getListActions(db *sql.DB, objType string) (ListActions, error) { |
233 | 243 | var resp ListActions |
234 | 244 | rows, err := db.Query(`SELECT |
235 | 245 | ACTION_CREATE, ACTION_UPDATE, ACTION_DELETE, ACTION_EXPORT, |
236 | - ACTION_PRINT, ACTION_GRAPH | |
246 | + ACTION_PRINT, ACTION_GRAPH, ACTION_LIVE_GRAPH | |
237 | 247 | FROM LIST_CONFIG |
238 | 248 | WHERE OBJECT_TYPE = ` + fmt.Sprintf("'%s'", objType)) |
239 | 249 | if err != nil { |
... | ... | @@ -241,15 +251,16 @@ func getListActions(db *sql.DB, objType string) (ListActions, error) { |
241 | 251 | } |
242 | 252 | defer rows.Close() |
243 | 253 | |
244 | - var create, update, delete, export, print, graph uint32 | |
254 | + var create, update, delete, export, print, graph, liveGraph uint32 | |
245 | 255 | if rows.Next() { |
246 | - rows.Scan(&create, &update, &delete, &export, &print, &graph) | |
256 | + rows.Scan(&create, &update, &delete, &export, &print, &graph, &liveGraph) | |
247 | 257 | resp.Create = create != 0 |
248 | 258 | resp.Update = update != 0 |
249 | 259 | resp.Delete = delete != 0 |
250 | 260 | resp.Export = export != 0 |
251 | 261 | resp.Print = print != 0 |
252 | 262 | resp.Graph = graph != 0 |
263 | + resp.LiveGraph = liveGraph != 0 | |
253 | 264 | } |
254 | 265 | if rows.Err() != nil { |
255 | 266 | return ListActions{}, rows.Err() |
... | ... | @@ -502,3 +513,24 @@ func getListDetails(db *sql.DB, objType string) (ListDetails, error) { |
502 | 513 | |
503 | 514 | return resp, nil |
504 | 515 | } |
516 | + | |
517 | +// getListLiveGraph returns live graph for the provided object type. | |
518 | +func getListLiveGraph(db *sql.DB, objType string) (ListLiveGraph, error) { | |
519 | + var resp ListLiveGraph | |
520 | + rows, err := db.Query(`SELECT | |
521 | + OBJECT_TYPE, VALUE_FIELDS, LABEL_FIELDS | |
522 | + FROM LIST_LIVE_GRAPH | |
523 | + WHERE OBJECT_TYPE = ` + fmt.Sprintf("'%s'", objType)) | |
524 | + if err != nil { | |
525 | + return resp, err | |
526 | + } | |
527 | + defer rows.Close() | |
528 | + if rows.Next() { | |
529 | + rows.Scan(&resp.ObjectType, &resp.ValueFields, &resp.LabelFields) | |
530 | + } | |
531 | + if rows.Err() != nil { | |
532 | + return resp, rows.Err() | |
533 | + } | |
534 | + | |
535 | + return resp, nil | |
536 | +} | ... | ... |