@gen3/frontend 0.11.0 → 0.11.11
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/dist/cjs/index.js +167 -100
- package/dist/cjs/index.js.map +1 -1
- package/dist/dts/components/Buttons/ActionButton.js +1 -1
- package/dist/dts/components/Buttons/ActionButton.js.map +1 -1
- package/dist/dts/components/Buttons/DownloadButtons/JSONObjectDownloadButton.js +1 -1
- package/dist/dts/components/Buttons/DownloadButtons/JSONObjectDownloadButton.js.map +1 -1
- package/dist/dts/components/Buttons/DropdownButtons/DropdownButton.js +1 -1
- package/dist/dts/components/Buttons/DropdownButtons/DropdownButton.js.map +1 -1
- package/dist/dts/components/Buttons/UploadJSONButton.js +1 -1
- package/dist/dts/components/Buttons/UploadJSONButton.js.map +1 -1
- package/dist/dts/components/Providers/Gen3Provider.js +1 -1
- package/dist/dts/components/Providers/Gen3Provider.js.map +1 -1
- package/dist/dts/components/charts/Charts.js +1 -1
- package/dist/dts/components/charts/Charts.js.map +1 -1
- package/dist/dts/components/charts/echarts/HorizontalBarChart.d.ts +1 -1
- package/dist/dts/components/charts/echarts/HorizontalBarChart.d.ts.map +1 -1
- package/dist/dts/components/charts/echarts/HorizontalBarChart.js +8 -4
- package/dist/dts/components/charts/echarts/HorizontalBarChart.js.map +1 -1
- package/dist/dts/components/counts/CountsValue.d.ts.map +1 -1
- package/dist/dts/components/counts/CountsValue.js +2 -2
- package/dist/dts/components/counts/CountsValue.js.map +1 -1
- package/dist/dts/components/facets/FacetControlsHeader.js +1 -1
- package/dist/dts/components/facets/FacetControlsHeader.js.map +1 -1
- package/dist/dts/components/facets/FacetEnumList.js +1 -1
- package/dist/dts/components/facets/FacetEnumList.js.map +1 -1
- package/dist/dts/components/facets/FacetTabs.js +1 -1
- package/dist/dts/components/facets/FacetTabs.js.map +1 -1
- package/dist/dts/features/Analysis/AnalysisCardCompact.stories.d.ts +14 -14
- package/dist/dts/features/Analysis/AnalysisCardCompact.stories.d.ts.map +1 -1
- package/dist/dts/features/CohortBuilder/CohortSelector.js +1 -1
- package/dist/dts/features/CohortBuilder/CohortSelector.js.map +1 -1
- package/dist/dts/features/CohortBuilder/DownloadsPanel.js +1 -1
- package/dist/dts/features/CohortBuilder/DownloadsPanel.js.map +1 -1
- package/dist/dts/features/CohortBuilder/ExplorerTable/SubTables/ExpandingSubtable.js +1 -1
- package/dist/dts/features/CohortBuilder/ExplorerTable/SubTables/ExpandingSubtable.js.map +1 -1
- package/dist/dts/features/CohortBuilder/Panels/AccordianPanel.js +1 -1
- package/dist/dts/features/CohortBuilder/Panels/AccordianPanel.js.map +1 -1
- package/dist/dts/features/CohortBuilder/Panels/DropdownPanel.js +1 -1
- package/dist/dts/features/CohortBuilder/Panels/DropdownPanel.js.map +1 -1
- package/dist/dts/features/CohortBuilder/QueryExpression/QueryExpressionSection.js +1 -1
- package/dist/dts/features/CohortBuilder/QueryExpression/QueryExpressionSection.js.map +1 -1
- package/dist/dts/features/CohortBuilder/TabbedCohortBuilder.d.ts.map +1 -1
- package/dist/dts/features/CohortBuilder/TabbedCohortBuilder.js +16 -9
- package/dist/dts/features/CohortBuilder/TabbedCohortBuilder.js.map +1 -1
- package/dist/dts/features/CohortDiscovery/ChartsAndFacetsPanel.d.ts +9 -1
- package/dist/dts/features/CohortDiscovery/ChartsAndFacetsPanel.d.ts.map +1 -1
- package/dist/dts/features/CohortDiscovery/ChartsAndFacetsPanel.js +7 -9
- package/dist/dts/features/CohortDiscovery/ChartsAndFacetsPanel.js.map +1 -1
- package/dist/dts/features/CohortDiscovery/CohortManagment/CohortManager.js +1 -1
- package/dist/dts/features/CohortDiscovery/CohortManagment/CohortManager.js.map +1 -1
- package/dist/dts/features/CohortDiscovery/IndexPanel.js +5 -8
- package/dist/dts/features/CohortDiscovery/IndexPanel.js.map +1 -1
- package/dist/dts/features/CohortDiscovery/SavedCohorts/SavedCohortsTable.js +1 -1
- package/dist/dts/features/CohortDiscovery/SavedCohorts/SavedCohortsTable.js.map +1 -1
- package/dist/dts/features/CohortDiscovery/api/analysisApiCohortDiscovery.d.ts.map +1 -1
- package/dist/dts/features/CohortDiscovery/api/analysisApiCohortDiscovery.js.map +1 -1
- package/dist/dts/features/CohortDiscovery/queryApi.d.ts +10 -0
- package/dist/dts/features/CohortDiscovery/queryApi.d.ts.map +1 -1
- package/dist/dts/features/CohortDiscovery/queryApi.js +19 -2
- package/dist/dts/features/CohortDiscovery/queryApi.js.map +1 -1
- package/dist/dts/features/DataLibrary/DatasetAccordionControl.js +1 -1
- package/dist/dts/features/DataLibrary/DatasetAccordionControl.js.map +1 -1
- package/dist/dts/features/DataLibrary/SearchAndActions.js +1 -1
- package/dist/dts/features/DataLibrary/SearchAndActions.js.map +1 -1
- package/dist/dts/features/DataLibrary/modals/SelectedItemsModal.js +1 -1
- package/dist/dts/features/DataLibrary/modals/SelectedItemsModal.js.map +1 -1
- package/dist/dts/features/DataLibrary/tables/SelectedItemsTable.js +1 -1
- package/dist/dts/features/DataLibrary/tables/SelectedItemsTable.js.map +1 -1
- package/dist/dts/features/Dictionary/CategoryHeader.js +1 -1
- package/dist/dts/features/Dictionary/CategoryHeader.js.map +1 -1
- package/dist/dts/features/Discovery/types.d.ts +1 -0
- package/dist/dts/features/Discovery/types.d.ts.map +1 -1
- package/dist/dts/features/Discovery/types.js.map +1 -1
- package/dist/dts/features/Navigation/NavigationBarButton.d.ts.map +1 -1
- package/dist/dts/features/Navigation/NavigationBarButton.js +3 -3
- package/dist/dts/features/Navigation/NavigationBarButton.js.map +1 -1
- package/dist/dts/features/Navigation/TopBar/AccountButton.d.ts.map +1 -1
- package/dist/dts/features/Navigation/TopBar/AccountButton.js.map +1 -1
- package/dist/dts/features/Navigation/TopBar/IconButton.js +1 -1
- package/dist/dts/features/Navigation/TopBar/IconButton.js.map +1 -1
- package/dist/dts/features/Workspace/NotebookCard.js +1 -1
- package/dist/dts/features/Workspace/NotebookCard.js.map +1 -1
- package/dist/dts/pages/TabbedCohortBuilder/TabbedCohortBuilderPage.d.ts.map +1 -1
- package/dist/dts/pages/TabbedCohortBuilder/TabbedCohortBuilderPage.js +4 -2
- package/dist/dts/pages/TabbedCohortBuilder/TabbedCohortBuilderPage.js.map +1 -1
- package/dist/dts/utils/strings.d.ts +1 -0
- package/dist/dts/utils/strings.d.ts.map +1 -1
- package/dist/dts/utils/strings.js +29 -0
- package/dist/dts/utils/strings.js.map +1 -1
- package/dist/esm/index.js +168 -102
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
package/dist/cjs/index.js
CHANGED
|
@@ -23,7 +23,7 @@ var reactCookie = require('react-cookie');
|
|
|
23
23
|
var FileSaver = require('file-saver');
|
|
24
24
|
var hooks = require('@mantine/hooks');
|
|
25
25
|
var defaultComposer = require('default-composer');
|
|
26
|
-
var react = require('@iconify/react');
|
|
26
|
+
var react = require('@iconify-icon/react');
|
|
27
27
|
var echarts = require('echarts');
|
|
28
28
|
var victory = require('victory');
|
|
29
29
|
var fa = require('react-icons/fa');
|
|
@@ -629,6 +629,27 @@ const toDisplayName = (field)=>{
|
|
|
629
629
|
if (!fieldName) return 'NotSet';
|
|
630
630
|
return fieldName.split('_').map((w)=>lodash.capitalize(w)).join(' ');
|
|
631
631
|
};
|
|
632
|
+
/*
|
|
633
|
+
Function to convert counts to a string with units
|
|
634
|
+
For example: count = 100 units = 'cases' => '100 Cases'
|
|
635
|
+
Function should handle pluralization
|
|
636
|
+
*/ const toCountsString = (counts, units)=>{
|
|
637
|
+
if (!counts) return `No ${lodash.capitalize(pluralize(units))}`;
|
|
638
|
+
// return a string with counts and units handling pluralization
|
|
639
|
+
const unitDisplay = counts === 1 ? units : pluralize(units);
|
|
640
|
+
return `${counts.toLocaleString()} ${lodash.capitalize(unitDisplay)}`;
|
|
641
|
+
};
|
|
642
|
+
// Helper function to handle basic pluralization
|
|
643
|
+
const pluralize = (word)=>{
|
|
644
|
+
// Handle special cases
|
|
645
|
+
if (word.endsWith('y')) {
|
|
646
|
+
return word.slice(0, -1) + 'ies';
|
|
647
|
+
} else if (word.endsWith('s') || word.endsWith('x') || word.endsWith('z') || word.endsWith('ch') || word.endsWith('sh')) {
|
|
648
|
+
return word + 'es';
|
|
649
|
+
} else {
|
|
650
|
+
return word + 's';
|
|
651
|
+
}
|
|
652
|
+
};
|
|
632
653
|
|
|
633
654
|
const isArrayOfString = (value)=>{
|
|
634
655
|
return Array.isArray(value) && value.every((element)=>typeof element === 'string');
|
|
@@ -2496,10 +2517,11 @@ const HorizontalBarChart = ({ data, valueType, total, showLegendInChart = true }
|
|
|
2496
2517
|
const chartDefinition = React.useMemo(()=>{
|
|
2497
2518
|
return {
|
|
2498
2519
|
tooltip: {
|
|
2499
|
-
trigger: '
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2520
|
+
trigger: 'item',
|
|
2521
|
+
formatter: function(param) {
|
|
2522
|
+
const p = lodash.isArray(param) && param.length > 0 ? param[0] : param;
|
|
2523
|
+
const colorSquare = `<span style="display:inline-block; width:10px; height:10px; background-color:${p.color}; margin-right:5px;"></span>`;
|
|
2524
|
+
return `${colorSquare}${p.seriesName}: <b>${p.value}</b>`;
|
|
2503
2525
|
}
|
|
2504
2526
|
},
|
|
2505
2527
|
legend: {
|
|
@@ -4842,7 +4864,7 @@ const FacetGroup = ({ facets, children })=>{
|
|
|
4842
4864
|
const availableFields = facets.map((f)=>f.field);
|
|
4843
4865
|
useScrollToHash(availableFields, false);
|
|
4844
4866
|
return /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
4845
|
-
className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-4 3xl:grid-cols-5 w-content gap-4
|
|
4867
|
+
className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-4 3xl:grid-cols-5 w-content gap-4 ml-2 w-full",
|
|
4846
4868
|
"data-testid": "title-cohort-builder-facet-groups",
|
|
4847
4869
|
children: children
|
|
4848
4870
|
});
|
|
@@ -5708,11 +5730,10 @@ const NavigationLogo = ({ src, title, description, width, height, divider = fals
|
|
|
5708
5730
|
* @param iconHeight - the height of the icon
|
|
5709
5731
|
* @param classNames - the class names to use for root, label, icon/tooltip and arrow'
|
|
5710
5732
|
* @param noBasePath - set to true to avoid prepending a basePath to the link
|
|
5711
|
-
*/ const NavigationBarButton = ({ tooltip, icon, href, name, iconHeight = '
|
|
5733
|
+
*/ const NavigationBarButton = ({ tooltip, icon, href, name, iconHeight = '32px', classNames = {}, noBasePath = false })=>{
|
|
5712
5734
|
const classNamesDefaults = {
|
|
5713
|
-
root: 'flex flex-col flex-nowrap px-3 py-2 pt-4 items-center align-center text-primary hover:text-accent opacity-80 hover:opacity-100',
|
|
5735
|
+
root: 'flex flex-col flex-nowrap px-3 py-2 pt-4 justify-between items-center align-center text-primary hover:text-accent opacity-80 hover:opacity-100',
|
|
5714
5736
|
label: 'pt-1.5 body-typo font-heading text-sm text-nowrap',
|
|
5715
|
-
icon: 'mt-0.5 ml-1',
|
|
5716
5737
|
...TooltipStyle
|
|
5717
5738
|
};
|
|
5718
5739
|
const mergedClassnames = mergeDefaultTailwindClassnames(classNamesDefaults, classNames);
|
|
@@ -11614,7 +11635,7 @@ const CountsValue = ({ label, isSuccess, counts })=>{
|
|
|
11614
11635
|
p: "xs",
|
|
11615
11636
|
withBorder: true,
|
|
11616
11637
|
className: "bg-primary text-primary-contrast font-heading text-md font-semibold",
|
|
11617
|
-
children:
|
|
11638
|
+
children: toCountsString(counts, label)
|
|
11618
11639
|
})
|
|
11619
11640
|
]
|
|
11620
11641
|
});
|
|
@@ -12729,6 +12750,11 @@ const TabbedCohortBuilder = ({ index, tabsConfiguration })=>{
|
|
|
12729
12750
|
filters: cohortFilters,
|
|
12730
12751
|
accessibility: accessLevel
|
|
12731
12752
|
});
|
|
12753
|
+
const { data: counts, isSuccess: isCountSuccess, isError } = core.useGetCountsQuery({
|
|
12754
|
+
type: index,
|
|
12755
|
+
filters: cohortFilters,
|
|
12756
|
+
accessibility: accessLevel
|
|
12757
|
+
});
|
|
12732
12758
|
const [facetDefinitions, setFacetDefinitions] = React.useState({});
|
|
12733
12759
|
React.useEffect(()=>{
|
|
12734
12760
|
// Check if the router initiated the change
|
|
@@ -12866,25 +12892,42 @@ const TabbedCohortBuilder = ({ index, tabsConfiguration })=>{
|
|
|
12866
12892
|
getRangeFacetData,
|
|
12867
12893
|
index
|
|
12868
12894
|
]);
|
|
12869
|
-
return /*#__PURE__*/ jsxRuntime.
|
|
12870
|
-
|
|
12871
|
-
|
|
12872
|
-
|
|
12873
|
-
|
|
12874
|
-
usedFacets: cohortBuilderFilters,
|
|
12875
|
-
hooks: facetDataHooks,
|
|
12876
|
-
customFacetHooks: {
|
|
12877
|
-
useCustomFacets,
|
|
12878
|
-
useAvailableCustomFacets: (usedFacets, onlyFiltersWithValues, queryOptions)=>({
|
|
12879
|
-
data: {},
|
|
12880
|
-
isSuccess: true
|
|
12881
|
-
}),
|
|
12882
|
-
useAddCustomFilter: ()=>(filter)=>{},
|
|
12883
|
-
useRemoveCustomFilter: ()=>(filter)=>{}
|
|
12895
|
+
return /*#__PURE__*/ jsxRuntime.jsxs(core$1.Stack, {
|
|
12896
|
+
gap: "xs",
|
|
12897
|
+
align: "stretch",
|
|
12898
|
+
classNames: {
|
|
12899
|
+
root: 'w-full'
|
|
12884
12900
|
},
|
|
12885
|
-
|
|
12886
|
-
|
|
12887
|
-
|
|
12901
|
+
children: [
|
|
12902
|
+
/*#__PURE__*/ jsxRuntime.jsx(core$1.Group, {
|
|
12903
|
+
justify: "flex-end",
|
|
12904
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(CountsValue, {
|
|
12905
|
+
label: index,
|
|
12906
|
+
counts: counts,
|
|
12907
|
+
isSuccess: isCountSuccess
|
|
12908
|
+
})
|
|
12909
|
+
}),
|
|
12910
|
+
/*#__PURE__*/ jsxRuntime.jsx(FacetTabs, {
|
|
12911
|
+
activeTab: activeTab,
|
|
12912
|
+
setActiveTab: setActiveTab,
|
|
12913
|
+
facetDefinitions: facetDefinitions,
|
|
12914
|
+
tabsConfig: tabsConfig,
|
|
12915
|
+
usedFacets: cohortBuilderFilters,
|
|
12916
|
+
hooks: facetDataHooks,
|
|
12917
|
+
customFacetHooks: {
|
|
12918
|
+
useCustomFacets,
|
|
12919
|
+
useAvailableCustomFacets: (usedFacets, onlyFiltersWithValues, queryOptions)=>({
|
|
12920
|
+
data: {},
|
|
12921
|
+
isSuccess: true
|
|
12922
|
+
}),
|
|
12923
|
+
useAddCustomFilter: ()=>(filter)=>{},
|
|
12924
|
+
useRemoveCustomFilter: ()=>(filter)=>{}
|
|
12925
|
+
},
|
|
12926
|
+
getFacetLabel: ()=>'Cases',
|
|
12927
|
+
cardScrollMargin: calculateStickyHeaderHeight(),
|
|
12928
|
+
useFieldNameToTitle: useFieldNameToTitle
|
|
12929
|
+
})
|
|
12930
|
+
]
|
|
12888
12931
|
});
|
|
12889
12932
|
};
|
|
12890
12933
|
|
|
@@ -15508,85 +15551,26 @@ const createFacetPanel = (facet, chartType, valueLabel, hooks)=>{
|
|
|
15508
15551
|
return null;
|
|
15509
15552
|
};
|
|
15510
15553
|
|
|
15511
|
-
const GEN3_COHORT_DISCOVERY_API = process.env.GEN3_COHORT_DISCOVERY_API || `${core.GEN3_API}/api/auth/analysis/cohortDiscovery`;
|
|
15512
|
-
|
|
15513
|
-
const useGraphQLData = (url, body, skip)=>{
|
|
15514
|
-
// Create a fetcher function that handles the GraphQL POST request
|
|
15515
|
-
const fetcher = async (fetchUrl, fetchBody)=>{
|
|
15516
|
-
const headers = new Headers({
|
|
15517
|
-
Accept: 'application/json',
|
|
15518
|
-
'Content-Type': 'application/json'
|
|
15519
|
-
});
|
|
15520
|
-
if (process.env.NODE_ENV === 'development') {
|
|
15521
|
-
// NOTE: This cookie can only be accessed from the client side
|
|
15522
|
-
// in development mode. Otherwise, the cookie is set as httpOnly
|
|
15523
|
-
const accessToken = cookiesNext.getCookie('credentials_token');
|
|
15524
|
-
if (accessToken) {
|
|
15525
|
-
headers.set('Authorization', `Bearer ${accessToken}`);
|
|
15526
|
-
}
|
|
15527
|
-
}
|
|
15528
|
-
const response = await fetch(fetchUrl, {
|
|
15529
|
-
method: 'POST',
|
|
15530
|
-
headers: headers,
|
|
15531
|
-
body: JSON.stringify(fetchBody)
|
|
15532
|
-
});
|
|
15533
|
-
if (!response.ok) {
|
|
15534
|
-
throw new Error(`Error ${response.status}: ${response.statusText}`);
|
|
15535
|
-
}
|
|
15536
|
-
return await response.json();
|
|
15537
|
-
};
|
|
15538
|
-
// Use SWR with the fetcher
|
|
15539
|
-
const { data, error, isLoading, mutate } = useSWR(!skip ? [
|
|
15540
|
-
url,
|
|
15541
|
-
body
|
|
15542
|
-
] : null, ([fetchUrl, fetchBody])=>fetcher(fetchUrl, fetchBody), {
|
|
15543
|
-
revalidateOnFocus: false
|
|
15544
|
-
});
|
|
15545
|
-
// Format error to match your ErrorDetails interface
|
|
15546
|
-
const formattedError = error ? {
|
|
15547
|
-
status: error.message.match(/\d+/)?.[0] || 'Unknown',
|
|
15548
|
-
message: error.message
|
|
15549
|
-
} : null;
|
|
15550
|
-
return {
|
|
15551
|
-
data,
|
|
15552
|
-
isLoading,
|
|
15553
|
-
isSuccess: !!data && !error,
|
|
15554
|
-
isError: !!error,
|
|
15555
|
-
error: formattedError,
|
|
15556
|
-
mutate
|
|
15557
|
-
};
|
|
15558
|
-
};
|
|
15559
|
-
const useRoundedAggsQuery = ({ type, fields, filters, accessibility = core.Accessibility.ALL }, { skip } = {
|
|
15560
|
-
skip: false
|
|
15561
|
-
})=>{
|
|
15562
|
-
const response = useGraphQLData(GEN3_COHORT_DISCOVERY_API, core.buildGetAggregationQuery(type, fields, filters, accessibility, false), skip);
|
|
15563
|
-
return {
|
|
15564
|
-
...response,
|
|
15565
|
-
data: response?.data?.data ? core.processHistogramResponse(response?.data.data?._aggregation[type] ?? {}) : {}
|
|
15566
|
-
};
|
|
15567
|
-
};
|
|
15568
|
-
|
|
15569
15554
|
const NUM_COLS = 2; // TODO: add to config
|
|
15570
15555
|
/**
|
|
15571
15556
|
* CartsAndFacetsPanel component
|
|
15572
15557
|
*
|
|
15573
15558
|
* @param {string} index - The index type used for querying data.
|
|
15559
|
+
* @param data
|
|
15560
|
+
* @param isLoading
|
|
15561
|
+
* @param isError
|
|
15562
|
+
* @param isSuccess
|
|
15574
15563
|
* @param {Array} facets - The list of facets to be rendered.
|
|
15575
15564
|
* @returns {JSX.Element} The rendered component showing facets.
|
|
15576
|
-
*/ const ChartsAndFacetsPanel = ({ index, facets })=>{
|
|
15565
|
+
*/ const ChartsAndFacetsPanel = ({ index, data, isLoading, isError, isSuccess, facets })=>{
|
|
15577
15566
|
const cohortFilters = useAppSelector((state)=>selectCurrentCohortIndexFilters(state, index));
|
|
15578
|
-
const { data, isSuccess, isLoading: isAggsQueryFetching, isError: isAggsQueryError } = useRoundedAggsQuery({
|
|
15579
|
-
type: index,
|
|
15580
|
-
fields: facets.map((x)=>x.field),
|
|
15581
|
-
filters: cohortFilters
|
|
15582
|
-
});
|
|
15583
15567
|
const getEnumFacetData = useDeepCompare.useDeepCompareCallback((field)=>{
|
|
15584
15568
|
return {
|
|
15585
15569
|
data: processBucketData(data?.[field]),
|
|
15586
15570
|
enumFilters: field in cohortFilters.root ? core.extractEnumFilterValue(cohortFilters.root[field]) : undefined,
|
|
15587
15571
|
isSuccess: isSuccess,
|
|
15588
|
-
isFetching:
|
|
15589
|
-
isError:
|
|
15572
|
+
isFetching: isLoading,
|
|
15573
|
+
isError: isError
|
|
15590
15574
|
};
|
|
15591
15575
|
}, [
|
|
15592
15576
|
cohortFilters,
|
|
@@ -16125,6 +16109,67 @@ const CohortManager = ({ indexResources, remoteSupportService, size = 'md' })=>{
|
|
|
16125
16109
|
});
|
|
16126
16110
|
};
|
|
16127
16111
|
|
|
16112
|
+
process.env.GEN3_COHORT_DISCOVERY_API || `${core.GEN3_API}/api/auth/analysis/cohortDiscovery`;
|
|
16113
|
+
|
|
16114
|
+
const useGraphQLData = (url, body, skip)=>{
|
|
16115
|
+
// Create a fetcher function that handles the GraphQL POST request
|
|
16116
|
+
const csrfToken = core.useCoreSelector((state)=>core.selectCSRFToken(state));
|
|
16117
|
+
const fetcher = async (fetchUrl, fetchBody)=>{
|
|
16118
|
+
const headers = new Headers({
|
|
16119
|
+
Accept: 'application/json',
|
|
16120
|
+
'Content-Type': 'application/json',
|
|
16121
|
+
'X-CSRF-Token': csrfToken ?? ''
|
|
16122
|
+
});
|
|
16123
|
+
if (process.env.NODE_ENV === 'development') {
|
|
16124
|
+
// NOTE: This cookie can only be accessed from the client side
|
|
16125
|
+
// in development mode. Otherwise, the cookie is set as httpOnly
|
|
16126
|
+
const accessToken = cookiesNext.getCookie('credentials_token');
|
|
16127
|
+
if (accessToken) {
|
|
16128
|
+
headers.set('Authorization', `Bearer ${accessToken}`);
|
|
16129
|
+
}
|
|
16130
|
+
}
|
|
16131
|
+
const response = await fetch(fetchUrl, {
|
|
16132
|
+
method: 'POST',
|
|
16133
|
+
headers: headers,
|
|
16134
|
+
body: JSON.stringify(fetchBody)
|
|
16135
|
+
});
|
|
16136
|
+
if (!response.ok) {
|
|
16137
|
+
throw new Error(`Error ${response.status}: ${response.statusText}`);
|
|
16138
|
+
}
|
|
16139
|
+
return await response.json();
|
|
16140
|
+
};
|
|
16141
|
+
// Use SWR with the fetcher
|
|
16142
|
+
const { data, error, isLoading, mutate } = useSWR(!skip ? [
|
|
16143
|
+
url,
|
|
16144
|
+
body
|
|
16145
|
+
] : null, ([fetchUrl, fetchBody])=>fetcher(fetchUrl, fetchBody), {
|
|
16146
|
+
revalidateOnFocus: false
|
|
16147
|
+
});
|
|
16148
|
+
// Format error to match your ErrorDetails interface
|
|
16149
|
+
const formattedError = error ? {
|
|
16150
|
+
status: error.message.match(/\d+/)?.[0] || 'Unknown',
|
|
16151
|
+
message: error.message
|
|
16152
|
+
} : null;
|
|
16153
|
+
return {
|
|
16154
|
+
data,
|
|
16155
|
+
isLoading,
|
|
16156
|
+
isSuccess: !!data && !error,
|
|
16157
|
+
isError: !!error,
|
|
16158
|
+
error: formattedError,
|
|
16159
|
+
mutate
|
|
16160
|
+
};
|
|
16161
|
+
};
|
|
16162
|
+
const COHORT_DISCOVERY_LIMIT$1 = process.env.NEXT_PUBLIC_GEN3_COHORT_DISCOVERY_LIMIT ? Number(process.env.NEXT_PUBLIC_GEN3_COHORT_DISCOVERY_LIMIT) : 100;
|
|
16163
|
+
const useUnsecureRoundedAggsQuery = ({ type, fields, filters, accessibility = core.Accessibility.ALL }, { skip } = {
|
|
16164
|
+
skip: false
|
|
16165
|
+
})=>{
|
|
16166
|
+
const response = useGraphQLData(`${core.GEN3_GUPPY_API}/graphql`, core.buildGetAggregationQuery(type, fields, filters, accessibility, false), skip);
|
|
16167
|
+
return {
|
|
16168
|
+
...response,
|
|
16169
|
+
data: response?.data?.data ? core.processHistogramResponse(core.roundHistogramResponse(response?.data?.data._aggregation[type], COHORT_DISCOVERY_LIMIT$1)) : {}
|
|
16170
|
+
};
|
|
16171
|
+
};
|
|
16172
|
+
|
|
16128
16173
|
const CohortQueryExpression = ({ index })=>{
|
|
16129
16174
|
const currentCohortId = useAppSelector((state)=>selectCurrentCohortId(state));
|
|
16130
16175
|
const currentCohortName = useAppSelector((state)=>selectCurrentCohortName(state));
|
|
@@ -16198,13 +16243,12 @@ const IndexPanel = ({ dataConfig, tabs, tabTitle, emptySelection, indexResources
|
|
|
16198
16243
|
facetDefinitions
|
|
16199
16244
|
]);
|
|
16200
16245
|
const cohortFilters = useAppSelector((state)=>selectCurrentCohortIndexFilters(state, index));
|
|
16201
|
-
const
|
|
16202
|
-
const { data, isSuccess, isError: isAggsQueryError } = useRoundedAggsQuery({
|
|
16246
|
+
const { data, isSuccess, isLoading: isAggsQueryFetching, isError: isAggsQueryError } = useUnsecureRoundedAggsQuery({
|
|
16203
16247
|
type: index,
|
|
16204
|
-
fields:
|
|
16248
|
+
fields: fields,
|
|
16205
16249
|
filters: cohortFilters
|
|
16206
16250
|
}, {
|
|
16207
|
-
skip:
|
|
16251
|
+
skip: fields.length === 0
|
|
16208
16252
|
});
|
|
16209
16253
|
const updateFields = useDeepCompare.useDeepCompareCallback((field, checked)=>{
|
|
16210
16254
|
if (!checked) {
|
|
@@ -16290,6 +16334,10 @@ const IndexPanel = ({ dataConfig, tabs, tabTitle, emptySelection, indexResources
|
|
|
16290
16334
|
remoteSupportService: remoteSupportService
|
|
16291
16335
|
}),
|
|
16292
16336
|
selectedFacets.length > 0 ? /*#__PURE__*/ jsxRuntime.jsx(ChartsAndFacetsPanel, {
|
|
16337
|
+
data: data,
|
|
16338
|
+
isLoading: isAggsQueryFetching,
|
|
16339
|
+
isError: isAggsQueryError,
|
|
16340
|
+
isSuccess: isSuccess,
|
|
16293
16341
|
index: index,
|
|
16294
16342
|
facets: activeFieldDefinitions
|
|
16295
16343
|
}) : /*#__PURE__*/ jsxRuntime.jsx(core$1.Center, {
|
|
@@ -25076,8 +25124,26 @@ const TabbedCohortBuilderPage = ({ headerProps, footerProps, configuration })=>{
|
|
|
25076
25124
|
content: 'Tabbed Cohort Builder Page',
|
|
25077
25125
|
key: 'gen3-tabbed-cohort-builder-page'
|
|
25078
25126
|
},
|
|
25079
|
-
children: /*#__PURE__*/ jsxRuntime.
|
|
25080
|
-
|
|
25127
|
+
children: /*#__PURE__*/ jsxRuntime.jsxs(core$1.Stack, {
|
|
25128
|
+
align: "stretch",
|
|
25129
|
+
classNames: {
|
|
25130
|
+
root: 'w-full'
|
|
25131
|
+
},
|
|
25132
|
+
children: [
|
|
25133
|
+
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
25134
|
+
className: "w-full flex-col flex gap-4 fixed bg-white z-10",
|
|
25135
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(CohortManager$1, {
|
|
25136
|
+
index: configuration.index
|
|
25137
|
+
})
|
|
25138
|
+
}),
|
|
25139
|
+
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
25140
|
+
className: "w-full mt-40 mr-4",
|
|
25141
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(TabbedCohortBuilder, {
|
|
25142
|
+
...configuration,
|
|
25143
|
+
index: configuration.index
|
|
25144
|
+
})
|
|
25145
|
+
})
|
|
25146
|
+
]
|
|
25081
25147
|
})
|
|
25082
25148
|
});
|
|
25083
25149
|
};
|
|
@@ -25717,6 +25783,7 @@ exports.sessionLogout = sessionLogout;
|
|
|
25717
25783
|
exports.sessionToken = sessionToken;
|
|
25718
25784
|
exports.staticNotebookAPI = staticNotebookAPI;
|
|
25719
25785
|
exports.stripTrailingSlash = stripTrailingSlash;
|
|
25786
|
+
exports.toCountsString = toCountsString;
|
|
25720
25787
|
exports.toDisplayName = toDisplayName;
|
|
25721
25788
|
exports.truncateString = truncateString;
|
|
25722
25789
|
exports.unixTimeToString = unixTimeToString;
|