@isoftdata/utility-dashboard-backend 1.4.1 → 1.4.2

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.
Files changed (2) hide show
  1. package/index.js +11 -9
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -31,7 +31,7 @@ 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
34
+ const loadChartData = async(mysqlConnection, { name, query: queryObject, formatting, chartWrapper, multiSeries, parameters, ...theRest }) => { // needs database connection
35
35
  const dataTable = await loadDataTable(mysqlConnection, { query: queryObject, multiSeries, formatting, chartType: chartWrapper.chartType })
36
36
 
37
37
  const proccessedFormatting = handleFormattingTemplates(formatting)
@@ -58,19 +58,21 @@ const loadChartData = async (mysqlConnection, { name, query: queryObject, format
58
58
  * Otherwise, it will return data in the google chart Datatable object literal format.
59
59
  * multiSeries, formatting properties should be deconstructed from the chart object, chartType should be deconstructed from the chart's chartWrapper property
60
60
  */
61
- const loadDataTable = async (mysqlConnection, { query: queryObject, multiSeries, formatting, chartType }) => {
61
+ const loadDataTable = async(mysqlConnection, { query: queryObject, multiSeries, formatting, chartType }) => {
62
62
  let { results: queryResultSet, fields } = (queryObject && queryObject.sql) ? await queryWithFields(mysqlConnection, queryObject) : { fields: [], results: [] }
63
63
  let data = handleChartTypeSpecificQuirks(chartType, queryResultSet)
64
64
 
65
+ const proccessedFormatting = handleFormattingTemplates(formatting)
66
+
65
67
  if (chartType.toLowerCase() === 'table') {
66
- return getRactiveTableDataFormat(data, fields, formatting)
68
+ return getRactiveTableDataFormat(data, fields, proccessedFormatting)
67
69
  }
68
70
 
69
71
  if (multiSeries) {
70
72
  ({ data, formatting, fields } = getMultiSeriesData({
71
73
  data,
72
74
  seriesOptions: multiSeries,
73
- formatting,
75
+ formatting: proccessedFormatting,
74
76
  fields,
75
77
  }))
76
78
  }
@@ -86,7 +88,7 @@ const loadDataTable = async (mysqlConnection, { query: queryObject, multiSeries,
86
88
  return dataTable
87
89
  }
88
90
 
89
- const loadOptionList = async (mysqlConnection, optionListQuery, optionList = []) => {
91
+ const loadOptionList = async(mysqlConnection, optionListQuery, optionList = []) => {
90
92
  return [
91
93
  ...optionList,
92
94
  // ...(optionListQuery && await query(mysqlConnection, optionListQuery)) || [],
@@ -95,7 +97,7 @@ const loadOptionList = async (mysqlConnection, optionListQuery, optionList = [])
95
97
  ]
96
98
  }
97
99
 
98
- const loadOutputParameterValues = async (mysqlConnection, { definitionList, selectionList = [], forClient = false }) => {
100
+ const loadOutputParameterValues = async(mysqlConnection, { definitionList, selectionList = [], forClient = false }) => {
99
101
  let parameterValues = []
100
102
 
101
103
  for (const definition of definitionList) {
@@ -156,7 +158,7 @@ const parameterizeQuery = (query, parameterValues) => {
156
158
  //Then include a capture group to get the inner part of that to use as a key
157
159
  const regexp = /\${([^}]+)}/g
158
160
 
159
- const queryParameterKeys = [...query.matchAll(regexp)].map(([fullToken, insideToken]) => insideToken.trim())
161
+ const queryParameterKeys = [ ...query.matchAll(regexp) ].map(([ fullToken, insideToken ]) => insideToken.trim())
160
162
  //if they put a token in the query that isn't one of the defined parameters of the report, just return null?
161
163
  const queryParameters = queryParameterKeys.map(key => queryParameterValues[key] || null)
162
164
 
@@ -167,7 +169,7 @@ const parameterizeQuery = (query, parameterValues) => {
167
169
  }
168
170
 
169
171
  module.exports = {
170
- formatReportMetadata: async (mysqlConnection, { report, chartsInReport }) => {
172
+ formatReportMetadata: async(mysqlConnection, { report, chartsInReport }) => {
171
173
  try {
172
174
  const parameterValues = await loadOutputParameterValues(mysqlConnection, { definitionList: report.parameters, forClient: true })
173
175
 
@@ -184,7 +186,7 @@ module.exports = {
184
186
  throw err
185
187
  }
186
188
  },
187
- formatChartDataForReport: async (mysqlConnection, { reportParameters, chart, reportChart, parameterSelectionList }) => {
189
+ formatChartDataForReport: async(mysqlConnection, { reportParameters, chart, reportChart, parameterSelectionList }) => {
188
190
  try {
189
191
  const parameterValues = await loadOutputParameterValues(mysqlConnection, { definitionList: reportParameters, selectionList: parameterSelectionList })
190
192
  if (reportChart?.jsonOverride?.chartWrapper?.dataTable) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@isoftdata/utility-dashboard-backend",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "description": "A utility for formatting chart and report data to be usable by the frontend dashboard component.",
5
5
  "main": "index.js",
6
6
  "scripts": {