mapa-library-ui 2.12.0 → 2.13.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 +3 -0
- package/docs/EXCEL_EXPORT.md +157 -0
- package/docs/TABLE_EXPORT.md +161 -0
- package/fesm2022/mapa-library-ui-src-lib-core-excel-export-excel-export.logo-DV7jykE5.mjs +5 -0
- package/fesm2022/mapa-library-ui-src-lib-core-excel-export-excel-export.logo-DV7jykE5.mjs.map +1 -0
- package/fesm2022/mapa-library-ui-src-lib-core-excel-export.mjs +814 -0
- package/fesm2022/mapa-library-ui-src-lib-core-excel-export.mjs.map +1 -0
- package/fesm2022/mapa-library-ui-src-lib-core-export.mjs +536 -0
- package/fesm2022/mapa-library-ui-src-lib-core-export.mjs.map +1 -0
- package/mapa-library-ui-2.13.1.tgz +0 -0
- package/package.json +38 -2
- package/src/lib/core/excel-export/index.d.ts +192 -0
- package/src/lib/core/export/index.d.ts +219 -0
- package/worker/excel-export.runtime.d.ts +4 -0
- package/worker/excel-export.runtime.js +76 -0
- package/worker/excel-export.worker.js +76 -0
- package/mapa-library-ui-2.12.0.tgz +0 -0
|
@@ -0,0 +1,536 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, inject, signal, Injectable, ViewEncapsulation, Component, ChangeDetectionStrategy } from '@angular/core';
|
|
3
|
+
import { MapaExcelExportService, ExcelExportCancelledError } from 'mapa-library-ui/src/lib/core/excel-export';
|
|
4
|
+
import * as i2 from '@angular/material/dialog';
|
|
5
|
+
import { MAT_DIALOG_DATA, MatDialogRef, MatDialogModule, MatDialog } from '@angular/material/dialog';
|
|
6
|
+
import * as i1 from '@angular/forms';
|
|
7
|
+
import { FormsModule } from '@angular/forms';
|
|
8
|
+
import * as i3 from '@angular/material/checkbox';
|
|
9
|
+
import { MatCheckboxModule } from '@angular/material/checkbox';
|
|
10
|
+
import * as i4 from '@angular/material/radio';
|
|
11
|
+
import { MatRadioModule } from '@angular/material/radio';
|
|
12
|
+
import * as i1$1 from '@angular/material/progress-bar';
|
|
13
|
+
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
|
14
|
+
import { HttpContextToken } from '@angular/common/http';
|
|
15
|
+
|
|
16
|
+
const EXPORT_FILE_ROW_LIMIT = 100_000;
|
|
17
|
+
/** Encode browser-local calendar fields for timezone-free Excel and CSV cells. */
|
|
18
|
+
function toExportDate(value) {
|
|
19
|
+
if (!Number.isFinite(value.getTime()))
|
|
20
|
+
throw new Error('Data inválida na exportação.');
|
|
21
|
+
return new Date(value.getTime() - value.getTimezoneOffset() * 60_000);
|
|
22
|
+
}
|
|
23
|
+
const exportSlug = (value) => value
|
|
24
|
+
.normalize('NFD')
|
|
25
|
+
.replace(/[\u0300-\u036f]/g, '')
|
|
26
|
+
.toLowerCase()
|
|
27
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
28
|
+
.replace(/^-|-$/g, '') || 'exportacao';
|
|
29
|
+
function exportFileBase(listing, company, date) {
|
|
30
|
+
const pad = (value) => String(value).padStart(2, '0');
|
|
31
|
+
return `mapahds_${exportSlug(listing)}_${exportSlug(company)}_${date.getFullYear()}${pad(date.getMonth() + 1)}${pad(date.getDate())}-${pad(date.getHours())}${pad(date.getMinutes())}`;
|
|
32
|
+
}
|
|
33
|
+
/** Greedy packing preserves dataset order and counts records across all sheets. */
|
|
34
|
+
function splitExportSheets(sheets, limit = EXPORT_FILE_ROW_LIMIT) {
|
|
35
|
+
if (!Number.isInteger(limit) || limit < 1)
|
|
36
|
+
throw new Error('Limite de registros inválido.');
|
|
37
|
+
const parts = [[]];
|
|
38
|
+
let used = 0;
|
|
39
|
+
for (const sheet of sheets) {
|
|
40
|
+
if (!sheet.rows.length) {
|
|
41
|
+
parts[parts.length - 1].push({ ...sheet, rows: [] });
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
for (let offset = 0; offset < sheet.rows.length;) {
|
|
45
|
+
if (used === limit) {
|
|
46
|
+
parts.push([]);
|
|
47
|
+
used = 0;
|
|
48
|
+
}
|
|
49
|
+
const length = Math.min(limit - used, sheet.rows.length - offset);
|
|
50
|
+
parts[parts.length - 1].push({
|
|
51
|
+
...sheet,
|
|
52
|
+
rows: sheet.rows.slice(offset, offset + length),
|
|
53
|
+
});
|
|
54
|
+
offset += length;
|
|
55
|
+
used += length;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return parts;
|
|
59
|
+
}
|
|
60
|
+
function encodeExportCsv(sheet, onProgress) {
|
|
61
|
+
const encode = (input) => {
|
|
62
|
+
const value = input && typeof input === 'object' && 'formula' in input
|
|
63
|
+
? input.result
|
|
64
|
+
: input;
|
|
65
|
+
if (value instanceof Date && !Number.isFinite(value.getTime()))
|
|
66
|
+
throw new Error('Data inválida na exportação.');
|
|
67
|
+
if (typeof value === 'number' && !Number.isFinite(value))
|
|
68
|
+
return '';
|
|
69
|
+
const text = value == null
|
|
70
|
+
? ''
|
|
71
|
+
: value instanceof Date
|
|
72
|
+
? value.toLocaleString('pt-BR', { timeZone: 'UTC' })
|
|
73
|
+
: String(value);
|
|
74
|
+
// Quoting alone does not stop spreadsheet apps interpreting user text as a formula.
|
|
75
|
+
const literal = typeof value === 'string' && /^[=+\-@\t\r]/.test(text)
|
|
76
|
+
? `'${text}`
|
|
77
|
+
: text;
|
|
78
|
+
return /[;"\r\n]/.test(literal)
|
|
79
|
+
? `"${literal.replace(/"/g, '""')}"`
|
|
80
|
+
: literal;
|
|
81
|
+
};
|
|
82
|
+
const lines = [sheet.columns.map((column) => encode(column.label)).join(';')];
|
|
83
|
+
sheet.rows.forEach((row, index) => {
|
|
84
|
+
lines.push(sheet.columns
|
|
85
|
+
.map((column) => encode(column.value ? column.value(row, index) : row[column.key]))
|
|
86
|
+
.join(';'));
|
|
87
|
+
if (index % 5_000 === 4_999)
|
|
88
|
+
onProgress?.(index + 1, sheet.rows.length);
|
|
89
|
+
});
|
|
90
|
+
onProgress?.(sheet.rows.length, sheet.rows.length);
|
|
91
|
+
return new TextEncoder().encode('\uFEFF' + lines.join('\r\n') + '\r\n')
|
|
92
|
+
.buffer;
|
|
93
|
+
}
|
|
94
|
+
/** HTTP and domain adaptation remain in load; this helper verifies completeness. */
|
|
95
|
+
async function collectExportPages(options) {
|
|
96
|
+
const result = [];
|
|
97
|
+
const keys = new Set();
|
|
98
|
+
let pageIndex = 1;
|
|
99
|
+
let pageSize = Math.max(1, options.totalCount);
|
|
100
|
+
let expected;
|
|
101
|
+
while (true) {
|
|
102
|
+
options.signal.throwIfAborted();
|
|
103
|
+
const page = await options.load(pageIndex, pageSize, options.signal);
|
|
104
|
+
options.signal.throwIfAborted();
|
|
105
|
+
if (!Number.isInteger(page.totalCount) ||
|
|
106
|
+
page.totalCount < 0 ||
|
|
107
|
+
page.totalCount !== options.totalCount ||
|
|
108
|
+
(expected !== undefined && expected !== page.totalCount) ||
|
|
109
|
+
(page.pageIndex !== undefined && page.pageIndex !== pageIndex) ||
|
|
110
|
+
(pageIndex > 1 && page.pageSize !== pageSize))
|
|
111
|
+
throw new Error('Os dados mudaram durante a exportação. Atualize a listagem e tente novamente.');
|
|
112
|
+
expected = page.totalCount;
|
|
113
|
+
for (const row of page.data) {
|
|
114
|
+
const key = options.key(row);
|
|
115
|
+
if (!key || keys.has(key))
|
|
116
|
+
throw new Error('Registros duplicados ou sem identificação na exportação.');
|
|
117
|
+
keys.add(key);
|
|
118
|
+
result.push(row);
|
|
119
|
+
}
|
|
120
|
+
options.onProgress?.(result.length, expected);
|
|
121
|
+
if (result.length === expected)
|
|
122
|
+
return result;
|
|
123
|
+
if (!page.data.length ||
|
|
124
|
+
result.length > expected ||
|
|
125
|
+
!Number.isInteger(page.pageSize) ||
|
|
126
|
+
page.pageSize < 1 ||
|
|
127
|
+
page.data.length !== page.pageSize)
|
|
128
|
+
throw new Error('A API retornou uma exportação incompleta.');
|
|
129
|
+
pageSize = page.pageSize;
|
|
130
|
+
pageIndex++;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const MAPA_EXPORT_WORKER_FACTORY = new InjectionToken('MAPA_EXPORT_WORKER_FACTORY');
|
|
135
|
+
function snapshotExportRequest(request) {
|
|
136
|
+
return {
|
|
137
|
+
...request,
|
|
138
|
+
context: { ...request.context, filters: [...request.context.filters] },
|
|
139
|
+
datasets: request.datasets.map((dataset) => ({
|
|
140
|
+
...dataset,
|
|
141
|
+
columns: dataset.columns.map((column) => ({
|
|
142
|
+
...column,
|
|
143
|
+
status: column.status?.map((status) => ({ ...status })),
|
|
144
|
+
})),
|
|
145
|
+
indicators: dataset.indicators?.map((indicator) => ({ ...indicator })),
|
|
146
|
+
rows: dataset.rows ? structuredClone(dataset.rows) : undefined,
|
|
147
|
+
selectedRows: dataset.selectedRows
|
|
148
|
+
? structuredClone(dataset.selectedRows)
|
|
149
|
+
: undefined,
|
|
150
|
+
})),
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
class MapaExportJobsService {
|
|
154
|
+
constructor() {
|
|
155
|
+
this.excel = inject(MapaExcelExportService);
|
|
156
|
+
this.defaultWorker = inject(MAPA_EXPORT_WORKER_FACTORY, {
|
|
157
|
+
optional: true,
|
|
158
|
+
});
|
|
159
|
+
this.state = signal([], ...(ngDevMode ? [{ debugName: "state" }] : []));
|
|
160
|
+
this.tasks = this.state.asReadonly();
|
|
161
|
+
this.pending = new Map();
|
|
162
|
+
this.controllers = new Map();
|
|
163
|
+
this.draining = false;
|
|
164
|
+
}
|
|
165
|
+
enqueue(request, choices) {
|
|
166
|
+
const id = crypto.randomUUID();
|
|
167
|
+
this.pending.set(id, {
|
|
168
|
+
request: snapshotExportRequest(request),
|
|
169
|
+
choices: { ...choices, datasetIds: [...choices.datasetIds] },
|
|
170
|
+
createdAt: new Date(),
|
|
171
|
+
});
|
|
172
|
+
this.state.update((tasks) => [
|
|
173
|
+
...tasks,
|
|
174
|
+
{
|
|
175
|
+
id,
|
|
176
|
+
title: request.listing,
|
|
177
|
+
state: 'queued',
|
|
178
|
+
files: [],
|
|
179
|
+
background: request.datasets
|
|
180
|
+
.filter((dataset) => choices.datasetIds.includes(dataset.id))
|
|
181
|
+
.reduce((sum, dataset) => sum +
|
|
182
|
+
(choices.scope === 'selected'
|
|
183
|
+
? (dataset.selectedRows?.length ?? 0)
|
|
184
|
+
: dataset.totalCount), 0) > 5_000,
|
|
185
|
+
},
|
|
186
|
+
]);
|
|
187
|
+
void this.drain();
|
|
188
|
+
return id;
|
|
189
|
+
}
|
|
190
|
+
cancel(id) {
|
|
191
|
+
this.controllers.get(id)?.abort();
|
|
192
|
+
this.patch(id, { state: 'cancelled', files: [], progress: undefined });
|
|
193
|
+
this.pending.delete(id);
|
|
194
|
+
}
|
|
195
|
+
remove(id) {
|
|
196
|
+
this.cancel(id);
|
|
197
|
+
this.state.update((tasks) => tasks.filter((task) => task.id !== id));
|
|
198
|
+
}
|
|
199
|
+
clear() {
|
|
200
|
+
for (const controller of this.controllers.values())
|
|
201
|
+
controller.abort();
|
|
202
|
+
this.pending.clear();
|
|
203
|
+
this.state.set([]);
|
|
204
|
+
}
|
|
205
|
+
retry(id) {
|
|
206
|
+
if (!this.pending.has(id) ||
|
|
207
|
+
this.tasks().find((task) => task.id === id)?.state !== 'error')
|
|
208
|
+
return;
|
|
209
|
+
this.patch(id, {
|
|
210
|
+
state: 'queued',
|
|
211
|
+
error: undefined,
|
|
212
|
+
progress: undefined,
|
|
213
|
+
files: [],
|
|
214
|
+
});
|
|
215
|
+
void this.drain();
|
|
216
|
+
}
|
|
217
|
+
download(file) {
|
|
218
|
+
const url = URL.createObjectURL(new Blob([file.buffer], { type: file.mime }));
|
|
219
|
+
const link = document.createElement('a');
|
|
220
|
+
try {
|
|
221
|
+
link.href = url;
|
|
222
|
+
link.download = file.name;
|
|
223
|
+
document.body.appendChild(link);
|
|
224
|
+
link.click();
|
|
225
|
+
}
|
|
226
|
+
finally {
|
|
227
|
+
link.remove();
|
|
228
|
+
URL.revokeObjectURL(url);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
patch(id, patch) {
|
|
232
|
+
this.state.update((tasks) => tasks.map((task) => (task.id === id ? { ...task, ...patch } : task)));
|
|
233
|
+
}
|
|
234
|
+
async drain() {
|
|
235
|
+
if (this.draining)
|
|
236
|
+
return;
|
|
237
|
+
this.draining = true;
|
|
238
|
+
try {
|
|
239
|
+
let task;
|
|
240
|
+
while ((task = this.tasks().find((item) => item.state === 'queued')))
|
|
241
|
+
await this.run(task.id);
|
|
242
|
+
}
|
|
243
|
+
finally {
|
|
244
|
+
this.draining = false;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
async run(id) {
|
|
248
|
+
const pending = this.pending.get(id);
|
|
249
|
+
if (!pending)
|
|
250
|
+
return;
|
|
251
|
+
const { request, choices, createdAt } = pending;
|
|
252
|
+
const controller = new AbortController();
|
|
253
|
+
const signal = controller.signal;
|
|
254
|
+
this.controllers.set(id, controller);
|
|
255
|
+
this.patch(id, { state: 'running', progress: { phase: 'fetching' } });
|
|
256
|
+
try {
|
|
257
|
+
const workerFactory = request.workerFactory ?? this.defaultWorker;
|
|
258
|
+
if (!workerFactory)
|
|
259
|
+
throw new Error('O worker de exportação não foi configurado nesta aplicação.');
|
|
260
|
+
const loadContext = {
|
|
261
|
+
signal,
|
|
262
|
+
generatedAt: createdAt,
|
|
263
|
+
scope: choices.scope,
|
|
264
|
+
onProgress: (completed, total) => this.patch(id, { progress: { phase: 'fetching', completed, total } }),
|
|
265
|
+
};
|
|
266
|
+
let prepared;
|
|
267
|
+
if (request.prepare)
|
|
268
|
+
prepared = await request.prepare(choices, loadContext);
|
|
269
|
+
else {
|
|
270
|
+
const sheets = [];
|
|
271
|
+
for (const dataset of request.datasets.filter((dataset) => choices.datasetIds.includes(dataset.id))) {
|
|
272
|
+
signal.throwIfAborted();
|
|
273
|
+
const rows = choices.scope === 'selected'
|
|
274
|
+
? (dataset.selectedRows ?? [])
|
|
275
|
+
: dataset.load
|
|
276
|
+
? await dataset.load(loadContext)
|
|
277
|
+
: (dataset.rows ?? []);
|
|
278
|
+
sheets.push({
|
|
279
|
+
sheetName: dataset.sheetName ?? dataset.label,
|
|
280
|
+
title: dataset.label,
|
|
281
|
+
rows,
|
|
282
|
+
columns: dataset.columns.filter((column) => column.exportable !== false &&
|
|
283
|
+
(!choices.visibleOnly || column.visible !== false)),
|
|
284
|
+
indicators: dataset.indicators,
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
prepared = { sheets };
|
|
288
|
+
}
|
|
289
|
+
signal.throwIfAborted();
|
|
290
|
+
if (!prepared.sheets.length)
|
|
291
|
+
throw new Error('Selecione pelo menos uma tabela.');
|
|
292
|
+
this.patch(id, {
|
|
293
|
+
background: prepared.sheets.reduce((sum, sheet) => sum + sheet.rows.length, 0) >
|
|
294
|
+
5_000,
|
|
295
|
+
});
|
|
296
|
+
// Resolve consumer functions before structured cloning the worker payload.
|
|
297
|
+
const sheets = [];
|
|
298
|
+
for (const sheet of prepared.sheets) {
|
|
299
|
+
if (!sheet.columns.length)
|
|
300
|
+
throw new Error(`Não há colunas para exportar em ${sheet.sheetName}.`);
|
|
301
|
+
const columns = sheet.columns.map((column, index) => ({
|
|
302
|
+
...column,
|
|
303
|
+
key: column.key ?? `column${index}`,
|
|
304
|
+
value: undefined,
|
|
305
|
+
}));
|
|
306
|
+
const rows = [];
|
|
307
|
+
for (let index = 0; index < sheet.rows.length; index++) {
|
|
308
|
+
if (index % 1_000 === 0) {
|
|
309
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
310
|
+
signal.throwIfAborted();
|
|
311
|
+
}
|
|
312
|
+
rows.push(Object.fromEntries(sheet.columns.map((column, col) => [
|
|
313
|
+
columns[col].key,
|
|
314
|
+
column.value
|
|
315
|
+
? column.value(sheet.rows[index], index)
|
|
316
|
+
: sheet.rows[index][column.key],
|
|
317
|
+
])));
|
|
318
|
+
}
|
|
319
|
+
sheets.push({
|
|
320
|
+
...sheet,
|
|
321
|
+
columns,
|
|
322
|
+
rows,
|
|
323
|
+
context: { ...request.context, generatedAt: createdAt },
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
const base = exportFileBase(request.listing, request.context.company, createdAt);
|
|
327
|
+
const batches = choices.format === 'xlsx'
|
|
328
|
+
? splitExportSheets(sheets)
|
|
329
|
+
: sheets.flatMap((sheet) => splitExportSheets([sheet]).map((part) => part));
|
|
330
|
+
const files = [];
|
|
331
|
+
const csvOccurrences = new Map();
|
|
332
|
+
const csvTotals = new Map();
|
|
333
|
+
batches.forEach((batch) => {
|
|
334
|
+
const key = batch[0].sheetName;
|
|
335
|
+
csvTotals.set(key, (csvTotals.get(key) ?? 0) + 1);
|
|
336
|
+
});
|
|
337
|
+
for (const [index, batch] of batches.entries()) {
|
|
338
|
+
signal.throwIfAborted();
|
|
339
|
+
const options = {
|
|
340
|
+
workerFactory,
|
|
341
|
+
isCancelled: () => signal.aborted,
|
|
342
|
+
onProgress: (progress) => this.patch(id, {
|
|
343
|
+
progress: {
|
|
344
|
+
...progress,
|
|
345
|
+
part: index + 1,
|
|
346
|
+
parts: batches.length,
|
|
347
|
+
},
|
|
348
|
+
}),
|
|
349
|
+
};
|
|
350
|
+
let name = base;
|
|
351
|
+
if (choices.format === 'csv') {
|
|
352
|
+
const key = batch[0].sheetName;
|
|
353
|
+
const occurrence = (csvOccurrences.get(key) ?? 0) + 1;
|
|
354
|
+
csvOccurrences.set(key, occurrence);
|
|
355
|
+
if (sheets.length > 1)
|
|
356
|
+
name = exportFileBase(`${request.listing}-${key}`, request.context.company, createdAt);
|
|
357
|
+
if (csvTotals.get(key) > 1)
|
|
358
|
+
name += `_parte${occurrence}`;
|
|
359
|
+
}
|
|
360
|
+
else if (batches.length > 1)
|
|
361
|
+
name += `_parte${index + 1}`;
|
|
362
|
+
const workbook = {
|
|
363
|
+
fileName: name,
|
|
364
|
+
sheets: batch,
|
|
365
|
+
created: createdAt,
|
|
366
|
+
creator: request.context.user,
|
|
367
|
+
extension: index === 0 ? prepared.extension : undefined,
|
|
368
|
+
};
|
|
369
|
+
const buffer = choices.format === 'xlsx'
|
|
370
|
+
? await this.excel.generateWorkbook(workbook, options)
|
|
371
|
+
: await this.excel.generateCsv(workbook, options);
|
|
372
|
+
signal.throwIfAborted();
|
|
373
|
+
files.push({
|
|
374
|
+
name: `${name}.${choices.format}`,
|
|
375
|
+
buffer,
|
|
376
|
+
mime: choices.format === 'xlsx'
|
|
377
|
+
? 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
|
378
|
+
: 'text/csv;charset=utf-8',
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
this.patch(id, {
|
|
382
|
+
state: 'ready',
|
|
383
|
+
files,
|
|
384
|
+
recordCount: sheets.reduce((sum, sheet) => sum + sheet.rows.length, 0),
|
|
385
|
+
progress: undefined,
|
|
386
|
+
});
|
|
387
|
+
this.pending.delete(id);
|
|
388
|
+
}
|
|
389
|
+
catch (error) {
|
|
390
|
+
if (signal.aborted || error instanceof ExcelExportCancelledError)
|
|
391
|
+
this.patch(id, { state: 'cancelled', files: [], progress: undefined });
|
|
392
|
+
else
|
|
393
|
+
this.patch(id, {
|
|
394
|
+
state: 'error',
|
|
395
|
+
files: [],
|
|
396
|
+
error: error instanceof Error
|
|
397
|
+
? error.message
|
|
398
|
+
: 'Não foi possível exportar.',
|
|
399
|
+
progress: undefined,
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
finally {
|
|
403
|
+
this.controllers.delete(id);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.21", ngImport: i0, type: MapaExportJobsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
407
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.21", ngImport: i0, type: MapaExportJobsService, providedIn: 'root' }); }
|
|
408
|
+
}
|
|
409
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.21", ngImport: i0, type: MapaExportJobsService, decorators: [{
|
|
410
|
+
type: Injectable,
|
|
411
|
+
args: [{ providedIn: 'root' }]
|
|
412
|
+
}] });
|
|
413
|
+
|
|
414
|
+
class MapaExportDialogComponent {
|
|
415
|
+
constructor() {
|
|
416
|
+
this.request = inject(MAT_DIALOG_DATA);
|
|
417
|
+
this.dialog = inject((MatDialogRef));
|
|
418
|
+
this.jobs = inject(MapaExportJobsService);
|
|
419
|
+
this.selectable = this.request.datasets.some((dataset) => dataset.selectable);
|
|
420
|
+
this.selectedCount = this.request.datasets.reduce((sum, dataset) => sum + (dataset.selectedRows?.length ?? 0), 0);
|
|
421
|
+
this.total = this.request.datasets.reduce((sum, dataset) => sum + dataset.totalCount, 0);
|
|
422
|
+
this.hasHiddenColumns = this.request.datasets.some((dataset) => dataset.columns.some((column) => column.exportable !== false && column.visible === false));
|
|
423
|
+
this.choices = {
|
|
424
|
+
format: 'xlsx',
|
|
425
|
+
visibleOnly: true,
|
|
426
|
+
scope: this.selectable &&
|
|
427
|
+
this.selectedCount &&
|
|
428
|
+
this.request.initialScope === 'selected'
|
|
429
|
+
? 'selected'
|
|
430
|
+
: 'all',
|
|
431
|
+
datasetIds: this.request.datasets.map((dataset) => dataset.id),
|
|
432
|
+
};
|
|
433
|
+
this.error = '';
|
|
434
|
+
}
|
|
435
|
+
get fileName() {
|
|
436
|
+
return `${exportFileBase(this.request.listing, this.request.context.company, new Date())}.${this.choices.format}`;
|
|
437
|
+
}
|
|
438
|
+
toggleDataset(id, checked) {
|
|
439
|
+
this.choices.datasetIds = checked
|
|
440
|
+
? [...this.choices.datasetIds, id]
|
|
441
|
+
: this.choices.datasetIds.filter((value) => value !== id);
|
|
442
|
+
}
|
|
443
|
+
generate() {
|
|
444
|
+
if (!this.choices.datasetIds.length ||
|
|
445
|
+
(this.choices.scope === 'selected' && !this.selectedCount))
|
|
446
|
+
return;
|
|
447
|
+
try {
|
|
448
|
+
this.dialog.close(this.jobs.enqueue(this.request, this.choices));
|
|
449
|
+
}
|
|
450
|
+
catch (error) {
|
|
451
|
+
this.error =
|
|
452
|
+
error instanceof Error
|
|
453
|
+
? error.message
|
|
454
|
+
: 'Não foi possível iniciar a exportação.';
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.21", ngImport: i0, type: MapaExportDialogComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
458
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.21", type: MapaExportDialogComponent, isStandalone: true, selector: "mapa-export-dialog", ngImport: i0, template: "<header class=\"mapa-export__header\">\n <div>\n <h2 mat-dialog-title>Exportar {{ request.listing }}</h2>\n <p>A planilha segue os filtros aplicados na tela.</p>\n </div>\n <button\n class=\"mapa-export__close\"\n type=\"button\"\n aria-label=\"Fechar\"\n (click)=\"dialog.close()\"\n >\n \u00D7\n </button>\n</header>\n<mat-dialog-content class=\"mapa-export__content\">\n <fieldset>\n <legend>O que exportar</legend>\n <mat-radio-group [(ngModel)]=\"choices.scope\" aria-label=\"O que exportar\">\n <mat-radio-button\n value=\"all\"\n class=\"mapa-export__option\"\n [class.mapa-export__option--selected]=\"choices.scope === 'all'\"\n >\n <span class=\"mapa-export__label\">Todos os registros filtrados</span>\n <span class=\"mapa-export__description\">{{\n request.allRecordsDescription ||\n total.toLocaleString(\"pt-BR\") +\n \" registros\" +\n (request.context.filters.length\n ? \" \u00B7 \" + request.context.filters.join(\" \u00B7 \")\n : \"\")\n }}</span>\n </mat-radio-button>\n @if (selectable) {\n <mat-radio-button\n value=\"selected\"\n [disabled]=\"!selectedCount\"\n class=\"mapa-export__option\"\n [class.mapa-export__option--selected]=\"choices.scope === 'selected'\"\n >\n <span class=\"mapa-export__label\">Somente os selecionados</span>\n <span class=\"mapa-export__description\"\n >{{ selectedCount }} registros marcados na lista</span\n >\n </mat-radio-button>\n }\n </mat-radio-group>\n </fieldset>\n @if (request.datasets.length > 1) {\n <fieldset>\n <legend>Conte\u00FAdo do arquivo</legend>\n @for (dataset of request.datasets; track dataset.id) {\n <mat-checkbox\n [checked]=\"choices.datasetIds.includes(dataset.id)\"\n (change)=\"toggleDataset(dataset.id, $event.checked)\"\n >{{ dataset.label }}</mat-checkbox\n >\n }\n </fieldset>\n }\n <fieldset>\n <legend>Formato</legend>\n <mat-radio-group\n class=\"mapa-export__formats\"\n [(ngModel)]=\"choices.format\"\n aria-label=\"Formato\"\n >\n <mat-radio-button\n value=\"xlsx\"\n class=\"mapa-export__option\"\n [class.mapa-export__option--selected]=\"choices.format === 'xlsx'\"\n >\n <span class=\"mapa-export__label\">Excel (.xlsx)</span\n ><span class=\"mapa-export__description\">Com o layout da marca</span>\n </mat-radio-button>\n <mat-radio-button\n value=\"csv\"\n class=\"mapa-export__option\"\n [class.mapa-export__option--selected]=\"choices.format === 'csv'\"\n >\n <span class=\"mapa-export__label\">CSV</span\n ><span class=\"mapa-export__description\"\n >Dados puros, sem formata\u00E7\u00E3o</span\n >\n </mat-radio-button>\n </mat-radio-group>\n </fieldset>\n @if (hasHiddenColumns) {\n <mat-checkbox [(ngModel)]=\"choices.visibleOnly\"\n >Incluir s\u00F3 as colunas vis\u00EDveis na tabela</mat-checkbox\n >\n }\n <p class=\"mapa-export__filename\">{{ fileName }}</p>\n @if (error) {\n <p role=\"alert\">{{ error }}</p>\n }\n</mat-dialog-content>\n<mat-dialog-actions class=\"mapa-export__actions\">\n <button class=\"mapa-export__button\" type=\"button\" (click)=\"dialog.close()\">\n Cancelar\n </button>\n <button\n class=\"mapa-export__button mapa-export__button--primary\"\n type=\"button\"\n [disabled]=\"!choices.datasetIds.length\"\n (click)=\"generate()\"\n >\n Gerar planilha\n </button>\n</mat-dialog-actions>\n", styles: [".mapa-export-dialog-panel{--mat-dialog-container-shape: 16px}mapa-export-dialog{display:block;color:#162f42;font-family:inherit}.mapa-export-dialog-panel mapa-export-dialog .mat-mdc-radio-button{--mat-radio-selected-icon-color: #d94021;--mat-radio-selected-hover-icon-color: #d94021}.mapa-export-dialog-panel mapa-export-dialog .mat-mdc-checkbox{--mat-checkbox-selected-icon-color: #d94021;--mat-checkbox-selected-hover-icon-color: #d94021}.mapa-export__header{display:flex;justify-content:space-between;align-items:flex-start;gap:12px;padding:24px 24px 8px}.mapa-export-dialog-panel .mapa-export__header h2{margin:0;padding:0;font-family:inherit;font-size:20px;font-weight:600;line-height:1.3;color:#162f42}.mapa-export__header h2:before{display:none}.mapa-export__header p{margin:6px 0 0;color:#41566a;font-size:14px}.mapa-export__close{background:transparent;border:0;color:inherit;font-size:26px;min-width:36px;min-height:36px;cursor:pointer}.mapa-export__content{display:flex;flex-direction:column;gap:20px;padding:20px 24px;color:inherit}mapa-export-dialog fieldset{border:0;margin:0;padding:0;min-width:0}mapa-export-dialog legend{margin-bottom:10px;font-size:14px;font-weight:600;color:#162f42}mapa-export-dialog mat-radio-group{display:flex;flex-direction:column;gap:8px}.mapa-export__option{display:block;border:1px solid #dce5e8;border-radius:10px;padding:8px;min-width:0}.mapa-export__option--selected{border-color:#ff560b;background:#ffede6}.mapa-export__label,.mapa-export__description{display:block}.mapa-export__label{font-weight:600;color:#162f42}.mapa-export__description{color:#41566a;font-size:13px;line-height:20px}.mapa-export__formats{display:grid;grid-template-columns:repeat(2,minmax(0,1fr))}.mapa-export__filename{background:#eef3f4;border-radius:10px;padding:12px;margin:0;overflow-wrap:anywhere;font:12px/1.5 monospace}.mapa-export__actions{border-top:1px solid #dce5e8;padding:16px 24px 20px;justify-content:flex-end;gap:8px}.mapa-export__button{min-height:44px;border:1px solid #8299a8;border-radius:8px;padding:0 16px;color:#162f42;background:transparent;font:inherit;font-weight:600;cursor:pointer}.mapa-export__button--primary{background:#d94021;border-color:#d94021;color:#fff}.mapa-export__button:disabled{opacity:.5;cursor:default}mapa-export-dialog button:focus-visible{outline:2px solid #162f42;outline-offset:3px}@media(max-width:440px){.mapa-export__formats{grid-template-columns:1fr}}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: MatDialogModule }, { kind: "directive", type: i2.MatDialogTitle, selector: "[mat-dialog-title], [matDialogTitle]", inputs: ["id"], exportAs: ["matDialogTitle"] }, { kind: "directive", type: i2.MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]", inputs: ["align"] }, { kind: "directive", type: i2.MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { kind: "ngmodule", type: MatCheckboxModule }, { kind: "component", type: i3.MatCheckbox, selector: "mat-checkbox", inputs: ["aria-label", "aria-labelledby", "aria-describedby", "aria-expanded", "aria-controls", "aria-owns", "id", "required", "labelPosition", "name", "value", "disableRipple", "tabIndex", "color", "disabledInteractive", "checked", "disabled", "indeterminate"], outputs: ["change", "indeterminateChange"], exportAs: ["matCheckbox"] }, { kind: "ngmodule", type: MatRadioModule }, { kind: "directive", type: i4.MatRadioGroup, selector: "mat-radio-group", inputs: ["color", "name", "labelPosition", "value", "selected", "disabled", "required", "disabledInteractive"], outputs: ["change"], exportAs: ["matRadioGroup"] }, { kind: "component", type: i4.MatRadioButton, selector: "mat-radio-button", inputs: ["id", "name", "aria-label", "aria-labelledby", "aria-describedby", "disableRipple", "tabIndex", "checked", "value", "labelPosition", "disabled", "required", "color", "disabledInteractive"], outputs: ["change"], exportAs: ["matRadioButton"] }], encapsulation: i0.ViewEncapsulation.None }); }
|
|
459
|
+
}
|
|
460
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.21", ngImport: i0, type: MapaExportDialogComponent, decorators: [{
|
|
461
|
+
type: Component,
|
|
462
|
+
args: [{ selector: 'mapa-export-dialog', standalone: true, encapsulation: ViewEncapsulation.None, imports: [FormsModule, MatDialogModule, MatCheckboxModule, MatRadioModule], template: "<header class=\"mapa-export__header\">\n <div>\n <h2 mat-dialog-title>Exportar {{ request.listing }}</h2>\n <p>A planilha segue os filtros aplicados na tela.</p>\n </div>\n <button\n class=\"mapa-export__close\"\n type=\"button\"\n aria-label=\"Fechar\"\n (click)=\"dialog.close()\"\n >\n \u00D7\n </button>\n</header>\n<mat-dialog-content class=\"mapa-export__content\">\n <fieldset>\n <legend>O que exportar</legend>\n <mat-radio-group [(ngModel)]=\"choices.scope\" aria-label=\"O que exportar\">\n <mat-radio-button\n value=\"all\"\n class=\"mapa-export__option\"\n [class.mapa-export__option--selected]=\"choices.scope === 'all'\"\n >\n <span class=\"mapa-export__label\">Todos os registros filtrados</span>\n <span class=\"mapa-export__description\">{{\n request.allRecordsDescription ||\n total.toLocaleString(\"pt-BR\") +\n \" registros\" +\n (request.context.filters.length\n ? \" \u00B7 \" + request.context.filters.join(\" \u00B7 \")\n : \"\")\n }}</span>\n </mat-radio-button>\n @if (selectable) {\n <mat-radio-button\n value=\"selected\"\n [disabled]=\"!selectedCount\"\n class=\"mapa-export__option\"\n [class.mapa-export__option--selected]=\"choices.scope === 'selected'\"\n >\n <span class=\"mapa-export__label\">Somente os selecionados</span>\n <span class=\"mapa-export__description\"\n >{{ selectedCount }} registros marcados na lista</span\n >\n </mat-radio-button>\n }\n </mat-radio-group>\n </fieldset>\n @if (request.datasets.length > 1) {\n <fieldset>\n <legend>Conte\u00FAdo do arquivo</legend>\n @for (dataset of request.datasets; track dataset.id) {\n <mat-checkbox\n [checked]=\"choices.datasetIds.includes(dataset.id)\"\n (change)=\"toggleDataset(dataset.id, $event.checked)\"\n >{{ dataset.label }}</mat-checkbox\n >\n }\n </fieldset>\n }\n <fieldset>\n <legend>Formato</legend>\n <mat-radio-group\n class=\"mapa-export__formats\"\n [(ngModel)]=\"choices.format\"\n aria-label=\"Formato\"\n >\n <mat-radio-button\n value=\"xlsx\"\n class=\"mapa-export__option\"\n [class.mapa-export__option--selected]=\"choices.format === 'xlsx'\"\n >\n <span class=\"mapa-export__label\">Excel (.xlsx)</span\n ><span class=\"mapa-export__description\">Com o layout da marca</span>\n </mat-radio-button>\n <mat-radio-button\n value=\"csv\"\n class=\"mapa-export__option\"\n [class.mapa-export__option--selected]=\"choices.format === 'csv'\"\n >\n <span class=\"mapa-export__label\">CSV</span\n ><span class=\"mapa-export__description\"\n >Dados puros, sem formata\u00E7\u00E3o</span\n >\n </mat-radio-button>\n </mat-radio-group>\n </fieldset>\n @if (hasHiddenColumns) {\n <mat-checkbox [(ngModel)]=\"choices.visibleOnly\"\n >Incluir s\u00F3 as colunas vis\u00EDveis na tabela</mat-checkbox\n >\n }\n <p class=\"mapa-export__filename\">{{ fileName }}</p>\n @if (error) {\n <p role=\"alert\">{{ error }}</p>\n }\n</mat-dialog-content>\n<mat-dialog-actions class=\"mapa-export__actions\">\n <button class=\"mapa-export__button\" type=\"button\" (click)=\"dialog.close()\">\n Cancelar\n </button>\n <button\n class=\"mapa-export__button mapa-export__button--primary\"\n type=\"button\"\n [disabled]=\"!choices.datasetIds.length\"\n (click)=\"generate()\"\n >\n Gerar planilha\n </button>\n</mat-dialog-actions>\n", styles: [".mapa-export-dialog-panel{--mat-dialog-container-shape: 16px}mapa-export-dialog{display:block;color:#162f42;font-family:inherit}.mapa-export-dialog-panel mapa-export-dialog .mat-mdc-radio-button{--mat-radio-selected-icon-color: #d94021;--mat-radio-selected-hover-icon-color: #d94021}.mapa-export-dialog-panel mapa-export-dialog .mat-mdc-checkbox{--mat-checkbox-selected-icon-color: #d94021;--mat-checkbox-selected-hover-icon-color: #d94021}.mapa-export__header{display:flex;justify-content:space-between;align-items:flex-start;gap:12px;padding:24px 24px 8px}.mapa-export-dialog-panel .mapa-export__header h2{margin:0;padding:0;font-family:inherit;font-size:20px;font-weight:600;line-height:1.3;color:#162f42}.mapa-export__header h2:before{display:none}.mapa-export__header p{margin:6px 0 0;color:#41566a;font-size:14px}.mapa-export__close{background:transparent;border:0;color:inherit;font-size:26px;min-width:36px;min-height:36px;cursor:pointer}.mapa-export__content{display:flex;flex-direction:column;gap:20px;padding:20px 24px;color:inherit}mapa-export-dialog fieldset{border:0;margin:0;padding:0;min-width:0}mapa-export-dialog legend{margin-bottom:10px;font-size:14px;font-weight:600;color:#162f42}mapa-export-dialog mat-radio-group{display:flex;flex-direction:column;gap:8px}.mapa-export__option{display:block;border:1px solid #dce5e8;border-radius:10px;padding:8px;min-width:0}.mapa-export__option--selected{border-color:#ff560b;background:#ffede6}.mapa-export__label,.mapa-export__description{display:block}.mapa-export__label{font-weight:600;color:#162f42}.mapa-export__description{color:#41566a;font-size:13px;line-height:20px}.mapa-export__formats{display:grid;grid-template-columns:repeat(2,minmax(0,1fr))}.mapa-export__filename{background:#eef3f4;border-radius:10px;padding:12px;margin:0;overflow-wrap:anywhere;font:12px/1.5 monospace}.mapa-export__actions{border-top:1px solid #dce5e8;padding:16px 24px 20px;justify-content:flex-end;gap:8px}.mapa-export__button{min-height:44px;border:1px solid #8299a8;border-radius:8px;padding:0 16px;color:#162f42;background:transparent;font:inherit;font-weight:600;cursor:pointer}.mapa-export__button--primary{background:#d94021;border-color:#d94021;color:#fff}.mapa-export__button:disabled{opacity:.5;cursor:default}mapa-export-dialog button:focus-visible{outline:2px solid #162f42;outline-offset:3px}@media(max-width:440px){.mapa-export__formats{grid-template-columns:1fr}}\n"] }]
|
|
463
|
+
}] });
|
|
464
|
+
|
|
465
|
+
class MapaExportDialogService {
|
|
466
|
+
constructor() {
|
|
467
|
+
this.dialog = inject(MatDialog);
|
|
468
|
+
}
|
|
469
|
+
open(request) {
|
|
470
|
+
if (this.ref)
|
|
471
|
+
return this.ref;
|
|
472
|
+
const ref = this.dialog.open(MapaExportDialogComponent, {
|
|
473
|
+
data: snapshotExportRequest(request),
|
|
474
|
+
width: '560px',
|
|
475
|
+
maxWidth: 'calc(100vw - 32px)',
|
|
476
|
+
maxHeight: 'calc(100dvh - 32px)',
|
|
477
|
+
autoFocus: 'first-tabbable',
|
|
478
|
+
restoreFocus: true,
|
|
479
|
+
ariaLabel: `Exportar ${request.listing}`,
|
|
480
|
+
panelClass: 'mapa-export-dialog-panel',
|
|
481
|
+
});
|
|
482
|
+
this.ref = ref;
|
|
483
|
+
ref.afterClosed().subscribe(() => {
|
|
484
|
+
if (this.ref === ref)
|
|
485
|
+
this.ref = undefined;
|
|
486
|
+
});
|
|
487
|
+
return ref;
|
|
488
|
+
}
|
|
489
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.21", ngImport: i0, type: MapaExportDialogService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
490
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.21", ngImport: i0, type: MapaExportDialogService, providedIn: 'root' }); }
|
|
491
|
+
}
|
|
492
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.21", ngImport: i0, type: MapaExportDialogService, decorators: [{
|
|
493
|
+
type: Injectable,
|
|
494
|
+
args: [{ providedIn: 'root' }]
|
|
495
|
+
}] });
|
|
496
|
+
|
|
497
|
+
class MapaExportJobsComponent {
|
|
498
|
+
constructor() {
|
|
499
|
+
this.jobs = inject(MapaExportJobsService);
|
|
500
|
+
}
|
|
501
|
+
percent(task) {
|
|
502
|
+
const progress = task.progress;
|
|
503
|
+
return progress?.total && progress.completed !== undefined
|
|
504
|
+
? Math.min(100, Math.round((progress.completed / progress.total) * 100))
|
|
505
|
+
: null;
|
|
506
|
+
}
|
|
507
|
+
phase(task) {
|
|
508
|
+
const text = task.state === 'queued'
|
|
509
|
+
? 'Aguardando na fila…'
|
|
510
|
+
: task.progress?.phase === 'fetching'
|
|
511
|
+
? 'Obtendo os registros…'
|
|
512
|
+
: task.progress?.phase === 'serializing'
|
|
513
|
+
? 'Compactando arquivo…'
|
|
514
|
+
: 'Gerando planilha…';
|
|
515
|
+
return (text +
|
|
516
|
+
(task.progress?.parts && task.progress.parts > 1
|
|
517
|
+
? ` Parte ${task.progress.part} de ${task.progress.parts}`
|
|
518
|
+
: ''));
|
|
519
|
+
}
|
|
520
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.21", ngImport: i0, type: MapaExportJobsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
521
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.21", type: MapaExportJobsComponent, isStandalone: true, selector: "mapa-export-jobs", ngImport: i0, template: "@if (jobs.tasks().length) {\n <aside class=\"mapa-export-jobs\" aria-label=\"Exporta\u00E7\u00F5es\">\n @for (task of jobs.tasks(); track task.id) {\n <section class=\"mapa-export-jobs__task\" [attr.aria-label]=\"task.title\">\n <header>\n <strong>{{ task.title }}</strong>\n @if (task.state === \"running\" || task.state === \"queued\") {\n <button type=\"button\" (click)=\"jobs.cancel(task.id)\">\n Cancelar\n </button>\n } @else {\n <button\n type=\"button\"\n (click)=\"jobs.remove(task.id)\"\n [attr.aria-label]=\"'Remover exporta\u00E7\u00E3o ' + task.title\"\n >\n \u00D7\n </button>\n }\n </header>\n @if (task.state === \"running\" || task.state === \"queued\") {\n <p role=\"status\">\n {{ phase(task) }}\n @if (percent(task) !== null) {\n {{ percent(task) }}%\n }\n </p>\n <mat-progress-bar\n [mode]=\"percent(task) === null ? 'indeterminate' : 'determinate'\"\n [value]=\"percent(task) ?? 0\"\n [attr.aria-label]=\"phase(task)\"\n />\n @if (task.background) {\n <p class=\"mapa-export-jobs__hint\">\n Gerando em segundo plano. Voc\u00EA pode continuar usando a plataforma.\n </p>\n }\n } @else if (task.state === \"ready\") {\n <p role=\"status\">\n Planilha pronta: {{ task.recordCount?.toLocaleString(\"pt-BR\") }}\n {{ task.recordCount === 1 ? \"registro\" : \"registros\" }}.\n {{ task.files.length }}\n {{\n task.files.length === 1\n ? \"arquivo dispon\u00EDvel\"\n : \"arquivos dispon\u00EDveis\"\n }}.\n </p>\n @for (file of task.files; track file.name) {\n <div class=\"mapa-export-jobs__file\">\n <span>{{ file.name }}</span\n ><button\n type=\"button\"\n (click)=\"jobs.download(file)\"\n [attr.aria-label]=\"'Baixar ' + file.name\"\n >\n Baixar\n </button>\n </div>\n }\n } @else if (task.state === \"error\") {\n <p role=\"alert\">{{ task.error }}</p>\n <button type=\"button\" (click)=\"jobs.retry(task.id)\">\n Tentar novamente\n </button>\n } @else {\n <p role=\"status\">Exporta\u00E7\u00E3o cancelada.</p>\n }\n </section>\n }\n </aside>\n}\n", styles: [":host{font-family:inherit}.mapa-export-jobs mat-progress-bar{--mat-progress-bar-active-indicator-color: #ff560b;--mat-progress-bar-track-color: #e4eef0}.mapa-export-jobs{position:fixed;z-index:900;right:24px;bottom:24px;width:420px;max-width:calc(100vw - 32px);max-height:55dvh;overflow-y:auto;display:flex;flex-direction:column;gap:12px}.mapa-export-jobs__task{background:#fff;color:#162f42;border:1px solid #dce5e8;border-radius:12px;padding:16px;box-shadow:0 8px 24px #162f4220}header{display:flex;justify-content:space-between;align-items:center;gap:12px}p{margin:12px 0}.mapa-export-jobs__hint{color:#41566a;font-size:13px}.mapa-export-jobs__file{display:flex;align-items:center;gap:12px;margin-top:10px}.mapa-export-jobs__file span{flex:1;min-width:0;overflow-wrap:anywhere;font-size:13px}button{min-height:36px;padding:4px 12px;border:1px solid #8299a8;border-radius:8px;background:transparent;color:inherit;font:inherit;font-weight:600;cursor:pointer}button:focus-visible{outline:2px solid #d94021;outline-offset:2px}@media(max-width:600px){.mapa-export-jobs{right:16px;bottom:16px}}\n"], dependencies: [{ kind: "ngmodule", type: MatProgressBarModule }, { kind: "component", type: i1$1.MatProgressBar, selector: "mat-progress-bar", inputs: ["color", "value", "bufferValue", "mode"], outputs: ["animationEnd"], exportAs: ["matProgressBar"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
522
|
+
}
|
|
523
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.21", ngImport: i0, type: MapaExportJobsComponent, decorators: [{
|
|
524
|
+
type: Component,
|
|
525
|
+
args: [{ selector: 'mapa-export-jobs', standalone: true, imports: [MatProgressBarModule], changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (jobs.tasks().length) {\n <aside class=\"mapa-export-jobs\" aria-label=\"Exporta\u00E7\u00F5es\">\n @for (task of jobs.tasks(); track task.id) {\n <section class=\"mapa-export-jobs__task\" [attr.aria-label]=\"task.title\">\n <header>\n <strong>{{ task.title }}</strong>\n @if (task.state === \"running\" || task.state === \"queued\") {\n <button type=\"button\" (click)=\"jobs.cancel(task.id)\">\n Cancelar\n </button>\n } @else {\n <button\n type=\"button\"\n (click)=\"jobs.remove(task.id)\"\n [attr.aria-label]=\"'Remover exporta\u00E7\u00E3o ' + task.title\"\n >\n \u00D7\n </button>\n }\n </header>\n @if (task.state === \"running\" || task.state === \"queued\") {\n <p role=\"status\">\n {{ phase(task) }}\n @if (percent(task) !== null) {\n {{ percent(task) }}%\n }\n </p>\n <mat-progress-bar\n [mode]=\"percent(task) === null ? 'indeterminate' : 'determinate'\"\n [value]=\"percent(task) ?? 0\"\n [attr.aria-label]=\"phase(task)\"\n />\n @if (task.background) {\n <p class=\"mapa-export-jobs__hint\">\n Gerando em segundo plano. Voc\u00EA pode continuar usando a plataforma.\n </p>\n }\n } @else if (task.state === \"ready\") {\n <p role=\"status\">\n Planilha pronta: {{ task.recordCount?.toLocaleString(\"pt-BR\") }}\n {{ task.recordCount === 1 ? \"registro\" : \"registros\" }}.\n {{ task.files.length }}\n {{\n task.files.length === 1\n ? \"arquivo dispon\u00EDvel\"\n : \"arquivos dispon\u00EDveis\"\n }}.\n </p>\n @for (file of task.files; track file.name) {\n <div class=\"mapa-export-jobs__file\">\n <span>{{ file.name }}</span\n ><button\n type=\"button\"\n (click)=\"jobs.download(file)\"\n [attr.aria-label]=\"'Baixar ' + file.name\"\n >\n Baixar\n </button>\n </div>\n }\n } @else if (task.state === \"error\") {\n <p role=\"alert\">{{ task.error }}</p>\n <button type=\"button\" (click)=\"jobs.retry(task.id)\">\n Tentar novamente\n </button>\n } @else {\n <p role=\"status\">Exporta\u00E7\u00E3o cancelada.</p>\n }\n </section>\n }\n </aside>\n}\n", styles: [":host{font-family:inherit}.mapa-export-jobs mat-progress-bar{--mat-progress-bar-active-indicator-color: #ff560b;--mat-progress-bar-track-color: #e4eef0}.mapa-export-jobs{position:fixed;z-index:900;right:24px;bottom:24px;width:420px;max-width:calc(100vw - 32px);max-height:55dvh;overflow-y:auto;display:flex;flex-direction:column;gap:12px}.mapa-export-jobs__task{background:#fff;color:#162f42;border:1px solid #dce5e8;border-radius:12px;padding:16px;box-shadow:0 8px 24px #162f4220}header{display:flex;justify-content:space-between;align-items:center;gap:12px}p{margin:12px 0}.mapa-export-jobs__hint{color:#41566a;font-size:13px}.mapa-export-jobs__file{display:flex;align-items:center;gap:12px;margin-top:10px}.mapa-export-jobs__file span{flex:1;min-width:0;overflow-wrap:anywhere;font-size:13px}button{min-height:36px;padding:4px 12px;border:1px solid #8299a8;border-radius:8px;background:transparent;color:inherit;font:inherit;font-weight:600;cursor:pointer}button:focus-visible{outline:2px solid #d94021;outline-offset:2px}@media(max-width:600px){.mapa-export-jobs{right:16px;bottom:16px}}\n"] }]
|
|
526
|
+
}] });
|
|
527
|
+
|
|
528
|
+
/** Lets a host keep export requests out of its blocking, global loading overlay. */
|
|
529
|
+
const MAPA_EXPORT_BACKGROUND_REQUEST = new HttpContextToken(() => false);
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Generated bundle index. Do not edit.
|
|
533
|
+
*/
|
|
534
|
+
|
|
535
|
+
export { EXPORT_FILE_ROW_LIMIT, MAPA_EXPORT_BACKGROUND_REQUEST, MAPA_EXPORT_WORKER_FACTORY, MapaExportDialogService, MapaExportJobsComponent, MapaExportJobsService, collectExportPages, encodeExportCsv, exportFileBase, exportSlug, snapshotExportRequest, splitExportSheets, toExportDate };
|
|
536
|
+
//# sourceMappingURL=mapa-library-ui-src-lib-core-export.mjs.map
|