@esfaenza/dashboard-feature 15.2.14 → 19.2.1

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 (70) hide show
  1. package/README.md +24 -24
  2. package/fesm2022/esfaenza-dashboard-feature.mjs +1814 -0
  3. package/fesm2022/esfaenza-dashboard-feature.mjs.map +1 -0
  4. package/index.d.ts +5 -5
  5. package/lib/components/dashboard/dashboard.component.d.ts +46 -46
  6. package/lib/components/widgets/BaseWidgetComponent.d.ts +44 -47
  7. package/lib/components/widgets/IWidgetComponent.d.ts +23 -23
  8. package/lib/components/widgets/JaceWidgetTypes.d.ts +6 -6
  9. package/lib/components/widgets/chart/jace-dsh-chart.component.d.ts +25 -25
  10. package/lib/components/widgets/counter/jace-dsh-counter.component.d.ts +24 -24
  11. package/lib/components/widgets/list/jace-dsh-list.component.d.ts +27 -27
  12. package/lib/components/widgets/multiprog/circle-progress/circle-progress.component.d.ts +219 -0
  13. package/lib/components/widgets/multiprog/jace-dsh-multiprog.component.d.ts +26 -26
  14. package/lib/dashboard-feature.module.d.ts +23 -24
  15. package/lib/models/config/JaceDashboardConfig.d.ts +51 -51
  16. package/lib/models/externals/JaceDashboardLayoutAppSearch.d.ts +6 -6
  17. package/lib/models/externals/JaceDashboardLayoutDetail.d.ts +6 -6
  18. package/lib/models/externals/JaceWidgetInstanceDetail.d.ts +18 -18
  19. package/lib/models/externals/Repository.d.ts +5 -5
  20. package/lib/models/externals/SaveJaceDashboardLayoutDTO.d.ts +6 -6
  21. package/lib/models/options/DefaultDashboardModuleOptions.d.ts +6 -6
  22. package/lib/models/options/IDashboardModuleOptions.d.ts +4 -4
  23. package/lib/models/options/IWidgetTypeConfig.d.ts +8 -8
  24. package/lib/models/widgets/BaseJaceWidgetModel.d.ts +32 -38
  25. package/lib/models/widgets/IJaceWidgetModel.d.ts +33 -39
  26. package/lib/models/widgets/JaceChartWidgetModel.d.ts +8 -14
  27. package/lib/models/widgets/JaceCounterWidgetModel.d.ts +10 -18
  28. package/lib/models/widgets/JaceListWidgetModel.d.ts +16 -27
  29. package/lib/models/widgets/JaceMultiprogWidgetModel.d.ts +9 -15
  30. package/lib/private-injection-tokens.d.ts +3 -0
  31. package/lib/{tokens.d.ts → public-injection-tokens.d.ts} +7 -9
  32. package/lib/services/DashboardWidgetFactory.d.ts +28 -28
  33. package/lib/services/IDashboardFeatureDataService.d.ts +11 -31
  34. package/lib/services/dashboard-feature.service.d.ts +18 -38
  35. package/package.json +15 -16
  36. package/public-api.d.ts +24 -23
  37. package/esm2020/esfaenza-dashboard-feature.mjs +0 -5
  38. package/esm2020/lib/components/dashboard/dashboard.component.mjs +0 -163
  39. package/esm2020/lib/components/widgets/BaseWidgetComponent.mjs +0 -89
  40. package/esm2020/lib/components/widgets/IWidgetComponent.mjs +0 -2
  41. package/esm2020/lib/components/widgets/JaceWidgetTypes.mjs +0 -8
  42. package/esm2020/lib/components/widgets/chart/jace-dsh-chart.component.mjs +0 -81
  43. package/esm2020/lib/components/widgets/counter/jace-dsh-counter.component.mjs +0 -80
  44. package/esm2020/lib/components/widgets/list/jace-dsh-list.component.mjs +0 -91
  45. package/esm2020/lib/components/widgets/multiprog/jace-dsh-multiprog.component.mjs +0 -82
  46. package/esm2020/lib/dashboard-feature.module.mjs +0 -98
  47. package/esm2020/lib/models/config/JaceDashboardConfig.mjs +0 -57
  48. package/esm2020/lib/models/externals/JaceDashboardLayoutAppSearch.mjs +0 -8
  49. package/esm2020/lib/models/externals/JaceDashboardLayoutDetail.mjs +0 -4
  50. package/esm2020/lib/models/externals/JaceWidgetInstanceDetail.mjs +0 -7
  51. package/esm2020/lib/models/externals/Repository.mjs +0 -6
  52. package/esm2020/lib/models/externals/SaveJaceDashboardLayoutDTO.mjs +0 -6
  53. package/esm2020/lib/models/options/DefaultDashboardModuleOptions.mjs +0 -35
  54. package/esm2020/lib/models/options/IDashboardModuleOptions.mjs +0 -2
  55. package/esm2020/lib/models/options/IWidgetTypeConfig.mjs +0 -2
  56. package/esm2020/lib/models/widgets/BaseJaceWidgetModel.mjs +0 -38
  57. package/esm2020/lib/models/widgets/IJaceWidgetModel.mjs +0 -2
  58. package/esm2020/lib/models/widgets/JaceChartWidgetModel.mjs +0 -29
  59. package/esm2020/lib/models/widgets/JaceCounterWidgetModel.mjs +0 -29
  60. package/esm2020/lib/models/widgets/JaceListWidgetModel.mjs +0 -48
  61. package/esm2020/lib/models/widgets/JaceMultiprogWidgetModel.mjs +0 -32
  62. package/esm2020/lib/services/DashboardWidgetFactory.mjs +0 -49
  63. package/esm2020/lib/services/IDashboardFeatureDataService.mjs +0 -2
  64. package/esm2020/lib/services/dashboard-feature.service.mjs +0 -58
  65. package/esm2020/lib/tokens.mjs +0 -8
  66. package/esm2020/public-api.mjs +0 -34
  67. package/fesm2015/esfaenza-dashboard-feature.mjs +0 -1076
  68. package/fesm2015/esfaenza-dashboard-feature.mjs.map +0 -1
  69. package/fesm2020/esfaenza-dashboard-feature.mjs +0 -1059
  70. package/fesm2020/esfaenza-dashboard-feature.mjs.map +0 -1
@@ -0,0 +1,1814 @@
1
+ import * as i0 from '@angular/core';
2
+ import { InjectionToken, EventEmitter, Output, Input, Inject, Component, Injectable, ViewContainerRef, ViewChildren, ViewEncapsulation, Optional, NgModule } from '@angular/core';
3
+ import * as i1 from '@angular/common';
4
+ import { DOCUMENT, CommonModule } from '@angular/common';
5
+ import * as i5 from '@angular/forms';
6
+ import { FormsModule } from '@angular/forms';
7
+ import * as i6 from 'angular-gridster2';
8
+ import { GridsterModule, GridType } from 'angular-gridster2';
9
+ import * as i2 from '@esfaenza/es-charts';
10
+ import { EsChartsModule } from '@esfaenza/es-charts';
11
+ import * as i1$1 from '@angular/router';
12
+ import { timer, Subject } from 'rxjs';
13
+ import * as i1$2 from '@esfaenza/extensions';
14
+ import { InboundMessageTypes } from '@esfaenza/extensions';
15
+ import { takeUntil, map } from 'rxjs/operators';
16
+ import * as i7 from '@esfaenza/forms-and-validations';
17
+ import { FormsAndValidationsModule } from '@esfaenza/forms-and-validations';
18
+ import * as i1$3 from '@esfaenza/httpservice';
19
+ import { HttpserviceModule } from '@esfaenza/httpservice';
20
+ import { HttpParams } from '@angular/common/http';
21
+ import { AppSearch } from '@esfaenza/es-table';
22
+
23
+ /**
24
+ * Token di registrazione della DashboardFeatureService.
25
+ * Permette di fare l'override dell'implementazione di default a scopo di test delle widget
26
+ */
27
+ const DSH_DATA_SERVICE = new InjectionToken('DSH_DATA_SERVICE');
28
+
29
+ const DSH_OPTIONS = new InjectionToken('DSH_MODULE_OPTIONS');
30
+
31
+ class JaceChartWidgetComponent {
32
+ constructor(dshService) {
33
+ this.dshService = dshService;
34
+ this.OnRemove = new EventEmitter();
35
+ this.configuration = false;
36
+ this.dataReady = false;
37
+ this.lastdate = "";
38
+ this.chartName = "";
39
+ }
40
+ setWidgetModel(dshBackendId, widgetModel) {
41
+ this.model = widgetModel;
42
+ if (this.model.backendid === undefined || this.model.backendid == "default_backend")
43
+ this.model.backendid = dshBackendId;
44
+ this.refreshData();
45
+ }
46
+ ngOnInit() { }
47
+ ngOnChanges(changes) {
48
+ //console.log(changes['DashboardDate'].currentValue);
49
+ if (changes['DashboardDate'].previousValue)
50
+ this.lastdate = changes['DashboardDate'].previousValue.toISOString();
51
+ let curdate = "";
52
+ if (changes['DashboardDate'].currentValue)
53
+ curdate = changes['DashboardDate'].currentValue.toISOString();
54
+ //fix per il datetimepicker material che cambia l'oggetto al momento del caricamento
55
+ if (this.lastdate != curdate) {
56
+ this.lastdate = curdate;
57
+ this.refreshData();
58
+ }
59
+ }
60
+ refreshData() {
61
+ if (!this.model)
62
+ return;
63
+ const pars = {};
64
+ if (this.DashboardDate)
65
+ pars["DT"] = this.DashboardDate.toISOString();
66
+ if (this.model.options && Object.keys(this.model.options).length != 0) {
67
+ for (let index = 0; index < Object.keys(this.model.options).length; index++) {
68
+ const k = Object.keys(this.model.options)[index];
69
+ pars[k] = this.model.options[k];
70
+ }
71
+ }
72
+ this.dshService.GetWidgetData(this.model.backendid, this.model.name, pars).subscribe(data => {
73
+ if (this.model) {
74
+ this.model.setData(data);
75
+ this.chartName = this.model.name;
76
+ this.dataReady = true;
77
+ }
78
+ });
79
+ }
80
+ removeWidget() {
81
+ if (!this.model)
82
+ return;
83
+ this.OnRemove.emit(this.model.name);
84
+ }
85
+ configure() {
86
+ if (this.configuration) {
87
+ //finito di configurare -> refreshData
88
+ this.refreshData();
89
+ }
90
+ this.configuration = !this.configuration;
91
+ }
92
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: JaceChartWidgetComponent, deps: [{ token: DSH_DATA_SERVICE }], target: i0.ɵɵFactoryTarget.Component }); }
93
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.18", type: JaceChartWidgetComponent, isStandalone: false, selector: "jace-dsh-chart", inputs: { DashboardDate: "DashboardDate" }, outputs: { OnRemove: "OnRemove" }, usesOnChanges: true, ngImport: i0, template: "<div class=\"jace-dsh-widget-header {{model?.name}}-header\">\r\n <div class=\"jace-dsh-widget-title\" *ngIf=\"model.title\">\r\n {{model.title}}\r\n </div>\r\n <div class=\"jace-dsh-widget-controls\" *ngIf=\"dataReady\">\r\n <span class=\"transition drag-handler jace-dsh-widget-drag\" *ngIf=\"model.dragEnabled\">\r\n <i class=\"fa fa-arrows-alt\"></i>\r\n </span>\r\n <span class=\"transition jace-dsh-widget-opts\" (click)=\"configure()\">\r\n <i class=\"fa fa-cog\"></i>\r\n </span>\r\n <span (click)=\"removeWidget()\" class=\"transition remove-button jace-dsh-widget-close\">\r\n <i class=\"fa fa-times\"></i>\r\n </span>\r\n </div>\r\n</div>\r\n<div class=\"jace-dsh-widget-body gridster-item-content {{model?.name}}-body\">\r\n <div class=\"jace-dsh-widget-loading\" *ngIf=\"!dataReady\">\r\n <i class=\"fa fa-spinner fa-spin\"></i>\r\n </div>\r\n\r\n <div class=\"jace-dsh-chart-container jace-dsh-widget-slide\"\r\n [ngClass]=\"{'jace-dsh-widget-content-hide':configuration,'jace-dsh-widget-content-show':!configuration}\"\r\n *ngIf=\"dataReady\">\r\n <!-- [Type]=\"Widget.chartType\" -->\r\n <h6 *ngIf=\"model?.queryerror\" class=\"fg-disabled\" style=\"margin-top: 0.5rem;\"><span\r\n class=\"fa fa-times-circle-o\"></span>&nbsp;&nbsp;Error retrieving data</h6>\r\n <es-chart [Legend]=\"model.legend\" [Theme]=\"'dataviz'\" [Type]=\"model.chartType\" [Data]=\"model.chartData\"\r\n [name]=\"chartName\"></es-chart>\r\n </div>\r\n\r\n <div class=\"jace-dsh-widget-settings jace-dsh-widget-slide \"\r\n [ngClass]=\"{'jace-dsh-widget-settings-hide':!configuration,'jace-dsh-widget-settings-show':configuration}\">\r\n <p>Configuration</p>\r\n </div>\r\n</div>", styles: [""], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i2.EsChartComponent, selector: "es-chart", inputs: ["Type", "Data", "DataArray"] }] }); }
94
+ }
95
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: JaceChartWidgetComponent, decorators: [{
96
+ type: Component,
97
+ args: [{ selector: 'jace-dsh-chart', standalone: false, template: "<div class=\"jace-dsh-widget-header {{model?.name}}-header\">\r\n <div class=\"jace-dsh-widget-title\" *ngIf=\"model.title\">\r\n {{model.title}}\r\n </div>\r\n <div class=\"jace-dsh-widget-controls\" *ngIf=\"dataReady\">\r\n <span class=\"transition drag-handler jace-dsh-widget-drag\" *ngIf=\"model.dragEnabled\">\r\n <i class=\"fa fa-arrows-alt\"></i>\r\n </span>\r\n <span class=\"transition jace-dsh-widget-opts\" (click)=\"configure()\">\r\n <i class=\"fa fa-cog\"></i>\r\n </span>\r\n <span (click)=\"removeWidget()\" class=\"transition remove-button jace-dsh-widget-close\">\r\n <i class=\"fa fa-times\"></i>\r\n </span>\r\n </div>\r\n</div>\r\n<div class=\"jace-dsh-widget-body gridster-item-content {{model?.name}}-body\">\r\n <div class=\"jace-dsh-widget-loading\" *ngIf=\"!dataReady\">\r\n <i class=\"fa fa-spinner fa-spin\"></i>\r\n </div>\r\n\r\n <div class=\"jace-dsh-chart-container jace-dsh-widget-slide\"\r\n [ngClass]=\"{'jace-dsh-widget-content-hide':configuration,'jace-dsh-widget-content-show':!configuration}\"\r\n *ngIf=\"dataReady\">\r\n <!-- [Type]=\"Widget.chartType\" -->\r\n <h6 *ngIf=\"model?.queryerror\" class=\"fg-disabled\" style=\"margin-top: 0.5rem;\"><span\r\n class=\"fa fa-times-circle-o\"></span>&nbsp;&nbsp;Error retrieving data</h6>\r\n <es-chart [Legend]=\"model.legend\" [Theme]=\"'dataviz'\" [Type]=\"model.chartType\" [Data]=\"model.chartData\"\r\n [name]=\"chartName\"></es-chart>\r\n </div>\r\n\r\n <div class=\"jace-dsh-widget-settings jace-dsh-widget-slide \"\r\n [ngClass]=\"{'jace-dsh-widget-settings-hide':!configuration,'jace-dsh-widget-settings-show':configuration}\">\r\n <p>Configuration</p>\r\n </div>\r\n</div>" }]
98
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
99
+ type: Inject,
100
+ args: [DSH_DATA_SERVICE]
101
+ }] }], propDecorators: { DashboardDate: [{
102
+ type: Input
103
+ }], OnRemove: [{
104
+ type: Output
105
+ }] } });
106
+
107
+ class JaceCounterWidgetComponent {
108
+ constructor(dshService) {
109
+ this.dshService = dshService;
110
+ this.OnRemove = new EventEmitter();
111
+ this.configuration = false;
112
+ this.dataReady = false;
113
+ this.lastdate = "";
114
+ }
115
+ //TODO per online update: importare cdr: ChangeDectectorRef
116
+ setWidgetModel(dshBackendId, widgetModel) {
117
+ this.model = widgetModel;
118
+ if (this.model.backendid === undefined || this.model.backendid == "default_backend")
119
+ this.model.backendid = dshBackendId;
120
+ this.refreshData();
121
+ }
122
+ ngOnInit() { }
123
+ ngOnChanges(changes) {
124
+ //console.log(changes['DashboardDate'].currentValue);
125
+ if (changes['DashboardDate'].previousValue)
126
+ this.lastdate = changes['DashboardDate'].previousValue.toISOString();
127
+ let curdate = "";
128
+ if (changes['DashboardDate'].currentValue)
129
+ curdate = changes['DashboardDate'].currentValue.toISOString();
130
+ //fix per il datetimepicker material che cambia l'oggetto al momento del caricamento
131
+ if (this.lastdate != curdate) {
132
+ this.lastdate = curdate;
133
+ this.refreshData();
134
+ }
135
+ }
136
+ refreshData() {
137
+ if (!this.model)
138
+ return;
139
+ const pars = {};
140
+ if (this.DashboardDate)
141
+ pars["DT"] = this.DashboardDate.toISOString();
142
+ if (this.model.options && Object.keys(this.model.options).length != 0) {
143
+ for (let index = 0; index < Object.keys(this.model.options).length; index++) {
144
+ const k = Object.keys(this.model.options)[index];
145
+ pars[k] = this.model.options[k];
146
+ }
147
+ }
148
+ this.dshService.GetWidgetData(this.model.backendid, this.model.name, pars).subscribe(data => {
149
+ if (this.model) {
150
+ this.model.setData(data);
151
+ this.dataReady = true;
152
+ //TODO per online update: this.cdr.markForCheck();
153
+ }
154
+ });
155
+ }
156
+ removeWidget() {
157
+ if (!this.model)
158
+ return;
159
+ this.OnRemove.emit(this.model.name);
160
+ }
161
+ configure() {
162
+ if (this.configuration) {
163
+ //finito di configurare -> refreshData
164
+ this.refreshData();
165
+ }
166
+ this.configuration = !this.configuration;
167
+ }
168
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: JaceCounterWidgetComponent, deps: [{ token: DSH_DATA_SERVICE }], target: i0.ɵɵFactoryTarget.Component }); }
169
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.18", type: JaceCounterWidgetComponent, isStandalone: false, selector: "jace-dsh-counter", inputs: { DashboardDate: "DashboardDate" }, outputs: { OnRemove: "OnRemove" }, usesOnChanges: true, ngImport: i0, template: "<div class=\"jace-dsh-widget-header {{model?.name}}-header\">\r\n <div class=\"jace-dsh-widget-title\" *ngIf=\"model.title\">\r\n {{model.title}}\r\n </div>\r\n <div class=\"jace-dsh-widget-controls\" *ngIf=\"dataReady\">\r\n <span class=\"transition drag-handler jace-dsh-widget-drag\" *ngIf=\"model.dragEnabled\">\r\n <i class=\"fa fa-arrows-alt\"></i>\r\n </span>\r\n <span class=\"transition jace-dsh-widget-opts\" (click)=\"configure()\">\r\n <i class=\"fa fa-cog\"></i>\r\n </span>\r\n <span (click)=\"removeWidget()\" class=\"transition remove-button jace-dsh-widget-close\">\r\n <i class=\"fa fa-times\"></i>\r\n </span>\r\n </div>\r\n</div>\r\n<div class=\"jace-dsh-widget-body gridster-item-content {{model?.name}}-body\">\r\n <div class=\"jace-dsh-widget-loading\" *ngIf=\"!dataReady\">\r\n <i class=\"fa fa-spinner fa-spin\"></i>\r\n </div>\r\n <div class=\"jace-dsh-counter-body jace-dsh-widget-slide\"\r\n [ngClass]=\"{'jace-dsh-widget-content-hide':configuration,'jace-dsh-widget-content-show':!configuration}\"\r\n *ngIf=\"dataReady\">\r\n <i class=\"jace-dsh-counter-icon fa fa-2x\" [ngClass]=\"[ model.icon ? model.icon : '']\" *ngIf=\"model.icon\"></i>\r\n <div class=\"jace-dsh-counter-super\">{{model.superText}}</div>\r\n <div class=\"jace-dsh-counter-value\"><span>{{model.value}}</span> <span\r\n class=\"jace-dsh-counter-unit\">{{model.unit}}</span> </div>\r\n\r\n <div class=\"jace-dsh-counter-sub\">{{model.subText}}</div>\r\n </div>\r\n\r\n <div class=\"jace-dsh-widget-settings jace-dsh-widget-slide \"\r\n [ngClass]=\"{'jace-dsh-widget-settings-hide':!configuration,'jace-dsh-widget-settings-show':configuration}\">\r\n <p>Configuration</p>\r\n </div>\r\n</div>", styles: [".jace-dsh-counter-body{padding:1em .5em}.jace-dsh-counter-value{font-size:2em;font-weight:700;text-align:center}.jace-dsh-counter-unit{margin-left:.08em;font-size:.5em;text-align:center}.jace-dsh-counter-super{font-size:1em;text-align:center}.jace-dsh-counter-sub{font-size:.8em;text-align:center}.jace-dsh-counter-icon{position:absolute;font-size:2.6em;color:#b0c4de}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] }); }
170
+ }
171
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: JaceCounterWidgetComponent, decorators: [{
172
+ type: Component,
173
+ args: [{ selector: 'jace-dsh-counter', standalone: false, template: "<div class=\"jace-dsh-widget-header {{model?.name}}-header\">\r\n <div class=\"jace-dsh-widget-title\" *ngIf=\"model.title\">\r\n {{model.title}}\r\n </div>\r\n <div class=\"jace-dsh-widget-controls\" *ngIf=\"dataReady\">\r\n <span class=\"transition drag-handler jace-dsh-widget-drag\" *ngIf=\"model.dragEnabled\">\r\n <i class=\"fa fa-arrows-alt\"></i>\r\n </span>\r\n <span class=\"transition jace-dsh-widget-opts\" (click)=\"configure()\">\r\n <i class=\"fa fa-cog\"></i>\r\n </span>\r\n <span (click)=\"removeWidget()\" class=\"transition remove-button jace-dsh-widget-close\">\r\n <i class=\"fa fa-times\"></i>\r\n </span>\r\n </div>\r\n</div>\r\n<div class=\"jace-dsh-widget-body gridster-item-content {{model?.name}}-body\">\r\n <div class=\"jace-dsh-widget-loading\" *ngIf=\"!dataReady\">\r\n <i class=\"fa fa-spinner fa-spin\"></i>\r\n </div>\r\n <div class=\"jace-dsh-counter-body jace-dsh-widget-slide\"\r\n [ngClass]=\"{'jace-dsh-widget-content-hide':configuration,'jace-dsh-widget-content-show':!configuration}\"\r\n *ngIf=\"dataReady\">\r\n <i class=\"jace-dsh-counter-icon fa fa-2x\" [ngClass]=\"[ model.icon ? model.icon : '']\" *ngIf=\"model.icon\"></i>\r\n <div class=\"jace-dsh-counter-super\">{{model.superText}}</div>\r\n <div class=\"jace-dsh-counter-value\"><span>{{model.value}}</span> <span\r\n class=\"jace-dsh-counter-unit\">{{model.unit}}</span> </div>\r\n\r\n <div class=\"jace-dsh-counter-sub\">{{model.subText}}</div>\r\n </div>\r\n\r\n <div class=\"jace-dsh-widget-settings jace-dsh-widget-slide \"\r\n [ngClass]=\"{'jace-dsh-widget-settings-hide':!configuration,'jace-dsh-widget-settings-show':configuration}\">\r\n <p>Configuration</p>\r\n </div>\r\n</div>", styles: [".jace-dsh-counter-body{padding:1em .5em}.jace-dsh-counter-value{font-size:2em;font-weight:700;text-align:center}.jace-dsh-counter-unit{margin-left:.08em;font-size:.5em;text-align:center}.jace-dsh-counter-super{font-size:1em;text-align:center}.jace-dsh-counter-sub{font-size:.8em;text-align:center}.jace-dsh-counter-icon{position:absolute;font-size:2.6em;color:#b0c4de}\n"] }]
174
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
175
+ type: Inject,
176
+ args: [DSH_DATA_SERVICE]
177
+ }] }], propDecorators: { DashboardDate: [{
178
+ type: Input
179
+ }], OnRemove: [{
180
+ type: Output
181
+ }] } });
182
+
183
+ class JaceListWidgetComponent {
184
+ constructor(dshService, router) {
185
+ this.dshService = dshService;
186
+ this.router = router;
187
+ this.OnRemove = new EventEmitter();
188
+ this.configuration = false;
189
+ this.dataReady = false;
190
+ this.lastdate = "";
191
+ }
192
+ setWidgetModel(dshBackendId, widgetModel) {
193
+ this.model = widgetModel;
194
+ if (this.model.backendid === undefined || this.model.backendid == "default_backend")
195
+ this.model.backendid = dshBackendId;
196
+ this.refreshData();
197
+ }
198
+ ngOnInit() { }
199
+ ngOnChanges(changes) {
200
+ //console.log(changes['DashboardDate'].currentValue);
201
+ if (changes['DashboardDate'].previousValue)
202
+ this.lastdate = changes['DashboardDate'].previousValue.toISOString();
203
+ let curdate = "";
204
+ if (changes['DashboardDate'].currentValue)
205
+ curdate = changes['DashboardDate'].currentValue.toISOString();
206
+ //fix per il datetimepicker material che cambia l'oggetto al momento del caricamento
207
+ if (this.lastdate != curdate) {
208
+ this.lastdate = curdate;
209
+ this.refreshData();
210
+ }
211
+ }
212
+ refreshData() {
213
+ if (!this.model)
214
+ return;
215
+ const pars = {};
216
+ if (this.DashboardDate)
217
+ pars["DT"] = this.DashboardDate.toISOString();
218
+ if (this.model.options && Object.keys(this.model.options).length != 0) {
219
+ for (let index = 0; index < Object.keys(this.model.options).length; index++) {
220
+ const k = Object.keys(this.model.options)[index];
221
+ pars[k] = this.model.options[k];
222
+ }
223
+ }
224
+ this.dshService.GetWidgetData(this.model.backendid, this.model.name, pars).subscribe(data => {
225
+ if (this.model) {
226
+ this.model.setData(data);
227
+ this.dataReady = true;
228
+ }
229
+ });
230
+ }
231
+ removeWidget() {
232
+ if (!this.model)
233
+ return;
234
+ this.OnRemove.emit(this.model.name);
235
+ }
236
+ itemClicked(item) {
237
+ if (item.link) {
238
+ //naviga al link
239
+ let to = item.link;
240
+ let par = {};
241
+ if (item.id && item.idParamName) {
242
+ par[item.idParamName] = item.id;
243
+ }
244
+ this.router.navigate([to, par]);
245
+ }
246
+ }
247
+ configure() {
248
+ if (this.configuration) {
249
+ //finito di configurare -> refreshData
250
+ this.refreshData();
251
+ }
252
+ this.configuration = !this.configuration;
253
+ }
254
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: JaceListWidgetComponent, deps: [{ token: DSH_DATA_SERVICE }, { token: i1$1.Router }], target: i0.ɵɵFactoryTarget.Component }); }
255
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.18", type: JaceListWidgetComponent, isStandalone: false, selector: "jace-dsh-list", inputs: { DashboardDate: "DashboardDate" }, outputs: { OnRemove: "OnRemove" }, usesOnChanges: true, ngImport: i0, template: "<div class=\"jace-dsh-widget-header {{model?.name}}-header\">\r\n <div class=\"jace-dsh-widget-title\" *ngIf=\"model.title\">\r\n {{model.title}}\r\n </div>\r\n <div class=\"jace-dsh-widget-controls\" *ngIf=\"dataReady\">\r\n <span class=\"transition drag-handler jace-dsh-widget-drag\" *ngIf=\"model.dragEnabled\">\r\n <i class=\"fa fa-arrows-alt\"></i>\r\n </span>\r\n <span class=\"transition jace-dsh-widget-opts\" (click)=\"configure()\">\r\n <i class=\"fa fa-cog\"></i>\r\n </span>\r\n <span (click)=\"removeWidget()\" class=\"transition remove-button jace-dsh-widget-close\">\r\n <i class=\"fa fa-times\"></i>\r\n </span>\r\n </div>\r\n</div>\r\n<div class=\"jace-dsh-widget-body gridster-item-content {{model?.name}}-body\">\r\n <div class=\"jace-dsh-widget-loading\" *ngIf=\"!dataReady\">\r\n <i class=\"fa fa-spinner fa-spin\"></i>\r\n </div>\r\n <div class=\"jace-dsh-list-body jace-dsh-widget-slide\"\r\n [ngClass]=\"{'jace-dsh-widget-content-hide':configuration,'jace-dsh-widget-content-show':!configuration}\"\r\n *ngIf=\"dataReady\">\r\n <div class=\"jace-dsh-list-super-text\" *ngIf=\"model.superText\">{{model.superText}}</div>\r\n <div class=\"jace-dsh-list-item\" (click)=\"itemClicked(item)\" [class.jace-dsh-list-link]=\"item.link\"\r\n *ngFor=\"let item of model.items\">\r\n <div>\r\n <span class=\"jace-dsh-list-item-id\" *ngIf=\"item.id && item.showId\">{{item.id}}</span>\r\n <span>{{item.description}}</span>\r\n </div>\r\n <div *ngIf=\"item.subline\">\r\n <span class=\"jace-dsh-list-item-subline\">{{item.subline}}</span>\r\n </div>\r\n </div>\r\n\r\n </div>\r\n <div class=\"jace-dsh-widget-settings jace-dsh-widget-slide \"\r\n [ngClass]=\"{'jace-dsh-widget-settings-hide':!configuration,'jace-dsh-widget-settings-show':configuration}\">\r\n <p>Configuration</p>\r\n </div>\r\n</div>", styles: [".jace-dsh-list-body{height:100%;overflow-y:auto}.jace-dsh-list-super-text{font-weight:500}.jace-dsh-list-item{display:flow;flex-direction:row;justify-content:flex-start;padding:.4em;border:1px solid #eee;margin-top:2px}.jace-dsh-list-item-id{margin-right:1em;color:#fff;background:#637ca0;font-size:.8em;padding:.2em .5em;border-radius:.2em}.jace-dsh-list-link{color:#0275d8!important;cursor:pointer;text-decoration:none;display:block}.jace-dsh-list-link:hover{cursor:pointer;color:#fff;background-color:#b0c4de;text-decoration:underline}.jace-dsh-list-item-subline{font-size:.5em}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] }); }
256
+ }
257
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: JaceListWidgetComponent, decorators: [{
258
+ type: Component,
259
+ args: [{ selector: 'jace-dsh-list', standalone: false, template: "<div class=\"jace-dsh-widget-header {{model?.name}}-header\">\r\n <div class=\"jace-dsh-widget-title\" *ngIf=\"model.title\">\r\n {{model.title}}\r\n </div>\r\n <div class=\"jace-dsh-widget-controls\" *ngIf=\"dataReady\">\r\n <span class=\"transition drag-handler jace-dsh-widget-drag\" *ngIf=\"model.dragEnabled\">\r\n <i class=\"fa fa-arrows-alt\"></i>\r\n </span>\r\n <span class=\"transition jace-dsh-widget-opts\" (click)=\"configure()\">\r\n <i class=\"fa fa-cog\"></i>\r\n </span>\r\n <span (click)=\"removeWidget()\" class=\"transition remove-button jace-dsh-widget-close\">\r\n <i class=\"fa fa-times\"></i>\r\n </span>\r\n </div>\r\n</div>\r\n<div class=\"jace-dsh-widget-body gridster-item-content {{model?.name}}-body\">\r\n <div class=\"jace-dsh-widget-loading\" *ngIf=\"!dataReady\">\r\n <i class=\"fa fa-spinner fa-spin\"></i>\r\n </div>\r\n <div class=\"jace-dsh-list-body jace-dsh-widget-slide\"\r\n [ngClass]=\"{'jace-dsh-widget-content-hide':configuration,'jace-dsh-widget-content-show':!configuration}\"\r\n *ngIf=\"dataReady\">\r\n <div class=\"jace-dsh-list-super-text\" *ngIf=\"model.superText\">{{model.superText}}</div>\r\n <div class=\"jace-dsh-list-item\" (click)=\"itemClicked(item)\" [class.jace-dsh-list-link]=\"item.link\"\r\n *ngFor=\"let item of model.items\">\r\n <div>\r\n <span class=\"jace-dsh-list-item-id\" *ngIf=\"item.id && item.showId\">{{item.id}}</span>\r\n <span>{{item.description}}</span>\r\n </div>\r\n <div *ngIf=\"item.subline\">\r\n <span class=\"jace-dsh-list-item-subline\">{{item.subline}}</span>\r\n </div>\r\n </div>\r\n\r\n </div>\r\n <div class=\"jace-dsh-widget-settings jace-dsh-widget-slide \"\r\n [ngClass]=\"{'jace-dsh-widget-settings-hide':!configuration,'jace-dsh-widget-settings-show':configuration}\">\r\n <p>Configuration</p>\r\n </div>\r\n</div>", styles: [".jace-dsh-list-body{height:100%;overflow-y:auto}.jace-dsh-list-super-text{font-weight:500}.jace-dsh-list-item{display:flow;flex-direction:row;justify-content:flex-start;padding:.4em;border:1px solid #eee;margin-top:2px}.jace-dsh-list-item-id{margin-right:1em;color:#fff;background:#637ca0;font-size:.8em;padding:.2em .5em;border-radius:.2em}.jace-dsh-list-link{color:#0275d8!important;cursor:pointer;text-decoration:none;display:block}.jace-dsh-list-link:hover{cursor:pointer;color:#fff;background-color:#b0c4de;text-decoration:underline}.jace-dsh-list-item-subline{font-size:.5em}\n"] }]
260
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
261
+ type: Inject,
262
+ args: [DSH_DATA_SERVICE]
263
+ }] }, { type: i1$1.Router }], propDecorators: { DashboardDate: [{
264
+ type: Input
265
+ }], OnRemove: [{
266
+ type: Output
267
+ }] } });
268
+
269
+ class CircleProgressOptions {
270
+ constructor() {
271
+ this.class = '';
272
+ this.backgroundGradient = false;
273
+ this.backgroundColor = 'transparent';
274
+ this.backgroundGradientStopColor = 'transparent';
275
+ this.backgroundOpacity = 1;
276
+ this.backgroundStroke = 'transparent';
277
+ this.backgroundStrokeWidth = 0;
278
+ this.backgroundPadding = 5;
279
+ this.percent = 0;
280
+ this.radius = 90;
281
+ this.space = 4;
282
+ this.toFixed = 0;
283
+ this.maxPercent = 1000;
284
+ this.renderOnClick = true;
285
+ this.units = '%';
286
+ this.unitsFontSize = '10';
287
+ this.unitsFontWeight = 'normal';
288
+ this.unitsColor = '#444444';
289
+ this.outerStrokeGradient = false;
290
+ this.outerStrokeWidth = 8;
291
+ this.outerStrokeColor = '#78C000';
292
+ this.outerStrokeGradientStopColor = 'transparent';
293
+ this.outerStrokeLinecap = 'round';
294
+ this.innerStrokeColor = '#C7E596';
295
+ this.innerStrokeWidth = 4;
296
+ this.titleFormat = undefined;
297
+ this.title = 'auto';
298
+ this.titleColor = '#444444';
299
+ this.titleFontSize = '20';
300
+ this.titleFontWeight = 'normal';
301
+ this.subtitleFormat = undefined;
302
+ this.subtitle = 'progress';
303
+ this.subtitleColor = '#A9A9A9';
304
+ this.subtitleFontSize = '10';
305
+ this.subtitleFontWeight = 'normal';
306
+ this.imageSrc = undefined;
307
+ this.imageHeight = 0;
308
+ this.imageWidth = 0;
309
+ this.animation = true;
310
+ this.animateTitle = true;
311
+ this.animateSubtitle = false;
312
+ this.animationDuration = 500;
313
+ this.showTitle = true;
314
+ this.showSubtitle = true;
315
+ this.showUnits = true;
316
+ this.showImage = false;
317
+ this.showBackground = true;
318
+ this.showInnerStroke = true;
319
+ this.clockwise = true;
320
+ this.responsive = false;
321
+ this.startFromZero = true;
322
+ this.showZeroOuterStroke = true;
323
+ this.lazy = false;
324
+ }
325
+ }
326
+ class CircleProgressComponent {
327
+ emitClickEvent(event) {
328
+ if (this.options.renderOnClick) {
329
+ this.animate(0, this.options.percent);
330
+ }
331
+ if (this.onClick.observers.length > 0) {
332
+ this.onClick.emit(event);
333
+ }
334
+ }
335
+ isDrawing() {
336
+ return (this._timerSubscription && !this._timerSubscription.closed);
337
+ }
338
+ findSvgElement() {
339
+ if (this.svgElement === null) {
340
+ let tags = this.elRef.nativeElement.getElementsByTagName('svg');
341
+ if (tags.length > 0) {
342
+ this.svgElement = tags[0];
343
+ }
344
+ }
345
+ }
346
+ isElementInViewport(el) {
347
+ // Return false if el has not been created in page.
348
+ if (el === null || el === undefined)
349
+ return false;
350
+ // Check if the element is out of view due to a container scrolling
351
+ let rect = el.getBoundingClientRect(), parent = el.parentNode, parentRect;
352
+ do {
353
+ parentRect = parent.getBoundingClientRect();
354
+ if (rect.top >= parentRect.bottom)
355
+ return false;
356
+ if (rect.bottom <= parentRect.top)
357
+ return false;
358
+ if (rect.left >= parentRect.right)
359
+ return false;
360
+ if (rect.right <= parentRect.left)
361
+ return false;
362
+ parent = parent.parentNode;
363
+ } while (parent != this.document.body);
364
+ // Check its within the document viewport
365
+ if (rect.top >= (this.window.innerHeight || this.document.documentElement.clientHeight))
366
+ return false;
367
+ if (rect.bottom <= 0)
368
+ return false;
369
+ if (rect.left >= (this.window.innerWidth || this.document.documentElement.clientWidth))
370
+ return false;
371
+ if (rect.right <= 0)
372
+ return false;
373
+ return true;
374
+ }
375
+ ngOnInit() {
376
+ this.loadEventsForLazyMode();
377
+ }
378
+ ngOnDestroy() {
379
+ this.unloadEventsForLazyMode();
380
+ }
381
+ ngOnChanges(changes) {
382
+ this.render();
383
+ if ('lazy' in changes) {
384
+ changes.lazy.currentValue ? this.loadEventsForLazyMode() : this.unloadEventsForLazyMode();
385
+ }
386
+ }
387
+ constructor(defaultOptions, ngZone, elRef, injector) {
388
+ this.ngZone = ngZone;
389
+ this.elRef = elRef;
390
+ this.onClick = new EventEmitter();
391
+ // <svg> of component
392
+ this.svgElement = null;
393
+ // whether <svg> is in viewport
394
+ this.isInViewport = false;
395
+ // event for notifying viewport change caused by scrolling or resizing
396
+ this.onViewportChanged = new EventEmitter();
397
+ this._viewportChangedSubscriber = null;
398
+ this.options = new CircleProgressOptions();
399
+ this.defaultOptions = new CircleProgressOptions();
400
+ this._lastPercent = 0;
401
+ this._gradientUUID = null;
402
+ this.render = () => {
403
+ this.applyOptions();
404
+ if (this.options.lazy) {
405
+ // Draw svg if it doesn't exist
406
+ this.svgElement === null && this.draw(this._lastPercent);
407
+ // Draw it only when it's in the viewport
408
+ if (this.isInViewport) {
409
+ // Draw it at the latest position when I am in.
410
+ if (this.options.animation && this.options.animationDuration > 0) {
411
+ this.animate(this._lastPercent, this.options.percent);
412
+ }
413
+ else {
414
+ this.draw(this.options.percent);
415
+ }
416
+ this._lastPercent = this.options.percent;
417
+ }
418
+ }
419
+ else {
420
+ if (this.options.animation && this.options.animationDuration > 0) {
421
+ this.animate(this._lastPercent, this.options.percent);
422
+ }
423
+ else {
424
+ this.draw(this.options.percent);
425
+ }
426
+ this._lastPercent = this.options.percent;
427
+ }
428
+ };
429
+ this.polarToCartesian = (centerX, centerY, radius, angleInDegrees) => {
430
+ let angleInRadius = angleInDegrees * Math.PI / 180;
431
+ let x = centerX + Math.sin(angleInRadius) * radius;
432
+ let y = centerY - Math.cos(angleInRadius) * radius;
433
+ return { x: x, y: y };
434
+ };
435
+ this.draw = (percent) => {
436
+ // make percent reasonable
437
+ percent = (percent === undefined) ? this.options.percent : Math.abs(percent);
438
+ // circle percent shouldn't be greater than 100%.
439
+ let circlePercent = (percent > 100) ? 100 : percent;
440
+ // determine box size
441
+ let boxSize = this.options.radius * 2 + this.options.outerStrokeWidth * 2;
442
+ if (this.options.showBackground) {
443
+ boxSize += (this.options.backgroundStrokeWidth * 2 + this.max(0, this.options.backgroundPadding * 2));
444
+ }
445
+ // the centre of the circle
446
+ let centre = { x: boxSize / 2, y: boxSize / 2 };
447
+ // the start point of the arc
448
+ let startPoint = { x: centre.x, y: centre.y - this.options.radius };
449
+ // get the end point of the arc
450
+ let endPoint = this.polarToCartesian(centre.x, centre.y, this.options.radius, 360 * (this.options.clockwise ?
451
+ circlePercent :
452
+ (100 - circlePercent)) / 100); // ####################
453
+ // We'll get an end point with the same [x, y] as the start point when percent is 100%, so move x a little bit.
454
+ if (circlePercent === 100) {
455
+ endPoint.x = endPoint.x + (this.options.clockwise ? -0.01 : +0.01);
456
+ }
457
+ // largeArcFlag and sweepFlag
458
+ let largeArcFlag, sweepFlag;
459
+ if (circlePercent > 50) {
460
+ [largeArcFlag, sweepFlag] = this.options.clockwise ? [1, 1] : [1, 0];
461
+ }
462
+ else {
463
+ [largeArcFlag, sweepFlag] = this.options.clockwise ? [0, 1] : [0, 0];
464
+ }
465
+ // percent may not equal the actual percent
466
+ let titlePercent = this.options.animateTitle ? percent : this.options.percent;
467
+ let titleTextPercent = titlePercent > this.options.maxPercent ?
468
+ `${this.options.maxPercent.toFixed(this.options.toFixed)}+` : titlePercent.toFixed(this.options.toFixed);
469
+ let subtitlePercent = this.options.animateSubtitle ? percent : this.options.percent;
470
+ // get title object
471
+ let title = {
472
+ x: centre.x,
473
+ y: centre.y,
474
+ textAnchor: 'middle',
475
+ color: this.options.titleColor,
476
+ fontSize: this.options.titleFontSize,
477
+ fontWeight: this.options.titleFontWeight,
478
+ texts: [],
479
+ tspans: []
480
+ };
481
+ // from v0.9.9, both title and titleFormat(...) may be an array of string.
482
+ if (this.options.titleFormat !== undefined && this.options.titleFormat.constructor.name === 'Function') {
483
+ let formatted = this.options.titleFormat(titlePercent);
484
+ if (formatted instanceof Array) {
485
+ title.texts = [...formatted];
486
+ }
487
+ else {
488
+ title.texts.push(formatted.toString());
489
+ }
490
+ }
491
+ else {
492
+ if (this.options.title === 'auto') {
493
+ title.texts.push(titleTextPercent);
494
+ }
495
+ else {
496
+ if (this.options.title instanceof Array) {
497
+ title.texts = [...this.options.title];
498
+ }
499
+ else {
500
+ title.texts.push(this.options.title.toString());
501
+ }
502
+ }
503
+ }
504
+ // get subtitle object
505
+ let subtitle = {
506
+ x: centre.x,
507
+ y: centre.y,
508
+ textAnchor: 'middle',
509
+ color: this.options.subtitleColor,
510
+ fontSize: this.options.subtitleFontSize,
511
+ fontWeight: this.options.subtitleFontWeight,
512
+ texts: [],
513
+ tspans: []
514
+ };
515
+ // from v0.9.9, both subtitle and subtitleFormat(...) may be an array of string.
516
+ if (this.options.subtitleFormat !== undefined && this.options.subtitleFormat.constructor.name === 'Function') {
517
+ let formatted = this.options.subtitleFormat(subtitlePercent);
518
+ if (formatted instanceof Array) {
519
+ subtitle.texts = [...formatted];
520
+ }
521
+ else {
522
+ subtitle.texts.push(formatted.toString());
523
+ }
524
+ }
525
+ else {
526
+ if (this.options.subtitle instanceof Array) {
527
+ subtitle.texts = [...this.options.subtitle];
528
+ }
529
+ else {
530
+ subtitle.texts.push(this.options.subtitle.toString());
531
+ }
532
+ }
533
+ // get units object
534
+ let units = {
535
+ text: `${this.options.units}`,
536
+ fontSize: this.options.unitsFontSize,
537
+ fontWeight: this.options.unitsFontWeight,
538
+ color: this.options.unitsColor
539
+ };
540
+ // get total count of text lines to be shown
541
+ let rowCount = 0, rowNum = 1;
542
+ this.options.showTitle && (rowCount += title.texts.length);
543
+ this.options.showSubtitle && (rowCount += subtitle.texts.length);
544
+ // calc dy for each tspan for title
545
+ if (this.options.showTitle) {
546
+ for (let span of title.texts) {
547
+ title.tspans.push({ span: span, dy: this.getRelativeY(rowNum, rowCount) });
548
+ rowNum++;
549
+ }
550
+ }
551
+ // calc dy for each tspan for subtitle
552
+ if (this.options.showSubtitle) {
553
+ for (let span of subtitle.texts) {
554
+ subtitle.tspans.push({ span: span, dy: this.getRelativeY(rowNum, rowCount) });
555
+ rowNum++;
556
+ }
557
+ }
558
+ // create ID for gradient element
559
+ if (null === this._gradientUUID) {
560
+ this._gradientUUID = this.uuid();
561
+ }
562
+ // Bring it all together
563
+ this.svg = {
564
+ viewBox: `0 0 ${boxSize} ${boxSize}`,
565
+ // Set both width and height to '100%' if it's responsive
566
+ width: this.options.responsive ? '100%' : boxSize,
567
+ height: this.options.responsive ? '100%' : boxSize,
568
+ backgroundCircle: {
569
+ cx: centre.x,
570
+ cy: centre.y,
571
+ r: this.options.radius + this.options.outerStrokeWidth / 2 + this.options.backgroundPadding,
572
+ fill: this.options.backgroundColor,
573
+ fillOpacity: this.options.backgroundOpacity,
574
+ stroke: this.options.backgroundStroke,
575
+ strokeWidth: this.options.backgroundStrokeWidth,
576
+ },
577
+ path: {
578
+ // A rx ry x-axis-rotation large-arc-flag sweep-flag x y (https://developer.mozilla.org/en/docs/Web/SVG/Tutorial/Paths#Arcs)
579
+ d: `M ${startPoint.x} ${startPoint.y}
580
+ A ${this.options.radius} ${this.options.radius} 0 ${largeArcFlag} ${sweepFlag} ${endPoint.x} ${endPoint.y}`,
581
+ stroke: this.options.outerStrokeColor,
582
+ strokeWidth: this.options.outerStrokeWidth,
583
+ strokeLinecap: this.options.outerStrokeLinecap,
584
+ fill: 'none'
585
+ },
586
+ circle: {
587
+ cx: centre.x,
588
+ cy: centre.y,
589
+ r: this.options.radius - this.options.space - this.options.outerStrokeWidth / 2 - this.options.innerStrokeWidth / 2,
590
+ fill: 'none',
591
+ stroke: this.options.innerStrokeColor,
592
+ strokeWidth: this.options.innerStrokeWidth,
593
+ },
594
+ title: title,
595
+ units: units,
596
+ subtitle: subtitle,
597
+ image: {
598
+ x: centre.x - this.options.imageWidth / 2,
599
+ y: centre.y - this.options.imageHeight / 2,
600
+ src: this.options.imageSrc,
601
+ width: this.options.imageWidth,
602
+ height: this.options.imageHeight,
603
+ },
604
+ outerLinearGradient: {
605
+ id: 'outer-linear-' + this._gradientUUID,
606
+ colorStop1: this.options.outerStrokeColor,
607
+ colorStop2: this.options.outerStrokeGradientStopColor === 'transparent' ? '#FFF' : this.options.outerStrokeGradientStopColor,
608
+ },
609
+ radialGradient: {
610
+ id: 'radial-' + this._gradientUUID,
611
+ colorStop1: this.options.backgroundColor,
612
+ colorStop2: this.options.backgroundGradientStopColor === 'transparent' ? '#FFF' : this.options.backgroundGradientStopColor,
613
+ }
614
+ };
615
+ };
616
+ this.getAnimationParameters = (previousPercent, currentPercent) => {
617
+ const MIN_INTERVAL = 10;
618
+ let times, step, interval;
619
+ let fromPercent = this.options.startFromZero ? 0 : (previousPercent < 0 ? 0 : previousPercent);
620
+ let toPercent = currentPercent < 0 ? 0 : this.min(currentPercent, this.options.maxPercent);
621
+ let delta = Math.abs(Math.round(toPercent - fromPercent));
622
+ if (delta >= 100) {
623
+ // we will finish animation in 100 times
624
+ times = 100;
625
+ if (!this.options.animateTitle && !this.options.animateSubtitle) {
626
+ step = 1;
627
+ }
628
+ else {
629
+ // show title or subtitle animation even if the arc is full, we also need to finish it in 100 times.
630
+ step = Math.round(delta / times);
631
+ }
632
+ }
633
+ else {
634
+ // we will finish in as many times as the number of percent.
635
+ times = delta;
636
+ step = 1;
637
+ }
638
+ // Get the interval of timer
639
+ interval = Math.round(this.options.animationDuration / times);
640
+ // Readjust all values if the interval of timer is extremely small.
641
+ if (interval < MIN_INTERVAL) {
642
+ interval = MIN_INTERVAL;
643
+ times = this.options.animationDuration / interval;
644
+ if (!this.options.animateTitle && !this.options.animateSubtitle && delta > 100) {
645
+ step = Math.round(100 / times);
646
+ }
647
+ else {
648
+ step = Math.round(delta / times);
649
+ }
650
+ }
651
+ // step must be greater than 0.
652
+ if (step < 1) {
653
+ step = 1;
654
+ }
655
+ return { times: times, step: step, interval: interval };
656
+ };
657
+ this.animate = (previousPercent, currentPercent) => {
658
+ if (this._timerSubscription && !this._timerSubscription.closed) {
659
+ this._timerSubscription.unsubscribe();
660
+ }
661
+ let fromPercent = this.options.startFromZero ? 0 : previousPercent;
662
+ let toPercent = currentPercent;
663
+ let { step: step, interval: interval } = this.getAnimationParameters(fromPercent, toPercent);
664
+ let count = fromPercent;
665
+ if (fromPercent < toPercent) {
666
+ this._timerSubscription = timer(0, interval).subscribe(() => {
667
+ count += step;
668
+ if (count <= toPercent) {
669
+ if (!this.options.animateTitle && !this.options.animateSubtitle && count >= 100) {
670
+ this.draw(toPercent);
671
+ this._timerSubscription.unsubscribe();
672
+ }
673
+ else {
674
+ this.draw(count);
675
+ }
676
+ }
677
+ else {
678
+ this.draw(toPercent);
679
+ this._timerSubscription.unsubscribe();
680
+ }
681
+ });
682
+ }
683
+ else {
684
+ this._timerSubscription = timer(0, interval).subscribe(() => {
685
+ count -= step;
686
+ if (count >= toPercent) {
687
+ if (!this.options.animateTitle && !this.options.animateSubtitle && toPercent >= 100) {
688
+ this.draw(toPercent);
689
+ this._timerSubscription.unsubscribe();
690
+ }
691
+ else {
692
+ this.draw(count);
693
+ }
694
+ }
695
+ else {
696
+ this.draw(toPercent);
697
+ this._timerSubscription.unsubscribe();
698
+ }
699
+ });
700
+ }
701
+ };
702
+ this.applyOptions = () => {
703
+ // the options of <circle-progress> may change already
704
+ for (let name of Object.keys(this.options)) {
705
+ if (this.hasOwnProperty(name) && this[name] !== undefined) {
706
+ this.options[name] = this[name];
707
+ }
708
+ else if (this.templateOptions && this.templateOptions[name] !== undefined) {
709
+ this.options[name] = this.templateOptions[name];
710
+ }
711
+ }
712
+ // make sure key options valid
713
+ this.options.radius = Math.abs(+this.options.radius);
714
+ this.options.space = +this.options.space;
715
+ this.options.percent = +this.options.percent > 0 ? +this.options.percent : 0;
716
+ this.options.maxPercent = Math.abs(+this.options.maxPercent);
717
+ this.options.animationDuration = Math.abs(this.options.animationDuration);
718
+ this.options.outerStrokeWidth = Math.abs(+this.options.outerStrokeWidth);
719
+ this.options.innerStrokeWidth = Math.abs(+this.options.innerStrokeWidth);
720
+ this.options.backgroundPadding = +this.options.backgroundPadding;
721
+ };
722
+ this.getRelativeY = (rowNum, rowCount) => {
723
+ // why '-0.18em'? It's a magic number when property 'alignment-baseline' equals 'baseline'. :)
724
+ let initialOffset = -0.18, offset = 1;
725
+ return (initialOffset + offset * (rowNum - rowCount / 2)).toFixed(2) + 'em';
726
+ };
727
+ this.min = (a, b) => {
728
+ return a < b ? a : b;
729
+ };
730
+ this.max = (a, b) => {
731
+ return a > b ? a : b;
732
+ };
733
+ this.uuid = () => {
734
+ // https://www.w3resource.com/javascript-exercises/javascript-math-exercise-23.php
735
+ var dt = new Date().getTime();
736
+ var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
737
+ var r = (dt + Math.random() * 16) % 16 | 0;
738
+ dt = Math.floor(dt / 16);
739
+ return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16);
740
+ });
741
+ return uuid;
742
+ };
743
+ this.checkViewport = () => {
744
+ this.findSvgElement();
745
+ let previousValue = this.isInViewport;
746
+ this.isInViewport = this.isElementInViewport(this.svgElement);
747
+ if (previousValue !== this.isInViewport && this.onViewportChanged.observers.length > 0) {
748
+ this.ngZone.run(() => {
749
+ this.onViewportChanged.emit({ oldValue: previousValue, newValue: this.isInViewport });
750
+ });
751
+ }
752
+ };
753
+ this.onScroll = (event) => {
754
+ this.checkViewport();
755
+ };
756
+ this.loadEventsForLazyMode = () => {
757
+ if (this.options.lazy) {
758
+ this.ngZone.runOutsideAngular(() => {
759
+ this.document.addEventListener('scroll', this.onScroll, true);
760
+ this.window.addEventListener('resize', this.onScroll, true);
761
+ });
762
+ if (this._viewportChangedSubscriber === null) {
763
+ this._viewportChangedSubscriber = this.onViewportChanged.subscribe(({ oldValue, newValue }) => {
764
+ newValue ? this.render() : null;
765
+ });
766
+ }
767
+ // svgElement must be created in DOM before being checked.
768
+ // Is there a better way to check the existence of svgElemnt?
769
+ let _timer = timer(0, 50).subscribe(() => {
770
+ this.svgElement === null ? this.checkViewport() : _timer.unsubscribe();
771
+ });
772
+ }
773
+ };
774
+ this.unloadEventsForLazyMode = () => {
775
+ // Remove event listeners
776
+ this.document.removeEventListener('scroll', this.onScroll, true);
777
+ this.window.removeEventListener('resize', this.onScroll, true);
778
+ // Unsubscribe onViewportChanged
779
+ if (this._viewportChangedSubscriber !== null) {
780
+ this._viewportChangedSubscriber.unsubscribe();
781
+ this._viewportChangedSubscriber = null;
782
+ }
783
+ };
784
+ this.document = injector.get(DOCUMENT);
785
+ this.window = this.document.defaultView;
786
+ Object.assign(this.options, defaultOptions);
787
+ Object.assign(this.defaultOptions, defaultOptions);
788
+ }
789
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: CircleProgressComponent, deps: [{ token: CircleProgressOptions }, { token: i0.NgZone }, { token: i0.ElementRef }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Component }); }
790
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.18", type: CircleProgressComponent, isStandalone: false, selector: "circle-progress", inputs: { name: "name", class: "class", backgroundGradient: "backgroundGradient", backgroundColor: "backgroundColor", backgroundGradientStopColor: "backgroundGradientStopColor", backgroundOpacity: "backgroundOpacity", backgroundStroke: "backgroundStroke", backgroundStrokeWidth: "backgroundStrokeWidth", backgroundPadding: "backgroundPadding", radius: "radius", space: "space", percent: "percent", toFixed: "toFixed", maxPercent: "maxPercent", renderOnClick: "renderOnClick", units: "units", unitsFontSize: "unitsFontSize", unitsFontWeight: "unitsFontWeight", unitsColor: "unitsColor", outerStrokeGradient: "outerStrokeGradient", outerStrokeWidth: "outerStrokeWidth", outerStrokeColor: "outerStrokeColor", outerStrokeGradientStopColor: "outerStrokeGradientStopColor", outerStrokeLinecap: "outerStrokeLinecap", innerStrokeColor: "innerStrokeColor", innerStrokeWidth: "innerStrokeWidth", titleFormat: "titleFormat", title: "title", titleColor: "titleColor", titleFontSize: "titleFontSize", titleFontWeight: "titleFontWeight", subtitleFormat: "subtitleFormat", subtitle: "subtitle", subtitleColor: "subtitleColor", subtitleFontSize: "subtitleFontSize", subtitleFontWeight: "subtitleFontWeight", imageSrc: "imageSrc", imageHeight: "imageHeight", imageWidth: "imageWidth", animation: "animation", animateTitle: "animateTitle", animateSubtitle: "animateSubtitle", animationDuration: "animationDuration", showTitle: "showTitle", showSubtitle: "showSubtitle", showUnits: "showUnits", showImage: "showImage", showBackground: "showBackground", showInnerStroke: "showInnerStroke", clockwise: "clockwise", responsive: "responsive", startFromZero: "startFromZero", showZeroOuterStroke: "showZeroOuterStroke", lazy: "lazy", templateOptions: ["options", "templateOptions"] }, outputs: { onClick: "onClick" }, usesOnChanges: true, ngImport: i0, template: `
791
+ <svg xmlns="http://www.w3.org/2000/svg" *ngIf="svg"
792
+ [attr.viewBox]="svg.viewBox" preserveAspectRatio="xMidYMid meet"
793
+ [attr.height]="svg.height" [attr.width]="svg.width" (click)="emitClickEvent($event)" [attr.class]="options.class">
794
+ <defs>
795
+ <linearGradient *ngIf="options.outerStrokeGradient" [attr.id]="svg.outerLinearGradient.id">
796
+ <stop offset="5%" [attr.stop-color]="svg.outerLinearGradient.colorStop1" [attr.stop-opacity]="1"/>
797
+ <stop offset="95%" [attr.stop-color]="svg.outerLinearGradient.colorStop2" [attr.stop-opacity]="1"/>
798
+ </linearGradient>
799
+ <radialGradient *ngIf="options.backgroundGradient" [attr.id]="svg.radialGradient.id">
800
+ <stop offset="5%" [attr.stop-color]="svg.radialGradient.colorStop1" [attr.stop-opacity]="1"/>
801
+ <stop offset="95%" [attr.stop-color]="svg.radialGradient.colorStop2" [attr.stop-opacity]="1"/>
802
+ </radialGradient>
803
+ </defs>
804
+ <ng-container *ngIf="options.showBackground">
805
+ <circle *ngIf="!options.backgroundGradient"
806
+ [attr.cx]="svg.backgroundCircle.cx"
807
+ [attr.cy]="svg.backgroundCircle.cy"
808
+ [attr.r]="svg.backgroundCircle.r"
809
+ [attr.fill]="svg.backgroundCircle.fill"
810
+ [attr.fill-opacity]="svg.backgroundCircle.fillOpacity"
811
+ [attr.stroke]="svg.backgroundCircle.stroke"
812
+ [attr.stroke-width]="svg.backgroundCircle.strokeWidth"/>
813
+ <circle *ngIf="options.backgroundGradient"
814
+ [attr.cx]="svg.backgroundCircle.cx"
815
+ [attr.cy]="svg.backgroundCircle.cy"
816
+ [attr.r]="svg.backgroundCircle.r"
817
+ attr.fill="url({{window.location.href}}#{{svg.radialGradient.id}})"
818
+ [attr.fill-opacity]="svg.backgroundCircle.fillOpacity"
819
+ [attr.stroke]="svg.backgroundCircle.stroke"
820
+ [attr.stroke-width]="svg.backgroundCircle.strokeWidth"/>
821
+ </ng-container>
822
+ <circle *ngIf="options.showInnerStroke"
823
+ [attr.cx]="svg.circle.cx"
824
+ [attr.cy]="svg.circle.cy"
825
+ [attr.r]="svg.circle.r"
826
+ [attr.fill]="svg.circle.fill"
827
+ [attr.stroke]="svg.circle.stroke"
828
+ [attr.stroke-width]="svg.circle.strokeWidth"/>
829
+ <ng-container *ngIf="+options.percent!==0 || options.showZeroOuterStroke">
830
+ <path *ngIf="!options.outerStrokeGradient"
831
+ [attr.d]="svg.path.d"
832
+ [attr.stroke]="svg.path.stroke"
833
+ [attr.stroke-width]="svg.path.strokeWidth"
834
+ [attr.stroke-linecap]="svg.path.strokeLinecap"
835
+ [attr.fill]="svg.path.fill"/>
836
+ <path *ngIf="options.outerStrokeGradient"
837
+ [attr.d]="svg.path.d"
838
+ attr.stroke="url({{window.location.href}}#{{svg.outerLinearGradient.id}})"
839
+ [attr.stroke-width]="svg.path.strokeWidth"
840
+ [attr.stroke-linecap]="svg.path.strokeLinecap"
841
+ [attr.fill]="svg.path.fill"/>
842
+ </ng-container>
843
+ <text *ngIf="!options.showImage && (options.showTitle || options.showUnits || options.showSubtitle)"
844
+ alignment-baseline="baseline"
845
+ [attr.x]="svg.circle.cx"
846
+ [attr.y]="svg.circle.cy"
847
+ [attr.text-anchor]="svg.title.textAnchor">
848
+ <ng-container *ngIf="options.showTitle">
849
+ <tspan *ngFor="let tspan of svg.title.tspans"
850
+ [attr.x]="svg.title.x"
851
+ [attr.y]="svg.title.y"
852
+ [attr.dy]="tspan.dy"
853
+ [attr.font-size]="svg.title.fontSize"
854
+ [attr.font-weight]="svg.title.fontWeight"
855
+ [attr.fill]="svg.title.color">{{tspan.span}}</tspan>
856
+ </ng-container>
857
+ <tspan *ngIf="options.showUnits"
858
+ [attr.font-size]="svg.units.fontSize"
859
+ [attr.font-weight]="svg.units.fontWeight"
860
+ [attr.fill]="svg.units.color">{{svg.units.text}}</tspan>
861
+ <ng-container *ngIf="options.showSubtitle">
862
+ <tspan *ngFor="let tspan of svg.subtitle.tspans"
863
+ [attr.x]="svg.subtitle.x"
864
+ [attr.y]="svg.subtitle.y"
865
+ [attr.dy]="tspan.dy"
866
+ [attr.font-size]="svg.subtitle.fontSize"
867
+ [attr.font-weight]="svg.subtitle.fontWeight"
868
+ [attr.fill]="svg.subtitle.color">{{tspan.span}}</tspan>
869
+ </ng-container>
870
+ </text>
871
+ <image *ngIf="options.showImage" preserveAspectRatio="none"
872
+ [attr.height]="svg.image.height"
873
+ [attr.width]="svg.image.width"
874
+ [attr.xlink:href]="svg.image.src"
875
+ [attr.x]="svg.image.x"
876
+ [attr.y]="svg.image.y"
877
+ />
878
+ </svg>
879
+ `, isInline: true, dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] }); }
880
+ }
881
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: CircleProgressComponent, decorators: [{
882
+ type: Component,
883
+ args: [{
884
+ selector: 'circle-progress',
885
+ standalone: false,
886
+ template: `
887
+ <svg xmlns="http://www.w3.org/2000/svg" *ngIf="svg"
888
+ [attr.viewBox]="svg.viewBox" preserveAspectRatio="xMidYMid meet"
889
+ [attr.height]="svg.height" [attr.width]="svg.width" (click)="emitClickEvent($event)" [attr.class]="options.class">
890
+ <defs>
891
+ <linearGradient *ngIf="options.outerStrokeGradient" [attr.id]="svg.outerLinearGradient.id">
892
+ <stop offset="5%" [attr.stop-color]="svg.outerLinearGradient.colorStop1" [attr.stop-opacity]="1"/>
893
+ <stop offset="95%" [attr.stop-color]="svg.outerLinearGradient.colorStop2" [attr.stop-opacity]="1"/>
894
+ </linearGradient>
895
+ <radialGradient *ngIf="options.backgroundGradient" [attr.id]="svg.radialGradient.id">
896
+ <stop offset="5%" [attr.stop-color]="svg.radialGradient.colorStop1" [attr.stop-opacity]="1"/>
897
+ <stop offset="95%" [attr.stop-color]="svg.radialGradient.colorStop2" [attr.stop-opacity]="1"/>
898
+ </radialGradient>
899
+ </defs>
900
+ <ng-container *ngIf="options.showBackground">
901
+ <circle *ngIf="!options.backgroundGradient"
902
+ [attr.cx]="svg.backgroundCircle.cx"
903
+ [attr.cy]="svg.backgroundCircle.cy"
904
+ [attr.r]="svg.backgroundCircle.r"
905
+ [attr.fill]="svg.backgroundCircle.fill"
906
+ [attr.fill-opacity]="svg.backgroundCircle.fillOpacity"
907
+ [attr.stroke]="svg.backgroundCircle.stroke"
908
+ [attr.stroke-width]="svg.backgroundCircle.strokeWidth"/>
909
+ <circle *ngIf="options.backgroundGradient"
910
+ [attr.cx]="svg.backgroundCircle.cx"
911
+ [attr.cy]="svg.backgroundCircle.cy"
912
+ [attr.r]="svg.backgroundCircle.r"
913
+ attr.fill="url({{window.location.href}}#{{svg.radialGradient.id}})"
914
+ [attr.fill-opacity]="svg.backgroundCircle.fillOpacity"
915
+ [attr.stroke]="svg.backgroundCircle.stroke"
916
+ [attr.stroke-width]="svg.backgroundCircle.strokeWidth"/>
917
+ </ng-container>
918
+ <circle *ngIf="options.showInnerStroke"
919
+ [attr.cx]="svg.circle.cx"
920
+ [attr.cy]="svg.circle.cy"
921
+ [attr.r]="svg.circle.r"
922
+ [attr.fill]="svg.circle.fill"
923
+ [attr.stroke]="svg.circle.stroke"
924
+ [attr.stroke-width]="svg.circle.strokeWidth"/>
925
+ <ng-container *ngIf="+options.percent!==0 || options.showZeroOuterStroke">
926
+ <path *ngIf="!options.outerStrokeGradient"
927
+ [attr.d]="svg.path.d"
928
+ [attr.stroke]="svg.path.stroke"
929
+ [attr.stroke-width]="svg.path.strokeWidth"
930
+ [attr.stroke-linecap]="svg.path.strokeLinecap"
931
+ [attr.fill]="svg.path.fill"/>
932
+ <path *ngIf="options.outerStrokeGradient"
933
+ [attr.d]="svg.path.d"
934
+ attr.stroke="url({{window.location.href}}#{{svg.outerLinearGradient.id}})"
935
+ [attr.stroke-width]="svg.path.strokeWidth"
936
+ [attr.stroke-linecap]="svg.path.strokeLinecap"
937
+ [attr.fill]="svg.path.fill"/>
938
+ </ng-container>
939
+ <text *ngIf="!options.showImage && (options.showTitle || options.showUnits || options.showSubtitle)"
940
+ alignment-baseline="baseline"
941
+ [attr.x]="svg.circle.cx"
942
+ [attr.y]="svg.circle.cy"
943
+ [attr.text-anchor]="svg.title.textAnchor">
944
+ <ng-container *ngIf="options.showTitle">
945
+ <tspan *ngFor="let tspan of svg.title.tspans"
946
+ [attr.x]="svg.title.x"
947
+ [attr.y]="svg.title.y"
948
+ [attr.dy]="tspan.dy"
949
+ [attr.font-size]="svg.title.fontSize"
950
+ [attr.font-weight]="svg.title.fontWeight"
951
+ [attr.fill]="svg.title.color">{{tspan.span}}</tspan>
952
+ </ng-container>
953
+ <tspan *ngIf="options.showUnits"
954
+ [attr.font-size]="svg.units.fontSize"
955
+ [attr.font-weight]="svg.units.fontWeight"
956
+ [attr.fill]="svg.units.color">{{svg.units.text}}</tspan>
957
+ <ng-container *ngIf="options.showSubtitle">
958
+ <tspan *ngFor="let tspan of svg.subtitle.tspans"
959
+ [attr.x]="svg.subtitle.x"
960
+ [attr.y]="svg.subtitle.y"
961
+ [attr.dy]="tspan.dy"
962
+ [attr.font-size]="svg.subtitle.fontSize"
963
+ [attr.font-weight]="svg.subtitle.fontWeight"
964
+ [attr.fill]="svg.subtitle.color">{{tspan.span}}</tspan>
965
+ </ng-container>
966
+ </text>
967
+ <image *ngIf="options.showImage" preserveAspectRatio="none"
968
+ [attr.height]="svg.image.height"
969
+ [attr.width]="svg.image.width"
970
+ [attr.xlink:href]="svg.image.src"
971
+ [attr.x]="svg.image.x"
972
+ [attr.y]="svg.image.y"
973
+ />
974
+ </svg>
975
+ `
976
+ }]
977
+ }], ctorParameters: () => [{ type: CircleProgressOptions }, { type: i0.NgZone }, { type: i0.ElementRef }, { type: i0.Injector }], propDecorators: { onClick: [{
978
+ type: Output
979
+ }], name: [{
980
+ type: Input
981
+ }], class: [{
982
+ type: Input
983
+ }], backgroundGradient: [{
984
+ type: Input
985
+ }], backgroundColor: [{
986
+ type: Input
987
+ }], backgroundGradientStopColor: [{
988
+ type: Input
989
+ }], backgroundOpacity: [{
990
+ type: Input
991
+ }], backgroundStroke: [{
992
+ type: Input
993
+ }], backgroundStrokeWidth: [{
994
+ type: Input
995
+ }], backgroundPadding: [{
996
+ type: Input
997
+ }], radius: [{
998
+ type: Input
999
+ }], space: [{
1000
+ type: Input
1001
+ }], percent: [{
1002
+ type: Input
1003
+ }], toFixed: [{
1004
+ type: Input
1005
+ }], maxPercent: [{
1006
+ type: Input
1007
+ }], renderOnClick: [{
1008
+ type: Input
1009
+ }], units: [{
1010
+ type: Input
1011
+ }], unitsFontSize: [{
1012
+ type: Input
1013
+ }], unitsFontWeight: [{
1014
+ type: Input
1015
+ }], unitsColor: [{
1016
+ type: Input
1017
+ }], outerStrokeGradient: [{
1018
+ type: Input
1019
+ }], outerStrokeWidth: [{
1020
+ type: Input
1021
+ }], outerStrokeColor: [{
1022
+ type: Input
1023
+ }], outerStrokeGradientStopColor: [{
1024
+ type: Input
1025
+ }], outerStrokeLinecap: [{
1026
+ type: Input
1027
+ }], innerStrokeColor: [{
1028
+ type: Input
1029
+ }], innerStrokeWidth: [{
1030
+ type: Input
1031
+ }], titleFormat: [{
1032
+ type: Input
1033
+ }], title: [{
1034
+ type: Input
1035
+ }], titleColor: [{
1036
+ type: Input
1037
+ }], titleFontSize: [{
1038
+ type: Input
1039
+ }], titleFontWeight: [{
1040
+ type: Input
1041
+ }], subtitleFormat: [{
1042
+ type: Input
1043
+ }], subtitle: [{
1044
+ type: Input
1045
+ }], subtitleColor: [{
1046
+ type: Input
1047
+ }], subtitleFontSize: [{
1048
+ type: Input
1049
+ }], subtitleFontWeight: [{
1050
+ type: Input
1051
+ }], imageSrc: [{
1052
+ type: Input
1053
+ }], imageHeight: [{
1054
+ type: Input
1055
+ }], imageWidth: [{
1056
+ type: Input
1057
+ }], animation: [{
1058
+ type: Input
1059
+ }], animateTitle: [{
1060
+ type: Input
1061
+ }], animateSubtitle: [{
1062
+ type: Input
1063
+ }], animationDuration: [{
1064
+ type: Input
1065
+ }], showTitle: [{
1066
+ type: Input
1067
+ }], showSubtitle: [{
1068
+ type: Input
1069
+ }], showUnits: [{
1070
+ type: Input
1071
+ }], showImage: [{
1072
+ type: Input
1073
+ }], showBackground: [{
1074
+ type: Input
1075
+ }], showInnerStroke: [{
1076
+ type: Input
1077
+ }], clockwise: [{
1078
+ type: Input
1079
+ }], responsive: [{
1080
+ type: Input
1081
+ }], startFromZero: [{
1082
+ type: Input
1083
+ }], showZeroOuterStroke: [{
1084
+ type: Input
1085
+ }], lazy: [{
1086
+ type: Input
1087
+ }], templateOptions: [{
1088
+ type: Input,
1089
+ args: ['options']
1090
+ }] } });
1091
+
1092
+ class JaceMultiprogWidgetComponent {
1093
+ constructor(dshService, router) {
1094
+ this.dshService = dshService;
1095
+ this.router = router;
1096
+ this.OnRemove = new EventEmitter();
1097
+ this.configuration = false;
1098
+ this.dataReady = false;
1099
+ this.lastdate = "";
1100
+ }
1101
+ setWidgetModel(dshBackendId, widgetModel) {
1102
+ this.model = widgetModel;
1103
+ if (this.model.backendid === undefined || this.model.backendid == "default_backend")
1104
+ this.model.backendid = dshBackendId;
1105
+ this.refreshData();
1106
+ }
1107
+ ngOnInit() { }
1108
+ ngOnChanges(changes) {
1109
+ //console.log(changes['DashboardDate'].currentValue);
1110
+ if (changes['DashboardDate'].previousValue)
1111
+ this.lastdate = changes['DashboardDate'].previousValue.toISOString();
1112
+ let curdate = "";
1113
+ if (changes['DashboardDate'].currentValue)
1114
+ curdate = changes['DashboardDate'].currentValue.toISOString();
1115
+ //fix per il datetimepicker material che cambia l'oggetto al momento del caricamento
1116
+ if (this.lastdate != curdate) {
1117
+ this.lastdate = curdate;
1118
+ this.refreshData();
1119
+ }
1120
+ }
1121
+ refreshData() {
1122
+ if (!this.model)
1123
+ return;
1124
+ const pars = {};
1125
+ if (this.DashboardDate)
1126
+ pars["DT"] = this.DashboardDate.toISOString();
1127
+ if (this.model.options && Object.keys(this.model.options).length != 0) {
1128
+ for (let index = 0; index < Object.keys(this.model.options).length; index++) {
1129
+ const k = Object.keys(this.model.options)[index];
1130
+ pars[k] = this.model.options[k];
1131
+ }
1132
+ }
1133
+ this.dshService.GetWidgetData(this.model.backendid, this.model.name, pars).subscribe(data => {
1134
+ if (this.model) {
1135
+ this.model.setData(data);
1136
+ this.dataReady = true;
1137
+ }
1138
+ });
1139
+ }
1140
+ removeWidget() {
1141
+ if (!this.model)
1142
+ return;
1143
+ this.OnRemove.emit(this.model.name);
1144
+ }
1145
+ configure() {
1146
+ if (this.configuration) {
1147
+ //finito di configurare -> refreshData
1148
+ this.refreshData();
1149
+ }
1150
+ this.configuration = !this.configuration;
1151
+ }
1152
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: JaceMultiprogWidgetComponent, deps: [{ token: DSH_DATA_SERVICE }, { token: i1$1.Router }], target: i0.ɵɵFactoryTarget.Component }); }
1153
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.18", type: JaceMultiprogWidgetComponent, isStandalone: false, selector: "jace-dsh-multiprog", inputs: { DashboardDate: "DashboardDate" }, outputs: { OnRemove: "OnRemove" }, usesOnChanges: true, ngImport: i0, template: "<div class=\"jace-dsh-widget-header {{model?.name}}-header\">\r\n <div class=\"jace-dsh-widget-title\" *ngIf=\"model.title\">\r\n {{model.title}}\r\n </div>\r\n <div class=\"jace-dsh-widget-controls\" *ngIf=\"dataReady\">\r\n <span class=\"transition drag-handler jace-dsh-widget-drag\" *ngIf=\"model.dragEnabled\">\r\n <i class=\"fa fa-arrows-alt\"></i>\r\n </span>\r\n <span class=\"transition jace-dsh-widget-opts\" (click)=\"configure()\">\r\n <i class=\"fa fa-cog\"></i>\r\n </span>\r\n <span (click)=\"removeWidget()\" class=\"transition remove-button jace-dsh-widget-close\">\r\n <i class=\"fa fa-times\"></i>\r\n </span>\r\n\r\n </div>\r\n</div>\r\n<div class=\"jace-dsh-widget-body gridster-item-content {{model?.name}}-body\">\r\n <div class=\"jace-dsh-widget-loading\" *ngIf=\"!dataReady\">\r\n <i class=\"fa fa-spinner\"></i>\r\n </div>\r\n <div class=\"jace-dsh-multiprog-container jace-dsh-widget-slide\"\r\n [ngClass]=\"{'jace-dsh-widget-content-hide':configuration,'jace-dsh-widget-content-show':!configuration}\"\r\n *ngIf=\"dataReady\">\r\n <div *ngFor=\"let item of model.progressTitles; let i = index\" class=\"jace-dsh-multiprog-progress\">\r\n <div class=\"jace-dsh-multiprog-title\">{{item}}</div>\r\n <!-- messo circle progress per tutto... prima si poteva switchare su progress bar ma pace -->\r\n <circle-progress [percent]=\"model.progressValues[i]\" [showSubtitle]=false [radius]=\"36\"\r\n [outerStrokeWidth]=\"4\" [innerStrokeWidth]=\"2\" [outerStrokeColor]=\"'#7489AA'\"\r\n [innerStrokeColor]=\"'#EFECCA'\" [animation]=\"true\" [animationDuration]=\"300\" [showTitle]=\"true\"\r\n ></circle-progress>\r\n </div>\r\n </div>\r\n <div class=\"jace-dsh-widget-settings jace-dsh-widget-slide \"\r\n [ngClass]=\"{'jace-dsh-widget-settings-hide':!configuration,'jace-dsh-widget-settings-show':configuration}\">\r\n <p>Configuration</p>\r\n </div>\r\n</div>", styles: [".jace-dsh-multiprog-title{text-align:center;font-weight:600;font-size:.8em}.jace-dsh-multiprog-container{display:flex;flex-direction:row;flex-wrap:wrap;justify-content:space-evenly;padding:.5rem}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: CircleProgressComponent, selector: "circle-progress", inputs: ["name", "class", "backgroundGradient", "backgroundColor", "backgroundGradientStopColor", "backgroundOpacity", "backgroundStroke", "backgroundStrokeWidth", "backgroundPadding", "radius", "space", "percent", "toFixed", "maxPercent", "renderOnClick", "units", "unitsFontSize", "unitsFontWeight", "unitsColor", "outerStrokeGradient", "outerStrokeWidth", "outerStrokeColor", "outerStrokeGradientStopColor", "outerStrokeLinecap", "innerStrokeColor", "innerStrokeWidth", "titleFormat", "title", "titleColor", "titleFontSize", "titleFontWeight", "subtitleFormat", "subtitle", "subtitleColor", "subtitleFontSize", "subtitleFontWeight", "imageSrc", "imageHeight", "imageWidth", "animation", "animateTitle", "animateSubtitle", "animationDuration", "showTitle", "showSubtitle", "showUnits", "showImage", "showBackground", "showInnerStroke", "clockwise", "responsive", "startFromZero", "showZeroOuterStroke", "lazy", "options"], outputs: ["onClick"] }] }); }
1154
+ }
1155
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: JaceMultiprogWidgetComponent, decorators: [{
1156
+ type: Component,
1157
+ args: [{ selector: 'jace-dsh-multiprog', standalone: false, template: "<div class=\"jace-dsh-widget-header {{model?.name}}-header\">\r\n <div class=\"jace-dsh-widget-title\" *ngIf=\"model.title\">\r\n {{model.title}}\r\n </div>\r\n <div class=\"jace-dsh-widget-controls\" *ngIf=\"dataReady\">\r\n <span class=\"transition drag-handler jace-dsh-widget-drag\" *ngIf=\"model.dragEnabled\">\r\n <i class=\"fa fa-arrows-alt\"></i>\r\n </span>\r\n <span class=\"transition jace-dsh-widget-opts\" (click)=\"configure()\">\r\n <i class=\"fa fa-cog\"></i>\r\n </span>\r\n <span (click)=\"removeWidget()\" class=\"transition remove-button jace-dsh-widget-close\">\r\n <i class=\"fa fa-times\"></i>\r\n </span>\r\n\r\n </div>\r\n</div>\r\n<div class=\"jace-dsh-widget-body gridster-item-content {{model?.name}}-body\">\r\n <div class=\"jace-dsh-widget-loading\" *ngIf=\"!dataReady\">\r\n <i class=\"fa fa-spinner\"></i>\r\n </div>\r\n <div class=\"jace-dsh-multiprog-container jace-dsh-widget-slide\"\r\n [ngClass]=\"{'jace-dsh-widget-content-hide':configuration,'jace-dsh-widget-content-show':!configuration}\"\r\n *ngIf=\"dataReady\">\r\n <div *ngFor=\"let item of model.progressTitles; let i = index\" class=\"jace-dsh-multiprog-progress\">\r\n <div class=\"jace-dsh-multiprog-title\">{{item}}</div>\r\n <!-- messo circle progress per tutto... prima si poteva switchare su progress bar ma pace -->\r\n <circle-progress [percent]=\"model.progressValues[i]\" [showSubtitle]=false [radius]=\"36\"\r\n [outerStrokeWidth]=\"4\" [innerStrokeWidth]=\"2\" [outerStrokeColor]=\"'#7489AA'\"\r\n [innerStrokeColor]=\"'#EFECCA'\" [animation]=\"true\" [animationDuration]=\"300\" [showTitle]=\"true\"\r\n ></circle-progress>\r\n </div>\r\n </div>\r\n <div class=\"jace-dsh-widget-settings jace-dsh-widget-slide \"\r\n [ngClass]=\"{'jace-dsh-widget-settings-hide':!configuration,'jace-dsh-widget-settings-show':configuration}\">\r\n <p>Configuration</p>\r\n </div>\r\n</div>", styles: [".jace-dsh-multiprog-title{text-align:center;font-weight:600;font-size:.8em}.jace-dsh-multiprog-container{display:flex;flex-direction:row;flex-wrap:wrap;justify-content:space-evenly;padding:.5rem}\n"] }]
1158
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
1159
+ type: Inject,
1160
+ args: [DSH_DATA_SERVICE]
1161
+ }] }, { type: i1$1.Router }], propDecorators: { DashboardDate: [{
1162
+ type: Input
1163
+ }], OnRemove: [{
1164
+ type: Output
1165
+ }] } });
1166
+
1167
+ class BaseJaceWidgetModel {
1168
+ constructor() {
1169
+ this.backendid = "default_backend";
1170
+ this.resizeEnabled = false;
1171
+ this.dataError = false;
1172
+ this.options = {};
1173
+ }
1174
+ configureFromInstanceDetails(details) {
1175
+ this.name = details.name;
1176
+ this.widgetType = details.type;
1177
+ this.title = details.title;
1178
+ this.x = details.x;
1179
+ this.y = details.y;
1180
+ this.cols = details.cols;
1181
+ this.rows = details.rows;
1182
+ this.compactEnabled = details.compactenabled;
1183
+ this.dragEnabled = details.dragenabled;
1184
+ this.options = details.options;
1185
+ this.dataError = details.queryerror;
1186
+ this.resizeEnabled = details.resizeenabled;
1187
+ this.backendid = details.backendid ?? "default_backend";
1188
+ }
1189
+ }
1190
+
1191
+ class JaceChartWidgetModel extends BaseJaceWidgetModel {
1192
+ constructor() {
1193
+ super();
1194
+ this.chartType = 'line';
1195
+ this.legend = false;
1196
+ this.widgetType = "CHART";
1197
+ }
1198
+ setData(data) {
1199
+ if (!data)
1200
+ return;
1201
+ if (data['queryerror'])
1202
+ this.dataError = data['queryerror'];
1203
+ if (data['legend'])
1204
+ this.legend = data['legend'];
1205
+ else
1206
+ this.legend = true;
1207
+ if (data['charttype'])
1208
+ this.chartType = data['charttype'];
1209
+ if (data['chartdata']) {
1210
+ this.chartData = data['chartdata'];
1211
+ }
1212
+ if (this.options && this.options['legend'] == undefined)
1213
+ this.options['legend'] = true;
1214
+ }
1215
+ }
1216
+
1217
+ class JaceCounterWidgetModel extends BaseJaceWidgetModel {
1218
+ constructor() {
1219
+ super();
1220
+ this.superText = undefined;
1221
+ this.subText = undefined;
1222
+ this.value = 0;
1223
+ this.icon = undefined;
1224
+ this.unit = undefined;
1225
+ this.widgetType = "COUNTER";
1226
+ }
1227
+ setData(data) {
1228
+ if (data['queryerror'])
1229
+ this.dataError = data['queryerror'];
1230
+ this.superText = data['supertext'];
1231
+ this.subText = data['subtext'];
1232
+ this.value = data['value'];
1233
+ this.icon = data['icon'];
1234
+ this.options = data['options'];
1235
+ this.unit = data['unit'];
1236
+ }
1237
+ }
1238
+
1239
+ class JaceListItemWidget {
1240
+ }
1241
+ class JaceListWidgetModel extends BaseJaceWidgetModel {
1242
+ constructor() {
1243
+ super();
1244
+ this.superText = undefined;
1245
+ this.items = [];
1246
+ this.widgetType = "LIST";
1247
+ }
1248
+ setData(data) {
1249
+ if (!data)
1250
+ return;
1251
+ if (data['queryerror'])
1252
+ this.dataError = data['queryerror'];
1253
+ this.superText = data['supertext'];
1254
+ if (data['items']) {
1255
+ const d = data['items'];
1256
+ this.items = [];
1257
+ for (let index = 0; index < d.length; index++) {
1258
+ const item = new JaceListItemWidget();
1259
+ const element = d[index];
1260
+ if (element['id'])
1261
+ item.id = element['id'];
1262
+ if (element['idparamname'])
1263
+ item.idParamName = element['idparamname'];
1264
+ if (element['link'])
1265
+ item.link = element['link'];
1266
+ if (element['subline'])
1267
+ item.subline = element['subline'];
1268
+ if (element['classes'])
1269
+ item.classes = element['classes'];
1270
+ item.description = element.description;
1271
+ this.items.push(item);
1272
+ }
1273
+ }
1274
+ }
1275
+ }
1276
+
1277
+ class JaceMultiprogWidgetModel extends BaseJaceWidgetModel {
1278
+ constructor() {
1279
+ super();
1280
+ this.resizeEnabled = true;
1281
+ this.progressTitles = [];
1282
+ this.progressValues = [];
1283
+ this.circleProgress = false;
1284
+ this.widgetType = "MULTIPROGRESS";
1285
+ }
1286
+ setData(data) {
1287
+ if (data['queryerror'])
1288
+ this.dataError = data['queryerror'];
1289
+ this.progressTitles = data['progresstitles'] ?? [];
1290
+ this.progressValues = data['progressvalues'] ?? [];
1291
+ this.circleProgress = data['circleprogress'];
1292
+ this.options = data['options'] ?? {};
1293
+ if (this.circleProgress === undefined)
1294
+ this.circleProgress = true;
1295
+ if (this.cols === undefined && this.progressValues) {
1296
+ if (this.progressValues.length == 1)
1297
+ this.cols = 1;
1298
+ else
1299
+ this.cols = 2;
1300
+ }
1301
+ }
1302
+ }
1303
+
1304
+ class DefaultDashboardModuleOptions {
1305
+ constructor() {
1306
+ this.widgetTypes = [
1307
+ {
1308
+ name: "COUNTER",
1309
+ component: JaceCounterWidgetComponent,
1310
+ model: JaceCounterWidgetModel
1311
+ },
1312
+ {
1313
+ name: "LIST",
1314
+ component: JaceListWidgetComponent,
1315
+ model: JaceListWidgetModel
1316
+ },
1317
+ {
1318
+ name: "CHART",
1319
+ component: JaceChartWidgetComponent,
1320
+ model: JaceChartWidgetModel
1321
+ },
1322
+ {
1323
+ name: "MULTIPROGRESS",
1324
+ component: JaceMultiprogWidgetComponent,
1325
+ model: JaceMultiprogWidgetModel
1326
+ }
1327
+ ];
1328
+ }
1329
+ }
1330
+
1331
+ class DashboardWidgetFactory {
1332
+ constructor() {
1333
+ this.types = {};
1334
+ }
1335
+ addOption(option) {
1336
+ if (option.widgetTypes) {
1337
+ option.widgetTypes.forEach((o) => {
1338
+ this.types[o.name] = o;
1339
+ });
1340
+ }
1341
+ }
1342
+ /**
1343
+ * Versione ng11 della creazione dei componenti dinamici delle widget
1344
+ * @param type
1345
+ * @param vcr
1346
+ * @returns
1347
+ */
1348
+ resolveComponent(type, vcr) {
1349
+ if (!this.types)
1350
+ return null;
1351
+ let t = this.types[type];
1352
+ if (!t)
1353
+ return null;
1354
+ let componentRef = vcr.createComponent(t.component);
1355
+ return componentRef;
1356
+ }
1357
+ resolveDefinition(type, details) {
1358
+ if (!this.types)
1359
+ return null;
1360
+ let t = this.types[type];
1361
+ if (!t)
1362
+ return null;
1363
+ let definitionInstance = this.createInstance(t.model);
1364
+ definitionInstance.configureFromInstanceDetails(details);
1365
+ return definitionInstance;
1366
+ }
1367
+ createInstance(type) {
1368
+ return new type();
1369
+ }
1370
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: DashboardWidgetFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1371
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: DashboardWidgetFactory, providedIn: "root" }); }
1372
+ }
1373
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: DashboardWidgetFactory, decorators: [{
1374
+ type: Injectable,
1375
+ args: [{ providedIn: "root" }]
1376
+ }], ctorParameters: () => [] });
1377
+
1378
+ class SaveJaceDashboardLayoutDTO {
1379
+ constructor() {
1380
+ this.backendid = "default_backend";
1381
+ }
1382
+ }
1383
+
1384
+ //Definizione della widget restituita dal backend
1385
+ class JaceWidgetInstanceDetail {
1386
+ constructor() {
1387
+ this.queryerror = false;
1388
+ }
1389
+ }
1390
+
1391
+ /**
1392
+ * Componente di base che rappresenta una dashboard.
1393
+ * Utilizza Gridster2 per il layout delle widget [Gridster2](https://tiberiuzuld.github.io/angular-gridster2/)
1394
+ */
1395
+ class DashboardComponent {
1396
+ constructor(dshService, intercom, route, cmpFactory, cdr) {
1397
+ this.dshService = dshService;
1398
+ this.intercom = intercom;
1399
+ this.route = route;
1400
+ this.cmpFactory = cmpFactory;
1401
+ this.cdr = cdr;
1402
+ this.dashboardDate = new Date();
1403
+ this.widgetDefinitions = [];
1404
+ this.trackedSubscriptions = [];
1405
+ this.destroySignal$ = new Subject();
1406
+ this.intercom.send(InboundMessageTypes.Navigation, { sub: false, routeTitle: this.route.snapshot.data["title"] });
1407
+ }
1408
+ ngOnInit() { }
1409
+ ngAfterViewInit() {
1410
+ //qui this.gridItemRefs è 'riempito'
1411
+ // sottoscrivo changes che sparerà tutte le volte che ngFor si aggiorna (ovvero quando cambia dashboard)
1412
+ this.changesSub = this.gridItemRefs.changes.pipe(takeUntil(this.destroySignal$)).subscribe((comps) => {
1413
+ this.renderLayout(comps);
1414
+ });
1415
+ //prima volta
1416
+ //setTimeout(()=>this.reloadData(),500);
1417
+ this.trackedSubscriptions.push(timer(500).pipe(takeUntil(this.destroySignal$), map(() => this.reloadData())).subscribe());
1418
+ }
1419
+ ngOnDestroy() {
1420
+ //unsubscribe dalle changes dei viewref
1421
+ if (this.changesSub)
1422
+ this.changesSub.unsubscribe();
1423
+ this.clearTrackedSubscriptions();
1424
+ this.destroySignal$.next();
1425
+ this.destroySignal$.complete();
1426
+ }
1427
+ clearTrackedSubscriptions() {
1428
+ if (this.trackedSubscriptions) {
1429
+ for (let index = 0; index < this.trackedSubscriptions.length; index++) {
1430
+ const element = this.trackedSubscriptions[index];
1431
+ element.unsubscribe();
1432
+ }
1433
+ this.trackedSubscriptions = [];
1434
+ }
1435
+ }
1436
+ ngOnChanges(changes) {
1437
+ //occhio: arriva prima di ngAfterViewInit
1438
+ if (changes.Configuration) {
1439
+ //appena ho configuration
1440
+ console.log(changes.Configuration);
1441
+ // la prima volta l'ho già fatta alla creazione del componente
1442
+ if (!changes.Configuration.firstChange) {
1443
+ this.reloadData();
1444
+ }
1445
+ }
1446
+ }
1447
+ reloadData() {
1448
+ if (!this.Configuration)
1449
+ return;
1450
+ this.dshService.GetUserDashboard(this.Configuration.backendId, this.Configuration.accountId, this.Configuration.dashboardName).pipe(takeUntil(this.destroySignal$)).subscribe(c => {
1451
+ this.dashboardLayout = c;
1452
+ this.widgetDefinitions = c.widgets.map(i => {
1453
+ return this.cmpFactory.resolveDefinition(i.type, i);
1454
+ });
1455
+ });
1456
+ }
1457
+ removeItem(widgetName) {
1458
+ if (!this.dashboardLayout)
1459
+ return;
1460
+ let idx = this.dashboardLayout.widgets.findIndex(s => s.name == widgetName);
1461
+ this.widgetDefinitions.splice(idx, 1);
1462
+ }
1463
+ saveDashboard() {
1464
+ if (!this.dashboardLayout)
1465
+ return;
1466
+ const dto = new SaveJaceDashboardLayoutDTO();
1467
+ dto.backendid = this.Configuration.backendId;
1468
+ dto.widgets = [];
1469
+ for (let index = 0; index < this.widgetDefinitions.length; index++) {
1470
+ const w = this.widgetDefinitions[index];
1471
+ if (w == null)
1472
+ continue;
1473
+ let v = new JaceWidgetInstanceDetail();
1474
+ v.id = w.id;
1475
+ v.name = w.name;
1476
+ v.x = w.x;
1477
+ v.y = w.y;
1478
+ v.cols = w.cols;
1479
+ v.rows = w.rows;
1480
+ v.compactenabled = w.compactEnabled;
1481
+ v.dragenabled = w.dragEnabled;
1482
+ v.resizeenabled = w.resizeEnabled;
1483
+ v.type = w.widgetType;
1484
+ v.title = w.title;
1485
+ v.options = w.options;
1486
+ dto.widgets.push(v);
1487
+ }
1488
+ this.dshService.SaveUserDashboard(dto).subscribe(res => {
1489
+ if (res.success)
1490
+ console.log('Dashboard saved');
1491
+ });
1492
+ }
1493
+ renderLayout(comps) {
1494
+ this.clearTrackedSubscriptions();
1495
+ comps.map((host, index) => {
1496
+ const vcr = host;
1497
+ vcr.clear();
1498
+ const widgetData = this.widgetDefinitions[index];
1499
+ if (!widgetData || !widgetData.widgetType)
1500
+ return;
1501
+ let componentRef;
1502
+ componentRef = this.cmpFactory.resolveComponent(widgetData?.widgetType, vcr);
1503
+ if (!componentRef) {
1504
+ console.log(`Tipo widget sconosciuto ${widgetData.widgetType}`);
1505
+ return;
1506
+ }
1507
+ //setta l'input della data
1508
+ if (this.Configuration.showDateInput)
1509
+ componentRef.instance.DashboardDate = this.dashboardDate;
1510
+ //setta il modello
1511
+ componentRef.instance.setWidgetModel(this.Configuration.backendId, widgetData);
1512
+ //setta la callback per OnRemove
1513
+ let s = componentRef.instance.OnRemove.pipe(takeUntil(this.destroySignal$)).subscribe(name => this.removeItem(name));
1514
+ this.trackedSubscriptions.push(s);
1515
+ //componentRef.changeDetectorRef.markForCheck();
1516
+ //componentRef.changeDetectorRef.detectChanges();
1517
+ });
1518
+ this.cdr.detectChanges();
1519
+ }
1520
+ addItem() {
1521
+ //this.dashboard.push({});
1522
+ }
1523
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: DashboardComponent, deps: [{ token: DSH_DATA_SERVICE }, { token: i1$2.InterComService }, { token: i1$1.ActivatedRoute }, { token: DashboardWidgetFactory }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
1524
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.18", type: DashboardComponent, isStandalone: false, selector: "es-dashboard", inputs: { Configuration: "Configuration" }, viewQueries: [{ propertyName: "gridItemRefs", predicate: ["grid_item"], descendants: true, read: ViewContainerRef }], usesOnChanges: true, ngImport: i0, template: "<ng-container *ngIf=\"Configuration\">\r\n\r\n <form role=\"form\" class=\"jace-dsh-toolbar\" *ngIf=\"Configuration.showToolbar\">\r\n <div *ngIf=\"Configuration.dashboardTitle\" class=\"jace-dsh-toolbar-title\">\r\n {{Configuration.dashboardTitle}}\r\n </div>\r\n <div class=\"jace-dsh-toolbar-dtp\" *ngIf=\"Configuration?.showDateInput\">\r\n <form-date InOutFormat=\"date\" [FormLayout]=\"false\" id=\"txt_dashboarddate\" [Validation]=\"false\"\r\n autocomplete=\"off\" [(ngModel)]=\"dashboardDate\" name=\"dashboarddate\" [Placeholder]=\"'Dashboard Date'\">\r\n </form-date>\r\n </div>\r\n <div class=\"jace-dsh-save-button\" (click)=\"saveDashboard()\">\r\n <span class=\"transition\">\r\n <i class=\"fa fa-save\"></i>\r\n </span>\r\n </div>\r\n </form>\r\n\r\n <gridster [options]=\"Configuration.gridsterConfig\" class=\"jace-dsh-widget-area\">\r\n <gridster-item [item]=\"item\" *ngFor=\"let item of widgetDefinitions\" class=\"jace-dsh-widget {{item.name}}\">\r\n <!-- <ng-container *ngFor=\"let item of widgetDefinitions\"> -->\r\n <ng-template #grid_item></ng-template>\r\n <!-- </ng-container> -->\r\n </gridster-item>\r\n </gridster>\r\n\r\n</ng-container>", styles: [".jace-dsh-toolbar{font-size:smaller;display:flex;flex-flow:row;justify-content:flex-end;align-items:center;padding:0 1em .5em}.jace-dsh-toolbar-title{flex:2 1 auto;font-size:2em;color:#777;font-variant:small-caps}.jace-dsh-toolbar-dtp{flex:1 1 auto}.jace-dsh-save-button{font-size:larger;padding:.5em 1em;border-radius:4px;border:1px solid #ddd;color:#777;margin-left:.5em;cursor:pointer;flex:0 0 auto}.jace-dsh-save-button:hover{color:#000;border-color:#000}.jace-dsh-widget-area{background:#e9ebee;scroll-behavior:auto}.jace-dsh-widget{border:solid 1px #ddd;border-radius:5px;min-width:204px}.jace-dsh-widget-header{margin:0rem .5rem;display:flex;flex-flow:row;justify-content:left;align-items:center}.jace-dsh-widget-title{padding:.5rem .2rem .3rem;border-bottom:solid 1px #ddd;text-transform:uppercase;font-size:.8rem}.jace-dsh-widget-body{margin:0rem .5rem;display:flex;flex-wrap:nowrap;overflow-x:clip}.jace-dsh-widget-loading{padding:.5rem;width:100%;flex:0 0 auto;font-size:4rem;font-weight:700;text-align:center}.jace-dsh-widget-slide{transition-property:transform;transition-duration:.75s;transition-timing-function:ease;width:100%;flex:0 0 auto}.jace-dsh-widget-content-show{transform:translate(0) translateZ(0)}.jace-dsh-widget-content-hide,.jace-dsh-widget-settings-show{transform:translate(-100%) translateZ(0)}.jace-dsh-widget-settings-hide{transform:translate(0) translateZ(0)}.jace-dsh-widget-settings{padding:.5rem;width:100%;flex:0 0 auto}.jace-dsh-widget-controls{margin-left:auto;order:2;z-index:1;top:0rem;right:0rem;padding:.2rem .1rem;font-size:1rem;color:#bbb;align-items:center;cursor:pointer}.jace-dsh-widget-drag{font-size:.78em}.jace-dsh-widget-opts{font-size:.92em}.jace-dsh-widget-close{font-size:1.1em}.jace-dsh-widget-controls span{margin-right:.1rem;margin-left:.1rem}.jace-dsh-widget-controls span:hover{color:#637ca0}\n"], dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i5.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i5.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i5.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i5.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i5.NgForm, selector: "form:not([ngNoForm]):not([formGroup]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: i6.GridsterComponent, selector: "gridster", inputs: ["options"] }, { kind: "component", type: i6.GridsterItemComponent, selector: "gridster-item", inputs: ["item"], outputs: ["itemInit", "itemChange", "itemResize"] }, { kind: "component", type: i7.EsFormDateComponent, selector: "form-date", inputs: ["InOutFormat", "FloatingLabel"] }], encapsulation: i0.ViewEncapsulation.None }); }
1525
+ }
1526
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: DashboardComponent, decorators: [{
1527
+ type: Component,
1528
+ args: [{ selector: 'es-dashboard', encapsulation: ViewEncapsulation.None, standalone: false, template: "<ng-container *ngIf=\"Configuration\">\r\n\r\n <form role=\"form\" class=\"jace-dsh-toolbar\" *ngIf=\"Configuration.showToolbar\">\r\n <div *ngIf=\"Configuration.dashboardTitle\" class=\"jace-dsh-toolbar-title\">\r\n {{Configuration.dashboardTitle}}\r\n </div>\r\n <div class=\"jace-dsh-toolbar-dtp\" *ngIf=\"Configuration?.showDateInput\">\r\n <form-date InOutFormat=\"date\" [FormLayout]=\"false\" id=\"txt_dashboarddate\" [Validation]=\"false\"\r\n autocomplete=\"off\" [(ngModel)]=\"dashboardDate\" name=\"dashboarddate\" [Placeholder]=\"'Dashboard Date'\">\r\n </form-date>\r\n </div>\r\n <div class=\"jace-dsh-save-button\" (click)=\"saveDashboard()\">\r\n <span class=\"transition\">\r\n <i class=\"fa fa-save\"></i>\r\n </span>\r\n </div>\r\n </form>\r\n\r\n <gridster [options]=\"Configuration.gridsterConfig\" class=\"jace-dsh-widget-area\">\r\n <gridster-item [item]=\"item\" *ngFor=\"let item of widgetDefinitions\" class=\"jace-dsh-widget {{item.name}}\">\r\n <!-- <ng-container *ngFor=\"let item of widgetDefinitions\"> -->\r\n <ng-template #grid_item></ng-template>\r\n <!-- </ng-container> -->\r\n </gridster-item>\r\n </gridster>\r\n\r\n</ng-container>", styles: [".jace-dsh-toolbar{font-size:smaller;display:flex;flex-flow:row;justify-content:flex-end;align-items:center;padding:0 1em .5em}.jace-dsh-toolbar-title{flex:2 1 auto;font-size:2em;color:#777;font-variant:small-caps}.jace-dsh-toolbar-dtp{flex:1 1 auto}.jace-dsh-save-button{font-size:larger;padding:.5em 1em;border-radius:4px;border:1px solid #ddd;color:#777;margin-left:.5em;cursor:pointer;flex:0 0 auto}.jace-dsh-save-button:hover{color:#000;border-color:#000}.jace-dsh-widget-area{background:#e9ebee;scroll-behavior:auto}.jace-dsh-widget{border:solid 1px #ddd;border-radius:5px;min-width:204px}.jace-dsh-widget-header{margin:0rem .5rem;display:flex;flex-flow:row;justify-content:left;align-items:center}.jace-dsh-widget-title{padding:.5rem .2rem .3rem;border-bottom:solid 1px #ddd;text-transform:uppercase;font-size:.8rem}.jace-dsh-widget-body{margin:0rem .5rem;display:flex;flex-wrap:nowrap;overflow-x:clip}.jace-dsh-widget-loading{padding:.5rem;width:100%;flex:0 0 auto;font-size:4rem;font-weight:700;text-align:center}.jace-dsh-widget-slide{transition-property:transform;transition-duration:.75s;transition-timing-function:ease;width:100%;flex:0 0 auto}.jace-dsh-widget-content-show{transform:translate(0) translateZ(0)}.jace-dsh-widget-content-hide,.jace-dsh-widget-settings-show{transform:translate(-100%) translateZ(0)}.jace-dsh-widget-settings-hide{transform:translate(0) translateZ(0)}.jace-dsh-widget-settings{padding:.5rem;width:100%;flex:0 0 auto}.jace-dsh-widget-controls{margin-left:auto;order:2;z-index:1;top:0rem;right:0rem;padding:.2rem .1rem;font-size:1rem;color:#bbb;align-items:center;cursor:pointer}.jace-dsh-widget-drag{font-size:.78em}.jace-dsh-widget-opts{font-size:.92em}.jace-dsh-widget-close{font-size:1.1em}.jace-dsh-widget-controls span{margin-right:.1rem;margin-left:.1rem}.jace-dsh-widget-controls span:hover{color:#637ca0}\n"] }]
1529
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
1530
+ type: Inject,
1531
+ args: [DSH_DATA_SERVICE]
1532
+ }] }, { type: i1$2.InterComService }, { type: i1$1.ActivatedRoute }, { type: DashboardWidgetFactory }, { type: i0.ChangeDetectorRef }], propDecorators: { Configuration: [{
1533
+ type: Input
1534
+ }], gridItemRefs: [{
1535
+ type: ViewChildren,
1536
+ args: ['grid_item', { read: ViewContainerRef }]
1537
+ }] } });
1538
+
1539
+ const Repository = {
1540
+ GET_Dashboard_GetLayout: "/api/Dashboard/GetLayout",
1541
+ POST_Dashboard_SaveLayout: "/api/Dashboard/SaveLayout",
1542
+ GET_Dashboard_GetWidgetData: "/api/Dashboard/GetWidgetData"
1543
+ };
1544
+
1545
+ class DashboardFeatureAPIDataService {
1546
+ constructor(http) {
1547
+ this.http = http;
1548
+ }
1549
+ GetUserDashboard(backendid, idaccount, dashboardName) {
1550
+ let params = new HttpParams();
1551
+ params = params.append("backendid", backendid.toString());
1552
+ params = params.append("idaccount", idaccount.toString());
1553
+ params = params.append("name", dashboardName);
1554
+ return this.http.get(Repository["GET_Dashboard_GetLayout"], params);
1555
+ }
1556
+ SaveUserDashboard(dto) {
1557
+ return this.http.post(Repository["POST_Dashboard_SaveLayout"], dto);
1558
+ }
1559
+ GetWidgetData(backendid, name, options) {
1560
+ let params = new HttpParams();
1561
+ params = params.append("backendid", backendid.toString());
1562
+ params = params.append("name", name.toString());
1563
+ if (options && Object.keys(options).length != 0) {
1564
+ for (let index = 0; index < Object.keys(options).length; index++) {
1565
+ const k = Object.keys(options)[index];
1566
+ params = params.append(k, options[k]);
1567
+ }
1568
+ }
1569
+ return this.http.get(Repository["GET_Dashboard_GetWidgetData"], params);
1570
+ }
1571
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: DashboardFeatureAPIDataService, deps: [{ token: i1$3.HTTPService }], target: i0.ɵɵFactoryTarget.Injectable }); }
1572
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: DashboardFeatureAPIDataService }); }
1573
+ }
1574
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: DashboardFeatureAPIDataService, decorators: [{
1575
+ type: Injectable
1576
+ }], ctorParameters: () => [{ type: i1$3.HTTPService }] });
1577
+
1578
+ const MODULES = [
1579
+ // Base
1580
+ CommonModule,
1581
+ FormsModule,
1582
+ GridsterModule,
1583
+ FormsAndValidationsModule,
1584
+ EsChartsModule,
1585
+ HttpserviceModule
1586
+ ];
1587
+ const COMPONENTS = [
1588
+ DashboardComponent,
1589
+ JaceListWidgetComponent,
1590
+ JaceCounterWidgetComponent,
1591
+ JaceChartWidgetComponent,
1592
+ JaceMultiprogWidgetComponent,
1593
+ CircleProgressComponent
1594
+ ];
1595
+ class DashboardFeatureModule {
1596
+ static forRoot(options) {
1597
+ return {
1598
+ ngModule: DashboardFeatureModule,
1599
+ providers: [
1600
+ { provide: DSH_OPTIONS, multi: true, useValue: new DefaultDashboardModuleOptions() },
1601
+ { provide: DSH_OPTIONS, multi: true, useValue: options },
1602
+ { provide: DSH_DATA_SERVICE, useClass: DashboardFeatureAPIDataService },
1603
+ DashboardWidgetFactory
1604
+ ]
1605
+ };
1606
+ }
1607
+ constructor(componentFactory, options) {
1608
+ if (!options)
1609
+ return;
1610
+ options.map((o) => componentFactory.addOption(o));
1611
+ }
1612
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: DashboardFeatureModule, deps: [{ token: DashboardWidgetFactory }, { token: DSH_OPTIONS, optional: true }], target: i0.ɵɵFactoryTarget.NgModule }); }
1613
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.18", ngImport: i0, type: DashboardFeatureModule, declarations: [DashboardComponent,
1614
+ JaceListWidgetComponent,
1615
+ JaceCounterWidgetComponent,
1616
+ JaceChartWidgetComponent,
1617
+ JaceMultiprogWidgetComponent,
1618
+ CircleProgressComponent], imports: [
1619
+ // Base
1620
+ CommonModule,
1621
+ FormsModule,
1622
+ GridsterModule,
1623
+ FormsAndValidationsModule,
1624
+ EsChartsModule,
1625
+ HttpserviceModule], exports: [DashboardComponent,
1626
+ JaceListWidgetComponent,
1627
+ JaceCounterWidgetComponent,
1628
+ JaceChartWidgetComponent,
1629
+ JaceMultiprogWidgetComponent,
1630
+ CircleProgressComponent] }); }
1631
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: DashboardFeatureModule, imports: [MODULES] }); }
1632
+ }
1633
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: DashboardFeatureModule, decorators: [{
1634
+ type: NgModule,
1635
+ args: [{
1636
+ declarations: [...COMPONENTS],
1637
+ imports: [...MODULES],
1638
+ exports: [...COMPONENTS]
1639
+ }]
1640
+ }], ctorParameters: () => [{ type: DashboardWidgetFactory }, { type: undefined, decorators: [{
1641
+ type: Optional
1642
+ }, {
1643
+ type: Inject,
1644
+ args: [DSH_OPTIONS]
1645
+ }] }] });
1646
+
1647
+ /**
1648
+ * Configurazione della dashboard
1649
+ */
1650
+ class JaceDashboardConfig {
1651
+ constructor() {
1652
+ /**
1653
+ * Id del backend a cui verranno indirizzate le chiamate di questa dashboard.
1654
+ * Deve essere uno di quelli definiti in appsetting.json del FE nella sezione **Backends**.
1655
+ */
1656
+ this.backendId = "default_backend";
1657
+ /**
1658
+ * Se questa dashboard contiene widget che mostrano dati che dipendono dalla data corrente
1659
+ * mostra il controllo (datetimepicker) per variare la data in base a cui mostrare i dati.
1660
+ *
1661
+ * NOTA: showToolbar deve essere a true.
1662
+ *
1663
+ * Default = false
1664
+ */
1665
+ this.showDateInput = false;
1666
+ /**
1667
+ * Mostrare la toolbar in cima alla dashboard che contiene il titolo, il pulsante per salvare il proprio layout personalizzato
1668
+ * e il picker per scegliere la data nel caso che le widget nella dashboard mostrino dati dipendenti dalla data.
1669
+ *
1670
+ * Default = true
1671
+ */
1672
+ this.showToolbar = true;
1673
+ /**
1674
+ * Titolo della dashboard mostrato in cima al layout all'interno della toolbar.
1675
+ *
1676
+ * NOTA: showToolbar deve essere a true.
1677
+ *
1678
+ * Default = undefined
1679
+ */
1680
+ this.dashboardTitle = undefined;
1681
+ //default per gridster
1682
+ this.gridsterConfig = {
1683
+ maxCols: 10,
1684
+ maxRows: 10,
1685
+ minCols: 5,
1686
+ minRows: 6,
1687
+ defaultItemCols: 1,
1688
+ defaultItemRows: 1,
1689
+ disablePushOnDrag: true,
1690
+ draggable: { enabled: true, ignoreContent: true },
1691
+ displayGrid: "onDrag&Resize",
1692
+ gridType: GridType.Fit,
1693
+ resizable: { enabled: true },
1694
+ /* fixedRowHeight: 164, */
1695
+ setGridSize: true,
1696
+ //compactType: "compactUp&Left"
1697
+ /* itemChangeCallback: AppComponent.itemChange,
1698
+ itemResizeCallback: AppComponent.itemResize, */
1699
+ };
1700
+ }
1701
+ }
1702
+
1703
+ class JaceDashboardLayoutAppSearch extends AppSearch {
1704
+ constructor() {
1705
+ super(...arguments);
1706
+ this.backendid = "default_backend";
1707
+ }
1708
+ }
1709
+
1710
+ //Definizione del layout della dashboard definito dal Backend
1711
+ class JaceDashboardLayoutDetail {
1712
+ }
1713
+
1714
+ /**
1715
+ * Classe di base astratta per la creazione di Widget custom.
1716
+ */
1717
+ class BaseWidgetComponent {
1718
+ constructor(dshService) {
1719
+ this.dshService = dshService;
1720
+ this.OnRemove = new EventEmitter();
1721
+ this.configuration = false;
1722
+ this.dataReady = false;
1723
+ this.lastdate = "";
1724
+ }
1725
+ setWidgetModel(dshBackendId, widgetModel) {
1726
+ this.model = widgetModel;
1727
+ if (this.model.backendid === undefined || this.model.backendid == "default_backend")
1728
+ this.model.backendid = dshBackendId;
1729
+ this.refreshData();
1730
+ }
1731
+ ngOnInit() { }
1732
+ ngOnChanges(changes) {
1733
+ //console.log(changes['DashboardDate'].currentValue);
1734
+ if (changes['DashboardDate'].previousValue)
1735
+ this.lastdate = changes['DashboardDate'].previousValue.toISOString();
1736
+ let curdate = "";
1737
+ if (changes['DashboardDate'].currentValue)
1738
+ curdate = changes['DashboardDate'].currentValue.toISOString();
1739
+ //fix per il datetimepicker material che cambia l'oggetto al momento del caricamento
1740
+ if (this.lastdate != curdate) {
1741
+ this.lastdate = curdate;
1742
+ this.refreshData();
1743
+ }
1744
+ }
1745
+ /**
1746
+ * Prepara i parametri e lancia la chiamata GetWidgetData della DashboardFeatureService.
1747
+ * Imposta il model con i dati restituiti (setData) e imposta la variabile dataReady del campo a true
1748
+ */
1749
+ refreshData() {
1750
+ if (!this.model)
1751
+ return;
1752
+ const pars = {};
1753
+ if (this.DashboardDate)
1754
+ pars["DT"] = this.DashboardDate.toISOString();
1755
+ if (this.model.options && Object.keys(this.model.options).length != 0) {
1756
+ for (let index = 0; index < Object.keys(this.model.options).length; index++) {
1757
+ const k = Object.keys(this.model.options)[index];
1758
+ pars[k] = this.model.options[k];
1759
+ }
1760
+ }
1761
+ this.prepareGetDataParameters(pars);
1762
+ this.dshService.GetWidgetData(this.model.backendid, this.model.name, pars).subscribe(data => {
1763
+ if (this.model) {
1764
+ this.model.setData(data);
1765
+ this.dataReady = true;
1766
+ }
1767
+ });
1768
+ }
1769
+ /**
1770
+ * Da chiamare quando l'utente preme il pulsante 'rimuovi' nella toolbar della widget.
1771
+ */
1772
+ removeWidget() {
1773
+ if (!this.model)
1774
+ return;
1775
+ this.OnRemove.emit(this.model.name);
1776
+ }
1777
+ /**
1778
+ * Da chiamare quando viene premuto il pulsante 'configure' nella toolbar della widget
1779
+ */
1780
+ configureWidget() {
1781
+ if (this.configuration) {
1782
+ //finito di configurare -> refreshData
1783
+ this.refreshData();
1784
+ }
1785
+ this.configuration = !this.configuration;
1786
+ }
1787
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: BaseWidgetComponent, deps: [{ token: DSH_DATA_SERVICE }], target: i0.ɵɵFactoryTarget.Injectable }); }
1788
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: BaseWidgetComponent }); }
1789
+ }
1790
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: BaseWidgetComponent, decorators: [{
1791
+ type: Injectable
1792
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
1793
+ type: Inject,
1794
+ args: [DSH_DATA_SERVICE]
1795
+ }] }] });
1796
+
1797
+ var JaceWidgetTypes;
1798
+ (function (JaceWidgetTypes) {
1799
+ JaceWidgetTypes["CHART"] = "CHART";
1800
+ JaceWidgetTypes["COUNTER"] = "COUNTER";
1801
+ JaceWidgetTypes["LIST"] = "LIST";
1802
+ JaceWidgetTypes["MULTIPROGRESS"] = "MULTIPROGRESS";
1803
+ })(JaceWidgetTypes || (JaceWidgetTypes = {}));
1804
+
1805
+ /*
1806
+ * Public API Surface of dashboard-feature
1807
+ */
1808
+
1809
+ /**
1810
+ * Generated bundle index. Do not edit.
1811
+ */
1812
+
1813
+ export { BaseJaceWidgetModel, BaseWidgetComponent, CircleProgressComponent, CircleProgressOptions, DSH_DATA_SERVICE, DashboardComponent, DashboardFeatureAPIDataService, DashboardFeatureModule, DashboardWidgetFactory, DefaultDashboardModuleOptions, JaceChartWidgetComponent, JaceCounterWidgetComponent, JaceDashboardConfig, JaceDashboardLayoutAppSearch, JaceDashboardLayoutDetail, JaceListWidgetComponent, JaceMultiprogWidgetComponent, JaceWidgetInstanceDetail, JaceWidgetTypes, SaveJaceDashboardLayoutDTO };
1814
+ //# sourceMappingURL=esfaenza-dashboard-feature.mjs.map