@fluxo-dev/shell-reporting 25.4.3 → 26.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.esm.js +5671 -9
- package/package.json +4 -4
- package/src/index.d.ts +5 -1
- package/src/lib/print-report-button/index.d.ts +2 -0
- package/src/lib/print-report-button/print-report-button.d.ts +24 -0
- package/src/lib/print-report-button/print-report-configuration.d.ts +18 -0
- package/src/lib/reports-manager/reports-manager.d.ts +1 -1
- package/index.esm2.js +0 -4326
- package/reports-manager.esm.js +0 -694
- package/src/lib/fluxo-module.d.ts +0 -2
- package/src/lib/reports-manager/reports-navigation.d.ts +0 -3
package/reports-manager.esm.js
DELETED
|
@@ -1,694 +0,0 @@
|
|
|
1
|
-
import { c as createReactComponent, p as promiseNativeConstructor, f as fails$1, _ as _export, s as speciesConstructor$1, g as getBuiltIn$1, a as promiseResolve$1, i as isCallable$1, d as defineBuiltIn$1, R as ReportDesigner } from './index.esm2.js';
|
|
2
|
-
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
3
|
-
import { Stack, Text, TextInput, Textarea, Group, Button, Paper, Skeleton, Center, Select, Badge, Menu, ActionIcon, Modal } from '@mantine/core';
|
|
4
|
-
import { useState, useEffect, useRef, useCallback } from 'react';
|
|
5
|
-
import { FluxoClientSys } from '@fluxo-dev/api-client-base';
|
|
6
|
-
import { useNavigate } from 'react-router-dom';
|
|
7
|
-
import { showNotification } from '@mantine/notifications';
|
|
8
|
-
import { ShellPage, ConfirmModal } from '@fluxo-dev/ui-components';
|
|
9
|
-
import '@mantine/dates';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @license @tabler/icons-react v3.36.0 - MIT
|
|
13
|
-
*
|
|
14
|
-
* This source code is licensed under the MIT license.
|
|
15
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const __iconNode$6 = [["path", { "d": "M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0", "key": "svg-0" }], ["path", { "d": "M12 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0", "key": "svg-1" }], ["path", { "d": "M12 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0", "key": "svg-2" }]];
|
|
20
|
-
const IconDotsVertical = createReactComponent("outline", "dots-vertical", "DotsVertical", __iconNode$6);
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* @license @tabler/icons-react v3.36.0 - MIT
|
|
24
|
-
*
|
|
25
|
-
* This source code is licensed under the MIT license.
|
|
26
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const __iconNode$5 = [["path", { "d": "M7 7h-1a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-1", "key": "svg-0" }], ["path", { "d": "M20.385 6.585a2.1 2.1 0 0 0 -2.97 -2.97l-8.415 8.385v3h3l8.385 -8.415z", "key": "svg-1" }], ["path", { "d": "M16 5l3 3", "key": "svg-2" }]];
|
|
31
|
-
const IconEdit = createReactComponent("outline", "edit", "Edit", __iconNode$5);
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* @license @tabler/icons-react v3.36.0 - MIT
|
|
35
|
-
*
|
|
36
|
-
* This source code is licensed under the MIT license.
|
|
37
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
38
|
-
*/
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const __iconNode$4 = [["path", { "d": "M12 6h-6a2 2 0 0 0 -2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-6", "key": "svg-0" }], ["path", { "d": "M11 13l9 -9", "key": "svg-1" }], ["path", { "d": "M15 4h5v5", "key": "svg-2" }]];
|
|
42
|
-
const IconExternalLink = createReactComponent("outline", "external-link", "ExternalLink", __iconNode$4);
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* @license @tabler/icons-react v3.36.0 - MIT
|
|
46
|
-
*
|
|
47
|
-
* This source code is licensed under the MIT license.
|
|
48
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
49
|
-
*/
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const __iconNode$3 = [["path", { "d": "M5 4h4l3 3h7a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2", "key": "svg-0" }]];
|
|
53
|
-
const IconFolder = createReactComponent("outline", "folder", "Folder", __iconNode$3);
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* @license @tabler/icons-react v3.36.0 - MIT
|
|
57
|
-
*
|
|
58
|
-
* This source code is licensed under the MIT license.
|
|
59
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
60
|
-
*/
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const __iconNode$2 = [["path", { "d": "M12 5l0 14", "key": "svg-0" }], ["path", { "d": "M5 12l14 0", "key": "svg-1" }]];
|
|
64
|
-
const IconPlus = createReactComponent("outline", "plus", "Plus", __iconNode$2);
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* @license @tabler/icons-react v3.36.0 - MIT
|
|
68
|
-
*
|
|
69
|
-
* This source code is licensed under the MIT license.
|
|
70
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
71
|
-
*/
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const __iconNode$1 = [["path", { "d": "M8 5h-2a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h5.697", "key": "svg-0" }], ["path", { "d": "M18 14v4h4", "key": "svg-1" }], ["path", { "d": "M18 11v-4a2 2 0 0 0 -2 -2h-2", "key": "svg-2" }], ["path", { "d": "M8 3m0 2a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v0a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2z", "key": "svg-3" }], ["path", { "d": "M18 18m-4 0a4 4 0 1 0 8 0a4 4 0 1 0 -8 0", "key": "svg-4" }], ["path", { "d": "M8 11h4", "key": "svg-5" }], ["path", { "d": "M8 15h3", "key": "svg-6" }]];
|
|
75
|
-
const IconReport = createReactComponent("outline", "report", "Report", __iconNode$1);
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* @license @tabler/icons-react v3.36.0 - MIT
|
|
79
|
-
*
|
|
80
|
-
* This source code is licensed under the MIT license.
|
|
81
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
82
|
-
*/
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const __iconNode = [["path", { "d": "M4 7l16 0", "key": "svg-0" }], ["path", { "d": "M10 11l0 6", "key": "svg-1" }], ["path", { "d": "M14 11l0 6", "key": "svg-2" }], ["path", { "d": "M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12", "key": "svg-3" }], ["path", { "d": "M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3", "key": "svg-4" }]];
|
|
86
|
-
const IconTrash = createReactComponent("outline", "trash", "Trash", __iconNode);
|
|
87
|
-
|
|
88
|
-
var $ = _export;
|
|
89
|
-
var NativePromiseConstructor = promiseNativeConstructor;
|
|
90
|
-
var fails = fails$1;
|
|
91
|
-
var getBuiltIn = getBuiltIn$1;
|
|
92
|
-
var isCallable = isCallable$1;
|
|
93
|
-
var speciesConstructor = speciesConstructor$1;
|
|
94
|
-
var promiseResolve = promiseResolve$1;
|
|
95
|
-
var defineBuiltIn = defineBuiltIn$1;
|
|
96
|
-
|
|
97
|
-
var NativePromisePrototype = NativePromiseConstructor && NativePromiseConstructor.prototype;
|
|
98
|
-
|
|
99
|
-
// Safari bug https://bugs.webkit.org/show_bug.cgi?id=200829
|
|
100
|
-
var NON_GENERIC = !!NativePromiseConstructor && fails(function () {
|
|
101
|
-
// eslint-disable-next-line unicorn/no-thenable -- required for testing
|
|
102
|
-
NativePromisePrototype['finally'].call({ then: function () { /* empty */ } }, function () { /* empty */ });
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
// `Promise.prototype.finally` method
|
|
106
|
-
// https://tc39.es/ecma262/#sec-promise.prototype.finally
|
|
107
|
-
$({ target: 'Promise', proto: true, real: true, forced: NON_GENERIC }, {
|
|
108
|
-
'finally': function (onFinally) {
|
|
109
|
-
var C = speciesConstructor(this, getBuiltIn('Promise'));
|
|
110
|
-
var isFunction = isCallable(onFinally);
|
|
111
|
-
return this.then(
|
|
112
|
-
isFunction ? function (x) {
|
|
113
|
-
return promiseResolve(C, onFinally()).then(function () { return x; });
|
|
114
|
-
} : onFinally,
|
|
115
|
-
isFunction ? function (e) {
|
|
116
|
-
return promiseResolve(C, onFinally()).then(function () { throw e; });
|
|
117
|
-
} : onFinally
|
|
118
|
-
);
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
// makes sure that native promise-based APIs `Promise#finally` properly works with patched `Promise#then`
|
|
123
|
-
if (isCallable(NativePromiseConstructor)) {
|
|
124
|
-
var method = getBuiltIn('Promise').prototype['finally'];
|
|
125
|
-
if (NativePromisePrototype['finally'] !== method) {
|
|
126
|
-
defineBuiltIn(NativePromisePrototype, 'finally', method, { unsafe: true });
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
function CreateReport(props) {
|
|
131
|
-
const [name, setName] = useState(props.initialName || '');
|
|
132
|
-
const [note, setNote] = useState(props.initialNote || '');
|
|
133
|
-
const [loading, setLoading] = useState(false);
|
|
134
|
-
const isEditMode = props.mode === 'edit';
|
|
135
|
-
useEffect(() => {
|
|
136
|
-
if (props.initialName) setName(props.initialName);
|
|
137
|
-
if (props.initialNote) setNote(props.initialNote);
|
|
138
|
-
}, [props.initialName, props.initialNote]);
|
|
139
|
-
const createReport = () => {
|
|
140
|
-
if (!name) return;
|
|
141
|
-
const command = {
|
|
142
|
-
name: name,
|
|
143
|
-
annotations: note,
|
|
144
|
-
scope: props.scope,
|
|
145
|
-
packageName: props.packageName,
|
|
146
|
-
namespace: props.namespace,
|
|
147
|
-
id: props.id
|
|
148
|
-
};
|
|
149
|
-
setLoading(true);
|
|
150
|
-
FluxoClientSys.Instance.reporting.createReport(command).then(res => {
|
|
151
|
-
showNotification({
|
|
152
|
-
title: 'Report creato',
|
|
153
|
-
message: 'Il report è stato creato con successo',
|
|
154
|
-
color: 'teal'
|
|
155
|
-
});
|
|
156
|
-
props.onCreated(res);
|
|
157
|
-
}).catch(err => {
|
|
158
|
-
showNotification({
|
|
159
|
-
title: 'Errore',
|
|
160
|
-
message: 'Si è verificato un errore durante la creazione del report',
|
|
161
|
-
color: 'red'
|
|
162
|
-
});
|
|
163
|
-
}).finally(() => {
|
|
164
|
-
setLoading(false);
|
|
165
|
-
});
|
|
166
|
-
};
|
|
167
|
-
const updateReport = () => {
|
|
168
|
-
if (!name || !props.reportId) return;
|
|
169
|
-
setLoading(true);
|
|
170
|
-
FluxoClientSys.Instance.reporting.updateReport(props.reportId, {
|
|
171
|
-
name: name,
|
|
172
|
-
annotations: note
|
|
173
|
-
}).then(() => {
|
|
174
|
-
var _a;
|
|
175
|
-
showNotification({
|
|
176
|
-
title: 'Report aggiornato',
|
|
177
|
-
message: 'Il report è stato aggiornato con successo',
|
|
178
|
-
color: 'teal'
|
|
179
|
-
});
|
|
180
|
-
(_a = props.onUpdated) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
181
|
-
}).catch(err => {
|
|
182
|
-
showNotification({
|
|
183
|
-
title: 'Errore',
|
|
184
|
-
message: 'Si è verificato un errore durante l\'aggiornamento del report',
|
|
185
|
-
color: 'red'
|
|
186
|
-
});
|
|
187
|
-
}).finally(() => {
|
|
188
|
-
setLoading(false);
|
|
189
|
-
});
|
|
190
|
-
};
|
|
191
|
-
const handleSubmit = () => {
|
|
192
|
-
if (isEditMode) {
|
|
193
|
-
updateReport();
|
|
194
|
-
} else {
|
|
195
|
-
createReport();
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
return jsxs(Stack, {
|
|
199
|
-
children: [!isEditMode && jsxs(Fragment, {
|
|
200
|
-
children: [jsxs(Text, {
|
|
201
|
-
children: [jsx("b", {
|
|
202
|
-
children: "Nome:"
|
|
203
|
-
}), " ", props.name]
|
|
204
|
-
}), jsxs(Text, {
|
|
205
|
-
children: [jsx("b", {
|
|
206
|
-
children: "Categoria:"
|
|
207
|
-
}), " ", props.scope, ".", props.packageName, ".", props.namespace, ".", props.id]
|
|
208
|
-
})]
|
|
209
|
-
}), jsx(TextInput, {
|
|
210
|
-
disabled: loading,
|
|
211
|
-
label: 'Nome report',
|
|
212
|
-
value: name,
|
|
213
|
-
onChange: v => setName(v.target.value)
|
|
214
|
-
}), jsx(Textarea, {
|
|
215
|
-
disabled: loading,
|
|
216
|
-
label: 'Note',
|
|
217
|
-
value: note,
|
|
218
|
-
onChange: v => setNote(v.target.value)
|
|
219
|
-
}), jsxs(Group, {
|
|
220
|
-
justify: 'right',
|
|
221
|
-
children: [jsx(Button, {
|
|
222
|
-
disabled: loading,
|
|
223
|
-
onClick: props.onCancel,
|
|
224
|
-
variant: 'subtle',
|
|
225
|
-
children: "Annulla"
|
|
226
|
-
}), jsx(Button, {
|
|
227
|
-
onClick: handleSubmit,
|
|
228
|
-
disabled: !name || loading,
|
|
229
|
-
children: isEditMode ? 'Salva' : 'Crea'
|
|
230
|
-
})]
|
|
231
|
-
})]
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
function ReportsManager() {
|
|
236
|
-
const [reportsList, setReportsList] = useState([]);
|
|
237
|
-
const [loading, setLoading] = useState(true);
|
|
238
|
-
useNavigate();
|
|
239
|
-
// Refactored state management
|
|
240
|
-
const [selectedCategory, setSelectedCategory] = useState(null);
|
|
241
|
-
const [selectedReport, setSelectedReport] = useState(null);
|
|
242
|
-
const [selectedCategoryKey, setSelectedCategoryKey] = useState(null);
|
|
243
|
-
const [modals, setModals] = useState({
|
|
244
|
-
create: false,
|
|
245
|
-
delete: false,
|
|
246
|
-
edit: false,
|
|
247
|
-
reportEditor: false
|
|
248
|
-
});
|
|
249
|
-
const [editingReportId, setEditingReportId] = useState(null);
|
|
250
|
-
const [editingReport, setEditingReport] = useState(null);
|
|
251
|
-
const isClosingRef = useRef(false);
|
|
252
|
-
useEffect(() => {
|
|
253
|
-
refresh();
|
|
254
|
-
}, []);
|
|
255
|
-
useEffect(() => {
|
|
256
|
-
// Auto-select first category when data loads
|
|
257
|
-
if (reportsList.length > 0 && !selectedCategoryKey) {
|
|
258
|
-
const firstCategory = reportsList[0];
|
|
259
|
-
setSelectedCategoryKey(`${firstCategory.scope}-${firstCategory.reportTypeId}`);
|
|
260
|
-
}
|
|
261
|
-
}, [reportsList, selectedCategoryKey]);
|
|
262
|
-
// Intercetta il refresh e il cambio tab del browser
|
|
263
|
-
useEffect(() => {
|
|
264
|
-
if (!modals.reportEditor) return;
|
|
265
|
-
const handleBeforeUnload = e => {
|
|
266
|
-
e.preventDefault();
|
|
267
|
-
e.returnValue = 'Sei sicuro di voler uscire? Le modifiche non salvate andranno perse.';
|
|
268
|
-
return e.returnValue;
|
|
269
|
-
};
|
|
270
|
-
window.addEventListener('beforeunload', handleBeforeUnload);
|
|
271
|
-
return () => window.removeEventListener('beforeunload', handleBeforeUnload);
|
|
272
|
-
}, [modals.reportEditor]);
|
|
273
|
-
// Intercetta la navigazione nel router (back button del browser)
|
|
274
|
-
useEffect(() => {
|
|
275
|
-
if (!modals.reportEditor) return;
|
|
276
|
-
const handlePopState = () => {
|
|
277
|
-
if (!isClosingRef.current) {
|
|
278
|
-
const confirmExit = window.confirm('Sei sicuro di voler uscire dall\'editor? Le modifiche non salvate andranno perse.');
|
|
279
|
-
if (!confirmExit) {
|
|
280
|
-
window.history.pushState(null, '', window.location.href);
|
|
281
|
-
} else {
|
|
282
|
-
setModals(prev => Object.assign(Object.assign({}, prev), {
|
|
283
|
-
reportEditor: false
|
|
284
|
-
}));
|
|
285
|
-
setEditingReportId(null);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
};
|
|
289
|
-
// Aggiungi uno stato alla history per intercettare il back button
|
|
290
|
-
window.history.pushState(null, '', window.location.href);
|
|
291
|
-
window.addEventListener('popstate', handlePopState);
|
|
292
|
-
return () => {
|
|
293
|
-
window.removeEventListener('popstate', handlePopState);
|
|
294
|
-
};
|
|
295
|
-
}, [modals.reportEditor]);
|
|
296
|
-
const refresh = () => {
|
|
297
|
-
FluxoClientSys.Instance.reporting.getReportsList().then(res => {
|
|
298
|
-
setReportsList(res);
|
|
299
|
-
setLoading(false);
|
|
300
|
-
});
|
|
301
|
-
};
|
|
302
|
-
// Helper functions for modal management
|
|
303
|
-
const openCreateModal = category => {
|
|
304
|
-
setSelectedCategory(category);
|
|
305
|
-
setModals(prev => Object.assign(Object.assign({}, prev), {
|
|
306
|
-
create: true
|
|
307
|
-
}));
|
|
308
|
-
};
|
|
309
|
-
const closeCreateModal = () => {
|
|
310
|
-
setSelectedCategory(null);
|
|
311
|
-
setModals(prev => Object.assign(Object.assign({}, prev), {
|
|
312
|
-
create: false
|
|
313
|
-
}));
|
|
314
|
-
};
|
|
315
|
-
const openEditModal = (report, category) => {
|
|
316
|
-
setEditingReport({
|
|
317
|
-
id: report.id,
|
|
318
|
-
name: report.name,
|
|
319
|
-
annotations: report.annotations || '',
|
|
320
|
-
scope: category.scope,
|
|
321
|
-
packageName: category.packageName,
|
|
322
|
-
namespace: category.namespace,
|
|
323
|
-
reportTypeId: category.reportTypeId,
|
|
324
|
-
categoryName: category.name
|
|
325
|
-
});
|
|
326
|
-
setModals(prev => Object.assign(Object.assign({}, prev), {
|
|
327
|
-
edit: true
|
|
328
|
-
}));
|
|
329
|
-
};
|
|
330
|
-
const closeEditModal = () => {
|
|
331
|
-
setEditingReport(null);
|
|
332
|
-
setModals(prev => Object.assign(Object.assign({}, prev), {
|
|
333
|
-
edit: false
|
|
334
|
-
}));
|
|
335
|
-
};
|
|
336
|
-
const openDeleteModal = report => {
|
|
337
|
-
setSelectedReport(report);
|
|
338
|
-
setModals(prev => Object.assign(Object.assign({}, prev), {
|
|
339
|
-
delete: true
|
|
340
|
-
}));
|
|
341
|
-
};
|
|
342
|
-
const closeDeleteModal = () => {
|
|
343
|
-
setSelectedReport(null);
|
|
344
|
-
setModals(prev => Object.assign(Object.assign({}, prev), {
|
|
345
|
-
delete: false
|
|
346
|
-
}));
|
|
347
|
-
};
|
|
348
|
-
const openReportEditor = reportId => {
|
|
349
|
-
setEditingReportId(reportId);
|
|
350
|
-
setModals(prev => Object.assign(Object.assign({}, prev), {
|
|
351
|
-
reportEditor: true
|
|
352
|
-
}));
|
|
353
|
-
};
|
|
354
|
-
const handleCloseReportEditor = useCallback(() => {
|
|
355
|
-
const confirmClose = window.confirm('Sei sicuro di voler chiudere l\'editor? Le modifiche non salvate andranno perse.');
|
|
356
|
-
if (confirmClose) {
|
|
357
|
-
isClosingRef.current = true;
|
|
358
|
-
setModals(prev => Object.assign(Object.assign({}, prev), {
|
|
359
|
-
reportEditor: false
|
|
360
|
-
}));
|
|
361
|
-
setEditingReportId(null);
|
|
362
|
-
// Reset del flag dopo un breve delay
|
|
363
|
-
setTimeout(() => {
|
|
364
|
-
isClosingRef.current = false;
|
|
365
|
-
}, 100);
|
|
366
|
-
}
|
|
367
|
-
}, []);
|
|
368
|
-
const deleteReport = () => {
|
|
369
|
-
if (!(selectedReport === null || selectedReport === void 0 ? void 0 : selectedReport.id)) return;
|
|
370
|
-
FluxoClientSys.Instance.reporting.deleteReport(selectedReport.id).then(() => {
|
|
371
|
-
showNotification({
|
|
372
|
-
title: 'Report eliminato',
|
|
373
|
-
message: 'Il report è stato eliminato con successo',
|
|
374
|
-
color: 'green'
|
|
375
|
-
});
|
|
376
|
-
refresh();
|
|
377
|
-
}).catch(() => {
|
|
378
|
-
showNotification({
|
|
379
|
-
title: 'Errore',
|
|
380
|
-
message: 'Si è verificato un errore durante l\'eliminazione del report',
|
|
381
|
-
color: 'red'
|
|
382
|
-
});
|
|
383
|
-
}).finally(() => {
|
|
384
|
-
closeDeleteModal();
|
|
385
|
-
});
|
|
386
|
-
};
|
|
387
|
-
// Get currently selected category data
|
|
388
|
-
const getCurrentCategory = () => {
|
|
389
|
-
if (!selectedCategoryKey) return null;
|
|
390
|
-
return reportsList.find(cat => `${cat.scope}-${cat.packageName}-${cat.namespace}-${cat.reportTypeId}` === selectedCategoryKey);
|
|
391
|
-
};
|
|
392
|
-
const currentCategory = getCurrentCategory();
|
|
393
|
-
return jsxs(ShellPage, {
|
|
394
|
-
headerProps: {
|
|
395
|
-
title: 'Reports'
|
|
396
|
-
},
|
|
397
|
-
children: [loading ? jsx(Stack, {
|
|
398
|
-
gap: "sm",
|
|
399
|
-
maw: 1280,
|
|
400
|
-
m: '0 auto',
|
|
401
|
-
children: [1, 2, 3].map(i => jsxs(Paper, {
|
|
402
|
-
p: "sm",
|
|
403
|
-
withBorder: true,
|
|
404
|
-
children: [jsxs(Group, {
|
|
405
|
-
justify: "space-between",
|
|
406
|
-
mb: "xs",
|
|
407
|
-
children: [jsx(Skeleton, {
|
|
408
|
-
height: 20,
|
|
409
|
-
width: 200
|
|
410
|
-
}), jsx(Skeleton, {
|
|
411
|
-
height: 16,
|
|
412
|
-
circle: true
|
|
413
|
-
})]
|
|
414
|
-
}), jsx(Skeleton, {
|
|
415
|
-
height: 32,
|
|
416
|
-
mt: "sm"
|
|
417
|
-
})]
|
|
418
|
-
}, i))
|
|
419
|
-
}) : reportsList.length === 0 ? jsx(Center, {
|
|
420
|
-
py: 60,
|
|
421
|
-
maw: 1280,
|
|
422
|
-
m: '0 auto',
|
|
423
|
-
children: jsxs(Stack, {
|
|
424
|
-
align: "center",
|
|
425
|
-
gap: "sm",
|
|
426
|
-
children: [jsx(IconFolder, {
|
|
427
|
-
size: 48,
|
|
428
|
-
stroke: 1.2,
|
|
429
|
-
style: {
|
|
430
|
-
opacity: 0.4
|
|
431
|
-
}
|
|
432
|
-
}), jsx(Text, {
|
|
433
|
-
size: "sm",
|
|
434
|
-
c: "dimmed",
|
|
435
|
-
children: "Nessuna categoria di report disponibile"
|
|
436
|
-
})]
|
|
437
|
-
})
|
|
438
|
-
}) : jsxs(Stack, {
|
|
439
|
-
gap: "sm",
|
|
440
|
-
maw: 1280,
|
|
441
|
-
m: '0 auto',
|
|
442
|
-
children: [jsx(Paper, {
|
|
443
|
-
p: "sm",
|
|
444
|
-
withBorder: true,
|
|
445
|
-
children: jsxs(Group, {
|
|
446
|
-
justify: "space-between",
|
|
447
|
-
align: "flex-end",
|
|
448
|
-
children: [jsx(Select, {
|
|
449
|
-
label: "Categoria",
|
|
450
|
-
placeholder: "Seleziona categoria",
|
|
451
|
-
value: selectedCategoryKey,
|
|
452
|
-
onChange: value => setSelectedCategoryKey(value),
|
|
453
|
-
data: reportsList.map(category => ({
|
|
454
|
-
value: `${category.scope}-${category.packageName}-${category.namespace}-${category.reportTypeId}`,
|
|
455
|
-
label: `${category.name} (${category.reports.length})`
|
|
456
|
-
})),
|
|
457
|
-
searchable: true,
|
|
458
|
-
clearable: true,
|
|
459
|
-
leftSection: jsx(IconFolder, {
|
|
460
|
-
size: 16
|
|
461
|
-
}),
|
|
462
|
-
style: {
|
|
463
|
-
flex: 1,
|
|
464
|
-
maxWidth: 400
|
|
465
|
-
},
|
|
466
|
-
size: "sm"
|
|
467
|
-
}), currentCategory && jsx(Button, {
|
|
468
|
-
size: "sm",
|
|
469
|
-
variant: "light",
|
|
470
|
-
leftSection: jsx(IconPlus, {
|
|
471
|
-
size: 16
|
|
472
|
-
}),
|
|
473
|
-
onClick: () => openCreateModal({
|
|
474
|
-
scope: currentCategory.scope,
|
|
475
|
-
packageName: currentCategory.packageName,
|
|
476
|
-
namespace: currentCategory.namespace,
|
|
477
|
-
reportTypeId: currentCategory.reportTypeId,
|
|
478
|
-
name: currentCategory.name
|
|
479
|
-
}),
|
|
480
|
-
children: "Nuovo report"
|
|
481
|
-
})]
|
|
482
|
-
})
|
|
483
|
-
}), currentCategory ? jsx(Paper, {
|
|
484
|
-
p: "sm",
|
|
485
|
-
withBorder: true,
|
|
486
|
-
children: jsxs(Stack, {
|
|
487
|
-
gap: "sm",
|
|
488
|
-
children: [jsx(Group, {
|
|
489
|
-
justify: "space-between",
|
|
490
|
-
mb: "xs",
|
|
491
|
-
children: jsxs(Group, {
|
|
492
|
-
gap: "xs",
|
|
493
|
-
children: [jsx(Text, {
|
|
494
|
-
size: "sm",
|
|
495
|
-
children: currentCategory.name
|
|
496
|
-
}), jsx(Badge, {
|
|
497
|
-
size: "sm",
|
|
498
|
-
variant: "dot",
|
|
499
|
-
color: currentCategory.reports.length > 0 ? 'blue' : 'gray',
|
|
500
|
-
children: currentCategory.reports.length
|
|
501
|
-
})]
|
|
502
|
-
})
|
|
503
|
-
}), currentCategory.reports.length === 0 ? jsx(Center, {
|
|
504
|
-
py: 40,
|
|
505
|
-
children: jsxs(Stack, {
|
|
506
|
-
align: "center",
|
|
507
|
-
gap: "sm",
|
|
508
|
-
children: [jsx(IconReport, {
|
|
509
|
-
size: 40,
|
|
510
|
-
stroke: 1.2,
|
|
511
|
-
style: {
|
|
512
|
-
opacity: 0.4
|
|
513
|
-
}
|
|
514
|
-
}), jsx(Text, {
|
|
515
|
-
size: "sm",
|
|
516
|
-
c: "dimmed",
|
|
517
|
-
children: "Nessun report"
|
|
518
|
-
}), jsx(Button, {
|
|
519
|
-
size: "xs",
|
|
520
|
-
variant: "light",
|
|
521
|
-
leftSection: jsx(IconPlus, {
|
|
522
|
-
size: 14
|
|
523
|
-
}),
|
|
524
|
-
onClick: () => openCreateModal({
|
|
525
|
-
scope: currentCategory.scope,
|
|
526
|
-
packageName: currentCategory.packageName,
|
|
527
|
-
namespace: currentCategory.namespace,
|
|
528
|
-
reportTypeId: currentCategory.reportTypeId,
|
|
529
|
-
name: currentCategory.name
|
|
530
|
-
}),
|
|
531
|
-
children: "Crea report"
|
|
532
|
-
})]
|
|
533
|
-
})
|
|
534
|
-
}) : jsx(Stack, {
|
|
535
|
-
gap: 8,
|
|
536
|
-
children: currentCategory.reports.map(report => jsx(Paper, {
|
|
537
|
-
p: "xs",
|
|
538
|
-
withBorder: true,
|
|
539
|
-
style: {
|
|
540
|
-
cursor: 'pointer'
|
|
541
|
-
},
|
|
542
|
-
onClick: () => openReportEditor(report.id),
|
|
543
|
-
children: jsxs(Group, {
|
|
544
|
-
justify: "space-between",
|
|
545
|
-
children: [jsxs(Group, {
|
|
546
|
-
gap: "sm",
|
|
547
|
-
children: [jsx(IconReport, {
|
|
548
|
-
size: 16,
|
|
549
|
-
style: {
|
|
550
|
-
opacity: 0.6
|
|
551
|
-
}
|
|
552
|
-
}), jsx(Text, {
|
|
553
|
-
size: "sm",
|
|
554
|
-
children: report.name
|
|
555
|
-
})]
|
|
556
|
-
}), jsxs(Menu, {
|
|
557
|
-
shadow: "sm",
|
|
558
|
-
width: 160,
|
|
559
|
-
position: "bottom-end",
|
|
560
|
-
children: [jsx(Menu.Target, {
|
|
561
|
-
children: jsx(ActionIcon, {
|
|
562
|
-
variant: "subtle",
|
|
563
|
-
color: "gray",
|
|
564
|
-
size: "sm",
|
|
565
|
-
onClick: e => e.stopPropagation(),
|
|
566
|
-
children: jsx(IconDotsVertical, {
|
|
567
|
-
size: 16
|
|
568
|
-
})
|
|
569
|
-
})
|
|
570
|
-
}), jsxs(Menu.Dropdown, {
|
|
571
|
-
children: [jsx(Menu.Item, {
|
|
572
|
-
leftSection: jsx(IconEdit, {
|
|
573
|
-
size: 14
|
|
574
|
-
}),
|
|
575
|
-
onClick: e => {
|
|
576
|
-
e.stopPropagation();
|
|
577
|
-
openEditModal(report, currentCategory);
|
|
578
|
-
},
|
|
579
|
-
children: "Modifica"
|
|
580
|
-
}), jsx(Menu.Item, {
|
|
581
|
-
leftSection: jsx(IconExternalLink, {
|
|
582
|
-
size: 14
|
|
583
|
-
}),
|
|
584
|
-
onClick: e => {
|
|
585
|
-
e.stopPropagation();
|
|
586
|
-
openReportEditor(report.id);
|
|
587
|
-
},
|
|
588
|
-
children: "Apri designer"
|
|
589
|
-
}), jsx(Menu.Item, {
|
|
590
|
-
leftSection: jsx(IconTrash, {
|
|
591
|
-
size: 14
|
|
592
|
-
}),
|
|
593
|
-
color: "red",
|
|
594
|
-
onClick: e => {
|
|
595
|
-
e.stopPropagation();
|
|
596
|
-
openDeleteModal({
|
|
597
|
-
id: report.id,
|
|
598
|
-
name: report.name
|
|
599
|
-
});
|
|
600
|
-
},
|
|
601
|
-
children: "Elimina"
|
|
602
|
-
})]
|
|
603
|
-
})]
|
|
604
|
-
})]
|
|
605
|
-
})
|
|
606
|
-
}, report.id))
|
|
607
|
-
})]
|
|
608
|
-
})
|
|
609
|
-
}) : jsx(Paper, {
|
|
610
|
-
p: "sm",
|
|
611
|
-
withBorder: true,
|
|
612
|
-
children: jsx(Center, {
|
|
613
|
-
py: 30,
|
|
614
|
-
children: jsx(Text, {
|
|
615
|
-
size: "sm",
|
|
616
|
-
c: "dimmed",
|
|
617
|
-
children: "Seleziona una categoria"
|
|
618
|
-
})
|
|
619
|
-
})
|
|
620
|
-
})]
|
|
621
|
-
}), jsx(Modal, {
|
|
622
|
-
title: "Nuovo report",
|
|
623
|
-
centered: true,
|
|
624
|
-
opened: modals.create,
|
|
625
|
-
onClose: closeCreateModal,
|
|
626
|
-
size: "sm",
|
|
627
|
-
children: selectedCategory && jsx(CreateReport, {
|
|
628
|
-
name: selectedCategory.name,
|
|
629
|
-
scope: selectedCategory.scope,
|
|
630
|
-
packageName: selectedCategory.packageName,
|
|
631
|
-
namespace: selectedCategory.namespace,
|
|
632
|
-
id: selectedCategory.reportTypeId,
|
|
633
|
-
onCreated: newReportId => {
|
|
634
|
-
closeCreateModal();
|
|
635
|
-
refresh();
|
|
636
|
-
openReportEditor(newReportId);
|
|
637
|
-
},
|
|
638
|
-
onCancel: closeCreateModal
|
|
639
|
-
})
|
|
640
|
-
}), jsx(Modal, {
|
|
641
|
-
title: "Modifica report",
|
|
642
|
-
centered: true,
|
|
643
|
-
opened: modals.edit,
|
|
644
|
-
onClose: closeEditModal,
|
|
645
|
-
size: "sm",
|
|
646
|
-
children: editingReport && jsx(CreateReport, {
|
|
647
|
-
mode: "edit",
|
|
648
|
-
reportId: editingReport.id,
|
|
649
|
-
initialName: editingReport.name,
|
|
650
|
-
initialNote: editingReport.annotations,
|
|
651
|
-
name: editingReport.categoryName,
|
|
652
|
-
scope: editingReport.scope,
|
|
653
|
-
packageName: editingReport.packageName,
|
|
654
|
-
namespace: editingReport.namespace,
|
|
655
|
-
id: editingReport.reportTypeId,
|
|
656
|
-
onCreated: () => {},
|
|
657
|
-
onUpdated: () => {
|
|
658
|
-
closeEditModal();
|
|
659
|
-
refresh();
|
|
660
|
-
},
|
|
661
|
-
onCancel: closeEditModal
|
|
662
|
-
})
|
|
663
|
-
}), jsx(ConfirmModal, {
|
|
664
|
-
open: modals.delete,
|
|
665
|
-
onButtonConfirmClick: deleteReport,
|
|
666
|
-
onButtonCancelClick: closeDeleteModal,
|
|
667
|
-
title: "Elimina report",
|
|
668
|
-
messageText: `Sei sicuro di voler eliminare il report "${selectedReport === null || selectedReport === void 0 ? void 0 : selectedReport.name}"?`
|
|
669
|
-
}), jsx(Modal, {
|
|
670
|
-
title: "Editor Report",
|
|
671
|
-
styles: {
|
|
672
|
-
header: {
|
|
673
|
-
marginBottom: 0,
|
|
674
|
-
boxShadow: 'rgba(33, 33, 33, 0.1) 2px 1px 1px',
|
|
675
|
-
minHeight: 48,
|
|
676
|
-
padding: 8
|
|
677
|
-
}
|
|
678
|
-
},
|
|
679
|
-
padding: 0,
|
|
680
|
-
closeOnEscape: false,
|
|
681
|
-
closeOnClickOutside: false,
|
|
682
|
-
withCloseButton: true,
|
|
683
|
-
opened: modals.reportEditor,
|
|
684
|
-
fullScreen: true,
|
|
685
|
-
onClose: handleCloseReportEditor,
|
|
686
|
-
children: editingReportId && jsx(ReportDesigner, {
|
|
687
|
-
mode: "designer",
|
|
688
|
-
reportId: editingReportId
|
|
689
|
-
})
|
|
690
|
-
})]
|
|
691
|
-
});
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
export { ReportsManager as default };
|