@isoftdata/utility-dashboard-backend 1.4.3 → 1.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/chart-helper.js +2 -1
- package/index.js +25 -17
- package/package.json +1 -1
package/chart-helper.js
CHANGED
|
@@ -237,12 +237,13 @@ module.exports = {
|
|
|
237
237
|
return {
|
|
238
238
|
property: field,
|
|
239
239
|
name: field,
|
|
240
|
-
class: 'text-right',
|
|
240
|
+
class: 'text-right border-top-0',
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
243
|
return {
|
|
244
244
|
property: field,
|
|
245
245
|
name: field,
|
|
246
|
+
class: 'border-top-0',
|
|
246
247
|
}
|
|
247
248
|
})
|
|
248
249
|
return {
|
package/index.js
CHANGED
|
@@ -31,17 +31,15 @@ const handleChartTypeSpecificQuirks = (chartType, resultSet) => {
|
|
|
31
31
|
return resultSet
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
const loadChartData = async(mysqlConnection, { name, query: queryObject, formatting, chartWrapper, multiSeries, parameters, ...theRest }) => { // needs database connection
|
|
35
|
-
const dataTable = await
|
|
36
|
-
|
|
37
|
-
const proccessedFormatting = handleFormattingTemplates(formatting)
|
|
34
|
+
const loadChartData = async(mysqlConnection, { name, query: queryObject, formatting, chartWrapper, multiSeries, table, parameters, ...theRest }) => { // needs database connection
|
|
35
|
+
const { dataTable, processedFormatting } = await loadDataTableAndProcessedFormatting(mysqlConnection, { query: queryObject, multiSeries, formatting, chartType: chartWrapper.chartType })
|
|
38
36
|
|
|
39
37
|
if (chartWrapper.chartType === 'Table') {
|
|
40
38
|
return {
|
|
41
39
|
...theRest,
|
|
42
40
|
chartWrapper,
|
|
43
|
-
table: dataTable,
|
|
44
|
-
formatting:
|
|
41
|
+
table: { ...table, ...dataTable }, // combine the data and any table setting overrides
|
|
42
|
+
formatting: processedFormatting,
|
|
45
43
|
}
|
|
46
44
|
}
|
|
47
45
|
return {
|
|
@@ -50,7 +48,7 @@ const loadChartData = async(mysqlConnection, { name, query: queryObject, formatt
|
|
|
50
48
|
...chartWrapper,
|
|
51
49
|
dataTable,
|
|
52
50
|
},
|
|
53
|
-
formatting:
|
|
51
|
+
formatting: processedFormatting,
|
|
54
52
|
}
|
|
55
53
|
}
|
|
56
54
|
/*
|
|
@@ -58,25 +56,25 @@ const loadChartData = async(mysqlConnection, { name, query: queryObject, formatt
|
|
|
58
56
|
* Otherwise, it will return data in the google chart Datatable object literal format.
|
|
59
57
|
* multiSeries, formatting properties should be deconstructed from the chart object, chartType should be deconstructed from the chart's chartWrapper property
|
|
60
58
|
*/
|
|
61
|
-
const
|
|
59
|
+
const loadDataTableAndProcessedFormatting = async(mysqlConnection, { query: queryObject, multiSeries, formatting, chartType }) => {
|
|
62
60
|
let { results: queryResultSet, fields } = (queryObject && queryObject.sql) ? await queryWithFields(mysqlConnection, queryObject) : { fields: [], results: [] }
|
|
63
61
|
let data = handleChartTypeSpecificQuirks(chartType, queryResultSet)
|
|
64
62
|
|
|
65
|
-
const proccessedFormatting = handleFormattingTemplates(formatting)
|
|
66
|
-
|
|
67
|
-
if (chartType.toLowerCase() === 'table') {
|
|
68
|
-
return getRactiveTableDataFormat(data, fields, proccessedFormatting)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
63
|
if (multiSeries) {
|
|
72
64
|
({ data, formatting, fields } = getMultiSeriesData({
|
|
73
65
|
data,
|
|
74
66
|
seriesOptions: multiSeries,
|
|
75
|
-
formatting
|
|
67
|
+
formatting,
|
|
76
68
|
fields,
|
|
77
69
|
}))
|
|
78
70
|
}
|
|
79
71
|
|
|
72
|
+
const processedFormatting = handleFormattingTemplates(formatting)
|
|
73
|
+
|
|
74
|
+
if (chartType.toLowerCase() === 'table') {
|
|
75
|
+
return { dataTable: getRactiveTableDataFormat(data, fields, processedFormatting), processedFormatting }
|
|
76
|
+
}
|
|
77
|
+
|
|
80
78
|
let dataTable = getDataTableFormat(data, fields, multiSeries) //per the Google Charts docs, the DataTable object literal format is the most performant, so we'll turn it into that format before returning
|
|
81
79
|
|
|
82
80
|
// Stacked area charts will have holes / jagged lines if there are nulls in the middle of a column
|
|
@@ -85,9 +83,13 @@ const loadDataTable = async(mysqlConnection, { query: queryObject, multiSeries,
|
|
|
85
83
|
dataTable = makeDataCumulative(dataTable)
|
|
86
84
|
}
|
|
87
85
|
|
|
88
|
-
return dataTable
|
|
86
|
+
return { dataTable, processedFormatting }
|
|
89
87
|
}
|
|
90
88
|
|
|
89
|
+
const loadDataTable = async(mysqlConnection, { query: queryObject, multiSeries, formatting, chartType }) => {
|
|
90
|
+
const { dataTable } = await loadDataTableAndProcessedFormatting(mysqlConnection, { query: queryObject, multiSeries, formatting, chartType })
|
|
91
|
+
return dataTable
|
|
92
|
+
}
|
|
91
93
|
const loadOptionList = async(mysqlConnection, optionListQuery, optionList = []) => {
|
|
92
94
|
return [
|
|
93
95
|
...optionList,
|
|
@@ -97,9 +99,14 @@ const loadOptionList = async(mysqlConnection, optionListQuery, optionList = [])
|
|
|
97
99
|
]
|
|
98
100
|
}
|
|
99
101
|
|
|
100
|
-
const loadOutputParameterValues = async(mysqlConnection, { definitionList, selectionList = [], forClient = false }) => {
|
|
102
|
+
const loadOutputParameterValues = async(mysqlConnection, { definitionList = [], selectionList = [], forClient = false }) => {
|
|
101
103
|
let parameterValues = []
|
|
102
104
|
|
|
105
|
+
// If definitionList is not an Array, there are no parameters, so just return []
|
|
106
|
+
if (!(definitionList instanceof Array)) {
|
|
107
|
+
return []
|
|
108
|
+
}
|
|
109
|
+
|
|
103
110
|
for (const definition of definitionList) {
|
|
104
111
|
const matchingParameterSelection = selectionList.find(param => param.name === definition.name)
|
|
105
112
|
|
|
@@ -206,6 +213,7 @@ module.exports = {
|
|
|
206
213
|
},
|
|
207
214
|
loadOutputParameterValues,
|
|
208
215
|
loadDataTable,
|
|
216
|
+
loadDataTableAndProcessedFormatting,
|
|
209
217
|
parameterizeQuery,
|
|
210
218
|
handleFormattingTemplates,
|
|
211
219
|
}
|
package/package.json
CHANGED