@isoftdata/utility-dashboard-backend 1.5.2 → 1.5.4

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.
@@ -0,0 +1,65 @@
1
+ /*
2
+ SQLyog Ultimate v13.1.7 (64 bit)
3
+ MySQL - 5.7.15-log : Database - itrackpro
4
+ *********************************************************************
5
+ */
6
+
7
+ /*!40101 SET NAMES utf8 */;
8
+
9
+ /*!40101 SET SQL_MODE=''*/;
10
+
11
+ /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
12
+ /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
13
+ /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
14
+ /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
15
+ /*Table structure for table `dashboard_chart` */
16
+
17
+ DROP TABLE IF EXISTS `dashboard_chart`;
18
+
19
+ CREATE TABLE `dashboard_chart` (
20
+ `chart_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
21
+ `name` VARCHAR(64) NOT NULL COMMENT 'Internal name.',
22
+ `title` VARCHAR(64) NOT NULL COMMENT 'Title shown to user.',
23
+ `supertype` ENUM('google','table','embed') NOT NULL DEFAULT 'google' COMMENT 'Designates how the chart needs to be loaded and displayed.',
24
+ `json` TEXT NOT NULL COMMENT 'JSON options for charts.',
25
+ `show_chart` BIT(1) NOT NULL DEFAULT b'1' COMMENT 'Whether to show the chart in the charts list in the configuration screen.',
26
+ PRIMARY KEY (`chart_id`)
27
+ ) ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
28
+
29
+ /*Table structure for table `dashboard_report` */
30
+
31
+ DROP TABLE IF EXISTS `dashboard_report`;
32
+
33
+ CREATE TABLE `dashboard_report` (
34
+ `dashboard_report_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
35
+ `report_name` VARCHAR(64) NOT NULL COMMENT 'Used internally in the program. Snake case.',
36
+ `report_title` VARCHAR(64) NOT NULL COMMENT 'Shown to the user.',
37
+ `json` TEXT NOT NULL COMMENT 'Parameters for the report. Array of objects.',
38
+ `share_type` ENUM('user','group','store','everyone') NOT NULL DEFAULT 'everyone' COMMENT 'The type of id to use for sharing',
39
+ `share_id` INT(11) DEFAULT NULL COMMENT 'User/Group/Store Id',
40
+ `owner_id` INT(10) DEFAULT NULL COMMENT 'ID of the user who created the report. Used to control edit permissions on the client.',
41
+ PRIMARY KEY (`dashboard_report_id`)
42
+ ) ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
43
+
44
+ /*Table structure for table `dashboard_report_chart` */
45
+
46
+ DROP TABLE IF EXISTS `dashboard_report_chart`;
47
+
48
+ CREATE TABLE `dashboard_report_chart` (
49
+ `report_chart_id` INT(11) NOT NULL AUTO_INCREMENT,
50
+ `dashboard_report_id` INT(10) UNSIGNED NOT NULL,
51
+ `chart_id` INT(10) UNSIGNED NOT NULL,
52
+ `rank` TINYINT(3) UNSIGNED NOT NULL DEFAULT '1' COMMENT 'Order to display this chart in this report.',
53
+ `json_override` TEXT COMMENT 'Json - report-specific overrides for chart options.',
54
+ PRIMARY KEY (`report_chart_id`),
55
+ UNIQUE KEY `UC_Report_Chart` (`dashboard_report_id`,`chart_id`),
56
+ KEY `maptochart` (`chart_id`),
57
+ KEY `reporttomap` (`dashboard_report_id`),
58
+ CONSTRAINT `maptochart` FOREIGN KEY (`chart_id`) REFERENCES `dashboard_chart` (`chart_id`) ON DELETE CASCADE ON UPDATE CASCADE,
59
+ CONSTRAINT `reporttomap` FOREIGN KEY (`dashboard_report_id`) REFERENCES `dashboard_report` (`dashboard_report_id`) ON DELETE CASCADE ON UPDATE CASCADE
60
+ ) ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
61
+
62
+ /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
63
+ /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
64
+ /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
65
+ /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
package/index.js CHANGED
@@ -36,7 +36,15 @@ const handleChartTypeSpecificQuirks = (chartType, resultSet) => {
36
36
  }
37
37
 
38
38
  const loadChartData = async(mysqlConnection, { name, query: queryObject, formatting, chartWrapper, multiSeries, table, parameters, supertype, ...theRest }) => { // needs database connection
39
- const { dataTable, processedFormatting } = await loadDataTableAndProcessedFormatting(mysqlConnection, { query: queryObject, multiSeries, formatting, chartType: chartWrapper?.chartType || supertype })
39
+ if (!chartWrapper) {
40
+ chartWrapper = {
41
+ chartType: supertype,
42
+ options: {
43
+ height: 450, width: 800,
44
+ },
45
+ }
46
+ }
47
+ const { dataTable, processedFormatting } = await loadDataTableAndProcessedFormatting(mysqlConnection, { query: queryObject, multiSeries, formatting, chartType: chartWrapper?.chartType })
40
48
 
41
49
  if (chartWrapper?.chartType === 'Table') {
42
50
  return {
@@ -75,7 +83,7 @@ const loadDataTableAndProcessedFormatting = async(mysqlConnection, { query: quer
75
83
 
76
84
  const processedFormatting = handleFormattingTemplates(formatting)
77
85
 
78
- if (chartType.toLowerCase() === 'table') {
86
+ if (chartType?.toLowerCase() === 'table') {
79
87
  return { dataTable: getRactiveTableDataFormat(data, fields, processedFormatting), processedFormatting }
80
88
  }
81
89
 
@@ -230,6 +238,7 @@ module.exports = {
230
238
  }
231
239
  return await loadChartData(mysqlConnection, {
232
240
  ...chart,
241
+ rank: reportChart.rank,
233
242
  reportChartId: reportChart.reportChartId,
234
243
  ...reportChart.jsonOverride, // overwrites whole chart wrapper :\
235
244
  query: parameterizeQuery(chart.query, parameterValues),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@isoftdata/utility-dashboard-backend",
3
- "version": "1.5.2",
3
+ "version": "1.5.4",
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": {