@pxp-nd/core 1.2.74 → 1.2.75
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/README.md +1 -1
- package/dist/PxpApp.d.ts +54 -54
- package/dist/PxpApp.js +283 -284
- package/dist/ScriptManager.d.ts +1 -1
- package/dist/ScriptManager.js +130 -130
- package/dist/database/script.d.ts +16 -16
- package/dist/database/script.js +143 -143
- package/dist/db.datasource.d.ts +2 -2
- package/dist/db.datasource.js +86 -86
- package/dist/entities/Log.d.ts +32 -32
- package/dist/entities/Log.js +95 -95
- package/dist/entities/ScriptVersion.d.ts +19 -19
- package/dist/entities/ScriptVersion.js +43 -43
- package/dist/index.d.ts +11 -11
- package/dist/index.js +28 -28
- package/dist/interfaces.d.ts +49 -49
- package/dist/interfaces.js +3 -3
- package/dist/lib/pxp/Controller.d.ts +51 -51
- package/dist/lib/pxp/Controller.js +377 -377
- package/dist/lib/pxp/ControllerInterface.d.ts +18 -18
- package/dist/lib/pxp/ControllerInterface.js +2 -2
- package/dist/lib/pxp/Decorators.d.ts +23 -23
- package/dist/lib/pxp/Decorators.js +123 -123
- package/dist/lib/pxp/ListParamInterface.d.ts +23 -23
- package/dist/lib/pxp/ListParamInterface.js +2 -2
- package/dist/lib/pxp/PxpError.d.ts +24 -24
- package/dist/lib/pxp/PxpError.js +57 -57
- package/dist/lib/pxp/RouteDefinition.d.ts +26 -26
- package/dist/lib/pxp/RouteDefinition.js +26 -26
- package/dist/lib/pxp/index.d.ts +20 -20
- package/dist/lib/pxp/index.js +33 -33
- package/dist/lib/pxp/loadControllers.d.ts +4 -4
- package/dist/lib/pxp/loadControllers.js +89 -89
- package/dist/lib/pxp/middlewares/ParseParams.d.ts +4 -4
- package/dist/lib/pxp/middlewares/ParseParams.js +71 -71
- package/dist/lib/pxp/middlewares/isReportMiddleware.d.ts +2 -2
- package/dist/lib/pxp/middlewares/isReportMiddleware.js +13 -13
- package/dist/lib/pxp/utils/Security.d.ts +23 -23
- package/dist/lib/pxp/utils/Security.js +79 -77
- package/dist/lib/pxp/utils/crypto.d.ts +3 -3
- package/dist/lib/pxp/utils/crypto.js +15 -15
- package/dist/lib/reports/fonts/Roboto-Regular-normal.d.ts +2 -2
- package/dist/lib/reports/fonts/Roboto-Regular-normal.js +4 -4
- package/dist/lib/reports/generated.d.ts +4 -4
- package/dist/lib/reports/generated.js +200 -200
- package/dist/lib/reports/helper.d.ts +8 -8
- package/dist/lib/reports/helper.js +49 -49
- package/dist/lib/reports/pdf.d.ts +3 -3
- package/dist/lib/reports/pdf.js +119 -119
- package/dist/lib/reports/report-routes.d.ts +3 -3
- package/dist/lib/reports/report-routes.js +24 -24
- package/dist/lib/reports/xlsx.d.ts +1 -1
- package/dist/lib/reports/xlsx.js +65 -65
- package/dist/sockets/basic-sockets.d.ts +5 -5
- package/dist/sockets/basic-sockets.js +38 -38
- package/dist/sockets/entities/UserIo.d.ts +6 -6
- package/dist/sockets/entities/UserIo.js +30 -30
- package/dist/sockets/entities/index.d.ts +5 -5
- package/dist/sockets/entities/index.js +9 -9
- package/dist/sockets/index.d.ts +2 -2
- package/dist/sockets/index.js +19 -19
- package/dist/sockets/pxp-io-server.d.ts +6 -6
- package/dist/sockets/pxp-io-server.js +50 -50
- package/dist/swaggerOptions.d.ts +16 -16
- package/dist/swaggerOptions.js +20 -20
- package/package.json +65 -65
- package/yalc.lock +9 -9
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const generateReport: (Report: any) => (req: any, res: any) => Promise<any>;
|
|
2
|
-
export declare const listGroup: (ReportGroup: any) => (req: any, res: any) => Promise<any>;
|
|
3
|
-
export declare const listReports: (Report: any) => (req: any, res: any) => Promise<any>;
|
|
4
|
-
export declare const getReport: (Report: any) => (req: any, res: any) => Promise<any>;
|
|
1
|
+
export declare const generateReport: (Report: any) => (req: any, res: any) => Promise<any>;
|
|
2
|
+
export declare const listGroup: (ReportGroup: any) => (req: any, res: any) => Promise<any>;
|
|
3
|
+
export declare const listReports: (Report: any) => (req: any, res: any) => Promise<any>;
|
|
4
|
+
export declare const getReport: (Report: any) => (req: any, res: any) => Promise<any>;
|
|
@@ -1,200 +1,200 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.getReport = exports.listReports = exports.listGroup = exports.generateReport = void 0;
|
|
23
|
-
const typeorm_1 = require("typeorm");
|
|
24
|
-
// import {Report, ReportGroup } from '@pxp-nd/entities';
|
|
25
|
-
const lodash_1 = require("lodash");
|
|
26
|
-
const pdf_1 = require("./pdf");
|
|
27
|
-
const xlsx_1 = require("./xlsx");
|
|
28
|
-
const _ = __importStar(require("lodash"));
|
|
29
|
-
const parseColumns = (columns) => Object.keys(columns).map((key) => ({
|
|
30
|
-
header: columns[key].label,
|
|
31
|
-
dataKey: key,
|
|
32
|
-
}));
|
|
33
|
-
const setLimitOffset = (query, limit, offset) => {
|
|
34
|
-
return `${query} LIMIT ${limit} OFFSET ${offset} `;
|
|
35
|
-
};
|
|
36
|
-
const setCountData = (query) => {
|
|
37
|
-
return `SELECT count(*) from (${query}) as report`;
|
|
38
|
-
};
|
|
39
|
-
const getDataQuery = async (query, filters, type, limit, start) => {
|
|
40
|
-
let qp = parseParamsReport(query, filters);
|
|
41
|
-
const dataCount = await typeorm_1.getManager().query(setCountData(qp));
|
|
42
|
-
qp = !type ? setLimitOffset(qp, limit, start) : qp;
|
|
43
|
-
const data = await typeorm_1.getManager().query(qp);
|
|
44
|
-
return {
|
|
45
|
-
data,
|
|
46
|
-
count: dataCount[0].count
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
const totalCalculate = (data, columns) => {
|
|
50
|
-
const totals = {};
|
|
51
|
-
Object.keys(columns).map((key) => {
|
|
52
|
-
const column = columns[key];
|
|
53
|
-
if (column.total && column.total === 'sum') {
|
|
54
|
-
totals[key] = _.round(_.sumBy(data, (item) => parseFloat(item[key])), 2);
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
return totals;
|
|
58
|
-
};
|
|
59
|
-
const getSummaryDetail = (columns, columnsDetail, config) => {
|
|
60
|
-
const result = {};
|
|
61
|
-
Object.keys(config).map(field => {
|
|
62
|
-
result[field] = {
|
|
63
|
-
value: eval(config[field].value),
|
|
64
|
-
label: config[field].label
|
|
65
|
-
};
|
|
66
|
-
});
|
|
67
|
-
return result;
|
|
68
|
-
};
|
|
69
|
-
const filtersLabelBuild = (filters, values) => {
|
|
70
|
-
const labels = {};
|
|
71
|
-
Object.keys(filters).forEach(key => {
|
|
72
|
-
labels[key] = {
|
|
73
|
-
label: filters[key].label,
|
|
74
|
-
value: values[key],
|
|
75
|
-
};
|
|
76
|
-
});
|
|
77
|
-
return labels;
|
|
78
|
-
};
|
|
79
|
-
const generateReport = (Report) => async (req, res) => {
|
|
80
|
-
try {
|
|
81
|
-
const report = await typeorm_1.getManager().findOne(Report, {
|
|
82
|
-
where: {
|
|
83
|
-
reportId: req.params.id
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
if (report) {
|
|
87
|
-
const config = JSON.parse(report.config);
|
|
88
|
-
const filters = req.query.filters && req.query.filters !== 'null' ? JSON.parse(req.query.filters) : {};
|
|
89
|
-
const type = lodash_1.get(req.params, 'type');
|
|
90
|
-
const limit = req.query.limit || 0;
|
|
91
|
-
const start = req.query.start || 0;
|
|
92
|
-
const result = await getDataQuery(report.query, filters, type, limit, start);
|
|
93
|
-
const resultTotal = await getDataQuery(report.query, filters, 'total', limit, start);
|
|
94
|
-
const totals = totalCalculate(resultTotal.data, config.columns);
|
|
95
|
-
const resultDetail = report.detailQuery ? await getDataQuery(report.detailQuery, filters, type, limit, start) : null;
|
|
96
|
-
let totalsDetail = null, summaryData = null;
|
|
97
|
-
if (resultDetail) {
|
|
98
|
-
totalsDetail = totalCalculate(resultDetail.data, config.columnsDetail);
|
|
99
|
-
summaryData = getSummaryDetail(totals, totalsDetail, config.detailSummary);
|
|
100
|
-
}
|
|
101
|
-
const reportData = () => {
|
|
102
|
-
const filtersReport = filtersLabelBuild(JSON.parse(report.filters), filters);
|
|
103
|
-
req.reportData = {
|
|
104
|
-
data: result.data,
|
|
105
|
-
totals,
|
|
106
|
-
filters: filtersReport
|
|
107
|
-
};
|
|
108
|
-
req.reportDetailData = resultDetail ? {
|
|
109
|
-
data: resultDetail.data,
|
|
110
|
-
columns: parseColumns(config.columnsDetail),
|
|
111
|
-
totals: totalsDetail
|
|
112
|
-
} : null;
|
|
113
|
-
req.reportSummary = summaryData;
|
|
114
|
-
req.report = {};
|
|
115
|
-
req.report.columns = parseColumns(config.columns);
|
|
116
|
-
req.report.filename = report.name;
|
|
117
|
-
};
|
|
118
|
-
if (type && type === 'pdf') {
|
|
119
|
-
reportData();
|
|
120
|
-
pdf_1.makePdf(req, res);
|
|
121
|
-
}
|
|
122
|
-
else if (type && type === 'xlsx') {
|
|
123
|
-
reportData();
|
|
124
|
-
xlsx_1.makeXlsx(req, res);
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
return res.send(Object.assign(Object.assign({}, result), { totals, dataDetail: resultDetail ? resultDetail.data : null, countDetail: resultDetail ? resultDetail.count : null, totalsDetail,
|
|
128
|
-
summaryData }));
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
res.status(400).send({
|
|
133
|
-
error: true,
|
|
134
|
-
message: 'Invalid Report'
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
catch (ex) {
|
|
139
|
-
console.log(ex);
|
|
140
|
-
res.status(500).send({
|
|
141
|
-
error: true,
|
|
142
|
-
message: 'Internal Server Error'
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
exports.generateReport = generateReport;
|
|
147
|
-
const listGroup = (ReportGroup) => async (req, res) => {
|
|
148
|
-
const reports = await typeorm_1.getManager().find(ReportGroup, {
|
|
149
|
-
where: {
|
|
150
|
-
active: true,
|
|
151
|
-
},
|
|
152
|
-
select: ['title', 'reportGroupId'],
|
|
153
|
-
});
|
|
154
|
-
return res.send(reports);
|
|
155
|
-
};
|
|
156
|
-
exports.listGroup = listGroup;
|
|
157
|
-
const listReports = (Report) => async (req, res) => {
|
|
158
|
-
const reports = await typeorm_1.getManager().find(Report, {
|
|
159
|
-
where: {
|
|
160
|
-
active: true,
|
|
161
|
-
reportGroupId: req.params.groupId
|
|
162
|
-
},
|
|
163
|
-
select: ['reportId', 'name'],
|
|
164
|
-
order: {
|
|
165
|
-
order: 'ASC'
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
return res.send(reports);
|
|
169
|
-
};
|
|
170
|
-
exports.listReports = listReports;
|
|
171
|
-
const getReport = (Report) => async (req, res) => {
|
|
172
|
-
const report = await typeorm_1.getManager().findOne(Report, {
|
|
173
|
-
where: {
|
|
174
|
-
reportId: req.params.id
|
|
175
|
-
},
|
|
176
|
-
select: ['reportId', 'name', 'filters', 'config']
|
|
177
|
-
});
|
|
178
|
-
return res.send(report);
|
|
179
|
-
};
|
|
180
|
-
exports.getReport = getReport;
|
|
181
|
-
const parseParamsReport = (query, params = {}) => {
|
|
182
|
-
const loadParams = query.replace(/\n/g, '').split(' ').filter(item => lodash_1.startsWith(item, ':'));
|
|
183
|
-
const convertParams = loadParams.map(item => {
|
|
184
|
-
const key = item.substring(1, item.length);
|
|
185
|
-
if (params[key]) {
|
|
186
|
-
return {
|
|
187
|
-
key,
|
|
188
|
-
value: `'${params[key]}'`,
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
else {
|
|
192
|
-
return {
|
|
193
|
-
key,
|
|
194
|
-
value: '',
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
convertParams.forEach(item => query = lodash_1.replace(query, ':' + item.key, item.value));
|
|
199
|
-
return query;
|
|
200
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.getReport = exports.listReports = exports.listGroup = exports.generateReport = void 0;
|
|
23
|
+
const typeorm_1 = require("typeorm");
|
|
24
|
+
// import {Report, ReportGroup } from '@pxp-nd/entities';
|
|
25
|
+
const lodash_1 = require("lodash");
|
|
26
|
+
const pdf_1 = require("./pdf");
|
|
27
|
+
const xlsx_1 = require("./xlsx");
|
|
28
|
+
const _ = __importStar(require("lodash"));
|
|
29
|
+
const parseColumns = (columns) => Object.keys(columns).map((key) => ({
|
|
30
|
+
header: columns[key].label,
|
|
31
|
+
dataKey: key,
|
|
32
|
+
}));
|
|
33
|
+
const setLimitOffset = (query, limit, offset) => {
|
|
34
|
+
return `${query} LIMIT ${limit} OFFSET ${offset} `;
|
|
35
|
+
};
|
|
36
|
+
const setCountData = (query) => {
|
|
37
|
+
return `SELECT count(*) from (${query}) as report`;
|
|
38
|
+
};
|
|
39
|
+
const getDataQuery = async (query, filters, type, limit, start) => {
|
|
40
|
+
let qp = parseParamsReport(query, filters);
|
|
41
|
+
const dataCount = await typeorm_1.getManager().query(setCountData(qp));
|
|
42
|
+
qp = !type ? setLimitOffset(qp, limit, start) : qp;
|
|
43
|
+
const data = await typeorm_1.getManager().query(qp);
|
|
44
|
+
return {
|
|
45
|
+
data,
|
|
46
|
+
count: dataCount[0].count
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
const totalCalculate = (data, columns) => {
|
|
50
|
+
const totals = {};
|
|
51
|
+
Object.keys(columns).map((key) => {
|
|
52
|
+
const column = columns[key];
|
|
53
|
+
if (column.total && column.total === 'sum') {
|
|
54
|
+
totals[key] = _.round(_.sumBy(data, (item) => parseFloat(item[key])), 2);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
return totals;
|
|
58
|
+
};
|
|
59
|
+
const getSummaryDetail = (columns, columnsDetail, config) => {
|
|
60
|
+
const result = {};
|
|
61
|
+
Object.keys(config).map(field => {
|
|
62
|
+
result[field] = {
|
|
63
|
+
value: eval(config[field].value),
|
|
64
|
+
label: config[field].label
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
return result;
|
|
68
|
+
};
|
|
69
|
+
const filtersLabelBuild = (filters, values) => {
|
|
70
|
+
const labels = {};
|
|
71
|
+
Object.keys(filters).forEach(key => {
|
|
72
|
+
labels[key] = {
|
|
73
|
+
label: filters[key].label,
|
|
74
|
+
value: values[key],
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
return labels;
|
|
78
|
+
};
|
|
79
|
+
const generateReport = (Report) => async (req, res) => {
|
|
80
|
+
try {
|
|
81
|
+
const report = await typeorm_1.getManager().findOne(Report, {
|
|
82
|
+
where: {
|
|
83
|
+
reportId: req.params.id
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
if (report) {
|
|
87
|
+
const config = JSON.parse(report.config);
|
|
88
|
+
const filters = req.query.filters && req.query.filters !== 'null' ? JSON.parse(req.query.filters) : {};
|
|
89
|
+
const type = lodash_1.get(req.params, 'type');
|
|
90
|
+
const limit = req.query.limit || 0;
|
|
91
|
+
const start = req.query.start || 0;
|
|
92
|
+
const result = await getDataQuery(report.query, filters, type, limit, start);
|
|
93
|
+
const resultTotal = await getDataQuery(report.query, filters, 'total', limit, start);
|
|
94
|
+
const totals = totalCalculate(resultTotal.data, config.columns);
|
|
95
|
+
const resultDetail = report.detailQuery ? await getDataQuery(report.detailQuery, filters, type, limit, start) : null;
|
|
96
|
+
let totalsDetail = null, summaryData = null;
|
|
97
|
+
if (resultDetail) {
|
|
98
|
+
totalsDetail = totalCalculate(resultDetail.data, config.columnsDetail);
|
|
99
|
+
summaryData = getSummaryDetail(totals, totalsDetail, config.detailSummary);
|
|
100
|
+
}
|
|
101
|
+
const reportData = () => {
|
|
102
|
+
const filtersReport = filtersLabelBuild(JSON.parse(report.filters), filters);
|
|
103
|
+
req.reportData = {
|
|
104
|
+
data: result.data,
|
|
105
|
+
totals,
|
|
106
|
+
filters: filtersReport
|
|
107
|
+
};
|
|
108
|
+
req.reportDetailData = resultDetail ? {
|
|
109
|
+
data: resultDetail.data,
|
|
110
|
+
columns: parseColumns(config.columnsDetail),
|
|
111
|
+
totals: totalsDetail
|
|
112
|
+
} : null;
|
|
113
|
+
req.reportSummary = summaryData;
|
|
114
|
+
req.report = {};
|
|
115
|
+
req.report.columns = parseColumns(config.columns);
|
|
116
|
+
req.report.filename = report.name;
|
|
117
|
+
};
|
|
118
|
+
if (type && type === 'pdf') {
|
|
119
|
+
reportData();
|
|
120
|
+
pdf_1.makePdf(req, res);
|
|
121
|
+
}
|
|
122
|
+
else if (type && type === 'xlsx') {
|
|
123
|
+
reportData();
|
|
124
|
+
xlsx_1.makeXlsx(req, res);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
return res.send(Object.assign(Object.assign({}, result), { totals, dataDetail: resultDetail ? resultDetail.data : null, countDetail: resultDetail ? resultDetail.count : null, totalsDetail,
|
|
128
|
+
summaryData }));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
res.status(400).send({
|
|
133
|
+
error: true,
|
|
134
|
+
message: 'Invalid Report'
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
catch (ex) {
|
|
139
|
+
console.log(ex);
|
|
140
|
+
res.status(500).send({
|
|
141
|
+
error: true,
|
|
142
|
+
message: 'Internal Server Error'
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
exports.generateReport = generateReport;
|
|
147
|
+
const listGroup = (ReportGroup) => async (req, res) => {
|
|
148
|
+
const reports = await typeorm_1.getManager().find(ReportGroup, {
|
|
149
|
+
where: {
|
|
150
|
+
active: true,
|
|
151
|
+
},
|
|
152
|
+
select: ['title', 'reportGroupId'],
|
|
153
|
+
});
|
|
154
|
+
return res.send(reports);
|
|
155
|
+
};
|
|
156
|
+
exports.listGroup = listGroup;
|
|
157
|
+
const listReports = (Report) => async (req, res) => {
|
|
158
|
+
const reports = await typeorm_1.getManager().find(Report, {
|
|
159
|
+
where: {
|
|
160
|
+
active: true,
|
|
161
|
+
reportGroupId: req.params.groupId
|
|
162
|
+
},
|
|
163
|
+
select: ['reportId', 'name'],
|
|
164
|
+
order: {
|
|
165
|
+
order: 'ASC'
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
return res.send(reports);
|
|
169
|
+
};
|
|
170
|
+
exports.listReports = listReports;
|
|
171
|
+
const getReport = (Report) => async (req, res) => {
|
|
172
|
+
const report = await typeorm_1.getManager().findOne(Report, {
|
|
173
|
+
where: {
|
|
174
|
+
reportId: req.params.id
|
|
175
|
+
},
|
|
176
|
+
select: ['reportId', 'name', 'filters', 'config']
|
|
177
|
+
});
|
|
178
|
+
return res.send(report);
|
|
179
|
+
};
|
|
180
|
+
exports.getReport = getReport;
|
|
181
|
+
const parseParamsReport = (query, params = {}) => {
|
|
182
|
+
const loadParams = query.replace(/\n/g, '').split(' ').filter(item => lodash_1.startsWith(item, ':'));
|
|
183
|
+
const convertParams = loadParams.map(item => {
|
|
184
|
+
const key = item.substring(1, item.length);
|
|
185
|
+
if (params[key]) {
|
|
186
|
+
return {
|
|
187
|
+
key,
|
|
188
|
+
value: `'${params[key]}'`,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
return {
|
|
193
|
+
key,
|
|
194
|
+
value: '',
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
convertParams.forEach(item => query = lodash_1.replace(query, ':' + item.key, item.value));
|
|
199
|
+
return query;
|
|
200
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export declare const getEntity: (module: string, entity: string) => Promise<any>;
|
|
2
|
-
export declare const parseParams: (req: any) => Promise<{
|
|
3
|
-
columns: any;
|
|
4
|
-
params: any;
|
|
5
|
-
filename: any;
|
|
6
|
-
module: any;
|
|
7
|
-
entity: any;
|
|
8
|
-
}>;
|
|
1
|
+
export declare const getEntity: (module: string, entity: string) => Promise<any>;
|
|
2
|
+
export declare const parseParams: (req: any) => Promise<{
|
|
3
|
+
columns: any;
|
|
4
|
+
params: any;
|
|
5
|
+
filename: any;
|
|
6
|
+
module: any;
|
|
7
|
+
entity: any;
|
|
8
|
+
}>;
|
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.parseParams = exports.getEntity = void 0;
|
|
26
|
-
const path_1 = __importDefault(require("path"));
|
|
27
|
-
const getEntity = async (module, entity) => {
|
|
28
|
-
const filePath = path_1.default.join(__dirname, '../../modules', module, 'entity', entity);
|
|
29
|
-
const Entity = await Promise.resolve().then(() => __importStar(require(filePath)));
|
|
30
|
-
return Entity.default || Entity[entity];
|
|
31
|
-
};
|
|
32
|
-
exports.getEntity = getEntity;
|
|
33
|
-
const parseParams = async (req) => {
|
|
34
|
-
// s-params
|
|
35
|
-
const columns = JSON.parse(req.query.columns);
|
|
36
|
-
const params = JSON.parse(req.query.params);
|
|
37
|
-
const filename = req.body.filename || req.query.filename;
|
|
38
|
-
const module = req.query.module;
|
|
39
|
-
const entity = req.query.entity;
|
|
40
|
-
// e-params
|
|
41
|
-
return {
|
|
42
|
-
columns,
|
|
43
|
-
params,
|
|
44
|
-
filename,
|
|
45
|
-
module,
|
|
46
|
-
entity,
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
exports.parseParams = parseParams;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.parseParams = exports.getEntity = void 0;
|
|
26
|
+
const path_1 = __importDefault(require("path"));
|
|
27
|
+
const getEntity = async (module, entity) => {
|
|
28
|
+
const filePath = path_1.default.join(__dirname, '../../modules', module, 'entity', entity);
|
|
29
|
+
const Entity = await Promise.resolve().then(() => __importStar(require(filePath)));
|
|
30
|
+
return Entity.default || Entity[entity];
|
|
31
|
+
};
|
|
32
|
+
exports.getEntity = getEntity;
|
|
33
|
+
const parseParams = async (req) => {
|
|
34
|
+
// s-params
|
|
35
|
+
const columns = JSON.parse(req.query.columns);
|
|
36
|
+
const params = JSON.parse(req.query.params);
|
|
37
|
+
const filename = req.body.filename || req.query.filename;
|
|
38
|
+
const module = req.query.module;
|
|
39
|
+
const entity = req.query.entity;
|
|
40
|
+
// e-params
|
|
41
|
+
return {
|
|
42
|
+
columns,
|
|
43
|
+
params,
|
|
44
|
+
filename,
|
|
45
|
+
module,
|
|
46
|
+
entity,
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
exports.parseParams = parseParams;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import 'jspdf-autotable';
|
|
2
|
-
export declare const setRobotoFont: (doc: any) => void;
|
|
3
|
-
export declare const makePdf: (req: any, res: any) => Promise<void>;
|
|
1
|
+
import 'jspdf-autotable';
|
|
2
|
+
export declare const setRobotoFont: (doc: any) => void;
|
|
3
|
+
export declare const makePdf: (req: any, res: any) => Promise<void>;
|