@esfaenza/dashboard-feature 11.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/README.md +24 -0
  2. package/bundles/esfaenza-dashboard-feature.umd.js +1328 -0
  3. package/bundles/esfaenza-dashboard-feature.umd.js.map +1 -0
  4. package/bundles/esfaenza-dashboard-feature.umd.min.js +2 -0
  5. package/bundles/esfaenza-dashboard-feature.umd.min.js.map +1 -0
  6. package/esfaenza-dashboard-feature.d.ts +8 -0
  7. package/esfaenza-dashboard-feature.metadata.json +1 -0
  8. package/esm2015/esfaenza-dashboard-feature.js +9 -0
  9. package/esm2015/lib/components/dashboard/dashboard.component.js +157 -0
  10. package/esm2015/lib/components/dashboard/dashboard.component.loc.js +16 -0
  11. package/esm2015/lib/components/widgets/BaseWidgetComponent.js +81 -0
  12. package/esm2015/lib/components/widgets/IWidgetComponent.js +2 -0
  13. package/esm2015/lib/components/widgets/JaceWidgetTypes.js +8 -0
  14. package/esm2015/lib/components/widgets/chart/jace-dsh-chart.component.js +77 -0
  15. package/esm2015/lib/components/widgets/counter/jace-dsh-counter.component.js +76 -0
  16. package/esm2015/lib/components/widgets/list/jace-dsh-list.component.js +89 -0
  17. package/esm2015/lib/components/widgets/multiprog/jace-dsh-multiprog.component.js +78 -0
  18. package/esm2015/lib/dashboard-feature.module.js +98 -0
  19. package/esm2015/lib/models/config/JaceDashboardConfig.js +49 -0
  20. package/esm2015/lib/models/externals/JaceDashboardLayoutDetail.js +4 -0
  21. package/esm2015/lib/models/externals/JaceWidgetInstanceDetail.js +7 -0
  22. package/esm2015/lib/models/externals/Repository.js +6 -0
  23. package/esm2015/lib/models/externals/SaveJaceDashboardLayoutDTO.js +3 -0
  24. package/esm2015/lib/models/options/DefaultDashboardModuleOptions.js +36 -0
  25. package/esm2015/lib/models/options/IDashboardModuleOptions.js +2 -0
  26. package/esm2015/lib/models/options/IWidgetTypeConfig.js +2 -0
  27. package/esm2015/lib/models/widgets/BaseJaceWidgetModel.js +22 -0
  28. package/esm2015/lib/models/widgets/IJaceWidgetModel.js +2 -0
  29. package/esm2015/lib/models/widgets/JaceChartWidgetModel.js +27 -0
  30. package/esm2015/lib/models/widgets/JaceCounterWidgetModel.js +23 -0
  31. package/esm2015/lib/models/widgets/JaceListWidgetModel.js +39 -0
  32. package/esm2015/lib/models/widgets/JaceMultiprogWidgetModel.js +29 -0
  33. package/esm2015/lib/private-injection-tokens.js +3 -0
  34. package/esm2015/lib/public-injection-tokens.js +15 -0
  35. package/esm2015/lib/services/DashboardWidgetFactory.js +66 -0
  36. package/esm2015/lib/services/IDashboardFeatureDataService.js +2 -0
  37. package/esm2015/lib/services/dashboard-feature.service.js +39 -0
  38. package/esm2015/public-api.js +20 -0
  39. package/fesm2015/esfaenza-dashboard-feature.js +955 -0
  40. package/fesm2015/esfaenza-dashboard-feature.js.map +1 -0
  41. package/lib/components/dashboard/dashboard.component.d.ts +44 -0
  42. package/lib/components/dashboard/dashboard.component.loc.d.ts +5 -0
  43. package/lib/components/widgets/BaseWidgetComponent.d.ts +41 -0
  44. package/lib/components/widgets/IWidgetComponent.d.ts +23 -0
  45. package/lib/components/widgets/JaceWidgetTypes.d.ts +6 -0
  46. package/lib/components/widgets/chart/jace-dsh-chart.component.d.ts +22 -0
  47. package/lib/components/widgets/counter/jace-dsh-counter.component.d.ts +21 -0
  48. package/lib/components/widgets/list/jace-dsh-list.component.d.ts +24 -0
  49. package/lib/components/widgets/multiprog/jace-dsh-multiprog.component.d.ts +23 -0
  50. package/lib/dashboard-feature.module.d.ts +8 -0
  51. package/lib/models/config/JaceDashboardConfig.d.ts +46 -0
  52. package/lib/models/externals/JaceDashboardLayoutDetail.d.ts +6 -0
  53. package/lib/models/externals/JaceWidgetInstanceDetail.d.ts +17 -0
  54. package/lib/models/externals/Repository.d.ts +5 -0
  55. package/lib/models/externals/SaveJaceDashboardLayoutDTO.d.ts +4 -0
  56. package/lib/models/options/DefaultDashboardModuleOptions.d.ts +7 -0
  57. package/lib/models/options/IDashboardModuleOptions.d.ts +5 -0
  58. package/lib/models/options/IWidgetTypeConfig.d.ts +8 -0
  59. package/lib/models/widgets/BaseJaceWidgetModel.d.ts +31 -0
  60. package/lib/models/widgets/IJaceWidgetModel.d.ts +13 -0
  61. package/lib/models/widgets/JaceChartWidgetModel.d.ts +8 -0
  62. package/lib/models/widgets/JaceCounterWidgetModel.d.ts +10 -0
  63. package/lib/models/widgets/JaceListWidgetModel.d.ts +15 -0
  64. package/lib/models/widgets/JaceMultiprogWidgetModel.d.ts +9 -0
  65. package/lib/private-injection-tokens.d.ts +3 -0
  66. package/lib/public-injection-tokens.d.ts +15 -0
  67. package/lib/services/DashboardWidgetFactory.d.ts +20 -0
  68. package/lib/services/IDashboardFeatureDataService.d.ts +11 -0
  69. package/lib/services/dashboard-feature.service.d.ts +16 -0
  70. package/package.json +27 -0
  71. package/public-api.d.ts +16 -0
@@ -0,0 +1,955 @@
1
+ import { InjectionToken, EventEmitter, Component, Inject, Input, Output, ChangeDetectionStrategy, ɵɵdefineInjectable, ɵɵinject, ComponentFactoryResolver, Injectable, ViewEncapsulation, ChangeDetectorRef, ViewChildren, ViewContainerRef, NgModule, Optional } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
3
+ import { FormsModule } from '@angular/forms';
4
+ import { GridsterModule } from 'angular-gridster2';
5
+ import { MatProgressBarModule } from '@angular/material/progress-bar';
6
+ import { Router, ActivatedRoute } from '@angular/router';
7
+ import { InboundMessageTypes, InterComService } from '@esfaenza/extensions';
8
+ import { LocalizationService } from '@esfaenza/localizations';
9
+ import { FormsAndValidationsModule } from '@esfaenza/forms-and-validations';
10
+ import { EsChartsModule } from '@esfaenza/es-charts';
11
+ import { NgCircleProgressModule } from 'ng-circle-progress';
12
+ import { HTTPService, HttpserviceModule } from '@esfaenza/httpservice';
13
+ import { HttpParams } from '@angular/common/http';
14
+
15
+ /**
16
+ * Injection Token della stringa che rappresenta il 'locale' nel sistema @es-faenza/localization
17
+ */
18
+ const DSH_LOCALE = new InjectionToken('DSH_LOCALE');
19
+ /**
20
+ * Injection Token dell'url del FE
21
+ */
22
+ const DSH_BACKEND_URL = new InjectionToken('DSH_BACKEND_URL');
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(widgetModel) {
41
+ this.model = widgetModel;
42
+ this.refreshData();
43
+ }
44
+ ngOnInit() { }
45
+ ngOnChanges(changes) {
46
+ //console.log(changes['DashboardDate'].currentValue);
47
+ if (changes['DashboardDate'].previousValue)
48
+ this.lastdate = changes['DashboardDate'].previousValue.toISOString();
49
+ let curdate = "";
50
+ if (changes['DashboardDate'].currentValue)
51
+ curdate = changes['DashboardDate'].currentValue.toISOString();
52
+ //fix per il datetimepicker material che cambia l'oggetto al momento del caricamento
53
+ if (this.lastdate != curdate) {
54
+ this.lastdate = curdate;
55
+ this.refreshData();
56
+ }
57
+ }
58
+ refreshData() {
59
+ if (!this.model)
60
+ return;
61
+ const pars = {};
62
+ if (this.DashboardDate)
63
+ pars["DT"] = this.DashboardDate.toISOString();
64
+ if (this.model.options && Object.keys(this.model.options).length != 0) {
65
+ for (let index = 0; index < Object.keys(this.model.options).length; index++) {
66
+ const k = Object.keys(this.model.options)[index];
67
+ pars[k] = this.model.options[k];
68
+ }
69
+ }
70
+ this.dshService.GetWidgetData(this.model.name, pars).subscribe(data => {
71
+ if (this.model) {
72
+ this.model.setData(data);
73
+ this.chartName = this.model.name;
74
+ this.dataReady = true;
75
+ }
76
+ });
77
+ }
78
+ removeWidget() {
79
+ if (!this.model)
80
+ return;
81
+ this.OnRemove.emit(this.model.name);
82
+ }
83
+ configure() {
84
+ if (this.configuration) {
85
+ //finito di configurare -> refreshData
86
+ this.refreshData();
87
+ }
88
+ this.configuration = !this.configuration;
89
+ }
90
+ }
91
+ JaceChartWidgetComponent.decorators = [
92
+ { type: Component, args: [{
93
+ selector: 'jace-dsh-chart',
94
+ 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>",
95
+ styles: [""]
96
+ },] }
97
+ ];
98
+ JaceChartWidgetComponent.ctorParameters = () => [
99
+ { type: undefined, decorators: [{ type: Inject, args: [DSH_DATA_SERVICE,] }] }
100
+ ];
101
+ JaceChartWidgetComponent.propDecorators = {
102
+ DashboardDate: [{ type: Input }],
103
+ OnRemove: [{ type: Output }]
104
+ };
105
+
106
+ class JaceCounterWidgetComponent {
107
+ constructor(dshService) {
108
+ this.dshService = dshService;
109
+ this.OnRemove = new EventEmitter();
110
+ this.configuration = false;
111
+ this.dataReady = false;
112
+ this.lastdate = "";
113
+ }
114
+ setWidgetModel(widgetModel) {
115
+ this.model = widgetModel;
116
+ this.refreshData();
117
+ }
118
+ ngOnInit() { }
119
+ ngOnChanges(changes) {
120
+ //console.log(changes['DashboardDate'].currentValue);
121
+ if (changes['DashboardDate'].previousValue)
122
+ this.lastdate = changes['DashboardDate'].previousValue.toISOString();
123
+ let curdate = "";
124
+ if (changes['DashboardDate'].currentValue)
125
+ curdate = changes['DashboardDate'].currentValue.toISOString();
126
+ //fix per il datetimepicker material che cambia l'oggetto al momento del caricamento
127
+ if (this.lastdate != curdate) {
128
+ this.lastdate = curdate;
129
+ this.refreshData();
130
+ }
131
+ }
132
+ refreshData() {
133
+ if (!this.model)
134
+ return;
135
+ const pars = {};
136
+ if (this.DashboardDate)
137
+ pars["DT"] = this.DashboardDate.toISOString();
138
+ if (this.model.options && Object.keys(this.model.options).length != 0) {
139
+ for (let index = 0; index < Object.keys(this.model.options).length; index++) {
140
+ const k = Object.keys(this.model.options)[index];
141
+ pars[k] = this.model.options[k];
142
+ }
143
+ }
144
+ this.dshService.GetWidgetData(this.model.name, pars).subscribe(data => {
145
+ if (this.model) {
146
+ this.model.setData(data);
147
+ this.dataReady = true;
148
+ }
149
+ });
150
+ }
151
+ removeWidget() {
152
+ if (!this.model)
153
+ return;
154
+ this.OnRemove.emit(this.model.name);
155
+ }
156
+ configure() {
157
+ if (this.configuration) {
158
+ //finito di configurare -> refreshData
159
+ this.refreshData();
160
+ }
161
+ this.configuration = !this.configuration;
162
+ }
163
+ }
164
+ JaceCounterWidgetComponent.decorators = [
165
+ { type: Component, args: [{
166
+ selector: 'jace-dsh-counter',
167
+ 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>",
168
+ changeDetection: ChangeDetectionStrategy.OnPush,
169
+ 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}"]
170
+ },] }
171
+ ];
172
+ JaceCounterWidgetComponent.ctorParameters = () => [
173
+ { type: undefined, decorators: [{ type: Inject, args: [DSH_DATA_SERVICE,] }] }
174
+ ];
175
+ JaceCounterWidgetComponent.propDecorators = {
176
+ DashboardDate: [{ type: Input }],
177
+ OnRemove: [{ type: Output }]
178
+ };
179
+
180
+ class JaceListWidgetComponent {
181
+ constructor(dshService, router) {
182
+ this.dshService = dshService;
183
+ this.router = router;
184
+ this.OnRemove = new EventEmitter();
185
+ this.configuration = false;
186
+ this.dataReady = false;
187
+ this.lastdate = "";
188
+ }
189
+ setWidgetModel(widgetModel) {
190
+ this.model = widgetModel;
191
+ this.refreshData();
192
+ }
193
+ ngOnInit() { }
194
+ ngOnChanges(changes) {
195
+ //console.log(changes['DashboardDate'].currentValue);
196
+ if (changes['DashboardDate'].previousValue)
197
+ this.lastdate = changes['DashboardDate'].previousValue.toISOString();
198
+ let curdate = "";
199
+ if (changes['DashboardDate'].currentValue)
200
+ curdate = changes['DashboardDate'].currentValue.toISOString();
201
+ //fix per il datetimepicker material che cambia l'oggetto al momento del caricamento
202
+ if (this.lastdate != curdate) {
203
+ this.lastdate = curdate;
204
+ this.refreshData();
205
+ }
206
+ }
207
+ refreshData() {
208
+ if (!this.model)
209
+ return;
210
+ const pars = {};
211
+ if (this.DashboardDate)
212
+ pars["DT"] = this.DashboardDate.toISOString();
213
+ if (this.model.options && Object.keys(this.model.options).length != 0) {
214
+ for (let index = 0; index < Object.keys(this.model.options).length; index++) {
215
+ const k = Object.keys(this.model.options)[index];
216
+ pars[k] = this.model.options[k];
217
+ }
218
+ }
219
+ this.dshService.GetWidgetData(this.model.name, pars).subscribe(data => {
220
+ if (this.model) {
221
+ this.model.setData(data);
222
+ this.dataReady = true;
223
+ }
224
+ });
225
+ }
226
+ removeWidget() {
227
+ if (!this.model)
228
+ return;
229
+ this.OnRemove.emit(this.model.name);
230
+ }
231
+ itemClicked(item) {
232
+ if (item.link) {
233
+ //naviga al link
234
+ let to = item.link;
235
+ let par = {};
236
+ if (item.id && item.idParamName) {
237
+ par[item.idParamName] = item.id;
238
+ }
239
+ this.router.navigate([to, par]);
240
+ }
241
+ }
242
+ configure() {
243
+ if (this.configuration) {
244
+ //finito di configurare -> refreshData
245
+ this.refreshData();
246
+ }
247
+ this.configuration = !this.configuration;
248
+ }
249
+ }
250
+ JaceListWidgetComponent.decorators = [
251
+ { type: Component, args: [{
252
+ selector: 'jace-dsh-list',
253
+ 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.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>",
254
+ 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}"]
255
+ },] }
256
+ ];
257
+ JaceListWidgetComponent.ctorParameters = () => [
258
+ { type: undefined, decorators: [{ type: Inject, args: [DSH_DATA_SERVICE,] }] },
259
+ { type: Router }
260
+ ];
261
+ JaceListWidgetComponent.propDecorators = {
262
+ DashboardDate: [{ type: Input }],
263
+ OnRemove: [{ type: Output }]
264
+ };
265
+
266
+ class JaceMultiprogWidgetComponent {
267
+ constructor(dshService, router) {
268
+ this.dshService = dshService;
269
+ this.router = router;
270
+ this.OnRemove = new EventEmitter();
271
+ this.configuration = false;
272
+ this.dataReady = false;
273
+ this.lastdate = "";
274
+ }
275
+ setWidgetModel(widgetModel) {
276
+ this.model = widgetModel;
277
+ this.refreshData();
278
+ }
279
+ ngOnInit() { }
280
+ ngOnChanges(changes) {
281
+ //console.log(changes['DashboardDate'].currentValue);
282
+ if (changes['DashboardDate'].previousValue)
283
+ this.lastdate = changes['DashboardDate'].previousValue.toISOString();
284
+ let curdate = "";
285
+ if (changes['DashboardDate'].currentValue)
286
+ curdate = changes['DashboardDate'].currentValue.toISOString();
287
+ //fix per il datetimepicker material che cambia l'oggetto al momento del caricamento
288
+ if (this.lastdate != curdate) {
289
+ this.lastdate = curdate;
290
+ this.refreshData();
291
+ }
292
+ }
293
+ refreshData() {
294
+ if (!this.model)
295
+ return;
296
+ const pars = {};
297
+ if (this.DashboardDate)
298
+ pars["DT"] = this.DashboardDate.toISOString();
299
+ if (this.model.options && Object.keys(this.model.options).length != 0) {
300
+ for (let index = 0; index < Object.keys(this.model.options).length; index++) {
301
+ const k = Object.keys(this.model.options)[index];
302
+ pars[k] = this.model.options[k];
303
+ }
304
+ }
305
+ this.dshService.GetWidgetData(this.model.name, pars).subscribe(data => {
306
+ if (this.model) {
307
+ this.model.setData(data);
308
+ this.dataReady = true;
309
+ }
310
+ });
311
+ }
312
+ removeWidget() {
313
+ if (!this.model)
314
+ return;
315
+ this.OnRemove.emit(this.model.name);
316
+ }
317
+ configure() {
318
+ if (this.configuration) {
319
+ //finito di configurare -> refreshData
320
+ this.refreshData();
321
+ }
322
+ this.configuration = !this.configuration;
323
+ }
324
+ }
325
+ JaceMultiprogWidgetComponent.decorators = [
326
+ { type: Component, args: [{
327
+ selector: 'jace-dsh-multiprog',
328
+ 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 <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 *ngIf=\"model.circleProgress\"></circle-progress>\r\n <!-- [title] = \"model.progressValues[i]|number||''\" -->\r\n <mat-progress-bar [value]=\"model.progressValues[i]\" [mode]=\"'determinate'\" *ngIf=\"!model.circleProgress\">\r\n </mat-progress-bar>\r\n <!-- <span>{{item}}</span>:<span>{{model.progressValues[i]}}</span> -->\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>",
329
+ 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}"]
330
+ },] }
331
+ ];
332
+ JaceMultiprogWidgetComponent.ctorParameters = () => [
333
+ { type: undefined, decorators: [{ type: Inject, args: [DSH_DATA_SERVICE,] }] },
334
+ { type: Router }
335
+ ];
336
+ JaceMultiprogWidgetComponent.propDecorators = {
337
+ DashboardDate: [{ type: Input }],
338
+ OnRemove: [{ type: Output }]
339
+ };
340
+
341
+ class BaseJaceWidgetModel {
342
+ constructor() {
343
+ this.resizeEnabled = false;
344
+ this.dataError = false;
345
+ this.options = {};
346
+ }
347
+ configureFromInstanceDetails(details) {
348
+ this.name = details.name;
349
+ this.widgetType = details.type;
350
+ this.title = details.title;
351
+ this.x = details.x;
352
+ this.y = details.y;
353
+ this.cols = details.cols;
354
+ this.rows = details.rows;
355
+ this.compactEnabled = details.compactenabled;
356
+ this.dragEnabled = details.dragenabled;
357
+ this.options = details.options;
358
+ this.dataError = details.queryerror;
359
+ this.resizeEnabled = details.resizeenabled;
360
+ }
361
+ }
362
+
363
+ class JaceChartWidgetModel extends BaseJaceWidgetModel {
364
+ constructor() {
365
+ super();
366
+ this.chartType = 'line';
367
+ this.legend = false;
368
+ this.widgetType = "CHART";
369
+ }
370
+ setData(data) {
371
+ if (!data)
372
+ return;
373
+ if (data['queryerror'])
374
+ this.dataError = data['queryerror'];
375
+ if (data['legend'])
376
+ this.legend = data['legend'];
377
+ else
378
+ this.legend = true;
379
+ if (data['charttype'])
380
+ this.chartType = data['charttype'];
381
+ if (data['chartdata']) {
382
+ this.chartData = data['chartdata'];
383
+ }
384
+ if (this.options && this.options['legend'] == undefined)
385
+ this.options['legend'] = true;
386
+ }
387
+ }
388
+
389
+ class JaceCounterWidgetModel extends BaseJaceWidgetModel {
390
+ constructor() {
391
+ super();
392
+ this.superText = undefined;
393
+ this.subText = undefined;
394
+ this.value = 0;
395
+ this.icon = undefined;
396
+ this.unit = undefined;
397
+ this.widgetType = "COUNTER";
398
+ }
399
+ setData(data) {
400
+ if (data['queryerror'])
401
+ this.dataError = data['queryerror'];
402
+ this.superText = data['supertext'];
403
+ this.subText = data['subtext'];
404
+ this.value = data['value'];
405
+ this.icon = data['icon'];
406
+ this.options = data['options'];
407
+ this.unit = data['unit'];
408
+ }
409
+ }
410
+
411
+ class JaceListItemWidget {
412
+ }
413
+ class JaceListWidgetModel extends BaseJaceWidgetModel {
414
+ constructor() {
415
+ super();
416
+ this.superText = undefined;
417
+ this.items = [];
418
+ this.widgetType = "LIST";
419
+ }
420
+ setData(data) {
421
+ if (!data)
422
+ return;
423
+ if (data['queryerror'])
424
+ this.dataError = data['queryerror'];
425
+ this.superText = data['supertext'];
426
+ if (data['items']) {
427
+ const d = data['items'];
428
+ this.items = [];
429
+ for (let index = 0; index < d.length; index++) {
430
+ const item = new JaceListItemWidget();
431
+ const element = d[index];
432
+ if (element['id'])
433
+ item.id = element['id'];
434
+ if (element['idparamname'])
435
+ item.idParamName = element['idparamname'];
436
+ if (element['link'])
437
+ item.link = element['link'];
438
+ if (element['subline'])
439
+ item.subline = element['subline'];
440
+ if (element['classes'])
441
+ item.classes = element['classes'];
442
+ item.description = element.description;
443
+ this.items.push(item);
444
+ }
445
+ }
446
+ }
447
+ }
448
+
449
+ class JaceMultiprogWidgetModel extends BaseJaceWidgetModel {
450
+ constructor() {
451
+ super();
452
+ this.resizeEnabled = true;
453
+ this.progressTitles = [];
454
+ this.progressValues = [];
455
+ this.circleProgress = false;
456
+ this.widgetType = "MULTIPROGRESS";
457
+ }
458
+ setData(data) {
459
+ var _a, _b, _c;
460
+ if (data['queryerror'])
461
+ this.dataError = data['queryerror'];
462
+ this.progressTitles = (_a = data['progresstitles']) !== null && _a !== void 0 ? _a : [];
463
+ this.progressValues = (_b = data['progressvalues']) !== null && _b !== void 0 ? _b : [];
464
+ this.circleProgress = data['circleprogress'];
465
+ this.options = (_c = data['options']) !== null && _c !== void 0 ? _c : {};
466
+ if (this.circleProgress === undefined)
467
+ this.circleProgress = true;
468
+ if (this.cols === undefined && this.progressValues) {
469
+ if (this.progressValues.length == 1)
470
+ this.cols = 1;
471
+ else
472
+ this.cols = 2;
473
+ }
474
+ }
475
+ }
476
+
477
+ class DefaultDashboardModuleOptions {
478
+ constructor() {
479
+ this.locale = "it-IT";
480
+ this.widgetTypes = [
481
+ {
482
+ name: "COUNTER",
483
+ component: JaceCounterWidgetComponent,
484
+ model: JaceCounterWidgetModel
485
+ },
486
+ {
487
+ name: "LIST",
488
+ component: JaceListWidgetComponent,
489
+ model: JaceListWidgetModel
490
+ },
491
+ {
492
+ name: "CHART",
493
+ component: JaceChartWidgetComponent,
494
+ model: JaceChartWidgetModel
495
+ },
496
+ {
497
+ name: "MULTIPROGRESS",
498
+ component: JaceMultiprogWidgetComponent,
499
+ model: JaceMultiprogWidgetModel
500
+ }
501
+ ];
502
+ }
503
+ }
504
+
505
+ //singleton
506
+ class DashboardWidgetFactory {
507
+ //verione ng 13
508
+ //constructor() { }
509
+ constructor(componentFactoryResolver) {
510
+ this.componentFactoryResolver = componentFactoryResolver;
511
+ this.types = {};
512
+ }
513
+ addOption(option) {
514
+ if (option.widgetTypes) {
515
+ option.widgetTypes.forEach((o) => {
516
+ this.types[o.name] = o;
517
+ });
518
+ }
519
+ }
520
+ //versione ng 13+
521
+ /* resolveComponent(type: string, vcr: ViewContainerRef): ComponentRef<IWidgetComponent> | null {
522
+
523
+ if (!this.types)
524
+ return null;
525
+
526
+ let t = this.types[type];
527
+
528
+ if (!t)
529
+ return null;
530
+
531
+ let componentRef: ComponentRef<IWidgetComponent> = vcr.createComponent(t.component);
532
+
533
+ return componentRef;
534
+ } */
535
+ //versione ng11
536
+ resolveComponent(type, vcr) {
537
+ if (!this.types)
538
+ return null;
539
+ let t = this.types[type];
540
+ if (!t)
541
+ return null;
542
+ //DEPRECATO dopo ng11: è stato tolto il meccanismo dei ComponentFactory per i componenti dinamici
543
+ let cf = this.componentFactoryResolver.resolveComponentFactory(t.component);
544
+ let componentRef = vcr.createComponent(cf);
545
+ return componentRef;
546
+ }
547
+ resolveDefinition(type, details) {
548
+ if (!this.types)
549
+ return null;
550
+ let t = this.types[type];
551
+ if (!t)
552
+ return null;
553
+ let definitionInstance = this.createInstance(t.model);
554
+ definitionInstance.configureFromInstanceDetails(details);
555
+ return definitionInstance;
556
+ }
557
+ createInstance(type) {
558
+ return new type();
559
+ }
560
+ }
561
+ DashboardWidgetFactory.ɵprov = ɵɵdefineInjectable({ factory: function DashboardWidgetFactory_Factory() { return new DashboardWidgetFactory(ɵɵinject(ComponentFactoryResolver)); }, token: DashboardWidgetFactory, providedIn: "root" });
562
+ DashboardWidgetFactory.decorators = [
563
+ { type: Injectable, args: [{ providedIn: 'root' },] }
564
+ ];
565
+ DashboardWidgetFactory.ctorParameters = () => [
566
+ { type: ComponentFactoryResolver }
567
+ ];
568
+
569
+ class DashboardLoc extends LocalizationService {
570
+ constructor(options) {
571
+ super(options.locale);
572
+ super.set("en->it", "Dashboard", ["Dashboard"]);
573
+ }
574
+ }
575
+ DashboardLoc.decorators = [
576
+ { type: Injectable }
577
+ ];
578
+ DashboardLoc.ctorParameters = () => [
579
+ { type: undefined, decorators: [{ type: Inject, args: [DSH_OPTIONS,] }] }
580
+ ];
581
+
582
+ class SaveJaceDashboardLayoutDTO {
583
+ }
584
+
585
+ //Definizione della widget restituita dal backend
586
+ class JaceWidgetInstanceDetail {
587
+ constructor() {
588
+ this.queryerror = false;
589
+ }
590
+ }
591
+
592
+ /**
593
+ * Componente di base che rappresenta una dashboard.
594
+ * Utilizza Gridster2 per il layout delle widget [Gridster2](https://tiberiuzuld.github.io/angular-gridster2/)
595
+ */
596
+ class DashboardComponent {
597
+ constructor(dshService, intercom, lc, route, cmpFactory, cdr) {
598
+ this.dshService = dshService;
599
+ this.intercom = intercom;
600
+ this.lc = lc;
601
+ this.route = route;
602
+ this.cmpFactory = cmpFactory;
603
+ this.cdr = cdr;
604
+ this.dashboardDate = new Date();
605
+ this.widgetDefinitions = [];
606
+ this.trackedSubscriptions = [];
607
+ this.intercom.send(InboundMessageTypes.Navigation, { sub: false, routeTitle: this.lc.loc(this.route.snapshot.data["title"]) });
608
+ }
609
+ ngOnInit() {
610
+ }
611
+ ngAfterViewInit() {
612
+ //qui this.gridItemRefs è 'riempito'
613
+ // sottoscrivo changes che sparerà tutte le volte che ngFor si aggiorna (ovvero quando cambia dashboard)
614
+ this.changesSub = this.gridItemRefs.changes.subscribe((comps) => {
615
+ this.renderLayout(comps);
616
+ });
617
+ //prima volta
618
+ /* if(this.Configuration)
619
+ this.reloadData(); */
620
+ setTimeout(() => this.reloadData(), 500);
621
+ }
622
+ ngOnDestroy() {
623
+ //unsubscribe dalle changes dei viewref
624
+ if (this.changesSub)
625
+ this.changesSub.unsubscribe();
626
+ this.clearTrackedSubscriptions();
627
+ }
628
+ clearTrackedSubscriptions() {
629
+ if (this.trackedSubscriptions) {
630
+ for (let index = 0; index < this.trackedSubscriptions.length; index++) {
631
+ const element = this.trackedSubscriptions[index];
632
+ element.unsubscribe();
633
+ }
634
+ this.trackedSubscriptions = [];
635
+ }
636
+ }
637
+ ngOnChanges(changes) {
638
+ if (changes.Configuration) {
639
+ //appena ho configuration
640
+ }
641
+ }
642
+ reloadData() {
643
+ this.dshService.GetUserDashboard(this.Configuration.accountId, this.Configuration.dashboardName).subscribe(c => {
644
+ this.dashboardLayout = c;
645
+ this.widgetDefinitions = c.widgets.map(i => {
646
+ return this.cmpFactory.resolveDefinition(i.type, i);
647
+ });
648
+ });
649
+ }
650
+ removeItem(widgetName) {
651
+ if (!this.dashboardLayout)
652
+ return;
653
+ let idx = this.dashboardLayout.widgets.findIndex(s => s.name == widgetName);
654
+ this.widgetDefinitions.splice(idx, 1);
655
+ }
656
+ saveDashboard() {
657
+ if (!this.dashboardLayout)
658
+ return;
659
+ const dto = new SaveJaceDashboardLayoutDTO();
660
+ dto.widgets = [];
661
+ for (let index = 0; index < this.widgetDefinitions.length; index++) {
662
+ const w = this.widgetDefinitions[index];
663
+ if (w == null)
664
+ continue;
665
+ let v = new JaceWidgetInstanceDetail();
666
+ v.id = w.id;
667
+ v.name = w.name;
668
+ v.x = w.x;
669
+ v.y = w.y;
670
+ v.cols = w.cols;
671
+ v.rows = w.rows;
672
+ v.compactenabled = w.compactEnabled;
673
+ v.dragenabled = w.dragEnabled;
674
+ v.resizeenabled = w.resizeEnabled;
675
+ v.type = w.widgetType;
676
+ v.title = w.title;
677
+ v.options = w.options;
678
+ dto.widgets.push(v);
679
+ }
680
+ this.dshService.SaveUserDashboard(dto).subscribe(res => {
681
+ if (res.success)
682
+ console.log('Dashboard saved');
683
+ });
684
+ }
685
+ renderLayout(comps) {
686
+ this.clearTrackedSubscriptions();
687
+ comps.map((host, index) => {
688
+ const vcr = host;
689
+ vcr.clear();
690
+ const widgetData = this.widgetDefinitions[index];
691
+ if (!widgetData || !widgetData.widgetType)
692
+ return;
693
+ let componentRef;
694
+ componentRef = this.cmpFactory.resolveComponent(widgetData === null || widgetData === void 0 ? void 0 : widgetData.widgetType, vcr);
695
+ if (!componentRef) {
696
+ console.log(`Tipo widget sconosciuto ${widgetData.widgetType}`);
697
+ return;
698
+ }
699
+ //setta l'input della data
700
+ if (this.Configuration.showDateInput)
701
+ componentRef.instance.DashboardDate = this.dashboardDate;
702
+ //setta il modello
703
+ componentRef.instance.setWidgetModel(widgetData);
704
+ //setta la callback per OnRemove
705
+ let s = componentRef.instance.OnRemove.subscribe(name => this.removeItem(name));
706
+ this.trackedSubscriptions.push(s);
707
+ //componentRef.changeDetectorRef.markForCheck();
708
+ //componentRef.changeDetectorRef.detectChanges();
709
+ });
710
+ this.cdr.detectChanges();
711
+ }
712
+ addItem() {
713
+ //this.dashboard.push({});
714
+ }
715
+ }
716
+ DashboardComponent.decorators = [
717
+ { type: Component, args: [{
718
+ selector: 'dashboard',
719
+ encapsulation: ViewEncapsulation.None,
720
+ providers: [
721
+ { provide: LocalizationService, useClass: DashboardLoc }
722
+ ],
723
+ 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 [JsDates]=\"true\" [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>",
724
+ 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:1px solid #ddd;border-radius:5px;min-width:204px}.jace-dsh-widget-header{margin:0 .5rem;display:flex;flex-flow:row;justify-content:left;align-items:center}.jace-dsh-widget-title{padding:.5rem .2rem .3rem;border-bottom:1px solid #ddd;text-transform:uppercase;font-size:.8rem}.jace-dsh-widget-body{margin:0 .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:0;right:0;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}"]
725
+ },] }
726
+ ];
727
+ DashboardComponent.ctorParameters = () => [
728
+ { type: undefined, decorators: [{ type: Inject, args: [DSH_DATA_SERVICE,] }] },
729
+ { type: InterComService },
730
+ { type: LocalizationService },
731
+ { type: ActivatedRoute },
732
+ { type: DashboardWidgetFactory },
733
+ { type: ChangeDetectorRef }
734
+ ];
735
+ DashboardComponent.propDecorators = {
736
+ Configuration: [{ type: Input }],
737
+ gridItemRefs: [{ type: ViewChildren, args: ['grid_item', { read: ViewContainerRef },] }]
738
+ };
739
+
740
+ const Repository = {
741
+ GET_Dashboard_GetLayout: "/api/Dashboard/GetLayout",
742
+ POST_Dashboard_SaveLayout: "/api/Dashboard/SaveLayout",
743
+ GET_Dashboard_GetWidgetData: "/api/Dashboard/GetWidgetData"
744
+ };
745
+
746
+ class DashboardFeatureAPIDataService {
747
+ constructor(http, backend) {
748
+ this.http = http;
749
+ this.backend = backend;
750
+ }
751
+ GetUserDashboard(idaccount, dashboardName) {
752
+ let params = new HttpParams();
753
+ params = params.append("idaccount", idaccount.toString());
754
+ params = params.append("name", dashboardName);
755
+ return this.http.get(this.backend + Repository["GET_Dashboard_GetLayout"], params);
756
+ }
757
+ SaveUserDashboard(dto) {
758
+ return this.http.post(this.backend + Repository["POST_Dashboard_SaveLayout"], dto);
759
+ }
760
+ GetWidgetData(name, options) {
761
+ let params = new HttpParams();
762
+ params = params.append("name", name.toString());
763
+ if (options && Object.keys(options).length != 0) {
764
+ for (let index = 0; index < Object.keys(options).length; index++) {
765
+ const k = Object.keys(options)[index];
766
+ params = params.append(k, options[k]);
767
+ }
768
+ }
769
+ return this.http.get(this.backend + Repository["GET_Dashboard_GetWidgetData"], params);
770
+ }
771
+ }
772
+ DashboardFeatureAPIDataService.decorators = [
773
+ { type: Injectable }
774
+ ];
775
+ DashboardFeatureAPIDataService.ctorParameters = () => [
776
+ { type: HTTPService },
777
+ { type: String, decorators: [{ type: Inject, args: [DSH_BACKEND_URL,] }] }
778
+ ];
779
+
780
+ const MODULES = [
781
+ // Base
782
+ CommonModule,
783
+ FormsModule,
784
+ GridsterModule,
785
+ MatProgressBarModule,
786
+ FormsAndValidationsModule,
787
+ EsChartsModule,
788
+ HttpserviceModule,
789
+ /* EsChartsModule.forRoot({
790
+ locale: myconfig.LOCALE,
791
+ animations: true,
792
+ theme: 'spiritedaway',
793
+ adapter: null,
794
+ debugMode: false
795
+ }), */
796
+ NgCircleProgressModule.forRoot({
797
+ // set defaults here
798
+ radius: 50,
799
+ outerStrokeWidth: 8,
800
+ innerStrokeWidth: 4,
801
+ outerStrokeColor: "#78C000",
802
+ innerStrokeColor: "#C7E596",
803
+ animationDuration: 300
804
+ })
805
+ ];
806
+ const COMPONENTS = [
807
+ DashboardComponent,
808
+ JaceListWidgetComponent,
809
+ JaceCounterWidgetComponent,
810
+ JaceChartWidgetComponent,
811
+ JaceMultiprogWidgetComponent
812
+ ];
813
+ class DashboardFeatureModule {
814
+ constructor(componentFactory, options) {
815
+ if (!options) {
816
+ //componentFactory.addOption(new DefaultDashboardModuleOptions());
817
+ return;
818
+ }
819
+ options.map((o) => componentFactory.addOption(o));
820
+ }
821
+ static forRoot(options) {
822
+ return {
823
+ ngModule: DashboardFeatureModule,
824
+ providers: [
825
+ { provide: DSH_OPTIONS, multi: true, useValue: new DefaultDashboardModuleOptions() },
826
+ { provide: DSH_OPTIONS, multi: true, useValue: options },
827
+ { provide: DSH_DATA_SERVICE, useClass: DashboardFeatureAPIDataService }
828
+ ]
829
+ };
830
+ }
831
+ static forChild(options) {
832
+ return {
833
+ ngModule: DashboardFeatureModule,
834
+ providers: [
835
+ { provide: DSH_OPTIONS, multi: true, useValue: new DefaultDashboardModuleOptions() },
836
+ { provide: DSH_OPTIONS, multi: true, useValue: options }
837
+ ]
838
+ };
839
+ }
840
+ }
841
+ DashboardFeatureModule.decorators = [
842
+ { type: NgModule, args: [{
843
+ declarations: [
844
+ ...COMPONENTS
845
+ ],
846
+ imports: [
847
+ ...MODULES
848
+ ],
849
+ exports: [
850
+ ...COMPONENTS
851
+ ]
852
+ },] }
853
+ ];
854
+ DashboardFeatureModule.ctorParameters = () => [
855
+ { type: DashboardWidgetFactory },
856
+ { type: Array, decorators: [{ type: Optional }, { type: Inject, args: [DSH_OPTIONS,] }] }
857
+ ];
858
+
859
+ /**
860
+ * Classe di base astratta per la creazione di Widget custom.
861
+ */
862
+ class BaseWidgetComponent {
863
+ constructor(dshService) {
864
+ this.dshService = dshService;
865
+ this.OnRemove = new EventEmitter();
866
+ this.configuration = false;
867
+ this.dataReady = false;
868
+ this.lastdate = "";
869
+ }
870
+ setWidgetModel(widgetModel) {
871
+ this.model = widgetModel;
872
+ this.refreshData();
873
+ }
874
+ ngOnInit() { }
875
+ ngOnChanges(changes) {
876
+ //console.log(changes['DashboardDate'].currentValue);
877
+ if (changes['DashboardDate'].previousValue)
878
+ this.lastdate = changes['DashboardDate'].previousValue.toISOString();
879
+ let curdate = "";
880
+ if (changes['DashboardDate'].currentValue)
881
+ curdate = changes['DashboardDate'].currentValue.toISOString();
882
+ //fix per il datetimepicker material che cambia l'oggetto al momento del caricamento
883
+ if (this.lastdate != curdate) {
884
+ this.lastdate = curdate;
885
+ this.refreshData();
886
+ }
887
+ }
888
+ /**
889
+ * Prepara i parametri e lancia la chiamata GetWidgetData della DashboardFeatureService.
890
+ * Imposta il model con i dati restituiti (setData) e imposta la variabile dataReady del campo a true
891
+ */
892
+ refreshData() {
893
+ if (!this.model)
894
+ return;
895
+ const pars = {};
896
+ if (this.DashboardDate)
897
+ pars["DT"] = this.DashboardDate.toISOString();
898
+ if (this.model.options && Object.keys(this.model.options).length != 0) {
899
+ for (let index = 0; index < Object.keys(this.model.options).length; index++) {
900
+ const k = Object.keys(this.model.options)[index];
901
+ pars[k] = this.model.options[k];
902
+ }
903
+ }
904
+ this.prepareGetDataParameters(pars);
905
+ this.dshService.GetWidgetData(this.model.name, pars).subscribe(data => {
906
+ if (this.model) {
907
+ this.model.setData(data);
908
+ this.dataReady = true;
909
+ }
910
+ });
911
+ }
912
+ /**
913
+ * Da chiamare quando l'utente preme il pulsante 'rimuovi' nella toolbar della widget.
914
+ */
915
+ removeWidget() {
916
+ if (!this.model)
917
+ return;
918
+ this.OnRemove.emit(this.model.name);
919
+ }
920
+ /**
921
+ * Da chiamare quando viene premuto il pulsante 'configure' nella toolbar della widget
922
+ */
923
+ configureWidget() {
924
+ if (this.configuration) {
925
+ //finito di configurare -> refreshData
926
+ this.refreshData();
927
+ }
928
+ this.configuration = !this.configuration;
929
+ }
930
+ }
931
+ BaseWidgetComponent.decorators = [
932
+ { type: Injectable }
933
+ ];
934
+ BaseWidgetComponent.ctorParameters = () => [
935
+ { type: undefined, decorators: [{ type: Inject, args: [DSH_DATA_SERVICE,] }] }
936
+ ];
937
+
938
+ var JaceWidgetTypes;
939
+ (function (JaceWidgetTypes) {
940
+ JaceWidgetTypes["CHART"] = "CHART";
941
+ JaceWidgetTypes["COUNTER"] = "COUNTER";
942
+ JaceWidgetTypes["LIST"] = "LIST";
943
+ JaceWidgetTypes["MULTIPROGRESS"] = "MULTIPROGRESS";
944
+ })(JaceWidgetTypes || (JaceWidgetTypes = {}));
945
+
946
+ /*
947
+ * Public API Surface of dashboard-feature
948
+ */
949
+
950
+ /**
951
+ * Generated bundle index. Do not edit.
952
+ */
953
+
954
+ export { BaseJaceWidgetModel, BaseWidgetComponent, DSH_BACKEND_URL, DSH_DATA_SERVICE, DSH_LOCALE, DashboardComponent, DashboardFeatureModule, DefaultDashboardModuleOptions, JaceChartWidgetComponent, JaceCounterWidgetComponent, JaceListWidgetComponent, JaceMultiprogWidgetComponent, JaceWidgetTypes, DashboardLoc as ɵa, DSH_OPTIONS as ɵb, DashboardWidgetFactory as ɵc, DashboardFeatureAPIDataService as ɵd };
955
+ //# sourceMappingURL=esfaenza-dashboard-feature.js.map