fng-reports 0.12.0-beta.179 → 0.12.0-beta.181
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/dist/fng-reports.js +52 -7
- package/dist/fng-reports.min.js +3 -3
- package/package.json +2 -2
- package/src/fng-reports.js +51 -6
package/dist/fng-reports.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! forms-angular 2022-04-
|
|
1
|
+
/*! forms-angular 2022-04-21 */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
formsAngular.controller('AnalysisCtrl', ['$rootScope', '$window', '$filter', '$scope', '$http', '$location', 'cssFrameworkService', 'routingService',
|
|
@@ -260,8 +260,8 @@ ${e.message}`);
|
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
262
|
return $http.get(apiCall).then(function (response) {
|
|
263
|
-
|
|
264
|
-
|
|
263
|
+
if (response && response.data && response.data.success) {
|
|
264
|
+
var data = response.data;
|
|
265
265
|
$scope.report = data.report;
|
|
266
266
|
$scope.reportSchema = data.schema;
|
|
267
267
|
$scope.reportSchema.title = $scope.reportSchema.title || $scope.modelName;
|
|
@@ -317,12 +317,11 @@ ${e.message}`);
|
|
|
317
317
|
}
|
|
318
318
|
}
|
|
319
319
|
} else {
|
|
320
|
-
|
|
320
|
+
$scope.showError(JSON.stringify(response.data.error), 'Invalid Response Error');
|
|
321
321
|
$scope.reportSchema.title = 'Error - see console log';
|
|
322
322
|
}
|
|
323
|
-
}, function (
|
|
324
|
-
|
|
325
|
-
$location.url('/404');
|
|
323
|
+
}, function () {
|
|
324
|
+
$scope.showError('The server could not process the request', 'Error');
|
|
326
325
|
});
|
|
327
326
|
};
|
|
328
327
|
|
|
@@ -340,6 +339,52 @@ ${e.message}`);
|
|
|
340
339
|
delete navScope.items;
|
|
341
340
|
});
|
|
342
341
|
|
|
342
|
+
// Error handling, stolen quickly from forms-angulat record-handler
|
|
343
|
+
$scope.showError = function(error, alertTitle) {
|
|
344
|
+
$scope.alertTitle = alertTitle ? alertTitle : 'Error!';
|
|
345
|
+
if (typeof error === 'string') {
|
|
346
|
+
$scope.errorMessage = error;
|
|
347
|
+
} else if (!error) {
|
|
348
|
+
$scope.errorMessage = `An error occurred - that's all we got. Sorry.`;
|
|
349
|
+
} else if (error.message && typeof error.message === 'string') {
|
|
350
|
+
$scope.errorMessage = error.message;
|
|
351
|
+
} else if (error.data && error.data.message) {
|
|
352
|
+
$scope.errorMessage = error.data.message;
|
|
353
|
+
} else {
|
|
354
|
+
try {
|
|
355
|
+
$scope.errorMessage = JSON.stringify(error);
|
|
356
|
+
} catch (e) {
|
|
357
|
+
$scope.errorMessage = error;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
$scope.errorHideTimer = window.setTimeout(function() {
|
|
361
|
+
$scope.dismissError();
|
|
362
|
+
$scope.$digest();
|
|
363
|
+
}, 3500 + (1000 * ($scope.alertTitle + $scope.errorMessage).length / 50));
|
|
364
|
+
$scope.errorVisible = true;
|
|
365
|
+
window.setTimeout(() => {
|
|
366
|
+
$scope.$digest();
|
|
367
|
+
});
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
$scope.clearTimeout = function() {
|
|
371
|
+
if ($scope.errorHideTimer) {
|
|
372
|
+
clearTimeout($scope.errorHideTimer);
|
|
373
|
+
delete $scope.errorHideTimer;
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
$scope.dismissError = function() {
|
|
378
|
+
$scope.clearTimeout;
|
|
379
|
+
$scope.errorVisible = false;
|
|
380
|
+
delete $scope.errorMessage;
|
|
381
|
+
delete $scope.alertTitle;
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
$scope.stickError = function() {
|
|
385
|
+
clearTimeout($scope.errorHideTimer);
|
|
386
|
+
};
|
|
387
|
+
|
|
343
388
|
}]);
|
|
344
389
|
|
|
345
390
|
'use strict';
|
package/dist/fng-reports.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*! forms-angular 2022-04-
|
|
2
|
-
"use strict";formsAngular.controller("AnalysisCtrl",["$rootScope","$window","$filter","$scope","$http","$location","cssFrameworkService","routingService",function(e,r,l,
|
|
3
|
-
`+e.message)}}if(angular.extend(
|
|
1
|
+
/*! forms-angular 2022-04-21 */
|
|
2
|
+
"use strict";formsAngular.controller("AnalysisCtrl",["$rootScope","$window","$filter","$scope","$http","$location","cssFrameworkService","routingService",function(e,r,a,l,c,s,i,t){var p=!0,o=new ngGridPdfExportPlugin({inhibitButton:!0}),n=new ngGridCsvExportPlugin({inhibitButton:!0});function u(r){try{return JSON.parse(r)}catch(e){throw new Error(`Invalid JSON ${r}
|
|
3
|
+
`+e.message)}}if(angular.extend(l,t.parsePathFunc()(s.$$path)),l.reportSchema={columnDefs:[]},l.gridOptions={data:"report",columnDefs:l.reportSchema.columnDefs,showColumnMenu:!0,enableRowHeaderSelection:!1,enableFiltering:!1,showGridFooter:!1,reallyShowFooter:!1,showTotals:!0,enableColumnResizing:!0,footerRowHeight:65,multiSelect:!1,plugins:[o,n],onRegisterApi:function(r){l.gridApi=r,l.gridOptions.plugins.forEach(function(e){e.init(l,r.grid,null)}),r.selection.on.rowSelectionChanged(l,function(o){var e=l.reportSchema.drilldown;e&&(e=t.buildUrl(e.replace(/\|.+?\|/g,function(e){var r,e=e.slice(1,-1),t=/\((.+)\)/.exec(e);return t?(r=l.reportSchema.params[t[1]])?(l.param=l.record[t[1]],r.conversionExpression?l.$eval(r.conversionExpression):r.value):l.reportSchema.params[t[1]].value:o.entity[e]})),window.location=e)})}},l.report=[],!l.reportSchemaName&&s.$$search.r)switch(s.$$search.r.slice(0,1)){case"[":l.reportSchema.pipeline=u(s.$$search.r);break;case"{":angular.extend(l.reportSchema,u(s.$$search.r));break;default:throw new Error("No report instructions specified")}function d(e){for(var r in l.paramSchema=[],l.record={},e){var t,o;e.hasOwnProperty(r)&&((t=e[r]).noInput||(o=l.paramSchema.push({name:r,id:"fp_"+r,label:t.label||a("titleCase")(r),type:t.type||"text",required:!0,add:t.add||void 0,size:t.size||("bs3"===i.frameWork?"large":"medium")}),"select"===t.type&&(l[r+"_Opts"]=t.enum,l.paramSchema[o-1].options=r+"_Opts")),(o=/^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3})(Z|[+ -]\d{4})$/.exec(t.value))&&(t.value=new Date(o[1])),l.record[r]=t.value)}l.$watch("record",function(e,r){r!==e&&(console.log("In the record watch ",JSON.stringify(e,null,2)),l.refreshQuery())},!0)}l.getTotalVal=function(r,e){var t="",o=_.find(l.reportSchema.columnDefs,function(e){return e.field===r});if(o)switch(o.totalsRow){case void 0:break;case"$SUM":for(var i=0,n=0;n<l.report.length;n++)i+=l.report[n][r];t=i,e&&(t=a(e)(t));break;default:t=o.totalsRow}return t},l.$on("exportToPDF",function(){o.createPDF()}),l.$on("exportToCSV",function(){n.createCSV()}),l.extractFilter=function(e,r){var t,o,i;e.cellFilter&&(-1===(i=e.cellFilter.indexOf(":"))?t=e.cellFilter:(t=e.cellFilter.slice(0,i).trim(),"'"!==(o=e.cellFilter.slice(i+1,999).trim())[0]&&'"'!==o[0]||(o=o.slice(1,-1))),i=angular.element(document.body).injector().get("$filter")(t.trim()),r[e.field]={filter:i,filterParam:o})};var f,m,h,g=document.querySelector("div.report-grow"),S=(g&&(f=g.offsetLeft,m=g.offsetTop+f,h=(h=document.querySelector("div.ui-grid-header"))?h.clientHeight:31,r=Math.floor((r.innerHeight-m-h-f)/30),angular.element(g).css("height",30*r+"px")),e.navScope);S.items=[{fn:o.createPDF,text:"Save as PDF"},{fn:n.createCSV,text:"Export as CSV"}],S.contextMenu="Report",l.titleWithSubstitutions=l.reportSchema.title,l.inhibitRefresh||(l.refreshQuery=function(){function t(e){return e.replace(/\|.+?\|/g,function(e){e=e.slice(1,-1),e=/\((.+)\)/.exec(e);return e?l.reportSchema.params[e[1]].value:""})}var e="/api/report/"+l.modelName,r="?",o=!1,i=s.$$url.match(/\?.*/);if(l.reportSchemaName?e+="/"+l.reportSchemaName:i&&(p&&(l.paramSchema=JSON.parse(s.search().r).params,d(l.paramSchema)),e+=r+i[0].slice(1),r="&",o=!0),l.paramSchema){for(var n in l.record)if(l.record.hasOwnProperty(n)){var a=l.reportSchema.params[n];if(l.record[n]&&""!==l.record[n])l.param=l.record[n],a.conversionExpression&&(l.param=l.$eval(a.conversionExpression)),e+=r+n+"="+l.param,r="&";else if(a.required)return}}else!o&&i&&(e+=r+i[0].slice(1),r="&");return c.get(e).then(function(e){var r;e&&e.data&&e.data.success?(r=e.data,l.report=r.report,l.reportSchema=r.schema,l.reportSchema.title=l.reportSchema.title||l.modelName,l.titleWithSubstitutions=t(l.reportSchema.title),l.gridOptions.enableFiltering=!!l.reportSchema.filter,S&&S.items&&(S.items.length=2,l.reportSchema.menu&&l.reportSchema.menu.forEach(function(e){S.items.push(JSON.parse(t(JSON.stringify(e))))})),p&&(p=!1,l.$watch("reportSchema.columnDefs",function(e){var r=!1;if(e){for(var t,o=0;o<e.length;o++)e[o].totalsRow&&(r=!0),e[o].align&&(t="fng-"+e[o].align,e[o].cellClass=e[o].cellClass||"",-1===e[o].cellClass.indexOf(t)&&(e[o].cellClass=e[o].cellClass+" "+t));e.forEach(function(e){e.width&&"string"==typeof e.width&&-1!==e.width.indexOf("px")&&(e.width=parseInt(e.width.slice(0,-2)))}),l.gridOptions.columnDefs=e}l.gridOptions.showTotals=r,l.gridOptions.reallyShowFooter=r,l.gridOptions.footerRowHeight=55+(r?10:0)},!0),!l.paramSchema&&r.schema.params&&d(r.schema.params))):(l.showError(JSON.stringify(e.data.error),"Invalid Response Error"),l.reportSchema.title="Error - see console log")},function(){l.showError("The server could not process the request","Error")})},l.refreshQuery()),l.showsContent=function(e){return/{{[\s]*COL_FIELD[\s]*}}/.test(e.replace(/(<([^>]+)>)/gi,""))},l.$on("$locationChangeStart",function(){delete S.contextMenu,delete S.items}),l.showError=function(r,e){if(l.alertTitle=e||"Error!","string"==typeof r)l.errorMessage=r;else if(r)if(r.message&&"string"==typeof r.message)l.errorMessage=r.message;else if(r.data&&r.data.message)l.errorMessage=r.data.message;else try{l.errorMessage=JSON.stringify(r)}catch(e){l.errorMessage=r}else l.errorMessage="An error occurred - that's all we got. Sorry.";l.errorHideTimer=window.setTimeout(function(){l.dismissError(),l.$digest()},3500+1e3*(l.alertTitle+l.errorMessage).length/50),l.errorVisible=!0,window.setTimeout(()=>{l.$digest()})},l.clearTimeout=function(){l.errorHideTimer&&(clearTimeout(l.errorHideTimer),delete l.errorHideTimer)},l.dismissError=function(){l.clearTimeout,l.errorVisible=!1,delete l.errorMessage,delete l.alertTitle},l.stickError=function(){clearTimeout(l.errorHideTimer)}}]);var COL_FIELD=/COL_FIELD/g;function ngGridCsvExportPlugin(e){var n=this;n.grid=null,n.scope=null,n.services=null,n.init=function(e,r,t){n.grid=r,n.scope=e,n.services=t},n.createCSV=function(){var e,r,t;e=n.scope.reportSchema.title+".csv",r="data:text/csv;charset=UTF-8,"+encodeURIComponent(n.prepareCSV()),(t=document.createElement("a")).download=e,t.href=r,e=new MouseEvent("click"),t.dispatchEvent(e)},n.prepareCSV=function(){function t(e,r){return null==e?"":r?r.filter(e,r.filterParam):"number"==typeof e?""+e:"boolean"==typeof e?e?"TRUE":"FALSE":("string"==typeof e?e:JSON.stringify(e)).replace(/"/g,'""')}function e(e){return e.substr(0,e.length-1)+"\n"}var o="",i={};return angular.forEach(n.grid.columns,function(e){n.scope.extractFilter(e,i),e.visible&&(!e.colDef.cellTemplate||n.scope.showsContent(e.colDef.cellTemplate))&&(void 0===e.width||"*"===e.width||0<e.width)?(o+='"'+t(e.displayName)+'",',e.doCSVExport=!0):e.doCSVExport=!1}),o=e(o),angular.forEach(n.scope.gridApi.core.getVisibleRows(),function(r){r.visible&&(angular.forEach(n.grid.columns,function(e){e.doCSVExport&&(o+='"'+t(r.entity[e.field],i[e.field])+'",')}),o=e(o))}),o}}function ngGridPdfExportPlugin(o){var a=this;a.grid=null,a.scope=null,a.services=null,a.options=o,a.init=function(e,r,t){a.grid=r,a.scope=e,a.services=t,o.inhibitButton||(e=r.$root.find(".ngFooterPanel"),null!=(t=r.$root.find(".ngFooterPanel .pdf-data-link-span"))&&t.remove(),e.append('<button class="pdf-data-link-span">PDF Export</button>'),e.on("click",function(){a.createPDF()}))},a.createPDF=function(){var t=[],i=[],o=[],e=[],n={},r=(angular.forEach(a.grid.columns,function(e,r){!e.visible||e.colDef.cellTemplate&&!a.scope.showsContent(e.colDef.cellTemplate)||(t.push(e.displayName),i.push(e.field)),e.colDef.totalsRow&&(o[e.field]=a.grid.getTotalVal(e.field,e.filter).toString()),a.scope.extractFilter(e,n)}),angular.forEach(a.scope.gridApi.core.getVisibleRows(),function(t){var o=[];t.visible&&(i.forEach(function(e){var r=t.entity[e];"string"==typeof(r=n[e]?n[e].filter(r,n[e].filterParam):r)&&(r=(r=(r=(r=(r=r.replace(/\u2019/g,"'")).replace(/\u2018/g,"'")).replace(/\u201c/g,'"')).replace(/\u201d/g,'"')).replace(/[^\x00-\xFF]/g,"")),o.push(r)}),e.push(o))}),new jspdf.jsPDF("landscape","mm","a4"));r.autoTable({head:[t],body:e}),window.open(r.output("bloburl"))}}formsAngular.directive("ngTotalCell",["$compile","$domUtilityService",function(i,t){return{scope:!1,compile:function(){return{pre:function(e,r){var t=e.col.cellTemplate.match(/{{COL_FIELD \|(.+)}}/),t=t?e.col.cellTemplate.replace("COL_FIELD |"+t[1],'getTotalVal("'+e.col.field+'","'+t[1]+'")'):e.col.cellTemplate.replace(COL_FIELD,'getTotalVal("'+e.col.field+'")'),o=e.col.enableCellEdit?(o=(o=e.col.cellEditTemplate).replace(DISPLAY_CELL_TEMPLATE,t)).replace(EDITABLE_CELL_TEMPLATE,e.col.editableCellTemplate.replace(COL_FIELD,"row.entity."+e.col.field)):t,t=i(o)(e);e.enableCellSelection&&-1===t[0].className.indexOf("ngSelectionCell")&&(t[0].setAttribute("tabindex",0),t.addClass("ngCellElement")),r.append(t)},post:function(e,r){e.enableCellSelection&&e.domAccessProvider.selectionHandlers(e,r),e.$on("ngGridEventDigestCell",function(){t.digest(e)})}}}}}]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fng-reports",
|
|
3
|
-
"version": "0.12.0-beta.
|
|
3
|
+
"version": "0.12.0-beta.181",
|
|
4
4
|
"description": "Reporting plugin for forms-angular",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"angular-messages": "1.8.3",
|
|
33
33
|
"angular-mocks": "1.8.3",
|
|
34
34
|
"angular-sanitize": "1.8.3",
|
|
35
|
-
"forms-angular": "0.12.0-beta.
|
|
35
|
+
"forms-angular": "0.12.0-beta.181",
|
|
36
36
|
"grunt": "^1.5.2",
|
|
37
37
|
"grunt-autoprefixer": "3.0.4",
|
|
38
38
|
"grunt-concurrent": "3.0.0",
|
package/src/fng-reports.js
CHANGED
|
@@ -259,8 +259,8 @@ ${e.message}`);
|
|
|
259
259
|
}
|
|
260
260
|
}
|
|
261
261
|
return $http.get(apiCall).then(function (response) {
|
|
262
|
-
|
|
263
|
-
|
|
262
|
+
if (response && response.data && response.data.success) {
|
|
263
|
+
var data = response.data;
|
|
264
264
|
$scope.report = data.report;
|
|
265
265
|
$scope.reportSchema = data.schema;
|
|
266
266
|
$scope.reportSchema.title = $scope.reportSchema.title || $scope.modelName;
|
|
@@ -316,12 +316,11 @@ ${e.message}`);
|
|
|
316
316
|
}
|
|
317
317
|
}
|
|
318
318
|
} else {
|
|
319
|
-
|
|
319
|
+
$scope.showError(JSON.stringify(response.data.error), 'Invalid Response Error');
|
|
320
320
|
$scope.reportSchema.title = 'Error - see console log';
|
|
321
321
|
}
|
|
322
|
-
}, function (
|
|
323
|
-
|
|
324
|
-
$location.url('/404');
|
|
322
|
+
}, function () {
|
|
323
|
+
$scope.showError('The server could not process the request', 'Error');
|
|
325
324
|
});
|
|
326
325
|
};
|
|
327
326
|
|
|
@@ -339,4 +338,50 @@ ${e.message}`);
|
|
|
339
338
|
delete navScope.items;
|
|
340
339
|
});
|
|
341
340
|
|
|
341
|
+
// Error handling, stolen quickly from forms-angulat record-handler
|
|
342
|
+
$scope.showError = function(error, alertTitle) {
|
|
343
|
+
$scope.alertTitle = alertTitle ? alertTitle : 'Error!';
|
|
344
|
+
if (typeof error === 'string') {
|
|
345
|
+
$scope.errorMessage = error;
|
|
346
|
+
} else if (!error) {
|
|
347
|
+
$scope.errorMessage = `An error occurred - that's all we got. Sorry.`;
|
|
348
|
+
} else if (error.message && typeof error.message === 'string') {
|
|
349
|
+
$scope.errorMessage = error.message;
|
|
350
|
+
} else if (error.data && error.data.message) {
|
|
351
|
+
$scope.errorMessage = error.data.message;
|
|
352
|
+
} else {
|
|
353
|
+
try {
|
|
354
|
+
$scope.errorMessage = JSON.stringify(error);
|
|
355
|
+
} catch (e) {
|
|
356
|
+
$scope.errorMessage = error;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
$scope.errorHideTimer = window.setTimeout(function() {
|
|
360
|
+
$scope.dismissError();
|
|
361
|
+
$scope.$digest();
|
|
362
|
+
}, 3500 + (1000 * ($scope.alertTitle + $scope.errorMessage).length / 50));
|
|
363
|
+
$scope.errorVisible = true;
|
|
364
|
+
window.setTimeout(() => {
|
|
365
|
+
$scope.$digest();
|
|
366
|
+
});
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
$scope.clearTimeout = function() {
|
|
370
|
+
if ($scope.errorHideTimer) {
|
|
371
|
+
clearTimeout($scope.errorHideTimer);
|
|
372
|
+
delete $scope.errorHideTimer;
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
$scope.dismissError = function() {
|
|
377
|
+
$scope.clearTimeout;
|
|
378
|
+
$scope.errorVisible = false;
|
|
379
|
+
delete $scope.errorMessage;
|
|
380
|
+
delete $scope.alertTitle;
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
$scope.stickError = function() {
|
|
384
|
+
clearTimeout($scope.errorHideTimer);
|
|
385
|
+
};
|
|
386
|
+
|
|
342
387
|
}]);
|