@fluxo-dev/shell-reporting 0.0.54 → 1.0.0

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.
@@ -1,290 +0,0 @@
1
- import { c as createReactComponent, _ as _export, p as promiseNativeConstructor, f as fails$1, g as getBuiltIn$1, i as isCallable$1, d as defineBuiltIn$1, s as speciesConstructor$1, a as promiseResolve$1 } from './index.esm2.js';
2
- import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
3
- import { ShellPage, DataCard, ConfirmModal } from '@fluxo-dev/ui-components';
4
- import { Stack, Text, TextInput, Textarea, Group, Button, Loader, Divider, Center, Modal } from '@mantine/core';
5
- import { useState, useEffect } from 'react';
6
- import { FluxoClientSys } from '@fluxo-dev/api-client-base';
7
- import { useNavigate } from 'react-router-dom';
8
- import { showNotification } from '@mantine/notifications';
9
- import '@mantine/dates';
10
-
11
- /**
12
- * @tabler/icons-react v2.47.0 - MIT
13
- */
14
-
15
-
16
- var IconPlus = createReactComponent("plus", "IconPlus", [
17
- ["path", { d: "M12 5l0 14", key: "svg-0" }],
18
- ["path", { d: "M5 12l14 0", key: "svg-1" }]
19
- ]);
20
-
21
- /**
22
- * @tabler/icons-react v2.47.0 - MIT
23
- */
24
-
25
-
26
- var IconReport = createReactComponent("report", "IconReport", [
27
- [
28
- "path",
29
- { d: "M8 5h-2a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h5.697", key: "svg-0" }
30
- ],
31
- ["path", { d: "M18 14v4h4", key: "svg-1" }],
32
- ["path", { d: "M18 11v-4a2 2 0 0 0 -2 -2h-2", key: "svg-2" }],
33
- [
34
- "path",
35
- {
36
- 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",
37
- key: "svg-3"
38
- }
39
- ],
40
- ["path", { d: "M18 18m-4 0a4 4 0 1 0 8 0a4 4 0 1 0 -8 0", key: "svg-4" }],
41
- ["path", { d: "M8 11h4", key: "svg-5" }],
42
- ["path", { d: "M8 15h3", key: "svg-6" }]
43
- ]);
44
-
45
- var $ = _export;
46
- var NativePromiseConstructor = promiseNativeConstructor;
47
- var fails = fails$1;
48
- var getBuiltIn = getBuiltIn$1;
49
- var isCallable = isCallable$1;
50
- var speciesConstructor = speciesConstructor$1;
51
- var promiseResolve = promiseResolve$1;
52
- var defineBuiltIn = defineBuiltIn$1;
53
-
54
- var NativePromisePrototype = NativePromiseConstructor && NativePromiseConstructor.prototype;
55
-
56
- // Safari bug https://bugs.webkit.org/show_bug.cgi?id=200829
57
- var NON_GENERIC = !!NativePromiseConstructor && fails(function () {
58
- // eslint-disable-next-line unicorn/no-thenable -- required for testing
59
- NativePromisePrototype['finally'].call({ then: function () { /* empty */ } }, function () { /* empty */ });
60
- });
61
-
62
- // `Promise.prototype.finally` method
63
- // https://tc39.es/ecma262/#sec-promise.prototype.finally
64
- $({ target: 'Promise', proto: true, real: true, forced: NON_GENERIC }, {
65
- 'finally': function (onFinally) {
66
- var C = speciesConstructor(this, getBuiltIn('Promise'));
67
- var isFunction = isCallable(onFinally);
68
- return this.then(
69
- isFunction ? function (x) {
70
- return promiseResolve(C, onFinally()).then(function () { return x; });
71
- } : onFinally,
72
- isFunction ? function (e) {
73
- return promiseResolve(C, onFinally()).then(function () { throw e; });
74
- } : onFinally
75
- );
76
- }
77
- });
78
-
79
- // makes sure that native promise-based APIs `Promise#finally` properly works with patched `Promise#then`
80
- if (isCallable(NativePromiseConstructor)) {
81
- var method = getBuiltIn('Promise').prototype['finally'];
82
- if (NativePromisePrototype['finally'] !== method) {
83
- defineBuiltIn(NativePromisePrototype, 'finally', method, { unsafe: true });
84
- }
85
- }
86
-
87
- function CreateReport(props) {
88
- const [name, setName] = useState('');
89
- const [note, setNote] = useState('');
90
- const [loading, setLoading] = useState(false);
91
- const createReport = () => {
92
- if (!name) return;
93
- const command = {
94
- name: name,
95
- annotations: note,
96
- scope: props.scope,
97
- packageName: props.packageName,
98
- namespace: props.namespace,
99
- id: props.id
100
- };
101
- setLoading(true);
102
- FluxoClientSys.Instance.reporting.createReport(command).then(res => {
103
- showNotification({
104
- title: 'Report creato',
105
- message: 'Il report è stato creato con successo',
106
- color: 'teal'
107
- });
108
- props.onCreated(res);
109
- }).catch(err => {
110
- showNotification({
111
- title: 'Errore',
112
- message: 'Si è verificato un errore durante la creazione del report',
113
- color: 'red'
114
- });
115
- }).finally(() => {
116
- setLoading(false);
117
- });
118
- };
119
- return jsxs(Stack, {
120
- children: [jsxs(Text, {
121
- children: [jsx("b", {
122
- children: "Nome:"
123
- }), " ", props.name]
124
- }), jsxs(Text, {
125
- children: [jsx("b", {
126
- children: "Categoria:"
127
- }), " ", props.scope, ".", props.packageName, ".", props.namespace, ".", props.id]
128
- }), jsx(TextInput, {
129
- disabled: loading,
130
- label: 'Nome report',
131
- onChange: v => setName(v.target.value)
132
- }), jsx(Textarea, {
133
- disabled: loading,
134
- label: 'Note',
135
- onChange: v => setNote(v.target.value)
136
- }), jsxs(Group, {
137
- justify: 'right',
138
- children: [jsx(Button, {
139
- disabled: loading,
140
- onClick: props.onCancel,
141
- variant: 'subtle',
142
- children: "Annulla"
143
- }), jsx(Button, {
144
- onClick: createReport,
145
- disabled: !name || loading,
146
- children: "Crea"
147
- })]
148
- })]
149
- });
150
- }
151
-
152
- function ReportsManager() {
153
- const [reportsList, setReportsList] = useState([]);
154
- const [loading, setLoading] = useState(true);
155
- const navigate = useNavigate();
156
- const [createReportModalOpened, setCreateReportModalOpened] = useState(false);
157
- const [deleteReportModalOpened, setDeleteReportModalOpened] = useState(false);
158
- const [currentId, setCurrentId] = useState();
159
- const [currentScope, setCurrentScope] = useState('');
160
- const [currentPackageName, setCurrentPackageName] = useState('');
161
- const [currentNamespace, setCurrentNamespace] = useState('');
162
- const [currentReportId, setCurrentReportId] = useState('');
163
- const [currentReportTypeName, setCurrentReportTypeName] = useState('');
164
- const [currentReportName, setCurrentReportName] = useState('');
165
- useEffect(() => {
166
- refresh();
167
- }, []);
168
- const refresh = () => {
169
- FluxoClientSys.Instance.reporting.getReportsList().then(res => {
170
- setReportsList(res);
171
- setLoading(false);
172
- });
173
- };
174
- const deleteReport = () => {
175
- if (!currentId) return;
176
- FluxoClientSys.Instance.reporting.deleteReport(currentId).then(() => {
177
- showNotification({
178
- title: 'Report eliminato',
179
- message: 'Il report è stato eliminato con successo',
180
- color: 'success'
181
- });
182
- refresh();
183
- }).catch(() => {
184
- showNotification({
185
- title: 'Errore',
186
- message: 'Si è verificato un errore durante l\'eliminazione del report',
187
- color: 'red'
188
- });
189
- }).finally(() => {
190
- setDeleteReportModalOpened(false);
191
- setCurrentId(undefined);
192
- });
193
- };
194
- return jsxs(ShellPage, {
195
- headerProps: {
196
- title: 'Reports',
197
- subtitle: ''
198
- },
199
- children: [loading ? jsx(Loader, {
200
- size: 48,
201
- style: {
202
- margin: 'auto'
203
- }
204
- }) : jsx(Stack, {
205
- children: reportsList.map(report => {
206
- return jsx(DataCard, {
207
- title: report.name,
208
- actions: [{
209
- label: 'Nuovo report',
210
- icon: jsx(IconPlus, {
211
- size: 18
212
- }),
213
- onClick: () => {
214
- setCurrentScope(report.scope);
215
- setCurrentPackageName(report.packageName);
216
- setCurrentNamespace(report.namespace);
217
- setCurrentReportId(report.reportTypeId);
218
- setCurrentReportTypeName(report.name);
219
- setCreateReportModalOpened(true);
220
- }
221
- }],
222
- children: jsxs(Stack, {
223
- children: [report.reports.map((r, index) => {
224
- return jsxs(Fragment, {
225
- children: [jsxs(Group, {
226
- justify: 'space-between',
227
- children: [jsxs(Group, {
228
- children: [jsx(IconReport, {
229
- color: 'gray',
230
- size: 18
231
- }), jsx(Text, {
232
- fw: 600,
233
- size: 'md',
234
- children: r.name
235
- })]
236
- }), jsxs(Group, {
237
- children: [jsx(Button, {
238
- onClick: () => navigate(r.id.toString()),
239
- size: 'xs',
240
- children: "Modifica"
241
- }), jsx(Button, {
242
- onClick: () => {
243
- setCurrentId(r.id);
244
- setCurrentReportName(r.name);
245
- setDeleteReportModalOpened(true);
246
- },
247
- size: 'xs',
248
- color: 'red',
249
- children: "Elimina"
250
- })]
251
- })]
252
- }), index !== report.reports.length - 1 && jsx(Divider, {})]
253
- });
254
- }), report.reports.length === 0 && jsx(Center, {
255
- children: jsx(Text, {
256
- size: 'md',
257
- children: "Nessun report per la categoria"
258
- })
259
- })]
260
- })
261
- });
262
- })
263
- }), jsx(Modal, {
264
- title: 'Nuovo report',
265
- centered: true,
266
- opened: createReportModalOpened,
267
- onClose: () => setCreateReportModalOpened(false),
268
- children: jsx(CreateReport, {
269
- name: currentReportTypeName,
270
- scope: currentScope,
271
- packageName: currentPackageName,
272
- namespace: currentNamespace,
273
- id: currentReportId,
274
- onCreated: newReportId => {
275
- setCreateReportModalOpened(false);
276
- navigate(newReportId.toString());
277
- },
278
- onCancel: () => setCreateReportModalOpened(false)
279
- })
280
- }), jsx(ConfirmModal, {
281
- open: deleteReportModalOpened,
282
- onButtonConfirmClick: () => deleteReport(),
283
- onButtonCancelClick: () => setDeleteReportModalOpened(true),
284
- title: 'Elimina report',
285
- messageText: `Sei sicuro di voler eliminare il report ${currentReportName}?`
286
- })]
287
- });
288
- }
289
-
290
- export { ReportsManager as default };
package/src/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export { reportsModule } from './lib/fluxo-module';
2
- export { ReportButton } from './lib/components/report-button';
3
- export { ReportChooser } from './lib/components/report-chooser';
@@ -1,16 +0,0 @@
1
- import { ButtonVariant } from "@mantine/core";
2
- import React from "react";
3
- export interface ReportButtonProps {
4
- reportScope: string;
5
- reportPackageName: string;
6
- reportNamespace: string;
7
- reportId: string;
8
- initialParameters?: {
9
- key: string;
10
- value: string | number | boolean | Date;
11
- }[];
12
- label?: string;
13
- icon?: React.ReactNode;
14
- variant?: string | ButtonVariant | undefined;
15
- }
16
- export declare function ReportButton(props: ReportButtonProps): import("react/jsx-runtime").JSX.Element;
@@ -1,13 +0,0 @@
1
- export interface ReportChooserProps {
2
- reportScope: string;
3
- reportPackageName: string;
4
- reportNamespace: string;
5
- reportId: string;
6
- initialParameters?: {
7
- key: string;
8
- value: string | number | boolean | Date;
9
- }[];
10
- onCancel: () => void;
11
- onSubmit: (reportId: string, parameters: string) => void;
12
- }
13
- export declare function ReportChooser(props: ReportChooserProps): import("react/jsx-runtime").JSX.Element;
@@ -1 +0,0 @@
1
- export * from './report-designer';
@@ -1,8 +0,0 @@
1
- import './report-designer.css';
2
- export interface ReportDesignerProps {
3
- mode: 'designer' | 'viewer';
4
- reportId?: number;
5
- reportParameters?: string;
6
- }
7
- export declare const ReportDesigner: (props: ReportDesignerProps) => import("react/jsx-runtime").JSX.Element;
8
- export default ReportDesigner;
@@ -1,18 +0,0 @@
1
- import { ParametersSchema } from "@fluxo-dev/api-client-base";
2
- export interface FiltersPanelProps {
3
- useParametersSchema: boolean;
4
- onFiltersChange: (parameters: {
5
- [key: string]: any;
6
- }) => void;
7
- initialParameters?: {
8
- key: string;
9
- value: string | number | boolean | Date;
10
- }[];
11
- parametersSchema: ParametersSchema;
12
- }
13
- export declare function FiltersPanel(props: FiltersPanelProps): import("react/jsx-runtime").JSX.Element;
14
- export declare namespace FiltersPanel {
15
- var defaultProps: {
16
- useParametersSchema: boolean;
17
- };
18
- }
@@ -1,2 +0,0 @@
1
- import { EmbeddedModule } from "@fluxo-dev/api-client-base";
2
- export declare const reportsModule: EmbeddedModule;
@@ -1,10 +0,0 @@
1
- export interface CreateReportProps {
2
- scope: string;
3
- packageName: string;
4
- namespace: string;
5
- id: string;
6
- name: string;
7
- onCreated: (id: number) => void;
8
- onCancel: () => void;
9
- }
10
- export declare function CreateReport(props: CreateReportProps): import("react/jsx-runtime").JSX.Element;
@@ -1 +0,0 @@
1
- export * from './reports-manager';
@@ -1 +0,0 @@
1
- export default function ReportsManager(): import("react/jsx-runtime").JSX.Element;
@@ -1,3 +0,0 @@
1
- import { EmbeddedModuleNavigation } from "@fluxo-dev/api-client-base";
2
- export declare const SuspenseWrapper: (props: any) => import("react/jsx-runtime").JSX.Element;
3
- export declare const reportsNavigation: EmbeddedModuleNavigation;