@visns-studio/visns-components 5.2.10 → 5.2.12
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/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"akar-icons": "^1.9.31",
|
|
15
15
|
"array-move": "^4.0.0",
|
|
16
16
|
"awesome-debounce-promise": "^2.1.0",
|
|
17
|
-
"axios": "^1.
|
|
17
|
+
"axios": "^1.8.1",
|
|
18
18
|
"dayjs": "^1.11.13",
|
|
19
19
|
"fabric": "^6.5.4",
|
|
20
20
|
"file-saver": "^2.0.5",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"react-dom": "^17.0.0 || ^18.0.0"
|
|
79
79
|
},
|
|
80
80
|
"name": "@visns-studio/visns-components",
|
|
81
|
-
"version": "5.2.
|
|
81
|
+
"version": "5.2.12",
|
|
82
82
|
"description": "Various packages to assist in the development of our Custom Applications.",
|
|
83
83
|
"main": "src/index.js",
|
|
84
84
|
"files": [
|
|
@@ -110,6 +110,7 @@ function GenericDashboard({ setting, userProfile }) {
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
|
+
|
|
113
114
|
if (widget.api?.url && widget.api?.method) {
|
|
114
115
|
return CustomFetch(
|
|
115
116
|
widget.api.url,
|
|
@@ -136,8 +137,18 @@ function GenericDashboard({ setting, userProfile }) {
|
|
|
136
137
|
};
|
|
137
138
|
|
|
138
139
|
useEffect(() => {
|
|
140
|
+
// Check if any widget has a "filters" property.
|
|
141
|
+
const widgetHasFilters = dashboardSetting?.widgets?.some((widget) =>
|
|
142
|
+
widget.hasOwnProperty('filters')
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
// If a widget has filters and our filters object is empty, do nothing.
|
|
146
|
+
if (widgetHasFilters && Object.keys(filters).length === 0) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
|
|
139
150
|
fetchData(filters);
|
|
140
|
-
}, [filters]);
|
|
151
|
+
}, [filters, dashboardSetting]);
|
|
141
152
|
|
|
142
153
|
const openModal = (widgetId) => {
|
|
143
154
|
setModalContent(widgetId);
|
|
@@ -665,6 +676,10 @@ function GenericDashboard({ setting, userProfile }) {
|
|
|
665
676
|
type
|
|
666
677
|
)}`}
|
|
667
678
|
>
|
|
679
|
+
<td>
|
|
680
|
+
{type ||
|
|
681
|
+
''}
|
|
682
|
+
</td>
|
|
668
683
|
{widget.total
|
|
669
684
|
.column &&
|
|
670
685
|
tableData.map(
|
|
@@ -673,9 +688,18 @@ function GenericDashboard({ setting, userProfile }) {
|
|
|
673
688
|
rowIndex
|
|
674
689
|
) => {
|
|
675
690
|
const columnKey =
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
691
|
+
Array.isArray(
|
|
692
|
+
widget
|
|
693
|
+
.axisKeys
|
|
694
|
+
.columnKey
|
|
695
|
+
)
|
|
696
|
+
? widget
|
|
697
|
+
.axisKeys
|
|
698
|
+
.columnKey[0]
|
|
699
|
+
: widget
|
|
700
|
+
.axisKeys
|
|
701
|
+
.columnKey;
|
|
702
|
+
|
|
679
703
|
const yAxisKey =
|
|
680
704
|
widget
|
|
681
705
|
.axisKeys
|
|
@@ -702,6 +726,7 @@ function GenericDashboard({ setting, userProfile }) {
|
|
|
702
726
|
: 0;
|
|
703
727
|
total +=
|
|
704
728
|
count;
|
|
729
|
+
|
|
705
730
|
return (
|
|
706
731
|
<td
|
|
707
732
|
key={`${toSnakeCase(
|
|
@@ -759,6 +784,8 @@ function GenericDashboard({ setting, userProfile }) {
|
|
|
759
784
|
<td>
|
|
760
785
|
<strong>Total</strong>
|
|
761
786
|
</td>
|
|
787
|
+
|
|
788
|
+
{/* Render each row's total */}
|
|
762
789
|
{tableData.map(
|
|
763
790
|
(row, rowIndex) => {
|
|
764
791
|
const tableTotal =
|
|
@@ -774,9 +801,9 @@ function GenericDashboard({ setting, userProfile }) {
|
|
|
774
801
|
.columnKey
|
|
775
802
|
].find(
|
|
776
803
|
(
|
|
777
|
-
|
|
804
|
+
col
|
|
778
805
|
) =>
|
|
779
|
-
|
|
806
|
+
col.form_template_label ===
|
|
780
807
|
type
|
|
781
808
|
);
|
|
782
809
|
return (
|
|
@@ -792,6 +819,7 @@ function GenericDashboard({ setting, userProfile }) {
|
|
|
792
819
|
},
|
|
793
820
|
0
|
|
794
821
|
);
|
|
822
|
+
|
|
795
823
|
return (
|
|
796
824
|
<td
|
|
797
825
|
key={`${toSnakeCase(
|
|
@@ -811,7 +839,54 @@ function GenericDashboard({ setting, userProfile }) {
|
|
|
811
839
|
);
|
|
812
840
|
}
|
|
813
841
|
)}
|
|
814
|
-
|
|
842
|
+
|
|
843
|
+
{/* Final cell: grand total of all row totals */}
|
|
844
|
+
<td>
|
|
845
|
+
<strong>
|
|
846
|
+
{tableData.reduce(
|
|
847
|
+
(
|
|
848
|
+
outerSum,
|
|
849
|
+
row
|
|
850
|
+
) => {
|
|
851
|
+
// sum up each row’s tableTotal again
|
|
852
|
+
return (
|
|
853
|
+
outerSum +
|
|
854
|
+
tableKeys.reduce(
|
|
855
|
+
(
|
|
856
|
+
sum,
|
|
857
|
+
type
|
|
858
|
+
) => {
|
|
859
|
+
const column =
|
|
860
|
+
row[
|
|
861
|
+
widget
|
|
862
|
+
.axisKeys
|
|
863
|
+
.columnKey
|
|
864
|
+
].find(
|
|
865
|
+
(
|
|
866
|
+
col
|
|
867
|
+
) =>
|
|
868
|
+
col.form_template_label ===
|
|
869
|
+
type
|
|
870
|
+
);
|
|
871
|
+
return (
|
|
872
|
+
sum +
|
|
873
|
+
(column
|
|
874
|
+
? column[
|
|
875
|
+
widget
|
|
876
|
+
.axisKeys
|
|
877
|
+
.yAxis
|
|
878
|
+
]
|
|
879
|
+
: 0)
|
|
880
|
+
);
|
|
881
|
+
},
|
|
882
|
+
0
|
|
883
|
+
)
|
|
884
|
+
);
|
|
885
|
+
},
|
|
886
|
+
0
|
|
887
|
+
)}
|
|
888
|
+
</strong>
|
|
889
|
+
</td>
|
|
815
890
|
</tr>
|
|
816
891
|
)}
|
|
817
892
|
</tbody>
|
|
@@ -382,15 +382,12 @@
|
|
|
382
382
|
display: block;
|
|
383
383
|
}
|
|
384
384
|
|
|
385
|
-
.table-scroll table {
|
|
386
|
-
min-width: max-content; /* Ensures the table width adapts to its content */
|
|
387
|
-
}
|
|
388
|
-
|
|
389
385
|
.table-container {
|
|
390
386
|
margin-top: 20px;
|
|
391
387
|
border: 1px solid #dadce0;
|
|
392
388
|
border-radius: 8px;
|
|
393
389
|
overflow: hidden;
|
|
390
|
+
max-width: 1400px;
|
|
394
391
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
|
395
392
|
}
|
|
396
393
|
|