@quillsql/react 1.6.8 → 1.7.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.
- package/lib/AddToDashboardModal.js +3 -3
- package/lib/AddToDashboardModal.js.map +1 -1
- package/lib/Chart.js +82 -145
- package/lib/Chart.js.map +1 -1
- package/lib/Context.d.ts +3 -3
- package/lib/Context.js +10 -20
- package/lib/Context.js.map +1 -1
- package/lib/Dashboard.js +34 -23
- package/lib/Dashboard.js.map +1 -1
- package/lib/QuillProvider.d.ts +2 -1
- package/lib/QuillProvider.js +2 -2
- package/lib/QuillProvider.js.map +1 -1
- package/lib/ReportBuilder.js +3 -3
- package/lib/ReportBuilder.js.map +1 -1
- package/lib/SQLEditor.js +3 -3
- package/lib/SQLEditor.js.map +1 -1
- package/lib/Table.js.map +1 -1
- package/lib/hooks/useQuill.js +3 -3
- package/lib/hooks/useQuill.js.map +1 -1
- package/package.json +24 -3
- package/rollup.config.ts +21 -0
- package/src/AddToDashboardModal.tsx +10 -3
- package/src/Chart.tsx +66 -195
- package/src/Context.tsx +10 -27
- package/src/Dashboard.tsx +38 -21
- package/src/QuillProvider.tsx +3 -0
- package/src/ReportBuilder.tsx +9 -3
- package/src/SQLEditor.tsx +9 -3
- package/src/Table.tsx +0 -1
- package/src/hooks/useQuill.ts +2 -1
- package/lib/AddToDashboardButton.d.ts +0 -1
- package/lib/AddToDashboardButton.js +0 -2
- package/lib/AddToDashboardButton.js.map +0 -1
- package/lib/AppContext.d.ts +0 -29
- package/lib/AppContext.js +0 -94
- package/lib/AppContext.js.map +0 -1
- package/lib/Button.d.ts +0 -26
- package/lib/Button.js +0 -151
- package/lib/Button.js.map +0 -1
- package/lib/ContextProvider.d.ts +0 -28
- package/lib/ContextProvider.js +0 -93
- package/lib/ContextProvider.js.map +0 -1
- package/lib/DateRangePicker.d.ts +0 -32
- package/lib/DateRangePicker.js +0 -105
- package/lib/DateRangePicker.js.map +0 -1
- package/lib/Dialog.d.ts +0 -68
- package/lib/Dialog.js +0 -407
- package/lib/Dialog.js.map +0 -1
- package/lib/Portal.d.ts +0 -32
- package/lib/Portal.js +0 -171
- package/lib/Portal.js.map +0 -1
- package/lib/Props.d.ts +0 -0
- package/lib/Props.js +0 -2
- package/lib/Props.js.map +0 -1
- package/lib/components/BigModal/Modal.d.ts +0 -14
- package/lib/components/BigModal/Modal.js +0 -109
- package/lib/components/BigModal/Modal.js.map +0 -1
- package/lib/components/Modal/Dropdown/Dropdown.d.ts +0 -12
- package/lib/components/Modal/Dropdown/Dropdown.js +0 -52
- package/lib/components/Modal/Dropdown/Dropdown.js.map +0 -1
- package/lib/components/Modal/Dropdown/DropdownItem.d.ts +0 -8
- package/lib/components/Modal/Dropdown/DropdownItem.js +0 -51
- package/lib/components/Modal/Dropdown/DropdownItem.js.map +0 -1
- package/lib/components/Modal/Dropdown/index.d.ts +0 -2
- package/lib/components/Modal/Dropdown/index.js +0 -3
- package/lib/components/Modal/Dropdown/index.js.map +0 -1
- package/lib/hooks/useSyncRefs.d.ts +0 -5
- package/lib/hooks/useSyncRefs.js +0 -38
- package/lib/hooks/useSyncRefs.js.map +0 -1
- package/lib/lib/colorClassNames.d.ts +0 -19
- package/lib/lib/colorClassNames.js +0 -3175
- package/lib/lib/colorClassNames.js.map +0 -1
- package/lib/lib/constants.d.ts +0 -16
- package/lib/lib/constants.js +0 -47
- package/lib/lib/constants.js.map +0 -1
- package/lib/lib/font.d.ts +0 -13
- package/lib/lib/font.js +0 -14
- package/lib/lib/font.js.map +0 -1
- package/lib/lib/hexColors.d.ts +0 -3
- package/lib/lib/hexColors.js +0 -29
- package/lib/lib/hexColors.js.map +0 -1
- package/lib/lib/index.d.ts +0 -3
- package/lib/lib/index.js +0 -4
- package/lib/lib/index.js.map +0 -1
- package/lib/lib/inputTypes.d.ts +0 -20
- package/lib/lib/inputTypes.js +0 -56
- package/lib/lib/inputTypes.js.map +0 -1
- package/lib/lib/shape.d.ts +0 -73
- package/lib/lib/shape.js +0 -74
- package/lib/lib/shape.js.map +0 -1
- package/lib/lib/sizing.d.ts +0 -46
- package/lib/lib/sizing.js +0 -43
- package/lib/lib/sizing.js.map +0 -1
- package/lib/lib/spacing.d.ts +0 -264
- package/lib/lib/spacing.js +0 -265
- package/lib/lib/spacing.js.map +0 -1
- package/lib/lib/theme.d.ts +0 -22
- package/lib/lib/theme.js +0 -46
- package/lib/lib/theme.js.map +0 -1
- package/lib/lib/utils.d.ts +0 -9
- package/lib/lib/utils.js +0 -40
- package/lib/lib/utils.js.map +0 -1
- package/lib/styles.css +0 -15795
- package/lib/types/Props.d.ts +0 -0
- package/lib/types/Props.js +0 -2
- package/lib/types/Props.js.map +0 -1
- package/lib/types.d.ts +0 -27
- package/lib/types.js +0 -6
- package/lib/types.js.map +0 -1
- package/src/lib/font.ts +0 -14
- package/src/lib/index.ts +0 -3
- package/src/lib/inputTypes.ts +0 -81
- package/src/lib/utils.tsx +0 -46
package/src/Chart.tsx
CHANGED
|
@@ -20,7 +20,6 @@ import axios from 'axios';
|
|
|
20
20
|
import {
|
|
21
21
|
ClientContext,
|
|
22
22
|
DashboardContext,
|
|
23
|
-
DateFilterContext,
|
|
24
23
|
ThemeContext,
|
|
25
24
|
DashboardFiltersContext,
|
|
26
25
|
} from './Context';
|
|
@@ -495,7 +494,6 @@ const Chart = ({
|
|
|
495
494
|
query?: string;
|
|
496
495
|
}) => {
|
|
497
496
|
const { dispatch, dashboard } = useContext(DashboardContext);
|
|
498
|
-
const { dateFilterObj } = useContext(DateFilterContext);
|
|
499
497
|
const { dashboardFilters } = useContext(DashboardFiltersContext);
|
|
500
498
|
const [client, _] = useContext(ClientContext);
|
|
501
499
|
const [theme] =
|
|
@@ -508,7 +506,6 @@ const Chart = ({
|
|
|
508
506
|
config={config}
|
|
509
507
|
dispatch={dispatch}
|
|
510
508
|
dashboard={dashboard}
|
|
511
|
-
dateFilter={dateFilterObj}
|
|
512
509
|
chartId={chartId}
|
|
513
510
|
containerStyle={containerStyle}
|
|
514
511
|
colors={chartColors}
|
|
@@ -521,71 +518,12 @@ const Chart = ({
|
|
|
521
518
|
);
|
|
522
519
|
};
|
|
523
520
|
|
|
524
|
-
function didFiltersChange(filterObject1, filterObject2) {
|
|
525
|
-
// Both objects are null or undefined
|
|
526
|
-
if (!filterObject1 && !filterObject2) {
|
|
527
|
-
return false;
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
// One of the objects is null or undefined but the other is not
|
|
531
|
-
if (
|
|
532
|
-
(!filterObject1 || Object.keys(filterObject1).length === 0) &&
|
|
533
|
-
filterObject2 &&
|
|
534
|
-
Object.keys(filterObject2).length > 0
|
|
535
|
-
) {
|
|
536
|
-
return true;
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
if (
|
|
540
|
-
(!filterObject2 || Object.keys(filterObject2).length === 0) &&
|
|
541
|
-
filterObject1 &&
|
|
542
|
-
Object.keys(filterObject1).length > 0
|
|
543
|
-
) {
|
|
544
|
-
return true;
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
// Objects have different number of keys
|
|
548
|
-
if (
|
|
549
|
-
filterObject1 &&
|
|
550
|
-
filterObject2 &&
|
|
551
|
-
Object.keys(filterObject1).length !== Object.keys(filterObject2).length
|
|
552
|
-
) {
|
|
553
|
-
return true;
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
for (const filterId in filterObject1) {
|
|
557
|
-
if (filterObject2 && !filterObject2.hasOwnProperty(filterId)) {
|
|
558
|
-
return true;
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
if (
|
|
562
|
-
filterObject1 &&
|
|
563
|
-
filterObject2 &&
|
|
564
|
-
JSON.stringify(filterObject1[filterId]) !==
|
|
565
|
-
JSON.stringify(filterObject2[filterId])
|
|
566
|
-
) {
|
|
567
|
-
// If the selectedValue field exists and is not undefined in either object
|
|
568
|
-
if (
|
|
569
|
-
('selectedValue' in filterObject1[filterId] &&
|
|
570
|
-
filterObject1[filterId].selectedValue !== undefined) ||
|
|
571
|
-
('selectedValue' in filterObject2[filterId] &&
|
|
572
|
-
filterObject2[filterId].selectedValue !== undefined)
|
|
573
|
-
) {
|
|
574
|
-
return true;
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
return false;
|
|
580
|
-
}
|
|
581
|
-
|
|
582
521
|
const ChartUpdater: React.FC<ChartProps> = ({
|
|
583
522
|
colors,
|
|
584
523
|
chartId,
|
|
585
524
|
config,
|
|
586
525
|
containerStyle,
|
|
587
526
|
dashboard,
|
|
588
|
-
dateFilter,
|
|
589
527
|
dispatch,
|
|
590
528
|
client,
|
|
591
529
|
theme,
|
|
@@ -593,64 +531,28 @@ const ChartUpdater: React.FC<ChartProps> = ({
|
|
|
593
531
|
dashboardFilters,
|
|
594
532
|
query,
|
|
595
533
|
}) => {
|
|
596
|
-
const [chartConfig, setChartConfig] = useState<any>(config || null);
|
|
597
534
|
const [loading, setLoading] = useState(true);
|
|
598
|
-
|
|
599
535
|
// console.log('chartConfig:', chartConfig);
|
|
600
536
|
// console.log('chartConfig.rows:', chartConfig.rows);
|
|
601
537
|
// console.log('chartConfig.xAxisField:', chartConfig.xAxisField);
|
|
602
538
|
|
|
603
539
|
useEffect(() => {
|
|
604
|
-
if (isDateFilter && !dateFilter
|
|
540
|
+
if (isDateFilter && !dateFilter) {
|
|
605
541
|
return;
|
|
606
542
|
}
|
|
607
543
|
|
|
608
544
|
let isSubscribed = true;
|
|
609
|
-
async function getChartOptions(
|
|
545
|
+
async function getChartOptions() {
|
|
610
546
|
if (isSubscribed) {
|
|
611
|
-
if (
|
|
612
|
-
dashboard &&
|
|
613
|
-
dashboard[id] &&
|
|
614
|
-
!filtersChanged &&
|
|
615
|
-
(!isDateFilter ||
|
|
616
|
-
dashboard[id].startDate === dateFilter.startDate ||
|
|
617
|
-
dashboard[id].endDate === dateFilter.endDate)
|
|
618
|
-
) {
|
|
619
|
-
const {
|
|
620
|
-
xAxisField,
|
|
621
|
-
yAxisFields,
|
|
622
|
-
xAxisLabel,
|
|
623
|
-
yAxisLabel,
|
|
624
|
-
xAxisFormat,
|
|
625
|
-
chartType,
|
|
626
|
-
rows,
|
|
627
|
-
startDate,
|
|
628
|
-
endDate,
|
|
629
|
-
filters,
|
|
630
|
-
} = dashboard[id];
|
|
631
|
-
setChartConfig({
|
|
632
|
-
xAxisField,
|
|
633
|
-
yAxisFields,
|
|
634
|
-
xAxisLabel,
|
|
635
|
-
yAxisLabel,
|
|
636
|
-
xAxisFormat,
|
|
637
|
-
chartType,
|
|
638
|
-
rows,
|
|
639
|
-
startDate,
|
|
640
|
-
endDate,
|
|
641
|
-
filters,
|
|
642
|
-
});
|
|
643
|
-
setLoading(false);
|
|
644
|
-
return;
|
|
645
|
-
}
|
|
646
547
|
const {
|
|
647
548
|
publicKey,
|
|
648
549
|
customerId,
|
|
649
550
|
environment,
|
|
650
551
|
queryEndpoint,
|
|
651
552
|
queryHeaders,
|
|
553
|
+
withCredentials,
|
|
652
554
|
} = client;
|
|
653
|
-
|
|
555
|
+
//queryEndpoint = undefined;
|
|
654
556
|
setLoading(true);
|
|
655
557
|
try {
|
|
656
558
|
// if self-hosting option, only get metadata and query
|
|
@@ -666,38 +568,34 @@ const ChartUpdater: React.FC<ChartProps> = ({
|
|
|
666
568
|
// environment: environment || undefined,
|
|
667
569
|
// }
|
|
668
570
|
// );
|
|
571
|
+
if (dashboardFilters['date_range'] && dashboard[chartId]) {
|
|
572
|
+
const dateFilter = dashboardFilters['date_range'];
|
|
573
|
+
dateFilter.dateField = dashboard[chartId].dateField;
|
|
574
|
+
}
|
|
669
575
|
const resp = await axios.post(
|
|
670
576
|
queryEndpoint,
|
|
671
|
-
{
|
|
672
|
-
|
|
577
|
+
{
|
|
578
|
+
metadata: {
|
|
579
|
+
id: chartId,
|
|
580
|
+
task: 'item',
|
|
581
|
+
filters: {
|
|
582
|
+
...Object.entries(dashboardFilters)
|
|
583
|
+
.filter(([key]) => key !== 'date_range')
|
|
584
|
+
.map(([, value]) => value),
|
|
585
|
+
dateFilter,
|
|
586
|
+
},
|
|
587
|
+
},
|
|
588
|
+
},
|
|
589
|
+
{ headers: queryHeaders, withCredentials }
|
|
673
590
|
);
|
|
674
591
|
|
|
675
592
|
if (resp.data) {
|
|
676
|
-
const {
|
|
677
|
-
xAxisField,
|
|
678
|
-
yAxisFields,
|
|
679
|
-
xAxisLabel,
|
|
680
|
-
yAxisLabel,
|
|
681
|
-
xAxisFormat,
|
|
682
|
-
chartType,
|
|
683
|
-
} = resp.data;
|
|
684
|
-
setChartConfig({
|
|
685
|
-
xAxisField,
|
|
686
|
-
yAxisFields,
|
|
687
|
-
xAxisLabel,
|
|
688
|
-
yAxisLabel,
|
|
689
|
-
xAxisFormat,
|
|
690
|
-
chartType,
|
|
691
|
-
rows: resp.data.rows,
|
|
692
|
-
filters: dashboardFilters,
|
|
693
|
-
});
|
|
694
593
|
setLoading(false);
|
|
695
594
|
dispatch({
|
|
696
595
|
type: 'UPDATE_DASHBOARD_ITEM',
|
|
697
|
-
id,
|
|
596
|
+
id: chartId,
|
|
698
597
|
data: {
|
|
699
598
|
...resp.data,
|
|
700
|
-
filters: dashboardFilters,
|
|
701
599
|
},
|
|
702
600
|
});
|
|
703
601
|
}
|
|
@@ -728,32 +626,11 @@ const ChartUpdater: React.FC<ChartProps> = ({
|
|
|
728
626
|
);
|
|
729
627
|
// console.log('RESP: ', resp.data);
|
|
730
628
|
if (resp.data) {
|
|
731
|
-
const {
|
|
732
|
-
xAxisField,
|
|
733
|
-
yAxisFields,
|
|
734
|
-
xAxisLabel,
|
|
735
|
-
yAxisLabel,
|
|
736
|
-
xAxisFormat,
|
|
737
|
-
chartType,
|
|
738
|
-
rows,
|
|
739
|
-
} = resp.data;
|
|
740
|
-
setChartConfig({
|
|
741
|
-
xAxisField,
|
|
742
|
-
yAxisFields,
|
|
743
|
-
xAxisLabel,
|
|
744
|
-
yAxisLabel,
|
|
745
|
-
xAxisFormat,
|
|
746
|
-
chartType,
|
|
747
|
-
rows,
|
|
748
|
-
startDate: dateFilter && dateFilter.startDate,
|
|
749
|
-
endDate: dateFilter && dateFilter.endDate,
|
|
750
|
-
filters: dashboardFilters,
|
|
751
|
-
});
|
|
752
629
|
setLoading(false);
|
|
753
630
|
dispatch({
|
|
754
631
|
type: 'UPDATE_DASHBOARD_ITEM',
|
|
755
|
-
id,
|
|
756
|
-
data: { ...resp.data
|
|
632
|
+
id: chartId,
|
|
633
|
+
data: { ...resp.data },
|
|
757
634
|
});
|
|
758
635
|
}
|
|
759
636
|
}
|
|
@@ -767,37 +644,31 @@ const ChartUpdater: React.FC<ChartProps> = ({
|
|
|
767
644
|
setLoading(false);
|
|
768
645
|
return;
|
|
769
646
|
}
|
|
770
|
-
const filtersChanged = didFiltersChange(
|
|
771
|
-
dashboardFilters,
|
|
772
|
-
chartConfig?.filters
|
|
773
|
-
);
|
|
774
647
|
|
|
775
|
-
if
|
|
776
|
-
|
|
777
|
-
(chartId && chartConfig && filtersChanged) ||
|
|
778
|
-
(chartId &&
|
|
779
|
-
chartConfig &&
|
|
780
|
-
isDateFilter &&
|
|
781
|
-
dateFilter &&
|
|
782
|
-
(chartConfig.startDate !== dateFilter.startDate ||
|
|
783
|
-
chartConfig.endDate !== dateFilter.endDate))
|
|
784
|
-
) {
|
|
785
|
-
getChartOptions(chartId, filtersChanged);
|
|
786
|
-
}
|
|
648
|
+
getChartOptions(); //when wouldn't you run this????? saw if statements before that implied you might not run this sometimes
|
|
649
|
+
|
|
787
650
|
return () => {
|
|
788
651
|
isSubscribed = false;
|
|
789
652
|
};
|
|
790
|
-
}, [
|
|
653
|
+
}, [dashboardFilters]);
|
|
791
654
|
|
|
792
655
|
// console.log('DASHBOARD FILTERS: ', dashboardFilters);
|
|
793
656
|
|
|
794
657
|
useEffect(() => {
|
|
795
658
|
if (config) {
|
|
796
|
-
|
|
659
|
+
dispatch({
|
|
660
|
+
type: 'UPDATE_DASHBOARD_ITEM',
|
|
661
|
+
id: chartId,
|
|
662
|
+
data: { ...config },
|
|
663
|
+
});
|
|
797
664
|
}
|
|
798
665
|
}, [config]);
|
|
799
666
|
|
|
800
|
-
|
|
667
|
+
const dateFilter = Object.values(dashboardFilters).find(
|
|
668
|
+
filter => filter && filter.filterType === 'DATE_RANGE'
|
|
669
|
+
);
|
|
670
|
+
|
|
671
|
+
if (!dashboard[chartId] || loading) {
|
|
801
672
|
return (
|
|
802
673
|
<div
|
|
803
674
|
// className="flex flex-col flex-1 h-[100%]"
|
|
@@ -841,18 +712,18 @@ const ChartUpdater: React.FC<ChartProps> = ({
|
|
|
841
712
|
);
|
|
842
713
|
}
|
|
843
714
|
|
|
844
|
-
if (
|
|
845
|
-
const { xAxisField, yAxisFields } =
|
|
715
|
+
if (dashboard[chartId]?.chartType === 'pie') {
|
|
716
|
+
const { xAxisField, yAxisFields } = dashboard[chartId];
|
|
846
717
|
return (
|
|
847
718
|
<PieChart
|
|
848
719
|
// @ts-ignore
|
|
849
720
|
containerStyle={containerStyle}
|
|
850
|
-
data={
|
|
721
|
+
data={dashboard[chartId].rows.map(row => {
|
|
851
722
|
return {
|
|
852
723
|
...row,
|
|
853
724
|
count:
|
|
854
725
|
parseInt(row[yAxisFields[0].field]) /
|
|
855
|
-
sumByKey(
|
|
726
|
+
sumByKey(dashboard[chartId].rows, yAxisFields[0].field),
|
|
856
727
|
};
|
|
857
728
|
})}
|
|
858
729
|
category={yAxisFields[0].field}
|
|
@@ -863,48 +734,48 @@ const ChartUpdater: React.FC<ChartProps> = ({
|
|
|
863
734
|
);
|
|
864
735
|
}
|
|
865
736
|
|
|
866
|
-
if (
|
|
737
|
+
if (dashboard[chartId]?.chartType === 'table') {
|
|
867
738
|
return (
|
|
868
739
|
<TableChart
|
|
869
|
-
data={
|
|
870
|
-
yAxisFields={
|
|
740
|
+
data={dashboard[chartId].rows}
|
|
741
|
+
yAxisFields={dashboard[chartId].yAxisFields}
|
|
871
742
|
theme={theme}
|
|
872
743
|
containerStyle={containerStyle}
|
|
873
744
|
/>
|
|
874
745
|
);
|
|
875
746
|
}
|
|
876
747
|
|
|
877
|
-
if (
|
|
748
|
+
if (dashboard[chartId]?.chartType === 'bar') {
|
|
878
749
|
return (
|
|
879
750
|
<BarList
|
|
880
|
-
data={
|
|
751
|
+
data={dashboard[chartId].rows}
|
|
881
752
|
theme={theme}
|
|
882
|
-
yAxisFields={
|
|
883
|
-
xAxisFormat={
|
|
753
|
+
yAxisFields={dashboard[chartId].yAxisFields}
|
|
754
|
+
xAxisFormat={dashboard[chartId].xAxisFormat}
|
|
884
755
|
colors={colors}
|
|
885
|
-
xAxisField={
|
|
756
|
+
xAxisField={dashboard[chartId].xAxisField}
|
|
886
757
|
containerStyle={containerStyle}
|
|
887
758
|
/>
|
|
888
759
|
);
|
|
889
760
|
}
|
|
890
761
|
|
|
891
|
-
if (
|
|
762
|
+
if (dashboard[chartId]?.chartType === 'column') {
|
|
892
763
|
return (
|
|
893
764
|
<BarChart
|
|
894
765
|
colors={colors}
|
|
895
766
|
theme={theme}
|
|
896
|
-
yAxisFields={
|
|
767
|
+
yAxisFields={dashboard[chartId].yAxisFields}
|
|
897
768
|
// @ts-ignore
|
|
898
|
-
data={
|
|
899
|
-
xAxisField={
|
|
900
|
-
xAxisLabel={
|
|
901
|
-
xAxisFormat={
|
|
769
|
+
data={dashboard[chartId].rows}
|
|
770
|
+
xAxisField={dashboard[chartId].xAxisField}
|
|
771
|
+
xAxisLabel={dashboard[chartId].xAxisLabel}
|
|
772
|
+
xAxisFormat={dashboard[chartId].xAxisFormat}
|
|
902
773
|
containerStyle={containerStyle}
|
|
903
774
|
/>
|
|
904
775
|
);
|
|
905
776
|
}
|
|
906
777
|
|
|
907
|
-
if (
|
|
778
|
+
if (dashboard[chartId]?.chartType === 'metric') {
|
|
908
779
|
return (
|
|
909
780
|
<div
|
|
910
781
|
style={{
|
|
@@ -931,14 +802,14 @@ const ChartUpdater: React.FC<ChartProps> = ({
|
|
|
931
802
|
}}
|
|
932
803
|
// className="qq-flex qq-flex-col qq-text-xl"
|
|
933
804
|
>
|
|
934
|
-
{
|
|
805
|
+
{dashboard[chartId].rows.length > 0 &&
|
|
935
806
|
valueFormatter({
|
|
936
|
-
value:
|
|
937
|
-
field:
|
|
807
|
+
value: dashboard[chartId].rows[0][dashboard[chartId].xAxisField],
|
|
808
|
+
field: dashboard[chartId].xAxisField,
|
|
938
809
|
fields: [
|
|
939
810
|
{
|
|
940
|
-
field:
|
|
941
|
-
format:
|
|
811
|
+
field: dashboard[chartId].xAxisField,
|
|
812
|
+
format: dashboard[chartId].xAxisFormat,
|
|
942
813
|
},
|
|
943
814
|
],
|
|
944
815
|
})}
|
|
@@ -949,12 +820,12 @@ const ChartUpdater: React.FC<ChartProps> = ({
|
|
|
949
820
|
return (
|
|
950
821
|
<LineChart
|
|
951
822
|
colors={colors}
|
|
952
|
-
yAxisFields={
|
|
823
|
+
yAxisFields={dashboard[chartId].yAxisFields}
|
|
953
824
|
// @ts-ignore
|
|
954
|
-
data={
|
|
955
|
-
xAxisField={
|
|
956
|
-
xAxisLabel={
|
|
957
|
-
xAxisFormat={
|
|
825
|
+
data={dashboard[chartId].rows}
|
|
826
|
+
xAxisField={dashboard[chartId].xAxisField}
|
|
827
|
+
xAxisLabel={dashboard[chartId].xAxisLabel}
|
|
828
|
+
xAxisFormat={dashboard[chartId].xAxisFormat}
|
|
958
829
|
containerStyle={containerStyle}
|
|
959
830
|
theme={theme}
|
|
960
831
|
/>
|
package/src/Context.tsx
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1
2
|
// @ts-nocheck
|
|
2
3
|
import React, { useState, createContext, useEffect, useReducer } from 'react';
|
|
3
4
|
import { QuillTheme } from './QuillProvider';
|
|
@@ -33,8 +34,7 @@ export const EditVisualizationModalVisibleContext = createContext([
|
|
|
33
34
|
export const ReportBuilderQueryContext = createContext(['', dummySetter]);
|
|
34
35
|
export const SavedReportsQueryContext = createContext(['', dummySetter]);
|
|
35
36
|
export const DashboardContext = createContext([{}, dummySetter]);
|
|
36
|
-
export const
|
|
37
|
-
export const DashboardFiltersContext = createContext({}, dummySetter);
|
|
37
|
+
export const DashboardFiltersContext = createContext([{}, dummySetter]);
|
|
38
38
|
|
|
39
39
|
const dashboardReducer = (state, action) => {
|
|
40
40
|
switch (action.type) {
|
|
@@ -58,18 +58,6 @@ const dashboardReducer = (state, action) => {
|
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
-
const dateFilterReducer = (state, action) => {
|
|
62
|
-
switch (action.type) {
|
|
63
|
-
case 'SET_GLOBAL_DATE_FILTER':
|
|
64
|
-
return {
|
|
65
|
-
...state,
|
|
66
|
-
...action.payload,
|
|
67
|
-
};
|
|
68
|
-
default:
|
|
69
|
-
return state;
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
|
|
73
61
|
const dashboardFiltersReducer = (state, action) => {
|
|
74
62
|
switch (action.type) {
|
|
75
63
|
case 'UPDATE_DASHBOARD_FILTER':
|
|
@@ -102,6 +90,7 @@ export const ContextProvider = ({
|
|
|
102
90
|
userId,
|
|
103
91
|
queryEndpoint,
|
|
104
92
|
queryHeaders,
|
|
93
|
+
withCredentials,
|
|
105
94
|
}) => {
|
|
106
95
|
const [client, setClient] = useState(null);
|
|
107
96
|
const [theme, setTheme] =
|
|
@@ -124,7 +113,6 @@ export const ContextProvider = ({
|
|
|
124
113
|
const [editVisualizationModalVisible, setEditVisualizationModalVisible] =
|
|
125
114
|
useState(false);
|
|
126
115
|
const [dashboard, dispatch] = useReducer(dashboardReducer, {});
|
|
127
|
-
const [dateFilter, dateFilterDispatch] = useReducer(dateFilterReducer, {});
|
|
128
116
|
const [dashboardFilters, dashboardFiltersDispatch] = useReducer(
|
|
129
117
|
dashboardFiltersReducer,
|
|
130
118
|
{}
|
|
@@ -148,6 +136,7 @@ export const ContextProvider = ({
|
|
|
148
136
|
environment,
|
|
149
137
|
queryEndpoint,
|
|
150
138
|
queryHeaders,
|
|
139
|
+
withCredentials,
|
|
151
140
|
});
|
|
152
141
|
}
|
|
153
142
|
}, [
|
|
@@ -158,6 +147,7 @@ export const ContextProvider = ({
|
|
|
158
147
|
client,
|
|
159
148
|
environment,
|
|
160
149
|
queryEndpoint,
|
|
150
|
+
withCredentials,
|
|
161
151
|
queryHeaders,
|
|
162
152
|
]);
|
|
163
153
|
|
|
@@ -233,21 +223,14 @@ export const ContextProvider = ({
|
|
|
233
223
|
<DashboardContext.Provider
|
|
234
224
|
value={{ dashboard, dispatch }}
|
|
235
225
|
>
|
|
236
|
-
<
|
|
226
|
+
<DashboardFiltersContext.Provider
|
|
237
227
|
value={{
|
|
238
|
-
|
|
239
|
-
|
|
228
|
+
dashboardFilters,
|
|
229
|
+
dashboardFiltersDispatch,
|
|
240
230
|
}}
|
|
241
231
|
>
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
dashboardFilters,
|
|
245
|
-
dashboardFiltersDispatch,
|
|
246
|
-
}}
|
|
247
|
-
>
|
|
248
|
-
{children}
|
|
249
|
-
</DashboardFiltersContext.Provider>
|
|
250
|
-
</DateFilterContext.Provider>
|
|
232
|
+
{children}
|
|
233
|
+
</DashboardFiltersContext.Provider>
|
|
251
234
|
</DashboardContext.Provider>
|
|
252
235
|
</SavedReportsQueryContext.Provider>
|
|
253
236
|
</ReportBuilderQueryContext.Provider>
|
package/src/Dashboard.tsx
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
1
2
|
// @ts-nocheck
|
|
2
3
|
import React, { useContext, useEffect, useState, useRef } from 'react';
|
|
3
4
|
import Chart from './Chart';
|
|
4
5
|
import {
|
|
5
6
|
ClientContext,
|
|
6
7
|
DashboardContext,
|
|
7
|
-
DateFilterContext,
|
|
8
8
|
ThemeContext,
|
|
9
9
|
DashboardFiltersContext,
|
|
10
10
|
} from './Context';
|
|
@@ -48,17 +48,9 @@ export default function Dashboard({
|
|
|
48
48
|
const [client, _] = useContext(ClientContext);
|
|
49
49
|
const [theme, _] =
|
|
50
50
|
useContext<[QuillTheme, (theme: QuillTheme) => void]>(ThemeContext);
|
|
51
|
-
const { dateFilter, dateFilterDispatch } = useContext(DateFilterContext);
|
|
52
51
|
const { dashboardFiltersDispatch } = useContext(DashboardFiltersContext);
|
|
53
52
|
const [configFilters, setConfigFilters] = useState([]);
|
|
54
53
|
|
|
55
|
-
const setGlobalDateFilter = (startDate, endDate) => {
|
|
56
|
-
dateFilterDispatch({
|
|
57
|
-
type: 'SET_GLOBAL_DATE_FILTER',
|
|
58
|
-
payload: { startDate, endDate },
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
|
|
62
54
|
React.useEffect(() => {
|
|
63
55
|
async function getDashboards() {
|
|
64
56
|
const {
|
|
@@ -67,13 +59,15 @@ export default function Dashboard({
|
|
|
67
59
|
environment,
|
|
68
60
|
queryEndpoint,
|
|
69
61
|
queryHeaders,
|
|
62
|
+
withCredentials,
|
|
70
63
|
} = client;
|
|
71
64
|
try {
|
|
72
65
|
// const response = await fetch(
|
|
73
66
|
// `https://quill-344421.uc.r.appspot.com/dashsections/${publicKey}/${customerId}/${name}`
|
|
74
67
|
// );
|
|
75
68
|
|
|
76
|
-
if (queryEndpoint
|
|
69
|
+
if (queryEndpoint) {
|
|
70
|
+
//&& queryHeaders
|
|
77
71
|
const response = await axios.post(
|
|
78
72
|
queryEndpoint,
|
|
79
73
|
{
|
|
@@ -81,8 +75,10 @@ export default function Dashboard({
|
|
|
81
75
|
},
|
|
82
76
|
{
|
|
83
77
|
headers: queryHeaders,
|
|
78
|
+
withCredentials,
|
|
84
79
|
}
|
|
85
80
|
);
|
|
81
|
+
|
|
86
82
|
if (response.status !== 200) {
|
|
87
83
|
throw new Error(`HTTP error! Status: ${response.status}`);
|
|
88
84
|
}
|
|
@@ -120,17 +116,18 @@ export default function Dashboard({
|
|
|
120
116
|
getDashboards();
|
|
121
117
|
}, [name]);
|
|
122
118
|
|
|
123
|
-
const onChangeDateFilter = dateFilter => {
|
|
124
|
-
setGlobalDateFilter(dateFilter[0], dateFilter[1]);
|
|
125
|
-
};
|
|
126
|
-
|
|
127
119
|
useEffect(() => {
|
|
128
120
|
// change to be set on the dashboard / section as default date range
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
121
|
+
const filter = {
|
|
122
|
+
startDate: sub(startOfToday(), { days: 90 }),
|
|
123
|
+
endDate: new Date(),
|
|
124
|
+
filterType: 'DATE_RANGE',
|
|
125
|
+
};
|
|
126
|
+
dashboardFiltersDispatch({
|
|
127
|
+
type: 'ADD_DASHBOARD_FILTER',
|
|
128
|
+
id: 'date_range',
|
|
129
|
+
data: {
|
|
130
|
+
...filter,
|
|
134
131
|
},
|
|
135
132
|
});
|
|
136
133
|
}, []);
|
|
@@ -141,10 +138,29 @@ export default function Dashboard({
|
|
|
141
138
|
}
|
|
142
139
|
};
|
|
143
140
|
|
|
141
|
+
const onChangeDateFilter = dateFilter => {
|
|
142
|
+
setGlobalDateFilter(dateFilter[0], dateFilter[1]);
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const setGlobalDateFilter = (startDate, endDate) => {
|
|
146
|
+
const filter = {
|
|
147
|
+
startDate: startDate,
|
|
148
|
+
endDate: endDate,
|
|
149
|
+
filterType: 'DATE_RANGE',
|
|
150
|
+
};
|
|
151
|
+
dashboardFiltersDispatch({
|
|
152
|
+
type: 'ADD_DASHBOARD_FILTER',
|
|
153
|
+
id: 'date_range',
|
|
154
|
+
data: {
|
|
155
|
+
...filter,
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
};
|
|
159
|
+
|
|
144
160
|
const onChangeFilter = (value, filter) => {
|
|
145
161
|
dashboardFiltersDispatch({
|
|
146
162
|
type: 'ADD_DASHBOARD_FILTER',
|
|
147
|
-
id:
|
|
163
|
+
id: 'date_range',
|
|
148
164
|
data: {
|
|
149
165
|
...filter,
|
|
150
166
|
selectedValue: filter.options.find(
|
|
@@ -391,7 +407,7 @@ export default function Dashboard({
|
|
|
391
407
|
// marginBottom: 50,
|
|
392
408
|
marginTop: 20,
|
|
393
409
|
}}
|
|
394
|
-
|
|
410
|
+
dateFilter={true}
|
|
395
411
|
chartId={elem._id}
|
|
396
412
|
query={elem.queryString}
|
|
397
413
|
// colors={theme.chartColors}
|
|
@@ -591,6 +607,7 @@ export default function Dashboard({
|
|
|
591
607
|
}
|
|
592
608
|
|
|
593
609
|
function Filter({ defaultValue, theme, onValueChange, filter }) {
|
|
610
|
+
//should be date as well as strings
|
|
594
611
|
const dropdownOptions = [
|
|
595
612
|
{ value: 'popupbagelsmardens', text: 'popupbagelsmardens' },
|
|
596
613
|
{ value: 'popupbagelswestport', text: 'popupbagelswestport' },
|
package/src/QuillProvider.tsx
CHANGED
|
@@ -19,6 +19,7 @@ interface WithQueryEndpoint extends BaseQuillProviderProps {
|
|
|
19
19
|
organizationId?: never;
|
|
20
20
|
queryEndpoint: string;
|
|
21
21
|
queryHeaders: object;
|
|
22
|
+
withCredentials?: boolean;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
type QuillProviderProps = WithOrganizationId | WithQueryEndpoint;
|
|
@@ -60,6 +61,7 @@ const QuillProvider = ({
|
|
|
60
61
|
environment,
|
|
61
62
|
children,
|
|
62
63
|
theme = defaultTheme,
|
|
64
|
+
withCredentials = false,
|
|
63
65
|
}: QuillProviderProps) => {
|
|
64
66
|
return (
|
|
65
67
|
<ContextProvider
|
|
@@ -69,6 +71,7 @@ const QuillProvider = ({
|
|
|
69
71
|
customerId={organizationId}
|
|
70
72
|
queryEndpoint={queryEndpoint}
|
|
71
73
|
queryHeaders={queryHeaders}
|
|
74
|
+
withCredentials={withCredentials}
|
|
72
75
|
>
|
|
73
76
|
{children}
|
|
74
77
|
</ContextProvider>
|
package/src/ReportBuilder.tsx
CHANGED
|
@@ -161,15 +161,21 @@ export default function ReportBuilder({
|
|
|
161
161
|
}, []);
|
|
162
162
|
|
|
163
163
|
const runQuery = async query => {
|
|
164
|
-
const {
|
|
165
|
-
|
|
164
|
+
const {
|
|
165
|
+
publicKey,
|
|
166
|
+
customerId,
|
|
167
|
+
environment,
|
|
168
|
+
queryEndpoint,
|
|
169
|
+
queryHeaders,
|
|
170
|
+
withCredentials,
|
|
171
|
+
} = client;
|
|
166
172
|
|
|
167
173
|
let response;
|
|
168
174
|
if (queryEndpoint) {
|
|
169
175
|
response = await axios.post(
|
|
170
176
|
queryEndpoint,
|
|
171
177
|
{ metadata: { query, task: 'query' } },
|
|
172
|
-
{ headers: queryHeaders }
|
|
178
|
+
{ headers: queryHeaders, withCredentials }
|
|
173
179
|
);
|
|
174
180
|
} else {
|
|
175
181
|
response = await axios.post(
|