@rafaelaalmeidaa/primordash 0.0.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.
- package/README.md +24 -0
- package/esm2020/lib/components/card/card.component.mjs +69 -0
- package/esm2020/lib/components/charts/bar-line/bar-line.component.mjs +245 -0
- package/esm2020/lib/components/charts/bubble/bubble.component.mjs +147 -0
- package/esm2020/lib/components/charts/pie/pie.component.mjs +161 -0
- package/esm2020/lib/components/charts/simple-card/simple-card.component.mjs +31 -0
- package/esm2020/lib/components/charts/table/table.component.mjs +26 -0
- package/esm2020/lib/components/dashboard/dashboard.component.mjs +251 -0
- package/esm2020/lib/components/modal-edit/modal-edit.component.mjs +133 -0
- package/esm2020/lib/components/modal-edit-chart/modal-edit-chart.component.mjs +56 -0
- package/esm2020/lib/models/dashboard.model.mjs +46 -0
- package/esm2020/lib/primordash.component.mjs +75 -0
- package/esm2020/lib/primordash.module.mjs +92 -0
- package/esm2020/lib/primordash.service.mjs +14 -0
- package/esm2020/lib/services/generic.mjs +50 -0
- package/esm2020/public-api.mjs +8 -0
- package/esm2020/rafaAlmeida-primordash.mjs +5 -0
- package/esm2020/rafaelaalmeidaa-primordash.mjs +5 -0
- package/fesm2015/rafaAlmeida-primordash.mjs +1374 -0
- package/fesm2015/rafaAlmeida-primordash.mjs.map +1 -0
- package/fesm2015/rafaelaalmeidaa-primordash.mjs +1374 -0
- package/fesm2015/rafaelaalmeidaa-primordash.mjs.map +1 -0
- package/fesm2020/rafaAlmeida-primordash.mjs +1349 -0
- package/fesm2020/rafaAlmeida-primordash.mjs.map +1 -0
- package/fesm2020/rafaelaalmeidaa-primordash.mjs +1349 -0
- package/fesm2020/rafaelaalmeidaa-primordash.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/components/card/card.component.d.ts +21 -0
- package/lib/components/charts/bar-line/bar-line.component.d.ts +32 -0
- package/lib/components/charts/bubble/bubble.component.d.ts +27 -0
- package/lib/components/charts/pie/pie.component.d.ts +28 -0
- package/lib/components/charts/simple-card/simple-card.component.d.ts +15 -0
- package/lib/components/charts/table/table.component.d.ts +13 -0
- package/lib/components/dashboard/dashboard.component.d.ts +58 -0
- package/lib/components/modal-edit/modal-edit.component.d.ts +32 -0
- package/lib/components/modal-edit-chart/modal-edit-chart.component.d.ts +16 -0
- package/lib/models/dashboard.model.d.ts +118 -0
- package/lib/primordash.component.d.ts +16 -0
- package/lib/primordash.module.d.ts +26 -0
- package/lib/primordash.service.d.ts +6 -0
- package/lib/services/generic.d.ts +3 -0
- package/package.json +40 -0
- package/public-api.d.ts +4 -0
- package/src/lib/assets/fonts/google_icons_outlined.ttf +0 -0
- package/src/lib/assets/fonts/google_icons_rounded.ttf +0 -0
- package/src/lib/assets/fonts/google_icons_sharp.ttf +0 -0
- package/src/lib/assets/images/bar.png +0 -0
- package/src/lib/assets/images/doughnut.png +0 -0
- package/src/lib/assets/images/halfDoughnut.png +0 -0
- package/src/lib/assets/images/lineBar.png +0 -0
- package/src/lib/assets/images/multiPie.png +0 -0
- package/src/lib/assets/images/pie.png +0 -0
- package/src/lib/assets/images/polarArea.png +0 -0
- package/src/lib/assets/images/verticalBar.png +0 -0
- package/src/lib/assets/images/verticalStackedBar.png +0 -0
- package/src/lib/assets/style.scss +5 -0
- package/src/lib/assets/styles/_colors.scss +11 -0
- package/src/lib/assets/styles/_fonts.scss +30 -0
- package/src/lib/assets/styles/_modal.scss +36 -0
- package/src/lib/assets/styles/_ng-select.scss +128 -0
|
@@ -0,0 +1,1349 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Injectable, Component, Input, ViewChild, HostListener, EventEmitter, Output, ViewChildren, NgModule } from '@angular/core';
|
|
3
|
+
import * as i3$1 from '@angular/cdk/drag-drop';
|
|
4
|
+
import { moveItemInArray, CdkDropList, DragDropModule } from '@angular/cdk/drag-drop';
|
|
5
|
+
import * as i1$2 from 'ngx-bootstrap/modal';
|
|
6
|
+
import { ModalModule } from 'ngx-bootstrap/modal';
|
|
7
|
+
import * as i2 from '@angular/common';
|
|
8
|
+
import { CommonModule } from '@angular/common';
|
|
9
|
+
import * as i4$1 from '@angular/material/grid-list';
|
|
10
|
+
import { MatGridListModule } from '@angular/material/grid-list';
|
|
11
|
+
import * as i5 from '@angular/material/menu';
|
|
12
|
+
import { MatMenuModule } from '@angular/material/menu';
|
|
13
|
+
import * as i1$1 from '@angular/platform-browser';
|
|
14
|
+
import { BrowserModule } from '@angular/platform-browser';
|
|
15
|
+
import * as i1 from 'ng2-charts';
|
|
16
|
+
import { BaseChartDirective, NgChartsModule } from 'ng2-charts';
|
|
17
|
+
import * as i3 from '@angular/forms';
|
|
18
|
+
import { ReactiveFormsModule, FormsModule } from '@angular/forms';
|
|
19
|
+
import * as i4 from '@ng-select/ng-select';
|
|
20
|
+
import { NgSelectModule } from '@ng-select/ng-select';
|
|
21
|
+
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
|
22
|
+
|
|
23
|
+
class PrimordashService {
|
|
24
|
+
constructor() { }
|
|
25
|
+
}
|
|
26
|
+
PrimordashService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: PrimordashService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
27
|
+
PrimordashService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: PrimordashService, providedIn: 'root' });
|
|
28
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: PrimordashService, decorators: [{
|
|
29
|
+
type: Injectable,
|
|
30
|
+
args: [{
|
|
31
|
+
providedIn: 'root'
|
|
32
|
+
}]
|
|
33
|
+
}], ctorParameters: function () { return []; } });
|
|
34
|
+
|
|
35
|
+
const DASHBOARD_CHART_TYPES = [
|
|
36
|
+
'bar',
|
|
37
|
+
'stackedBar',
|
|
38
|
+
'verticalBar',
|
|
39
|
+
'verticalStackedBar',
|
|
40
|
+
'verticalProgressBar',
|
|
41
|
+
'progressBar',
|
|
42
|
+
'lineBar',
|
|
43
|
+
'lineBarStacked',
|
|
44
|
+
'line',
|
|
45
|
+
'radar',
|
|
46
|
+
'curveLine',
|
|
47
|
+
'pie',
|
|
48
|
+
'multiPie',
|
|
49
|
+
'doughnut',
|
|
50
|
+
'halfDoughnut',
|
|
51
|
+
'area',
|
|
52
|
+
'bubble',
|
|
53
|
+
'polarArea',
|
|
54
|
+
'simpleCard',
|
|
55
|
+
'table',
|
|
56
|
+
'html',
|
|
57
|
+
];
|
|
58
|
+
const DASHBOARD_BAR_LINE_TYPES = [
|
|
59
|
+
'bar', 'stackedBar', 'verticalBar', 'verticalStackedBar', 'progressBar', 'verticalProgressBar',
|
|
60
|
+
'lineBar', 'lineBarStacked', 'line', 'radar', 'curveLine'
|
|
61
|
+
];
|
|
62
|
+
const SUPPORTED_CHART_TYPES = [
|
|
63
|
+
'bar',
|
|
64
|
+
'line',
|
|
65
|
+
'radar'
|
|
66
|
+
];
|
|
67
|
+
const AXIS_ORIENTATION = [
|
|
68
|
+
'x',
|
|
69
|
+
'y',
|
|
70
|
+
];
|
|
71
|
+
const AXIS_DIMENSION = [
|
|
72
|
+
'x',
|
|
73
|
+
'y',
|
|
74
|
+
'r',
|
|
75
|
+
];
|
|
76
|
+
const MODAL_TYPES = [
|
|
77
|
+
'group',
|
|
78
|
+
'option'
|
|
79
|
+
];
|
|
80
|
+
|
|
81
|
+
function randomColor() {
|
|
82
|
+
const r = Math.floor(Math.random() * 255);
|
|
83
|
+
const g = Math.floor(Math.random() * 255);
|
|
84
|
+
const b = Math.floor(Math.random() * 255);
|
|
85
|
+
return `rgba(${r}, ${g}, ${b}, 0.6)`;
|
|
86
|
+
}
|
|
87
|
+
function getOpacityColors(listColors, index) {
|
|
88
|
+
const opacity = Math.max(0.1, 1 - index * 0.30);
|
|
89
|
+
return listColors.map(color => replaceAlpha(color, opacity));
|
|
90
|
+
}
|
|
91
|
+
function replaceAlpha(rgba, newAlpha) {
|
|
92
|
+
const match = rgba.match(/rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)(?:[,\s]+([\d.]+))?\s*\)/);
|
|
93
|
+
if (!match)
|
|
94
|
+
return rgba;
|
|
95
|
+
const r = match[1];
|
|
96
|
+
const g = match[2];
|
|
97
|
+
const b = match[3];
|
|
98
|
+
return `rgba(${r}, ${g}, ${b}, ${newAlpha})`;
|
|
99
|
+
}
|
|
100
|
+
function getContrastColor(color) {
|
|
101
|
+
const rgb = getRGB(color);
|
|
102
|
+
if (!rgb)
|
|
103
|
+
return '#000';
|
|
104
|
+
const { r, g, b } = rgb;
|
|
105
|
+
const luminance = (0.299 * r + 0.587 * g + 0.114 * b);
|
|
106
|
+
return luminance > 186 ? '#000' : '#fff';
|
|
107
|
+
}
|
|
108
|
+
function getRGB(color) {
|
|
109
|
+
if (color.startsWith('#')) {
|
|
110
|
+
const hex = color.replace('#', '');
|
|
111
|
+
const bigint = parseInt(hex.length === 3
|
|
112
|
+
? hex.split('').map(c => c + c).join('')
|
|
113
|
+
: hex, 16);
|
|
114
|
+
return {
|
|
115
|
+
r: (bigint >> 16) & 255,
|
|
116
|
+
g: (bigint >> 8) & 255,
|
|
117
|
+
b: bigint & 255
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
const match = color.match(/\d+/g);
|
|
121
|
+
if (match) {
|
|
122
|
+
return {
|
|
123
|
+
r: Number(match[0]),
|
|
124
|
+
g: Number(match[1]),
|
|
125
|
+
b: Number(match[2])
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
class BarLineComponent {
|
|
132
|
+
constructor() {
|
|
133
|
+
this.type = 'bar';
|
|
134
|
+
this.isDark = false;
|
|
135
|
+
this.card = {};
|
|
136
|
+
this.description = '';
|
|
137
|
+
this.loading = true;
|
|
138
|
+
this.canvasHeight = 0;
|
|
139
|
+
this.canvasWidth = 0;
|
|
140
|
+
this.config = {
|
|
141
|
+
type: 'bar',
|
|
142
|
+
data: {
|
|
143
|
+
labels: [],
|
|
144
|
+
datasets: []
|
|
145
|
+
},
|
|
146
|
+
options: {}
|
|
147
|
+
};
|
|
148
|
+
this.options = {
|
|
149
|
+
responsive: true,
|
|
150
|
+
maintainAspectRatio: false,
|
|
151
|
+
plugins: {
|
|
152
|
+
legend: {
|
|
153
|
+
position: 'top',
|
|
154
|
+
color: this.isDark ? '#FFF' : '#333'
|
|
155
|
+
},
|
|
156
|
+
datalabels: {
|
|
157
|
+
display: false
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
ngOnInit() {
|
|
163
|
+
if (['stackedBar', 'verticalBar', 'verticalStackedBar', 'progressBar', 'verticalProgressBar'].includes(this.type)) {
|
|
164
|
+
this.config.type = 'bar';
|
|
165
|
+
}
|
|
166
|
+
else if (['line', 'curveLine', 'lineBar', 'lineBarStacked'].includes(this.type)) {
|
|
167
|
+
this.config.type = 'line';
|
|
168
|
+
}
|
|
169
|
+
else if (['radar'].includes(this.type)) {
|
|
170
|
+
this.config.type = 'radar';
|
|
171
|
+
}
|
|
172
|
+
this.options.indexAxis = ['verticalBar', 'verticalStackedBar', 'verticalProgressBar'].includes(this.type) ? 'y' : 'x';
|
|
173
|
+
if (['stackedBar', 'verticalStackedBar', 'lineBarStacked', 'progressBar', 'verticalProgressBar'].includes(this.type)) {
|
|
174
|
+
this.options.scales = { x: { stacked: true }, y: { stacked: true } };
|
|
175
|
+
}
|
|
176
|
+
if (['progressBar', 'verticalProgressBar'].includes(this.type) || this.card.showPorcent) {
|
|
177
|
+
this.options.plugins.tooltip = {
|
|
178
|
+
callbacks: {
|
|
179
|
+
label: function (context) {
|
|
180
|
+
return context.raw + '%';
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
if (this.card.showLabel) {
|
|
186
|
+
this.options.plugins.datalabels = {
|
|
187
|
+
anchor: 'center',
|
|
188
|
+
align: 'center',
|
|
189
|
+
formatter: (value) => this.card.showPorcent ? value + '%' : value,
|
|
190
|
+
color: (context) => {
|
|
191
|
+
if (this.card.fontColor)
|
|
192
|
+
return this.card.fontColor;
|
|
193
|
+
const bg = context.dataset.backgroundColor;
|
|
194
|
+
return getContrastColor(bg);
|
|
195
|
+
},
|
|
196
|
+
font: {
|
|
197
|
+
weight: 'bold'
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
this.config.options = this.options;
|
|
202
|
+
this.config.data.datasets = this.formatDataset();
|
|
203
|
+
this.description = this.describeBar(this.config);
|
|
204
|
+
}
|
|
205
|
+
ngAfterViewInit() {
|
|
206
|
+
this.resizeObserver = new ResizeObserver(() => {
|
|
207
|
+
if (this.chart) {
|
|
208
|
+
setTimeout(() => {
|
|
209
|
+
this.triggerResize();
|
|
210
|
+
}, 0);
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
this.resizeObserver.observe(this.container.nativeElement);
|
|
214
|
+
setTimeout(() => {
|
|
215
|
+
this.chart?.chart?.resize();
|
|
216
|
+
}, 50);
|
|
217
|
+
this.loading = false;
|
|
218
|
+
}
|
|
219
|
+
ngOnDestroy() {
|
|
220
|
+
if (this.resizeObserver) {
|
|
221
|
+
this.resizeObserver.disconnect();
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
ngOnChanges(changes) {
|
|
225
|
+
if (changes['isDark']) {
|
|
226
|
+
this.applyTheme();
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
applyTheme() {
|
|
230
|
+
if (this.chart) {
|
|
231
|
+
this.chart.update();
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
triggerResize() {
|
|
235
|
+
if (this.chart?.chart) {
|
|
236
|
+
this.chart.chart.resize();
|
|
237
|
+
this.chart.update();
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
formatDataset() {
|
|
241
|
+
if (!this.card?.data?.length)
|
|
242
|
+
return [];
|
|
243
|
+
if (!this.card.axisX?.key)
|
|
244
|
+
return [];
|
|
245
|
+
const labels = this.card.data.map(row => row[this.card.axisX?.key ?? '']);
|
|
246
|
+
this.config.data.labels = labels;
|
|
247
|
+
var sumData = [];
|
|
248
|
+
const datasets = this.card.keys?.map(item => {
|
|
249
|
+
const data = this.card.data?.map(row => {
|
|
250
|
+
const value = row[item.key];
|
|
251
|
+
return typeof value === 'string'
|
|
252
|
+
? Number(value)
|
|
253
|
+
: value ?? 0;
|
|
254
|
+
}) ?? [];
|
|
255
|
+
if (['progressBar', 'verticalProgressBar'].includes(this.type)) {
|
|
256
|
+
sumData.push(...data);
|
|
257
|
+
}
|
|
258
|
+
if (!item.color) {
|
|
259
|
+
item.color = randomColor();
|
|
260
|
+
}
|
|
261
|
+
var result = {
|
|
262
|
+
label: item.label,
|
|
263
|
+
data,
|
|
264
|
+
backgroundColor: item.color,
|
|
265
|
+
borderColor: item.color,
|
|
266
|
+
fill: item.fill ?? false,
|
|
267
|
+
};
|
|
268
|
+
if (this.card.stacked && item.stackKey) {
|
|
269
|
+
result['stack'] = item.stackKey;
|
|
270
|
+
}
|
|
271
|
+
if (item.type) {
|
|
272
|
+
result['type'] = item.type;
|
|
273
|
+
}
|
|
274
|
+
if (this.type == 'curveLine') {
|
|
275
|
+
result = {
|
|
276
|
+
...result,
|
|
277
|
+
tension: 0.4
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
return result;
|
|
281
|
+
}) ?? [];
|
|
282
|
+
if (['progressBar', 'verticalProgressBar'].includes(this.type)) {
|
|
283
|
+
const remaining = sumData.map(s => 100 - s);
|
|
284
|
+
datasets.push({
|
|
285
|
+
label: '',
|
|
286
|
+
data: remaining,
|
|
287
|
+
backgroundColor: '#e0e0e05e',
|
|
288
|
+
borderWidth: 0
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
return datasets;
|
|
292
|
+
}
|
|
293
|
+
describeBar(config) {
|
|
294
|
+
const { data } = config;
|
|
295
|
+
const labels = data?.labels || [];
|
|
296
|
+
const datasets = data?.datasets || [];
|
|
297
|
+
const axisLabel = this.card?.axisX?.label || 'categoria';
|
|
298
|
+
const barDatasets = datasets.filter((ds) => !ds.type || ds.type === 'bar');
|
|
299
|
+
const lineDatasets = datasets.filter((ds) => ds.type === 'line');
|
|
300
|
+
const seriesNames = barDatasets.map((ds) => ds.label || 'Série');
|
|
301
|
+
const lineNames = lineDatasets.map((ds) => ds.label || 'Linha');
|
|
302
|
+
let type = 'barras';
|
|
303
|
+
if (['curveLine', 'lineBar', 'lineBarStacked'].includes(this.type)) {
|
|
304
|
+
type = 'linhas';
|
|
305
|
+
}
|
|
306
|
+
let orientation = '';
|
|
307
|
+
if (['verticalBar', 'verticalStackedBar', 'verticalProgressBar'].includes(this.type)) {
|
|
308
|
+
orientation = 'vertical ';
|
|
309
|
+
}
|
|
310
|
+
let format = 'agrupadas';
|
|
311
|
+
if (['stackedBar', 'verticalStackedBar', 'lineBarStacked'].includes(this.type)) {
|
|
312
|
+
format = 'empilhadas';
|
|
313
|
+
}
|
|
314
|
+
let extra = '';
|
|
315
|
+
if (['progressBar', 'verticalProgressBar'].includes(this.type)) {
|
|
316
|
+
extra = ' demonstrando as porcentagens';
|
|
317
|
+
}
|
|
318
|
+
let description = this.card.title +
|
|
319
|
+
` - Gráfico de ${type} ${orientation}${format} por ${axisLabel}${extra}, comparando ${seriesNames.join(' e ')}`;
|
|
320
|
+
if (lineDatasets.length) {
|
|
321
|
+
description += `, com linha representando ${lineNames.join(' e ')}`;
|
|
322
|
+
}
|
|
323
|
+
description += '. ';
|
|
324
|
+
labels.forEach((label, index) => {
|
|
325
|
+
const barValues = barDatasets.map((ds) => {
|
|
326
|
+
const value = ds.data?.[index] ?? 'sem valor';
|
|
327
|
+
return `${ds.label}: ${value}`;
|
|
328
|
+
});
|
|
329
|
+
let lineValueText = '';
|
|
330
|
+
if (lineDatasets.length) {
|
|
331
|
+
const lineValues = lineDatasets.map((ds) => {
|
|
332
|
+
const value = ds.data?.[index] ?? 'sem valor';
|
|
333
|
+
return `${ds.label}: ${value}`;
|
|
334
|
+
});
|
|
335
|
+
lineValueText = `. Linha: ${lineValues.join(', ')}`;
|
|
336
|
+
}
|
|
337
|
+
description += `\nEm ${label}: ${barValues.join(', ')}${lineValueText}.`;
|
|
338
|
+
});
|
|
339
|
+
return description.trim();
|
|
340
|
+
}
|
|
341
|
+
describeStackedBar(labels, datasets) {
|
|
342
|
+
return this.card.title + ` - Gráfico de barras empilhadas com ${datasets.length} séries: ` +
|
|
343
|
+
datasets.map(ds => ds.label).join(', ');
|
|
344
|
+
}
|
|
345
|
+
onresize() {
|
|
346
|
+
this.triggerResize();
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
BarLineComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: BarLineComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
350
|
+
BarLineComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: BarLineComponent, selector: "lib-bar-line", inputs: { type: "type", isDark: "isDark", card: "card" }, host: { listeners: { "window:resize": "onresize()" } }, viewQueries: [{ propertyName: "container", first: true, predicate: ["container"], descendants: true }, { propertyName: "chart", first: true, predicate: BaseChartDirective, descendants: true }], usesOnChanges: true, ngImport: i0, template: "\r\n<div class=\"chart-div\" #container>\r\n <canvas\r\n #chart\r\n baseChart\r\n class=\"chart chart-bar chart-item\"\r\n [data]=\"config.data\"\r\n [options]=\"config.options\"\r\n [type]=\"config.type\"\r\n [title]=\"description\"\r\n >\r\n </canvas>\r\n</div>", styles: [".chart-div{width:100%;height:100%}.chart-bar{max-height:100%}.chart{width:100%!important;height:100%!important;position:relative}\n"], dependencies: [{ kind: "directive", type: i1.BaseChartDirective, selector: "canvas[baseChart]", inputs: ["type", "legend", "data", "options", "plugins", "labels", "datasets"], outputs: ["chartClick", "chartHover"], exportAs: ["base-chart"] }] });
|
|
351
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: BarLineComponent, decorators: [{
|
|
352
|
+
type: Component,
|
|
353
|
+
args: [{ selector: 'lib-bar-line', template: "\r\n<div class=\"chart-div\" #container>\r\n <canvas\r\n #chart\r\n baseChart\r\n class=\"chart chart-bar chart-item\"\r\n [data]=\"config.data\"\r\n [options]=\"config.options\"\r\n [type]=\"config.type\"\r\n [title]=\"description\"\r\n >\r\n </canvas>\r\n</div>", styles: [".chart-div{width:100%;height:100%}.chart-bar{max-height:100%}.chart{width:100%!important;height:100%!important;position:relative}\n"] }]
|
|
354
|
+
}], ctorParameters: function () { return []; }, propDecorators: { type: [{
|
|
355
|
+
type: Input
|
|
356
|
+
}], isDark: [{
|
|
357
|
+
type: Input
|
|
358
|
+
}], card: [{
|
|
359
|
+
type: Input
|
|
360
|
+
}], container: [{
|
|
361
|
+
type: ViewChild,
|
|
362
|
+
args: ['container']
|
|
363
|
+
}], chart: [{
|
|
364
|
+
type: ViewChild,
|
|
365
|
+
args: [BaseChartDirective]
|
|
366
|
+
}], onresize: [{
|
|
367
|
+
type: HostListener,
|
|
368
|
+
args: ['window:resize']
|
|
369
|
+
}] } });
|
|
370
|
+
|
|
371
|
+
class BubbleComponent {
|
|
372
|
+
constructor() {
|
|
373
|
+
this.type = 'bubble';
|
|
374
|
+
this.isDark = false;
|
|
375
|
+
this.card = {};
|
|
376
|
+
this.loading = true;
|
|
377
|
+
this.canvasHeight = 0;
|
|
378
|
+
this.canvasWidth = 0;
|
|
379
|
+
this.config = {
|
|
380
|
+
type: this.type,
|
|
381
|
+
data: {
|
|
382
|
+
labels: [],
|
|
383
|
+
datasets: []
|
|
384
|
+
},
|
|
385
|
+
options: {}
|
|
386
|
+
};
|
|
387
|
+
this.options = {
|
|
388
|
+
responsive: true,
|
|
389
|
+
maintainAspectRatio: false,
|
|
390
|
+
plugins: {
|
|
391
|
+
legend: {
|
|
392
|
+
position: 'top',
|
|
393
|
+
color: this.isDark ? '#FFF' : '#333',
|
|
394
|
+
},
|
|
395
|
+
datalabels: {
|
|
396
|
+
display: false
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
ngOnInit() {
|
|
402
|
+
this.options.indexAxis = this.card.axisOrientation ?? 'x';
|
|
403
|
+
if (this.card.stacked) {
|
|
404
|
+
this.options.scales = { x: { stacked: true }, y: { stacked: true } };
|
|
405
|
+
}
|
|
406
|
+
if (this.card.showPorcent) {
|
|
407
|
+
this.options.plugins.tooltip = {
|
|
408
|
+
callbacks: {
|
|
409
|
+
label: function (context) {
|
|
410
|
+
return context.raw + '%';
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
if (this.card.showLabel) {
|
|
416
|
+
this.options.plugins.datalabels = {
|
|
417
|
+
anchor: 'center',
|
|
418
|
+
align: 'center',
|
|
419
|
+
formatter: (value) => this.card.showPorcent ? value + '%' : value,
|
|
420
|
+
color: '#fff',
|
|
421
|
+
font: {
|
|
422
|
+
weight: 'bold'
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
this.config.type = this.type;
|
|
427
|
+
this.config.options = this.options;
|
|
428
|
+
this.config.data.datasets = this.formatDataset();
|
|
429
|
+
}
|
|
430
|
+
ngAfterViewInit() {
|
|
431
|
+
this.resizeObserver = new ResizeObserver(() => {
|
|
432
|
+
if (this.chart) {
|
|
433
|
+
setTimeout(() => {
|
|
434
|
+
this.triggerResize();
|
|
435
|
+
}, 0);
|
|
436
|
+
}
|
|
437
|
+
});
|
|
438
|
+
this.resizeObserver.observe(this.container.nativeElement);
|
|
439
|
+
setTimeout(() => {
|
|
440
|
+
this.chart?.chart?.resize();
|
|
441
|
+
}, 50);
|
|
442
|
+
this.loading = false;
|
|
443
|
+
}
|
|
444
|
+
ngOnDestroy() {
|
|
445
|
+
if (this.resizeObserver) {
|
|
446
|
+
this.resizeObserver.disconnect();
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
triggerResize() {
|
|
450
|
+
if (this.chart?.chart) {
|
|
451
|
+
this.chart.chart.resize();
|
|
452
|
+
this.chart.update();
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
formatDataset() {
|
|
456
|
+
if (!this.card?.data?.length)
|
|
457
|
+
return [];
|
|
458
|
+
if (!this.card.axisX?.key)
|
|
459
|
+
return [];
|
|
460
|
+
const labels = this.card.data.map(row => row[this.card.axisX?.key ?? '']);
|
|
461
|
+
this.config.data.labels = labels;
|
|
462
|
+
const datasets = this.card.keys?.map(item => {
|
|
463
|
+
const data = this.card.data?.map(row => {
|
|
464
|
+
const value = {
|
|
465
|
+
x: row[item.keyX ?? ''],
|
|
466
|
+
y: row[item.keyY ?? ''],
|
|
467
|
+
r: row[item.keyR ?? '']
|
|
468
|
+
};
|
|
469
|
+
return value;
|
|
470
|
+
}) ?? [];
|
|
471
|
+
if (!item.color) {
|
|
472
|
+
item.color = randomColor();
|
|
473
|
+
}
|
|
474
|
+
var result = {
|
|
475
|
+
label: item.label,
|
|
476
|
+
data,
|
|
477
|
+
backgroundColor: item.color,
|
|
478
|
+
fill: item.fill ?? false,
|
|
479
|
+
};
|
|
480
|
+
if (this.card.stacked && item.stackKey) {
|
|
481
|
+
result['stack'] = item.stackKey;
|
|
482
|
+
}
|
|
483
|
+
return result;
|
|
484
|
+
}) ?? [];
|
|
485
|
+
return datasets;
|
|
486
|
+
}
|
|
487
|
+
onresize() {
|
|
488
|
+
this.triggerResize();
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
BubbleComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: BubbleComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
492
|
+
BubbleComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: BubbleComponent, selector: "lib-bubble", inputs: { type: "type", isDark: "isDark", card: "card" }, host: { listeners: { "window:resize": "onresize()" } }, viewQueries: [{ propertyName: "container", first: true, predicate: ["container"], descendants: true }, { propertyName: "chart", first: true, predicate: BaseChartDirective, descendants: true }], ngImport: i0, template: "<div class=\"chart-div\" #container>\r\n <canvas\r\n #chart\r\n baseChart\r\n class=\"chart chart-bar chart-item\"\r\n [data]=\"config.data\"\r\n [options]=\"config.options\"\r\n [type]=\"config.type\"\r\n >\r\n </canvas>\r\n</div>", styles: [".chart-div{width:100%;height:100%}.chart-bar{max-height:100%}.chart{width:100%!important;height:100%!important;position:relative}\n"], dependencies: [{ kind: "directive", type: i1.BaseChartDirective, selector: "canvas[baseChart]", inputs: ["type", "legend", "data", "options", "plugins", "labels", "datasets"], outputs: ["chartClick", "chartHover"], exportAs: ["base-chart"] }] });
|
|
493
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: BubbleComponent, decorators: [{
|
|
494
|
+
type: Component,
|
|
495
|
+
args: [{ selector: 'lib-bubble', template: "<div class=\"chart-div\" #container>\r\n <canvas\r\n #chart\r\n baseChart\r\n class=\"chart chart-bar chart-item\"\r\n [data]=\"config.data\"\r\n [options]=\"config.options\"\r\n [type]=\"config.type\"\r\n >\r\n </canvas>\r\n</div>", styles: [".chart-div{width:100%;height:100%}.chart-bar{max-height:100%}.chart{width:100%!important;height:100%!important;position:relative}\n"] }]
|
|
496
|
+
}], ctorParameters: function () { return []; }, propDecorators: { type: [{
|
|
497
|
+
type: Input
|
|
498
|
+
}], isDark: [{
|
|
499
|
+
type: Input
|
|
500
|
+
}], card: [{
|
|
501
|
+
type: Input
|
|
502
|
+
}], container: [{
|
|
503
|
+
type: ViewChild,
|
|
504
|
+
args: ['container']
|
|
505
|
+
}], chart: [{
|
|
506
|
+
type: ViewChild,
|
|
507
|
+
args: [BaseChartDirective]
|
|
508
|
+
}], onresize: [{
|
|
509
|
+
type: HostListener,
|
|
510
|
+
args: ['window:resize']
|
|
511
|
+
}] } });
|
|
512
|
+
|
|
513
|
+
class PieComponent {
|
|
514
|
+
constructor() {
|
|
515
|
+
this.type = 'pie';
|
|
516
|
+
this.isDark = false;
|
|
517
|
+
this.card = {};
|
|
518
|
+
this.loading = true;
|
|
519
|
+
this.canvasHeight = 0;
|
|
520
|
+
this.canvasWidth = 0;
|
|
521
|
+
this.config = {
|
|
522
|
+
type: 'pie',
|
|
523
|
+
data: {
|
|
524
|
+
labels: [],
|
|
525
|
+
datasets: []
|
|
526
|
+
},
|
|
527
|
+
options: {}
|
|
528
|
+
};
|
|
529
|
+
this.options = {
|
|
530
|
+
responsive: true,
|
|
531
|
+
maintainAspectRatio: false,
|
|
532
|
+
plugins: {
|
|
533
|
+
legend: {
|
|
534
|
+
position: 'top',
|
|
535
|
+
color: this.isDark ? '#FFF' : '#333',
|
|
536
|
+
},
|
|
537
|
+
datalabels: {
|
|
538
|
+
display: false
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
ngOnInit() {
|
|
544
|
+
this.config.type = this.type == 'halfDoughnut' ? 'doughnut' : (this.type == 'multiPie' ? 'pie' : this.type);
|
|
545
|
+
this.formatOption();
|
|
546
|
+
this.config.options = this.options;
|
|
547
|
+
this.config.data.datasets = this.formatDataset();
|
|
548
|
+
}
|
|
549
|
+
ngAfterViewInit() {
|
|
550
|
+
this.resizeObserver = new ResizeObserver(() => {
|
|
551
|
+
if (this.chart) {
|
|
552
|
+
setTimeout(() => {
|
|
553
|
+
this.triggerResize();
|
|
554
|
+
}, 0);
|
|
555
|
+
}
|
|
556
|
+
});
|
|
557
|
+
this.resizeObserver.observe(this.container.nativeElement);
|
|
558
|
+
setTimeout(() => {
|
|
559
|
+
this.chart?.chart?.resize();
|
|
560
|
+
}, 50);
|
|
561
|
+
this.loading = false;
|
|
562
|
+
}
|
|
563
|
+
ngOnDestroy() {
|
|
564
|
+
if (this.resizeObserver) {
|
|
565
|
+
this.resizeObserver.disconnect();
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
triggerResize() {
|
|
569
|
+
if (this.chart?.chart) {
|
|
570
|
+
this.chart.chart.resize();
|
|
571
|
+
this.chart.update();
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
formatOption() {
|
|
575
|
+
if (this.type == 'halfDoughnut') {
|
|
576
|
+
this.options = {
|
|
577
|
+
...this.options,
|
|
578
|
+
rotation: -90,
|
|
579
|
+
circumference: 180
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
if (this.card.showPorcent) {
|
|
583
|
+
this.options.plugins.tooltip = {
|
|
584
|
+
callbacks: {
|
|
585
|
+
label: function (context) {
|
|
586
|
+
return context.raw + '%';
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
if (this.card.showLabel) {
|
|
592
|
+
this.options.plugins.datalabels = {
|
|
593
|
+
anchor: 'center',
|
|
594
|
+
align: 'center',
|
|
595
|
+
formatter: (value) => this.card.showPorcent ? value + '%' : value,
|
|
596
|
+
color: '#fff',
|
|
597
|
+
font: {
|
|
598
|
+
weight: 'bold'
|
|
599
|
+
}
|
|
600
|
+
};
|
|
601
|
+
}
|
|
602
|
+
if (this.type == 'multiPie') {
|
|
603
|
+
this.options.plugins.tooltip = {
|
|
604
|
+
callbacks: {
|
|
605
|
+
title: (context) => {
|
|
606
|
+
const datasetLabel = context[0].dataset.label;
|
|
607
|
+
const sliceLabel = context[0].label;
|
|
608
|
+
return `${datasetLabel} - ${sliceLabel}`;
|
|
609
|
+
},
|
|
610
|
+
label: (context) => {
|
|
611
|
+
return context.raw + '%';
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
formatDataset() {
|
|
618
|
+
if (!this.card?.data?.length)
|
|
619
|
+
return [];
|
|
620
|
+
if (!this.card.axisX?.key)
|
|
621
|
+
return [];
|
|
622
|
+
const labels = this.card.data.map(row => row[this.card.axisX?.key ?? '']);
|
|
623
|
+
const colors = this.card.data.map(row => row[this.card.axisX?.keyColor ?? ''] ?? randomColor());
|
|
624
|
+
this.config.data.labels = labels;
|
|
625
|
+
const datasets = this.card.keys?.map((item, index) => {
|
|
626
|
+
const data = this.card.data?.map(row => {
|
|
627
|
+
const value = row[item.key];
|
|
628
|
+
return typeof value === 'string'
|
|
629
|
+
? Number(value)
|
|
630
|
+
: value ?? 0;
|
|
631
|
+
}) ?? [];
|
|
632
|
+
var result = {
|
|
633
|
+
label: item.label,
|
|
634
|
+
data,
|
|
635
|
+
backgroundColor: getOpacityColors(colors, index),
|
|
636
|
+
borderColor: 'white',
|
|
637
|
+
fill: item.fill ?? false,
|
|
638
|
+
};
|
|
639
|
+
return result;
|
|
640
|
+
}) ?? [];
|
|
641
|
+
return datasets;
|
|
642
|
+
}
|
|
643
|
+
onresize() {
|
|
644
|
+
this.triggerResize();
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
PieComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: PieComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
648
|
+
PieComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: PieComponent, selector: "lib-pie", inputs: { type: "type", isDark: "isDark", card: "card" }, host: { listeners: { "window:resize": "onresize()" } }, viewQueries: [{ propertyName: "container", first: true, predicate: ["container"], descendants: true }, { propertyName: "chart", first: true, predicate: BaseChartDirective, descendants: true }], ngImport: i0, template: "<div class=\"chart-div\" #container>\r\n <canvas\r\n #chart\r\n baseChart\r\n class=\"chart chart-bar chart-item\"\r\n [data]=\"config.data\"\r\n [options]=\"config.options\"\r\n [type]=\"config.type\"\r\n >\r\n </canvas>\r\n</div>", styles: [".chart-div{width:100%;height:100%}.chart-bar{max-height:100%}.chart{width:100%!important;height:100%!important;position:relative}\n"], dependencies: [{ kind: "directive", type: i1.BaseChartDirective, selector: "canvas[baseChart]", inputs: ["type", "legend", "data", "options", "plugins", "labels", "datasets"], outputs: ["chartClick", "chartHover"], exportAs: ["base-chart"] }] });
|
|
649
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: PieComponent, decorators: [{
|
|
650
|
+
type: Component,
|
|
651
|
+
args: [{ selector: 'lib-pie', template: "<div class=\"chart-div\" #container>\r\n <canvas\r\n #chart\r\n baseChart\r\n class=\"chart chart-bar chart-item\"\r\n [data]=\"config.data\"\r\n [options]=\"config.options\"\r\n [type]=\"config.type\"\r\n >\r\n </canvas>\r\n</div>", styles: [".chart-div{width:100%;height:100%}.chart-bar{max-height:100%}.chart{width:100%!important;height:100%!important;position:relative}\n"] }]
|
|
652
|
+
}], ctorParameters: function () { return []; }, propDecorators: { type: [{
|
|
653
|
+
type: Input
|
|
654
|
+
}], isDark: [{
|
|
655
|
+
type: Input
|
|
656
|
+
}], card: [{
|
|
657
|
+
type: Input
|
|
658
|
+
}], container: [{
|
|
659
|
+
type: ViewChild,
|
|
660
|
+
args: ['container']
|
|
661
|
+
}], chart: [{
|
|
662
|
+
type: ViewChild,
|
|
663
|
+
args: [BaseChartDirective]
|
|
664
|
+
}], onresize: [{
|
|
665
|
+
type: HostListener,
|
|
666
|
+
args: ['window:resize']
|
|
667
|
+
}] } });
|
|
668
|
+
|
|
669
|
+
class SimpleCardComponent {
|
|
670
|
+
constructor() {
|
|
671
|
+
this.type = 'simpleCard';
|
|
672
|
+
this.isDark = false;
|
|
673
|
+
this.card = {};
|
|
674
|
+
this.loading = true;
|
|
675
|
+
this.currentData = {};
|
|
676
|
+
this.currentKey = {};
|
|
677
|
+
}
|
|
678
|
+
ngOnInit() {
|
|
679
|
+
this.currentData = this.card.data?.[0] ?? {};
|
|
680
|
+
this.currentKey = this.card.keys?.[0] ?? {};
|
|
681
|
+
this.currentKey.color = this.currentKey.color ?? randomColor();
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
SimpleCardComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: SimpleCardComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
685
|
+
SimpleCardComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: SimpleCardComponent, selector: "lib-simple-card", inputs: { type: "type", isDark: "isDark", card: "card" }, ngImport: i0, template: "<div class=\"chart-div\" #container>\r\n <b class=\"chart-number\">{{currentData[currentKey.key]}}</b>\r\n <b class=\"chart-label\">{{currentKey.label}}</b>\r\n</div>", styles: [".chart-div{width:100%;height:100%;display:flex;flex-direction:column}.chart-number{font-size:90pt;line-height:normal;width:100%;display:flex;flex-direction:column;justify-content:center;flex-grow:1}@media (max-width: 768px){::ng-deep .dashboard:not(.responsive) .chart-number{font-size:45pt}}\n"] });
|
|
686
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: SimpleCardComponent, decorators: [{
|
|
687
|
+
type: Component,
|
|
688
|
+
args: [{ selector: 'lib-simple-card', template: "<div class=\"chart-div\" #container>\r\n <b class=\"chart-number\">{{currentData[currentKey.key]}}</b>\r\n <b class=\"chart-label\">{{currentKey.label}}</b>\r\n</div>", styles: [".chart-div{width:100%;height:100%;display:flex;flex-direction:column}.chart-number{font-size:90pt;line-height:normal;width:100%;display:flex;flex-direction:column;justify-content:center;flex-grow:1}@media (max-width: 768px){::ng-deep .dashboard:not(.responsive) .chart-number{font-size:45pt}}\n"] }]
|
|
689
|
+
}], ctorParameters: function () { return []; }, propDecorators: { type: [{
|
|
690
|
+
type: Input
|
|
691
|
+
}], isDark: [{
|
|
692
|
+
type: Input
|
|
693
|
+
}], card: [{
|
|
694
|
+
type: Input
|
|
695
|
+
}] } });
|
|
696
|
+
|
|
697
|
+
class TableComponent {
|
|
698
|
+
constructor() {
|
|
699
|
+
this.type = 'table';
|
|
700
|
+
this.isDark = false;
|
|
701
|
+
this.card = {};
|
|
702
|
+
this.loading = true;
|
|
703
|
+
}
|
|
704
|
+
ngOnInit() {
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
TableComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TableComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
708
|
+
TableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: TableComponent, selector: "lib-table", inputs: { type: "type", isDark: "isDark", card: "card" }, ngImport: i0, template: "<div class=\"chart-div pt-2\" #container>\r\n <table class=\"table table-striped\" [class.table-dark]=\"isDark\">\r\n <thead>\r\n <tr>\r\n <th *ngFor=\"let key of card.keys\">{{key.label}}</th>\r\n </tr>\r\n </thead>\r\n <tbody class=\"table-group-divider\">\r\n <tr *ngFor=\"let data of card.data\">\r\n <td *ngFor=\"let key of card.keys\">{{data[key.key]}}</td>\r\n </tr>\r\n </tbody>\r\n </table>\r\n</div>", styles: [""], dependencies: [{ kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
|
|
709
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TableComponent, decorators: [{
|
|
710
|
+
type: Component,
|
|
711
|
+
args: [{ selector: 'lib-table', template: "<div class=\"chart-div pt-2\" #container>\r\n <table class=\"table table-striped\" [class.table-dark]=\"isDark\">\r\n <thead>\r\n <tr>\r\n <th *ngFor=\"let key of card.keys\">{{key.label}}</th>\r\n </tr>\r\n </thead>\r\n <tbody class=\"table-group-divider\">\r\n <tr *ngFor=\"let data of card.data\">\r\n <td *ngFor=\"let key of card.keys\">{{data[key.key]}}</td>\r\n </tr>\r\n </tbody>\r\n </table>\r\n</div>" }]
|
|
712
|
+
}], ctorParameters: function () { return []; }, propDecorators: { type: [{
|
|
713
|
+
type: Input
|
|
714
|
+
}], isDark: [{
|
|
715
|
+
type: Input
|
|
716
|
+
}], card: [{
|
|
717
|
+
type: Input
|
|
718
|
+
}] } });
|
|
719
|
+
|
|
720
|
+
class CardComponent {
|
|
721
|
+
constructor(sanitizer) {
|
|
722
|
+
this.sanitizer = sanitizer;
|
|
723
|
+
this.barItems = DASHBOARD_BAR_LINE_TYPES;
|
|
724
|
+
this.data = {};
|
|
725
|
+
this.isDark = false;
|
|
726
|
+
}
|
|
727
|
+
ngOnInit() {
|
|
728
|
+
if (this.data.innerHtml) {
|
|
729
|
+
this.safeHtml = this.sanitizer.bypassSecurityTrustHtml(this.data.innerHtml);
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
includeBarType(data) {
|
|
733
|
+
return data.type ? this.barItems.includes(data.type) : false;
|
|
734
|
+
}
|
|
735
|
+
get barLineType() {
|
|
736
|
+
if (this.includeBarType(this.data)) {
|
|
737
|
+
return this.data.type ?? 'bar';
|
|
738
|
+
}
|
|
739
|
+
return 'bar';
|
|
740
|
+
}
|
|
741
|
+
get pieType() {
|
|
742
|
+
if (this.data?.type === 'pie' || this.data?.type === 'doughnut' ||
|
|
743
|
+
this.data?.type === 'polarArea' || this.data?.type === 'halfDoughnut' ||
|
|
744
|
+
this.data?.type === 'multiPie') {
|
|
745
|
+
return this.data.type;
|
|
746
|
+
}
|
|
747
|
+
return 'pie';
|
|
748
|
+
}
|
|
749
|
+
get bubbleType() {
|
|
750
|
+
if (this.data?.type === 'bubble') {
|
|
751
|
+
return this.data.type;
|
|
752
|
+
}
|
|
753
|
+
return 'bubble';
|
|
754
|
+
}
|
|
755
|
+
get cardType() {
|
|
756
|
+
if (this.data?.type === 'simpleCard') {
|
|
757
|
+
return this.data.type;
|
|
758
|
+
}
|
|
759
|
+
return 'simpleCard';
|
|
760
|
+
}
|
|
761
|
+
get tableType() {
|
|
762
|
+
if (this.data?.type === 'table') {
|
|
763
|
+
return this.data.type;
|
|
764
|
+
}
|
|
765
|
+
return 'table';
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
CardComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CardComponent, deps: [{ token: i1$1.DomSanitizer }], target: i0.ɵɵFactoryTarget.Component });
|
|
769
|
+
CardComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: CardComponent, selector: "lib-card", inputs: { data: "data", isDark: "isDark" }, ngImport: i0, template: "<section class=\"card-section\">\r\n {{data.title}}\r\n <div class=\"card-chart\">\r\n <lib-bar-line *ngIf=\"this.includeBarType(this.data)\" \r\n [card]=\"data\" [type]=\"barLineType\" [isDark]=\"isDark\"></lib-bar-line>\r\n\r\n <lib-pie *ngIf=\"['pie', 'doughnut', 'polarArea', 'halfDoughnut', 'multiPie'].includes(data.type ?? '')\" \r\n [card]=\"data\" [type]=\"pieType\" [isDark]=\"isDark\"></lib-pie>\r\n\r\n <lib-bubble *ngIf=\"['bubble'].includes(data.type ?? '')\" \r\n [card]=\"data\" [type]=\"bubbleType\" [isDark]=\"isDark\"></lib-bubble>\r\n\r\n <lib-simple-card *ngIf=\"['simpleCard'].includes(data.type ?? '')\" \r\n [card]=\"data\" [type]=\"cardType\" [isDark]=\"isDark\"></lib-simple-card>\r\n\r\n <lib-table *ngIf=\"['table'].includes(data.type ?? '')\" \r\n [card]=\"data\" [type]=\"tableType\" [isDark]=\"isDark\"></lib-table>\r\n\r\n <div class=\"card-html\" *ngIf=\"data.type == 'html'\" [innerHtml]=\"safeHtml\">\r\n </div>\r\n </div>\r\n</section>", styles: [".card-section{display:flex;flex-direction:column;height:100%}.card-section .card-chart{flex-grow:1;min-height:0}.card-section .card-chart .card-html{height:100%}\n"], dependencies: [{ kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: BarLineComponent, selector: "lib-bar-line", inputs: ["type", "isDark", "card"] }, { kind: "component", type: BubbleComponent, selector: "lib-bubble", inputs: ["type", "isDark", "card"] }, { kind: "component", type: PieComponent, selector: "lib-pie", inputs: ["type", "isDark", "card"] }, { kind: "component", type: SimpleCardComponent, selector: "lib-simple-card", inputs: ["type", "isDark", "card"] }, { kind: "component", type: TableComponent, selector: "lib-table", inputs: ["type", "isDark", "card"] }] });
|
|
770
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CardComponent, decorators: [{
|
|
771
|
+
type: Component,
|
|
772
|
+
args: [{ selector: 'lib-card', template: "<section class=\"card-section\">\r\n {{data.title}}\r\n <div class=\"card-chart\">\r\n <lib-bar-line *ngIf=\"this.includeBarType(this.data)\" \r\n [card]=\"data\" [type]=\"barLineType\" [isDark]=\"isDark\"></lib-bar-line>\r\n\r\n <lib-pie *ngIf=\"['pie', 'doughnut', 'polarArea', 'halfDoughnut', 'multiPie'].includes(data.type ?? '')\" \r\n [card]=\"data\" [type]=\"pieType\" [isDark]=\"isDark\"></lib-pie>\r\n\r\n <lib-bubble *ngIf=\"['bubble'].includes(data.type ?? '')\" \r\n [card]=\"data\" [type]=\"bubbleType\" [isDark]=\"isDark\"></lib-bubble>\r\n\r\n <lib-simple-card *ngIf=\"['simpleCard'].includes(data.type ?? '')\" \r\n [card]=\"data\" [type]=\"cardType\" [isDark]=\"isDark\"></lib-simple-card>\r\n\r\n <lib-table *ngIf=\"['table'].includes(data.type ?? '')\" \r\n [card]=\"data\" [type]=\"tableType\" [isDark]=\"isDark\"></lib-table>\r\n\r\n <div class=\"card-html\" *ngIf=\"data.type == 'html'\" [innerHtml]=\"safeHtml\">\r\n </div>\r\n </div>\r\n</section>", styles: [".card-section{display:flex;flex-direction:column;height:100%}.card-section .card-chart{flex-grow:1;min-height:0}.card-section .card-chart .card-html{height:100%}\n"] }]
|
|
773
|
+
}], ctorParameters: function () { return [{ type: i1$1.DomSanitizer }]; }, propDecorators: { data: [{
|
|
774
|
+
type: Input
|
|
775
|
+
}], isDark: [{
|
|
776
|
+
type: Input
|
|
777
|
+
}] } });
|
|
778
|
+
|
|
779
|
+
class ModalEditComponent {
|
|
780
|
+
constructor(modalService) {
|
|
781
|
+
this.modalService = modalService;
|
|
782
|
+
this.rows = [];
|
|
783
|
+
this.rowsType = '';
|
|
784
|
+
this.simpleType = { id: 'simple', label: 'Quantidade' };
|
|
785
|
+
this.types = [];
|
|
786
|
+
this.data = [];
|
|
787
|
+
this.groupType = [];
|
|
788
|
+
this.closeModal = new EventEmitter();
|
|
789
|
+
this.saveData = new EventEmitter();
|
|
790
|
+
}
|
|
791
|
+
ngOnInit() {
|
|
792
|
+
this.types = [this.simpleType, ...this.groupType];
|
|
793
|
+
this.rowsType = 'simple';
|
|
794
|
+
if (this.rows?.length) {
|
|
795
|
+
this.rows = this.rows.map(r => this.buildRowFromFinalValue(r.finalValue));
|
|
796
|
+
}
|
|
797
|
+
else {
|
|
798
|
+
this.addRow();
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
addRow() {
|
|
802
|
+
this.rows.push({
|
|
803
|
+
levels: [this.addTodosOption(this.data)],
|
|
804
|
+
selectedPath: [],
|
|
805
|
+
finalValue: [],
|
|
806
|
+
finalFontColor: '',
|
|
807
|
+
finalBackgroudColor: ''
|
|
808
|
+
});
|
|
809
|
+
}
|
|
810
|
+
removeRow(index) {
|
|
811
|
+
this.rows.splice(index, 1);
|
|
812
|
+
}
|
|
813
|
+
cloneRow(index) {
|
|
814
|
+
const original = this.rows[index];
|
|
815
|
+
const cloned = this.buildRowFromFinalValue(original.finalValue);
|
|
816
|
+
cloned.finalFontColor = original.finalFontColor;
|
|
817
|
+
cloned.finalBackgroudColor = original.finalBackgroudColor;
|
|
818
|
+
this.rows.push(cloned);
|
|
819
|
+
}
|
|
820
|
+
onSelect(item, rowIndex, levelIndex) {
|
|
821
|
+
const row = this.rows[rowIndex];
|
|
822
|
+
row.levels = row.levels.slice(0, levelIndex + 1);
|
|
823
|
+
row.selectedPath = row.selectedPath.slice(0, levelIndex);
|
|
824
|
+
row.selectedPath[levelIndex] = item;
|
|
825
|
+
if (item.type === 'group' && item.items?.length) {
|
|
826
|
+
row.levels.push(this.addTodosOption(item.items));
|
|
827
|
+
}
|
|
828
|
+
this.updateFinalValue(row);
|
|
829
|
+
}
|
|
830
|
+
updateFinalValue(row) {
|
|
831
|
+
row.finalValue = row.selectedPath.map(i => String(i.id));
|
|
832
|
+
}
|
|
833
|
+
onFontColorChange(event, rowIndex) {
|
|
834
|
+
const row = this.rows[rowIndex];
|
|
835
|
+
const color = event.target.value;
|
|
836
|
+
row.finalFontColor = color;
|
|
837
|
+
}
|
|
838
|
+
onBackgroundChange(event, rowIndex) {
|
|
839
|
+
var row = this.rows[rowIndex];
|
|
840
|
+
const color = event.target.value;
|
|
841
|
+
row.finalBackgroudColor = color;
|
|
842
|
+
}
|
|
843
|
+
onCloseModal() {
|
|
844
|
+
this.closeModal.emit();
|
|
845
|
+
}
|
|
846
|
+
onSaveData() {
|
|
847
|
+
const newData = this.rows.map(r => ({
|
|
848
|
+
finalValue: r.finalValue,
|
|
849
|
+
finalBackgroudColor: r.finalBackgroudColor,
|
|
850
|
+
finalFontColor: r.finalFontColor,
|
|
851
|
+
}));
|
|
852
|
+
this.saveData.emit({ rowsType: this.rowsType, rows: this.rows });
|
|
853
|
+
}
|
|
854
|
+
isFlatLevel(level) {
|
|
855
|
+
return level.every(item => item.type !== 'group') ?? false;
|
|
856
|
+
}
|
|
857
|
+
buildRowFromFinalValue(finalValue) {
|
|
858
|
+
const row = {
|
|
859
|
+
levels: [this.addTodosOption(this.data)],
|
|
860
|
+
selectedPath: [],
|
|
861
|
+
finalValue,
|
|
862
|
+
finalFontColor: '',
|
|
863
|
+
finalBackgroudColor: ''
|
|
864
|
+
};
|
|
865
|
+
let currentLevel = this.data;
|
|
866
|
+
finalValue.forEach((id, index) => {
|
|
867
|
+
const found = currentLevel.find(item => item.id === id);
|
|
868
|
+
if (!found)
|
|
869
|
+
return;
|
|
870
|
+
row.selectedPath[index] = found;
|
|
871
|
+
if (found.type === 'group' && found.items) {
|
|
872
|
+
currentLevel = found.items;
|
|
873
|
+
row.levels.push(this.addTodosOption(currentLevel));
|
|
874
|
+
}
|
|
875
|
+
});
|
|
876
|
+
return row;
|
|
877
|
+
}
|
|
878
|
+
addTodosOption(items) {
|
|
879
|
+
const isFlat = items?.every(item => item.type !== 'group');
|
|
880
|
+
if (!isFlat)
|
|
881
|
+
return items;
|
|
882
|
+
const alreadyHasTodos = items.some(i => i.id === 'todos');
|
|
883
|
+
if (alreadyHasTodos)
|
|
884
|
+
return items;
|
|
885
|
+
return [
|
|
886
|
+
{ id: 'todos', label: 'Todos', type: 'option' },
|
|
887
|
+
...items
|
|
888
|
+
];
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
ModalEditComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ModalEditComponent, deps: [{ token: i1$2.BsModalService }], target: i0.ɵɵFactoryTarget.Component });
|
|
892
|
+
ModalEditComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: ModalEditComponent, selector: "lib-modal-edit", inputs: { data: "data", groupType: "groupType" }, outputs: { closeModal: "closeModal", saveData: "saveData" }, ngImport: i0, template: "<header class=\"modal-header\">\r\n <h4 class=\"modal-title pull-left\">Editar fonte dos dados</h4>\r\n <button type=\"button\" class=\"btn-close close pull-right\" aria-label=\"Close\" (click)=\"onCloseModal()\">\r\n <span aria-hidden=\"true\" class=\"visually-hidden\">×</span>\r\n </button>\r\n</header>\r\n<body class=\"modal-body table-form py-2\">\r\n <label>Tipo de Agrupamento dos dados:</label>\r\n <ng-select\r\n class=\" col-12 col-sm-4 mb-1\"\r\n [items]=\"types\"\r\n bindValue=\"id\"\r\n bindLabel=\"label\"\r\n [clearable]=\"false\"\r\n placeholder=\"Selecione...\"\r\n [(ngModel)]=\"rowsType\">\r\n </ng-select>\r\n <article *ngFor=\"let row of rows; let rowIndex = index\" class=\"line mb-2\">\r\n <div class=\"d-flex\">\r\n <ng-container *ngFor=\"let level of row.levels; let levelIndex = index\">\r\n <ng-select class=\"me-1\"\r\n [items]=\"level\"\r\n bindLabel=\"label\"\r\n [clearable]=\"false\"\r\n [placeholder]=\"'Selecione...'\"\r\n [ngModel]=\"row.selectedPath[levelIndex]\"\r\n (change)=\"onSelect($event, rowIndex, levelIndex)\">\r\n </ng-select>\r\n </ng-container>\r\n </div>\r\n <div class=\"d-flex\">\r\n <div class=\"color-div me-2\" [style.background-color]=\"rows[rowIndex].finalBackgroudColor\">\r\n <button class=\"btn font-icon\" [style.color]=\"rows[rowIndex].finalFontColor\"\r\n title=\"Cor do texto\" (click)=\"fontColor.click()\">\r\n format_color_text\r\n </button>\r\n <input #fontColor class=\"hide\" type=\"color\" (change)=\"onFontColorChange($event, rowIndex)\">\r\n <hr class=\"divisor\">\r\n <button class=\"btn font-icon\" [style.color]=\"rows[rowIndex].finalFontColor\"\r\n title=\"Cor de fundo\" (click)=\"backgroundColor.click()\">\r\n colors\r\n </button>\r\n <input #backgroundColor class=\"hide\" type=\"color\" (change)=\"onBackgroundChange($event, rowIndex)\">\r\n </div>\r\n <button class=\"btn btn-basic font-icon me-2\" type=\"button\" (click)=\"cloneRow(rowIndex)\" title=\"Clonar linha\">\r\n copy_all\r\n </button>\r\n <button class=\"btn btn-danger font-icon\" type=\"button\" (click)=\"removeRow(rowIndex)\" title=\"Remover linha\">\r\n delete\r\n </button>\r\n </div>\r\n </article>\r\n <div class=\"d-flex mb-2\">\r\n <button class=\"btn btn-success\" type=\"button\" (click)=\"addRow()\" title=\"Adicionar linha\">+</button>\r\n </div>\r\n <div class=\"d-flex justify-content-end mb-2\">\r\n <button class=\"btn btn-success\" type=\"button\" (click)=\"onSaveData()\" title=\"Salvar\">Salvar</button>\r\n </div>\r\n</body>", styles: [".modal-body{overflow-x:scroll}.modal-body .line{display:flex;justify-content:space-between}.modal-body .ng-select-alternative{min-width:150px}.modal-body .hide{width:0;visibility:hidden}.modal-body .color-div,.modal-body .btn-basic{border:1px solid gray;border-radius:5px}.modal-body .color-div{display:flex}.modal-body .color-div .divisor{height:80%;margin:5% 0;border:1px solid black}\n"], dependencies: [{ kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i3.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: i4.NgSelectComponent, selector: "ng-select", inputs: ["bindLabel", "bindValue", "markFirst", "placeholder", "notFoundText", "typeToSearchText", "addTagText", "loadingText", "clearAllText", "appearance", "dropdownPosition", "appendTo", "loading", "closeOnSelect", "hideSelected", "selectOnTab", "openOnEnter", "maxSelectedItems", "groupBy", "groupValue", "bufferAmount", "virtualScroll", "selectableGroup", "selectableGroupAsModel", "searchFn", "trackByFn", "clearOnBackspace", "labelForId", "inputAttrs", "tabIndex", "readonly", "searchWhileComposing", "minTermLength", "editableSearchTerm", "keyDownFn", "typeahead", "multiple", "addTag", "searchable", "clearable", "isOpen", "items", "compareWith", "clearSearchOnAdd"], outputs: ["blur", "focus", "change", "open", "close", "search", "clear", "add", "remove", "scroll", "scrollToEnd"] }] });
|
|
893
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ModalEditComponent, decorators: [{
|
|
894
|
+
type: Component,
|
|
895
|
+
args: [{ selector: 'lib-modal-edit', template: "<header class=\"modal-header\">\r\n <h4 class=\"modal-title pull-left\">Editar fonte dos dados</h4>\r\n <button type=\"button\" class=\"btn-close close pull-right\" aria-label=\"Close\" (click)=\"onCloseModal()\">\r\n <span aria-hidden=\"true\" class=\"visually-hidden\">×</span>\r\n </button>\r\n</header>\r\n<body class=\"modal-body table-form py-2\">\r\n <label>Tipo de Agrupamento dos dados:</label>\r\n <ng-select\r\n class=\" col-12 col-sm-4 mb-1\"\r\n [items]=\"types\"\r\n bindValue=\"id\"\r\n bindLabel=\"label\"\r\n [clearable]=\"false\"\r\n placeholder=\"Selecione...\"\r\n [(ngModel)]=\"rowsType\">\r\n </ng-select>\r\n <article *ngFor=\"let row of rows; let rowIndex = index\" class=\"line mb-2\">\r\n <div class=\"d-flex\">\r\n <ng-container *ngFor=\"let level of row.levels; let levelIndex = index\">\r\n <ng-select class=\"me-1\"\r\n [items]=\"level\"\r\n bindLabel=\"label\"\r\n [clearable]=\"false\"\r\n [placeholder]=\"'Selecione...'\"\r\n [ngModel]=\"row.selectedPath[levelIndex]\"\r\n (change)=\"onSelect($event, rowIndex, levelIndex)\">\r\n </ng-select>\r\n </ng-container>\r\n </div>\r\n <div class=\"d-flex\">\r\n <div class=\"color-div me-2\" [style.background-color]=\"rows[rowIndex].finalBackgroudColor\">\r\n <button class=\"btn font-icon\" [style.color]=\"rows[rowIndex].finalFontColor\"\r\n title=\"Cor do texto\" (click)=\"fontColor.click()\">\r\n format_color_text\r\n </button>\r\n <input #fontColor class=\"hide\" type=\"color\" (change)=\"onFontColorChange($event, rowIndex)\">\r\n <hr class=\"divisor\">\r\n <button class=\"btn font-icon\" [style.color]=\"rows[rowIndex].finalFontColor\"\r\n title=\"Cor de fundo\" (click)=\"backgroundColor.click()\">\r\n colors\r\n </button>\r\n <input #backgroundColor class=\"hide\" type=\"color\" (change)=\"onBackgroundChange($event, rowIndex)\">\r\n </div>\r\n <button class=\"btn btn-basic font-icon me-2\" type=\"button\" (click)=\"cloneRow(rowIndex)\" title=\"Clonar linha\">\r\n copy_all\r\n </button>\r\n <button class=\"btn btn-danger font-icon\" type=\"button\" (click)=\"removeRow(rowIndex)\" title=\"Remover linha\">\r\n delete\r\n </button>\r\n </div>\r\n </article>\r\n <div class=\"d-flex mb-2\">\r\n <button class=\"btn btn-success\" type=\"button\" (click)=\"addRow()\" title=\"Adicionar linha\">+</button>\r\n </div>\r\n <div class=\"d-flex justify-content-end mb-2\">\r\n <button class=\"btn btn-success\" type=\"button\" (click)=\"onSaveData()\" title=\"Salvar\">Salvar</button>\r\n </div>\r\n</body>", styles: [".modal-body{overflow-x:scroll}.modal-body .line{display:flex;justify-content:space-between}.modal-body .ng-select-alternative{min-width:150px}.modal-body .hide{width:0;visibility:hidden}.modal-body .color-div,.modal-body .btn-basic{border:1px solid gray;border-radius:5px}.modal-body .color-div{display:flex}.modal-body .color-div .divisor{height:80%;margin:5% 0;border:1px solid black}\n"] }]
|
|
896
|
+
}], ctorParameters: function () { return [{ type: i1$2.BsModalService }]; }, propDecorators: { data: [{
|
|
897
|
+
type: Input
|
|
898
|
+
}], groupType: [{
|
|
899
|
+
type: Input
|
|
900
|
+
}], closeModal: [{
|
|
901
|
+
type: Output
|
|
902
|
+
}], saveData: [{
|
|
903
|
+
type: Output
|
|
904
|
+
}] } });
|
|
905
|
+
|
|
906
|
+
class ModalEditChartComponent {
|
|
907
|
+
constructor() {
|
|
908
|
+
this.options = [
|
|
909
|
+
{ id: 'bar', title: 'Barra' },
|
|
910
|
+
{ id: 'stackedBar', title: 'Barra Empilhada' },
|
|
911
|
+
{ id: 'verticalBar', title: 'Barra Vertical' },
|
|
912
|
+
{ id: 'verticalStackedBar', title: 'Barra Vertical Empilhada' },
|
|
913
|
+
{ id: 'verticalProgressBar', title: 'Barra de Progresso Vertical' },
|
|
914
|
+
{ id: 'progressBar', title: 'Barra de Progresso' },
|
|
915
|
+
{ id: 'lineBar', title: 'Linha + Barra' },
|
|
916
|
+
{ id: 'lineBarStacked', title: 'Linha + Barra Empilhada' },
|
|
917
|
+
{ id: 'line', title: 'Linha' },
|
|
918
|
+
{ id: 'radar', title: 'Radar' },
|
|
919
|
+
{ id: 'curveLine', title: 'Linha Curva' },
|
|
920
|
+
{ id: 'pie', title: 'Pizza' },
|
|
921
|
+
{ id: 'multiPie', title: 'Múltiplas Pizzas' },
|
|
922
|
+
{ id: 'doughnut', title: 'Rosca' },
|
|
923
|
+
{ id: 'halfDoughnut', title: 'Meia Rosca' },
|
|
924
|
+
{ id: 'area', title: 'Área' },
|
|
925
|
+
{ id: 'bubble', title: 'Bolhas' },
|
|
926
|
+
{ id: 'polarArea', title: 'Área Polar' },
|
|
927
|
+
{ id: 'simpleCard', title: 'Card Simples' },
|
|
928
|
+
{ id: 'table', title: 'Tabela' },
|
|
929
|
+
{ id: 'html', title: 'HTML Personalizado' },
|
|
930
|
+
];
|
|
931
|
+
this.closeModal = new EventEmitter();
|
|
932
|
+
this.saveData = new EventEmitter();
|
|
933
|
+
}
|
|
934
|
+
ngOnInit() {
|
|
935
|
+
}
|
|
936
|
+
setCurrentOption(option) {
|
|
937
|
+
this.currentOption = option;
|
|
938
|
+
}
|
|
939
|
+
onCloseModal() {
|
|
940
|
+
this.closeModal.emit();
|
|
941
|
+
}
|
|
942
|
+
onSaveData() {
|
|
943
|
+
this.saveData.emit(this.currentOption);
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
ModalEditChartComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ModalEditChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
947
|
+
ModalEditChartComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: ModalEditChartComponent, selector: "lib-modal-edit-chart", inputs: { currentOption: "currentOption" }, outputs: { closeModal: "closeModal", saveData: "saveData" }, ngImport: i0, template: "<header class=\"modal-header\">\r\n <h4 class=\"modal-title pull-left\">Editar fonte dos dados</h4>\r\n <button type=\"button\" class=\"btn-close close pull-right\" aria-label=\"Close\" (click)=\"onCloseModal()\">\r\n <span aria-hidden=\"true\" class=\"visually-hidden\">×</span>\r\n </button>\r\n</header>\r\n<body class=\"modal-body table-form py-2\">\r\n <section class=\"d-grid\">\r\n <label >Titulo:\r\n <input class=\"form-control\"/>\r\n </label>\r\n <label>\r\n <input type=\"checkbox\"> Mostrar legenda no Gr\u00E1fico\r\n </label>\r\n <label>\r\n <input type=\"checkbox\"> Mostrar simbolo '%' na legenda\r\n </label>\r\n </section>\r\n <hr>\r\n <h3>TIPO:</h3>\r\n <section class=\"row g-0\">\r\n <div class=\"card-chart col-12 col-sm-6 col-md-6 col-lg-4 col-xl-3\" *ngFor=\"let opt of options\">\r\n <b>{{opt.title}}</b>\r\n <img [src]=\"'assets/dashboard/images/' + opt.id +'.png'\" (click)=\"setCurrentOption(opt.id)\">\r\n </div>\r\n </section>\r\n <div class=\"d-flex justify-content-end mb-2\">\r\n <button class=\"btn btn-success\" type=\"button\" (click)=\"onSaveData()\" title=\"Salvar\">Salvar</button>\r\n </div>\r\n</body>", styles: [".card-chart{display:flex;flex-direction:column;border:1px solid gray;border-radius:5px;padding:5px;aspect-ratio:1/1;overflow:hidden}.card-chart img{object-fit:cover;width:100%;margin:auto}\n"], dependencies: [{ kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
|
|
948
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ModalEditChartComponent, decorators: [{
|
|
949
|
+
type: Component,
|
|
950
|
+
args: [{ selector: 'lib-modal-edit-chart', template: "<header class=\"modal-header\">\r\n <h4 class=\"modal-title pull-left\">Editar fonte dos dados</h4>\r\n <button type=\"button\" class=\"btn-close close pull-right\" aria-label=\"Close\" (click)=\"onCloseModal()\">\r\n <span aria-hidden=\"true\" class=\"visually-hidden\">×</span>\r\n </button>\r\n</header>\r\n<body class=\"modal-body table-form py-2\">\r\n <section class=\"d-grid\">\r\n <label >Titulo:\r\n <input class=\"form-control\"/>\r\n </label>\r\n <label>\r\n <input type=\"checkbox\"> Mostrar legenda no Gr\u00E1fico\r\n </label>\r\n <label>\r\n <input type=\"checkbox\"> Mostrar simbolo '%' na legenda\r\n </label>\r\n </section>\r\n <hr>\r\n <h3>TIPO:</h3>\r\n <section class=\"row g-0\">\r\n <div class=\"card-chart col-12 col-sm-6 col-md-6 col-lg-4 col-xl-3\" *ngFor=\"let opt of options\">\r\n <b>{{opt.title}}</b>\r\n <img [src]=\"'assets/dashboard/images/' + opt.id +'.png'\" (click)=\"setCurrentOption(opt.id)\">\r\n </div>\r\n </section>\r\n <div class=\"d-flex justify-content-end mb-2\">\r\n <button class=\"btn btn-success\" type=\"button\" (click)=\"onSaveData()\" title=\"Salvar\">Salvar</button>\r\n </div>\r\n</body>", styles: [".card-chart{display:flex;flex-direction:column;border:1px solid gray;border-radius:5px;padding:5px;aspect-ratio:1/1;overflow:hidden}.card-chart img{object-fit:cover;width:100%;margin:auto}\n"] }]
|
|
951
|
+
}], ctorParameters: function () { return []; }, propDecorators: { currentOption: [{
|
|
952
|
+
type: Input
|
|
953
|
+
}], closeModal: [{
|
|
954
|
+
type: Output
|
|
955
|
+
}], saveData: [{
|
|
956
|
+
type: Output
|
|
957
|
+
}] } });
|
|
958
|
+
|
|
959
|
+
class DashboardComponent {
|
|
960
|
+
constructor(modalService, cd) {
|
|
961
|
+
this.modalService = modalService;
|
|
962
|
+
this.cd = cd;
|
|
963
|
+
this.emptyCard = {
|
|
964
|
+
type: 'html',
|
|
965
|
+
innerHtml: '<button class="btn empty-card font-icon" >dashboard_customize</button>'
|
|
966
|
+
};
|
|
967
|
+
this.copyComplete = false;
|
|
968
|
+
this.isDark = false;
|
|
969
|
+
this.isResponsive = true;
|
|
970
|
+
this.canEdit = false;
|
|
971
|
+
this.cols = 4;
|
|
972
|
+
this.options = [
|
|
973
|
+
{ title: '1x1', cols: 1, rows: 1 },
|
|
974
|
+
{ title: '2x1', cols: 2, rows: 1 },
|
|
975
|
+
{ title: '3x1', cols: 3, rows: 1 },
|
|
976
|
+
{ title: '1x2', cols: 1, rows: 2 },
|
|
977
|
+
{ title: '2x2', cols: 2, rows: 2 },
|
|
978
|
+
];
|
|
979
|
+
this.cards = [];
|
|
980
|
+
this.groupType = [];
|
|
981
|
+
this.modalData = [];
|
|
982
|
+
this.debug = false;
|
|
983
|
+
this.drops = [];
|
|
984
|
+
}
|
|
985
|
+
ngOnInit() {
|
|
986
|
+
this.cards = [...this.cards].sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
|
|
987
|
+
if (this.isResponsive) {
|
|
988
|
+
this.recalcCols();
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
ngAfterViewInit() {
|
|
992
|
+
this.dropsQuery.changes.subscribe(() => {
|
|
993
|
+
this.drops = this.dropsQuery.toArray();
|
|
994
|
+
});
|
|
995
|
+
Promise.resolve().then(() => {
|
|
996
|
+
this.drops = this.dropsQuery.toArray();
|
|
997
|
+
});
|
|
998
|
+
}
|
|
999
|
+
entered($event) {
|
|
1000
|
+
moveItemInArray(this.cards, $event.item.data, $event.container.data);
|
|
1001
|
+
}
|
|
1002
|
+
get orderOptions() {
|
|
1003
|
+
return [...this.options].sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
|
|
1004
|
+
}
|
|
1005
|
+
recalcCols() {
|
|
1006
|
+
this.cols = Math.max(1, Math.floor(window.innerWidth / 300));
|
|
1007
|
+
}
|
|
1008
|
+
openModalChart(card) {
|
|
1009
|
+
this.currentCard = card;
|
|
1010
|
+
this.modalChartRef = this.modalService.show(this.modalChart, {
|
|
1011
|
+
class: 'modal-xl modal-top',
|
|
1012
|
+
});
|
|
1013
|
+
}
|
|
1014
|
+
closeModalChart() {
|
|
1015
|
+
this.modalChartRef?.hide();
|
|
1016
|
+
}
|
|
1017
|
+
openModalData(card) {
|
|
1018
|
+
this.currentCard = card;
|
|
1019
|
+
this.currentOption = card.type ?? null;
|
|
1020
|
+
this.modalRef = this.modalService.show(this.modal, {
|
|
1021
|
+
class: 'modal-xl modal-top',
|
|
1022
|
+
});
|
|
1023
|
+
}
|
|
1024
|
+
closeModalData() {
|
|
1025
|
+
this.modalRef?.hide();
|
|
1026
|
+
}
|
|
1027
|
+
get jsonData() {
|
|
1028
|
+
return JSON.stringify(this.currentCard);
|
|
1029
|
+
}
|
|
1030
|
+
openModalCode(card) {
|
|
1031
|
+
this.currentCard = card;
|
|
1032
|
+
this.currentOption = card.type ?? null;
|
|
1033
|
+
this.modalCodeRef = this.modalService.show(this.modalCode, {
|
|
1034
|
+
class: 'modal-xl modal-top',
|
|
1035
|
+
});
|
|
1036
|
+
}
|
|
1037
|
+
closeModalCode() {
|
|
1038
|
+
this.modalCodeRef?.hide();
|
|
1039
|
+
}
|
|
1040
|
+
copyCode() {
|
|
1041
|
+
const texto = JSON.stringify(this.currentCard, null, 2);
|
|
1042
|
+
navigator.clipboard.writeText(texto)
|
|
1043
|
+
.then(() => {
|
|
1044
|
+
this.copyComplete = true;
|
|
1045
|
+
setTimeout(() => this.copyComplete = false, 1500);
|
|
1046
|
+
})
|
|
1047
|
+
.catch(err => {
|
|
1048
|
+
console.error('Erro ao copiar:', err);
|
|
1049
|
+
});
|
|
1050
|
+
}
|
|
1051
|
+
saveData(payload) {
|
|
1052
|
+
const rows = payload.rows;
|
|
1053
|
+
const rowsType = payload.rowsType;
|
|
1054
|
+
const currentType = rowsType == 'simple' ? rowsType : 'group';
|
|
1055
|
+
if (!rows?.length)
|
|
1056
|
+
return;
|
|
1057
|
+
this.cards = this.cards.map(card => {
|
|
1058
|
+
if (card.id !== this.currentCard.id)
|
|
1059
|
+
return card;
|
|
1060
|
+
const baseData = this.data[currentType];
|
|
1061
|
+
if (!baseData)
|
|
1062
|
+
return card;
|
|
1063
|
+
const keys = rows.map((row, index) => {
|
|
1064
|
+
const id = row.finalValue[row.finalValue.length - 1];
|
|
1065
|
+
const last = row.selectedPath.find(r => r.id == id);
|
|
1066
|
+
return {
|
|
1067
|
+
key: last?.id || `key_${index}`,
|
|
1068
|
+
label: last?.label || `Item ${index + 1}`,
|
|
1069
|
+
fill: true,
|
|
1070
|
+
color: row.finalBackgroudColor,
|
|
1071
|
+
fontColor: row.finalFontColor
|
|
1072
|
+
};
|
|
1073
|
+
});
|
|
1074
|
+
const typeLabel = this.groupType.find(t => t.id == rowsType)?.label ?? '';
|
|
1075
|
+
var data = this.formatData(rowsType, rows[0]?.selectedPath, rows[0]?.finalValue);
|
|
1076
|
+
return {
|
|
1077
|
+
...card,
|
|
1078
|
+
axisX: { key: rowsType, label: typeLabel },
|
|
1079
|
+
keys: [...keys],
|
|
1080
|
+
data: data
|
|
1081
|
+
};
|
|
1082
|
+
});
|
|
1083
|
+
this.modalRef?.hide();
|
|
1084
|
+
}
|
|
1085
|
+
formatData(type, selectedPath, finalValue) {
|
|
1086
|
+
const currentType = type == 'simple' ? type : 'group';
|
|
1087
|
+
const baseData = this.data[currentType];
|
|
1088
|
+
let data = [];
|
|
1089
|
+
if (currentType === 'simple') {
|
|
1090
|
+
var finalData = baseData;
|
|
1091
|
+
finalValue?.slice(0, -1)?.forEach(r => {
|
|
1092
|
+
finalData = finalData[r];
|
|
1093
|
+
});
|
|
1094
|
+
data = finalData;
|
|
1095
|
+
}
|
|
1096
|
+
else if (currentType === 'group') {
|
|
1097
|
+
var finalData = baseData;
|
|
1098
|
+
finalValue?.slice(0, -1)?.forEach(r => {
|
|
1099
|
+
finalData = finalData[r];
|
|
1100
|
+
});
|
|
1101
|
+
data = finalData[type];
|
|
1102
|
+
}
|
|
1103
|
+
return data;
|
|
1104
|
+
}
|
|
1105
|
+
randomValueFromPath(row) {
|
|
1106
|
+
const base = row.selectedPath.length * 10;
|
|
1107
|
+
return Math.floor(Math.random() * 20) + base;
|
|
1108
|
+
}
|
|
1109
|
+
saveChartData(data) {
|
|
1110
|
+
alert('TODO'); //proxima versao
|
|
1111
|
+
this.modalRef?.hide();
|
|
1112
|
+
}
|
|
1113
|
+
addNewCard() {
|
|
1114
|
+
const newItem = { title: 'Novo', order: 99, cols: 1, rows: 1 };
|
|
1115
|
+
this.cards.push(newItem);
|
|
1116
|
+
this.cd.detectChanges();
|
|
1117
|
+
}
|
|
1118
|
+
downloadImage(id) {
|
|
1119
|
+
const canvases = document.querySelectorAll(`#card_${id} canvas`);
|
|
1120
|
+
canvases.forEach((canvas, index) => {
|
|
1121
|
+
const scale = 3;
|
|
1122
|
+
const tempCanvas = document.createElement('canvas');
|
|
1123
|
+
tempCanvas.width = canvas.width * scale;
|
|
1124
|
+
tempCanvas.height = canvas.height * scale;
|
|
1125
|
+
const ctx = tempCanvas.getContext('2d');
|
|
1126
|
+
if (ctx) {
|
|
1127
|
+
ctx.fillStyle = '#ffffff';
|
|
1128
|
+
ctx.fillRect(0, 0, tempCanvas.width, tempCanvas.height);
|
|
1129
|
+
ctx.scale(scale, scale);
|
|
1130
|
+
ctx.drawImage(canvas, 0, 0);
|
|
1131
|
+
}
|
|
1132
|
+
const link = document.createElement('a');
|
|
1133
|
+
link.download = `canvas_${index + 1}.png`;
|
|
1134
|
+
link.href = tempCanvas.toDataURL('image/png', 1.0);
|
|
1135
|
+
link.click();
|
|
1136
|
+
});
|
|
1137
|
+
}
|
|
1138
|
+
openChart(card, id) {
|
|
1139
|
+
this.currentCard = card;
|
|
1140
|
+
this.currentOption = card.type ?? null;
|
|
1141
|
+
this.modalViewRef = this.modalService.show(this.modalView, {
|
|
1142
|
+
class: 'modal-xl modal-top',
|
|
1143
|
+
});
|
|
1144
|
+
}
|
|
1145
|
+
closeModalView() {
|
|
1146
|
+
this.modalViewRef?.hide();
|
|
1147
|
+
}
|
|
1148
|
+
onresize() {
|
|
1149
|
+
if (this.isResponsive) {
|
|
1150
|
+
this.recalcCols();
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
DashboardComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DashboardComponent, deps: [{ token: i1$2.BsModalService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
1155
|
+
DashboardComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: DashboardComponent, selector: "lib-dashboard", inputs: { isDark: "isDark", isResponsive: "isResponsive", canEdit: "canEdit", cols: "cols", options: "options", cards: "cards", groupType: "groupType", modalData: "modalData", data: "data", debug: "debug" }, host: { listeners: { "window:resize": "onresize()" } }, viewQueries: [{ propertyName: "modalChart", first: true, predicate: ["modalChart"], descendants: true }, { propertyName: "modal", first: true, predicate: ["modal"], descendants: true }, { propertyName: "modalView", first: true, predicate: ["modalView"], descendants: true }, { propertyName: "modalCode", first: true, predicate: ["modalCode"], descendants: true }, { propertyName: "dropsQuery", predicate: CdkDropList, descendants: true }], ngImport: i0, template: "<main class=\"dashboard\" [class.responsive]=\"isResponsive\" [class.dark-class]=\"isDark\">\r\n <mat-grid-list [cols]=\"cols\" rowHeight=\"300px\" gutterSize=\"10px\">\r\n <mat-grid-tile\r\n *ngFor=\"let card of cards; let i = index\"\r\n [colspan]=\"card.cols > cols? cols : card.cols\"\r\n [rowspan]=\"card.rows\"\r\n [class.dark-class]=\"isDark\"\r\n class=\"card\"\r\n >\r\n <div cdkDropList [cdkDropListConnectedTo]=\"drops\" [cdkDropListData]=\"i\">\r\n <div\r\n [id]=\"'card_' + i\"\r\n cdkDrag\r\n (cdkDragEntered)=\"entered($event)\"\r\n [cdkDragData]=\"i\"\r\n class=\"card-body\"\r\n [cdkDragDisabled]=\"!canEdit\"\r\n [class.dark-class]=\"isDark\"\r\n [class.has-color]=\"card.backgroundColor\"\r\n [style.background-color]=\"card.backgroundColor\"\r\n [style.color]=\"card.fontColor\"\r\n >\r\n <nav class=\"nav-hover\">\r\n <button *ngIf=\"!canEdit\" class=\"btn font-icon\" title=\"Ampliar gr\u00E1fico\" (click)=\"openChart(card, i)\">search</button>\r\n <button *ngIf=\"!canEdit\" class=\"btn font-icon\" title=\"Baixar imagem\" (click)=\"downloadImage(i)\">download</button>\r\n </nav>\r\n <nav class=\"card-nav\" *ngIf=\"canEdit\">\r\n <div class=\"card-handle font-icon\" title=\"Mover\" cdkDragHandle>\r\n drag_pan\r\n </div>\r\n <button class=\"btn card-options font-icon\" title=\"Modificar tamanho\" mat-button [matMenuTriggerFor]=\"menu\">\r\n resize\r\n </button>\r\n <mat-menu #menu=\"matMenu\">\r\n <ng-container *ngFor=\"let opt of orderOptions\">\r\n <button mat-menu-item (click)=\"card.cols = opt.cols; card.rows = opt.rows\" >{{opt.title}}</button>\r\n </ng-container>\r\n </mat-menu>\r\n <button class=\"btn font-icon\" title=\"Editar Tipo do Gr\u00E1fico\" (click)=\"openModalChart(card)\">{{'landscape_2_edit'}}</button>\r\n <button class=\"btn font-icon\" title=\"Editar fonte de dados\" (click)=\"openModalData(card)\">edit_note</button>\r\n <button class=\"btn font-icon\" *ngIf=\"debug\" title=\"Exibir c\u00F3digo de configura\u00E7\u00E3o\" (click)=\"openModalCode(card)\">code_blocks</button>\r\n </nav>\r\n <div class=\"custom-placeholder\" *cdkDragPlaceholder></div>\r\n <lib-card [data]=\"card\" [ngClass]=\"{'canEdit': canEdit}\" [isDark]=\"isDark\"></lib-card>\r\n </div>\r\n </div>\r\n </mat-grid-tile>\r\n <mat-grid-tile class=\"card\" [colspan]=\"1\" [rowspan]=\"1\" [class.dark-class]=\"isDark\" *ngIf=\"canEdit\">\r\n <lib-card [data]=\"emptyCard\" [ngClass]=\"{'canEdit': canEdit, cardEmpty:true}\" [isDark]=\"isDark\"\r\n (click)=\"addNewCard()\"\r\n ></lib-card>\r\n </mat-grid-tile>\r\n </mat-grid-list>\r\n</main>\r\n<ng-template #modal>\r\n <lib-modal-edit (closeModal)=\"closeModalData()\" (saveData)=\"saveData($event)\" [data]=\"modalData\" [groupType]=\"groupType\"></lib-modal-edit>\r\n</ng-template>\r\n<ng-template #modalView>\r\n <header class=\"modal-header\">\r\n <h4 class=\"modal-title pull-left mb-0\">{{currentCard.title}}</h4>\r\n <button type=\"button\" class=\"btn-close close pull-right\" aria-label=\"Close\" (click)=\"closeModalView()\">\r\n <span aria-hidden=\"true\" class=\"visually-hidden\">×</span>\r\n </button>\r\n </header>\r\n <body id=\"modalViewBody\" class=\"modal-body py-2 overflow-auto\">\r\n <lib-card [data]=\"currentCard\" [ngClass]=\"{'canEdit': canEdit}\" [isDark]=\"isDark\"></lib-card>\r\n </body>\r\n</ng-template>\r\n<ng-template #modalCode>\r\n <header class=\"modal-header\">\r\n <h4 class=\"modal-title pull-left mb-0\">{{currentCard.title}}</h4>\r\n <button type=\"button\" class=\"btn-close close pull-right\" aria-label=\"Close\" (click)=\"closeModalCode()\">\r\n <span aria-hidden=\"true\" class=\"visually-hidden\">×</span>\r\n </button>\r\n </header>\r\n <body id=\"modalCodeBody\" class=\"modal-body py-2 overflow-auto\">\r\n <pre class=\"code-area\">{{ currentCard | json }}</pre>\r\n <button class=\"font-icon code-copy\" title=\"Copiar json\" (click)=\"copyCode()\">content_copy</button>\r\n <span *ngIf=\"copyComplete\" class=\"copy-message\">Copiado!</span>\r\n </body>\r\n</ng-template>\r\n<ng-template #modalChart>\r\n <lib-modal-edit-chart (closeModal)=\"closeModalChart()\" [currentOption]=\"currentOption\" (saveData)=\"saveChartData($event)\"></lib-modal-edit-chart>\r\n</ng-template>", styles: [".dashboard{padding:5px;background-color:#e4e4e4}.copy-message{position:absolute;bottom:10px;left:45%;right:auto;color:#fff;padding:5px 25px;border-radius:20px;background:#1b1b1b}.code-area{background:black;color:#fff;padding:10px;line-height:1;border-radius:10px}.code-copy{top:15px;position:absolute;color:#fff;background:#3f3f3f;right:25px;display:hidden;display:none;border-radius:25px;padding:8px;border:none}.modal-body:hover .code-copy{display:inline}.card{box-sizing:border-box;color:#000000de;background:#fff;border-radius:4px;z-index:1;box-shadow:0 3px 1px -2px #0003,0 2px 2px #00000024,0 1px 5px #0000001f;transition:box-shadow .2s cubic-bezier(0,0,.2,1)}.card-body{border:solid 1px #ccc;height:100%}.card-body:active{border:solid 1px #ccc;box-shadow:0 5px 5px -3px #0003,0 8px 10px 1px #00000024,0 3px 14px 2px #0000001f}.card-body .card-nav{width:100%;height:30px;display:flex;border-bottom:1px solid gray}.card-body .card-nav .card-handle{cursor:move;width:24px;height:24px}.card-body .card-nav .card-options{border:none;display:flex;padding:0}.card-body .card-nav button,.card-body .card-nav .card-handle{font-size:18pt;display:flex;color:#898989;padding:0;margin-left:5px}.cdk-drag-preview{box-sizing:border-box;border-radius:4px;box-shadow:0 5px 5px -3px #0003,0 8px 10px 1px #00000024,0 3px 14px 2px #0000001f}.more-button{float:right;font-size:2em}.cdk-drop-list{height:100%;width:100%}.cdk-drag-animating{transition:unset}.cdk-drag-placeholder{display:none}.mat-grid-tile{overflow:visible!important}.mat-grid-tile-content{height:100%!important;display:flex!important}.nav-hover{display:flex;right:10px;position:absolute;top:10px;display:none}::ng-deep .mat-grid-tile:hover .nav-hover{display:inherit}::ng-deep .dark-class:not(.has-color){background-color:#000!important;color:#fff!important}::ng-deep .dark-class.card-body:not(.has-color){background-color:#1a1a1a!important;color:#fff!important}::ng-deep .mat-grid-tile-content:has(lib-card.cardEmpty .empty-card:active){background-color:#c6c6c6}::ng-deep lib-card.cardEmpty{width:100%}::ng-deep lib-card.cardEmpty .empty-card{width:100%;height:100%;text-align:center;padding:auto;font-size:28pt}::ng-deep lib-card.cardEmpty .empty-card:active{border:none}::ng-deep lib-card.canEdit{display:block;height:calc(100% - 30px)}\n"], dependencies: [{ kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i3$1.CdkDropList, selector: "[cdkDropList], cdk-drop-list", inputs: ["cdkDropListConnectedTo", "cdkDropListData", "cdkDropListOrientation", "id", "cdkDropListLockAxis", "cdkDropListDisabled", "cdkDropListSortingDisabled", "cdkDropListEnterPredicate", "cdkDropListSortPredicate", "cdkDropListAutoScrollDisabled", "cdkDropListAutoScrollStep"], outputs: ["cdkDropListDropped", "cdkDropListEntered", "cdkDropListExited", "cdkDropListSorted"], exportAs: ["cdkDropList"] }, { kind: "directive", type: i3$1.CdkDrag, selector: "[cdkDrag]", inputs: ["cdkDragData", "cdkDragLockAxis", "cdkDragRootElement", "cdkDragBoundary", "cdkDragStartDelay", "cdkDragFreeDragPosition", "cdkDragDisabled", "cdkDragConstrainPosition", "cdkDragPreviewClass", "cdkDragPreviewContainer"], outputs: ["cdkDragStarted", "cdkDragReleased", "cdkDragEnded", "cdkDragEntered", "cdkDragExited", "cdkDragDropped", "cdkDragMoved"], exportAs: ["cdkDrag"] }, { kind: "directive", type: i3$1.CdkDragHandle, selector: "[cdkDragHandle]", inputs: ["cdkDragHandleDisabled"] }, { kind: "directive", type: i3$1.CdkDragPlaceholder, selector: "ng-template[cdkDragPlaceholder]", inputs: ["data"] }, { kind: "component", type: i4$1.MatGridList, selector: "mat-grid-list", inputs: ["cols", "gutterSize", "rowHeight"], exportAs: ["matGridList"] }, { kind: "component", type: i4$1.MatGridTile, selector: "mat-grid-tile", inputs: ["rowspan", "colspan"], exportAs: ["matGridTile"] }, { kind: "component", type: i5.MatMenu, selector: "mat-menu", exportAs: ["matMenu"] }, { kind: "component", type: i5.MatMenuItem, selector: "[mat-menu-item]", inputs: ["disabled", "disableRipple", "role"], exportAs: ["matMenuItem"] }, { kind: "directive", type: i5.MatMenuTrigger, selector: "[mat-menu-trigger-for], [matMenuTriggerFor]", exportAs: ["matMenuTrigger"] }, { kind: "component", type: CardComponent, selector: "lib-card", inputs: ["data", "isDark"] }, { kind: "component", type: ModalEditComponent, selector: "lib-modal-edit", inputs: ["data", "groupType"], outputs: ["closeModal", "saveData"] }, { kind: "component", type: ModalEditChartComponent, selector: "lib-modal-edit-chart", inputs: ["currentOption"], outputs: ["closeModal", "saveData"] }, { kind: "pipe", type: i2.JsonPipe, name: "json" }] });
|
|
1156
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DashboardComponent, decorators: [{
|
|
1157
|
+
type: Component,
|
|
1158
|
+
args: [{ selector: 'lib-dashboard', template: "<main class=\"dashboard\" [class.responsive]=\"isResponsive\" [class.dark-class]=\"isDark\">\r\n <mat-grid-list [cols]=\"cols\" rowHeight=\"300px\" gutterSize=\"10px\">\r\n <mat-grid-tile\r\n *ngFor=\"let card of cards; let i = index\"\r\n [colspan]=\"card.cols > cols? cols : card.cols\"\r\n [rowspan]=\"card.rows\"\r\n [class.dark-class]=\"isDark\"\r\n class=\"card\"\r\n >\r\n <div cdkDropList [cdkDropListConnectedTo]=\"drops\" [cdkDropListData]=\"i\">\r\n <div\r\n [id]=\"'card_' + i\"\r\n cdkDrag\r\n (cdkDragEntered)=\"entered($event)\"\r\n [cdkDragData]=\"i\"\r\n class=\"card-body\"\r\n [cdkDragDisabled]=\"!canEdit\"\r\n [class.dark-class]=\"isDark\"\r\n [class.has-color]=\"card.backgroundColor\"\r\n [style.background-color]=\"card.backgroundColor\"\r\n [style.color]=\"card.fontColor\"\r\n >\r\n <nav class=\"nav-hover\">\r\n <button *ngIf=\"!canEdit\" class=\"btn font-icon\" title=\"Ampliar gr\u00E1fico\" (click)=\"openChart(card, i)\">search</button>\r\n <button *ngIf=\"!canEdit\" class=\"btn font-icon\" title=\"Baixar imagem\" (click)=\"downloadImage(i)\">download</button>\r\n </nav>\r\n <nav class=\"card-nav\" *ngIf=\"canEdit\">\r\n <div class=\"card-handle font-icon\" title=\"Mover\" cdkDragHandle>\r\n drag_pan\r\n </div>\r\n <button class=\"btn card-options font-icon\" title=\"Modificar tamanho\" mat-button [matMenuTriggerFor]=\"menu\">\r\n resize\r\n </button>\r\n <mat-menu #menu=\"matMenu\">\r\n <ng-container *ngFor=\"let opt of orderOptions\">\r\n <button mat-menu-item (click)=\"card.cols = opt.cols; card.rows = opt.rows\" >{{opt.title}}</button>\r\n </ng-container>\r\n </mat-menu>\r\n <button class=\"btn font-icon\" title=\"Editar Tipo do Gr\u00E1fico\" (click)=\"openModalChart(card)\">{{'landscape_2_edit'}}</button>\r\n <button class=\"btn font-icon\" title=\"Editar fonte de dados\" (click)=\"openModalData(card)\">edit_note</button>\r\n <button class=\"btn font-icon\" *ngIf=\"debug\" title=\"Exibir c\u00F3digo de configura\u00E7\u00E3o\" (click)=\"openModalCode(card)\">code_blocks</button>\r\n </nav>\r\n <div class=\"custom-placeholder\" *cdkDragPlaceholder></div>\r\n <lib-card [data]=\"card\" [ngClass]=\"{'canEdit': canEdit}\" [isDark]=\"isDark\"></lib-card>\r\n </div>\r\n </div>\r\n </mat-grid-tile>\r\n <mat-grid-tile class=\"card\" [colspan]=\"1\" [rowspan]=\"1\" [class.dark-class]=\"isDark\" *ngIf=\"canEdit\">\r\n <lib-card [data]=\"emptyCard\" [ngClass]=\"{'canEdit': canEdit, cardEmpty:true}\" [isDark]=\"isDark\"\r\n (click)=\"addNewCard()\"\r\n ></lib-card>\r\n </mat-grid-tile>\r\n </mat-grid-list>\r\n</main>\r\n<ng-template #modal>\r\n <lib-modal-edit (closeModal)=\"closeModalData()\" (saveData)=\"saveData($event)\" [data]=\"modalData\" [groupType]=\"groupType\"></lib-modal-edit>\r\n</ng-template>\r\n<ng-template #modalView>\r\n <header class=\"modal-header\">\r\n <h4 class=\"modal-title pull-left mb-0\">{{currentCard.title}}</h4>\r\n <button type=\"button\" class=\"btn-close close pull-right\" aria-label=\"Close\" (click)=\"closeModalView()\">\r\n <span aria-hidden=\"true\" class=\"visually-hidden\">×</span>\r\n </button>\r\n </header>\r\n <body id=\"modalViewBody\" class=\"modal-body py-2 overflow-auto\">\r\n <lib-card [data]=\"currentCard\" [ngClass]=\"{'canEdit': canEdit}\" [isDark]=\"isDark\"></lib-card>\r\n </body>\r\n</ng-template>\r\n<ng-template #modalCode>\r\n <header class=\"modal-header\">\r\n <h4 class=\"modal-title pull-left mb-0\">{{currentCard.title}}</h4>\r\n <button type=\"button\" class=\"btn-close close pull-right\" aria-label=\"Close\" (click)=\"closeModalCode()\">\r\n <span aria-hidden=\"true\" class=\"visually-hidden\">×</span>\r\n </button>\r\n </header>\r\n <body id=\"modalCodeBody\" class=\"modal-body py-2 overflow-auto\">\r\n <pre class=\"code-area\">{{ currentCard | json }}</pre>\r\n <button class=\"font-icon code-copy\" title=\"Copiar json\" (click)=\"copyCode()\">content_copy</button>\r\n <span *ngIf=\"copyComplete\" class=\"copy-message\">Copiado!</span>\r\n </body>\r\n</ng-template>\r\n<ng-template #modalChart>\r\n <lib-modal-edit-chart (closeModal)=\"closeModalChart()\" [currentOption]=\"currentOption\" (saveData)=\"saveChartData($event)\"></lib-modal-edit-chart>\r\n</ng-template>", styles: [".dashboard{padding:5px;background-color:#e4e4e4}.copy-message{position:absolute;bottom:10px;left:45%;right:auto;color:#fff;padding:5px 25px;border-radius:20px;background:#1b1b1b}.code-area{background:black;color:#fff;padding:10px;line-height:1;border-radius:10px}.code-copy{top:15px;position:absolute;color:#fff;background:#3f3f3f;right:25px;display:hidden;display:none;border-radius:25px;padding:8px;border:none}.modal-body:hover .code-copy{display:inline}.card{box-sizing:border-box;color:#000000de;background:#fff;border-radius:4px;z-index:1;box-shadow:0 3px 1px -2px #0003,0 2px 2px #00000024,0 1px 5px #0000001f;transition:box-shadow .2s cubic-bezier(0,0,.2,1)}.card-body{border:solid 1px #ccc;height:100%}.card-body:active{border:solid 1px #ccc;box-shadow:0 5px 5px -3px #0003,0 8px 10px 1px #00000024,0 3px 14px 2px #0000001f}.card-body .card-nav{width:100%;height:30px;display:flex;border-bottom:1px solid gray}.card-body .card-nav .card-handle{cursor:move;width:24px;height:24px}.card-body .card-nav .card-options{border:none;display:flex;padding:0}.card-body .card-nav button,.card-body .card-nav .card-handle{font-size:18pt;display:flex;color:#898989;padding:0;margin-left:5px}.cdk-drag-preview{box-sizing:border-box;border-radius:4px;box-shadow:0 5px 5px -3px #0003,0 8px 10px 1px #00000024,0 3px 14px 2px #0000001f}.more-button{float:right;font-size:2em}.cdk-drop-list{height:100%;width:100%}.cdk-drag-animating{transition:unset}.cdk-drag-placeholder{display:none}.mat-grid-tile{overflow:visible!important}.mat-grid-tile-content{height:100%!important;display:flex!important}.nav-hover{display:flex;right:10px;position:absolute;top:10px;display:none}::ng-deep .mat-grid-tile:hover .nav-hover{display:inherit}::ng-deep .dark-class:not(.has-color){background-color:#000!important;color:#fff!important}::ng-deep .dark-class.card-body:not(.has-color){background-color:#1a1a1a!important;color:#fff!important}::ng-deep .mat-grid-tile-content:has(lib-card.cardEmpty .empty-card:active){background-color:#c6c6c6}::ng-deep lib-card.cardEmpty{width:100%}::ng-deep lib-card.cardEmpty .empty-card{width:100%;height:100%;text-align:center;padding:auto;font-size:28pt}::ng-deep lib-card.cardEmpty .empty-card:active{border:none}::ng-deep lib-card.canEdit{display:block;height:calc(100% - 30px)}\n"] }]
|
|
1159
|
+
}], ctorParameters: function () { return [{ type: i1$2.BsModalService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { isDark: [{
|
|
1160
|
+
type: Input
|
|
1161
|
+
}], isResponsive: [{
|
|
1162
|
+
type: Input
|
|
1163
|
+
}], canEdit: [{
|
|
1164
|
+
type: Input
|
|
1165
|
+
}], cols: [{
|
|
1166
|
+
type: Input
|
|
1167
|
+
}], options: [{
|
|
1168
|
+
type: Input
|
|
1169
|
+
}], cards: [{
|
|
1170
|
+
type: Input
|
|
1171
|
+
}], groupType: [{
|
|
1172
|
+
type: Input
|
|
1173
|
+
}], modalData: [{
|
|
1174
|
+
type: Input
|
|
1175
|
+
}], data: [{
|
|
1176
|
+
type: Input
|
|
1177
|
+
}], debug: [{
|
|
1178
|
+
type: Input
|
|
1179
|
+
}], dropsQuery: [{
|
|
1180
|
+
type: ViewChildren,
|
|
1181
|
+
args: [CdkDropList]
|
|
1182
|
+
}], modalChart: [{
|
|
1183
|
+
type: ViewChild,
|
|
1184
|
+
args: ['modalChart']
|
|
1185
|
+
}], modal: [{
|
|
1186
|
+
type: ViewChild,
|
|
1187
|
+
args: ['modal']
|
|
1188
|
+
}], modalView: [{
|
|
1189
|
+
type: ViewChild,
|
|
1190
|
+
args: ['modalView']
|
|
1191
|
+
}], modalCode: [{
|
|
1192
|
+
type: ViewChild,
|
|
1193
|
+
args: ['modalCode']
|
|
1194
|
+
}], onresize: [{
|
|
1195
|
+
type: HostListener,
|
|
1196
|
+
args: ['window:resize']
|
|
1197
|
+
}] } });
|
|
1198
|
+
|
|
1199
|
+
class PrimordashComponent {
|
|
1200
|
+
constructor() {
|
|
1201
|
+
this.isDark = false;
|
|
1202
|
+
this.isResponsive = true;
|
|
1203
|
+
this.canEdit = false;
|
|
1204
|
+
this.cols = 4;
|
|
1205
|
+
this.options = [
|
|
1206
|
+
{ title: '1x1', cols: 1, rows: 1 },
|
|
1207
|
+
{ title: '2x1', cols: 2, rows: 1 },
|
|
1208
|
+
{ title: '3x1', cols: 3, rows: 1 },
|
|
1209
|
+
{ title: '1x2', cols: 1, rows: 2 },
|
|
1210
|
+
{ title: '2x2', cols: 2, rows: 2 },
|
|
1211
|
+
];
|
|
1212
|
+
this.cards = [];
|
|
1213
|
+
this.groupType = [];
|
|
1214
|
+
this.modalData = [];
|
|
1215
|
+
this.debug = false;
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
PrimordashComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: PrimordashComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1219
|
+
PrimordashComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: PrimordashComponent, selector: "lib-primordash", inputs: { isDark: "isDark", isResponsive: "isResponsive", canEdit: "canEdit", cols: "cols", options: "options", cards: "cards", groupType: "groupType", modalData: "modalData", data: "data", debug: "debug" }, ngImport: i0, template: `
|
|
1220
|
+
<lib-dashboard
|
|
1221
|
+
[isDark]="isDark"
|
|
1222
|
+
[isResponsive]="isResponsive"
|
|
1223
|
+
[canEdit]="canEdit"
|
|
1224
|
+
[cols]="cols"
|
|
1225
|
+
[options]="options"
|
|
1226
|
+
[cards]="cards"
|
|
1227
|
+
[groupType]="groupType"
|
|
1228
|
+
[modalData]="modalData"
|
|
1229
|
+
[data]="data"
|
|
1230
|
+
[debug]="true"
|
|
1231
|
+
></lib-dashboard>
|
|
1232
|
+
`, isInline: true, dependencies: [{ kind: "component", type: DashboardComponent, selector: "lib-dashboard", inputs: ["isDark", "isResponsive", "canEdit", "cols", "options", "cards", "groupType", "modalData", "data", "debug"] }] });
|
|
1233
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: PrimordashComponent, decorators: [{
|
|
1234
|
+
type: Component,
|
|
1235
|
+
args: [{ selector: 'lib-primordash', template: `
|
|
1236
|
+
<lib-dashboard
|
|
1237
|
+
[isDark]="isDark"
|
|
1238
|
+
[isResponsive]="isResponsive"
|
|
1239
|
+
[canEdit]="canEdit"
|
|
1240
|
+
[cols]="cols"
|
|
1241
|
+
[options]="options"
|
|
1242
|
+
[cards]="cards"
|
|
1243
|
+
[groupType]="groupType"
|
|
1244
|
+
[modalData]="modalData"
|
|
1245
|
+
[data]="data"
|
|
1246
|
+
[debug]="true"
|
|
1247
|
+
></lib-dashboard>
|
|
1248
|
+
` }]
|
|
1249
|
+
}], propDecorators: { isDark: [{
|
|
1250
|
+
type: Input
|
|
1251
|
+
}], isResponsive: [{
|
|
1252
|
+
type: Input
|
|
1253
|
+
}], canEdit: [{
|
|
1254
|
+
type: Input
|
|
1255
|
+
}], cols: [{
|
|
1256
|
+
type: Input
|
|
1257
|
+
}], options: [{
|
|
1258
|
+
type: Input
|
|
1259
|
+
}], cards: [{
|
|
1260
|
+
type: Input
|
|
1261
|
+
}], groupType: [{
|
|
1262
|
+
type: Input
|
|
1263
|
+
}], modalData: [{
|
|
1264
|
+
type: Input
|
|
1265
|
+
}], data: [{
|
|
1266
|
+
type: Input
|
|
1267
|
+
}], debug: [{
|
|
1268
|
+
type: Input
|
|
1269
|
+
}] } });
|
|
1270
|
+
|
|
1271
|
+
class PrimordashModule {
|
|
1272
|
+
}
|
|
1273
|
+
PrimordashModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: PrimordashModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1274
|
+
PrimordashModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.10", ngImport: i0, type: PrimordashModule, declarations: [DashboardComponent,
|
|
1275
|
+
CardComponent,
|
|
1276
|
+
BarLineComponent,
|
|
1277
|
+
BubbleComponent,
|
|
1278
|
+
PieComponent,
|
|
1279
|
+
SimpleCardComponent,
|
|
1280
|
+
TableComponent,
|
|
1281
|
+
ModalEditComponent,
|
|
1282
|
+
ModalEditChartComponent,
|
|
1283
|
+
PrimordashComponent], imports: [BrowserModule,
|
|
1284
|
+
DragDropModule,
|
|
1285
|
+
BrowserAnimationsModule,
|
|
1286
|
+
MatGridListModule,
|
|
1287
|
+
MatMenuModule,
|
|
1288
|
+
NgChartsModule,
|
|
1289
|
+
ReactiveFormsModule,
|
|
1290
|
+
FormsModule,
|
|
1291
|
+
CommonModule, i1$2.ModalModule, NgSelectModule], exports: [DashboardComponent,
|
|
1292
|
+
PrimordashComponent] });
|
|
1293
|
+
PrimordashModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: PrimordashModule, imports: [BrowserModule,
|
|
1294
|
+
DragDropModule,
|
|
1295
|
+
BrowserAnimationsModule,
|
|
1296
|
+
MatGridListModule,
|
|
1297
|
+
MatMenuModule,
|
|
1298
|
+
NgChartsModule,
|
|
1299
|
+
ReactiveFormsModule,
|
|
1300
|
+
FormsModule,
|
|
1301
|
+
CommonModule,
|
|
1302
|
+
ModalModule.forRoot(),
|
|
1303
|
+
NgSelectModule] });
|
|
1304
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: PrimordashModule, decorators: [{
|
|
1305
|
+
type: NgModule,
|
|
1306
|
+
args: [{
|
|
1307
|
+
declarations: [
|
|
1308
|
+
DashboardComponent,
|
|
1309
|
+
CardComponent,
|
|
1310
|
+
BarLineComponent,
|
|
1311
|
+
BubbleComponent,
|
|
1312
|
+
PieComponent,
|
|
1313
|
+
SimpleCardComponent,
|
|
1314
|
+
TableComponent,
|
|
1315
|
+
ModalEditComponent,
|
|
1316
|
+
ModalEditChartComponent,
|
|
1317
|
+
PrimordashComponent
|
|
1318
|
+
],
|
|
1319
|
+
imports: [
|
|
1320
|
+
BrowserModule,
|
|
1321
|
+
DragDropModule,
|
|
1322
|
+
BrowserAnimationsModule,
|
|
1323
|
+
MatGridListModule,
|
|
1324
|
+
MatMenuModule,
|
|
1325
|
+
NgChartsModule,
|
|
1326
|
+
ReactiveFormsModule,
|
|
1327
|
+
FormsModule,
|
|
1328
|
+
CommonModule,
|
|
1329
|
+
ModalModule.forRoot(),
|
|
1330
|
+
NgSelectModule
|
|
1331
|
+
],
|
|
1332
|
+
exports: [
|
|
1333
|
+
DashboardComponent,
|
|
1334
|
+
PrimordashComponent
|
|
1335
|
+
],
|
|
1336
|
+
providers: []
|
|
1337
|
+
}]
|
|
1338
|
+
}] });
|
|
1339
|
+
|
|
1340
|
+
/*
|
|
1341
|
+
* Public API Surface of primordash
|
|
1342
|
+
*/
|
|
1343
|
+
|
|
1344
|
+
/**
|
|
1345
|
+
* Generated bundle index. Do not edit.
|
|
1346
|
+
*/
|
|
1347
|
+
|
|
1348
|
+
export { DashboardComponent, PrimordashComponent, PrimordashModule, PrimordashService };
|
|
1349
|
+
//# sourceMappingURL=rafaelaalmeidaa-primordash.mjs.map
|