Skip to content

Commit

Permalink
chore: hide time-series graph when org filter is active
Browse files Browse the repository at this point in the history
  • Loading branch information
NilsOveTen committed Nov 1, 2024
1 parent de7d2c5 commit ad8d30c
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 56 deletions.
16 changes: 8 additions & 8 deletions src/api/statistics-api/time-series.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,22 @@ const extractLabelsAndData = (
const timeSeriesRequest = (body: TimeSeriesRequest) =>
statisticsApiPost('time-series', body);

export const conceptTimeSeriesRequest = (orgPath: string | undefined) =>
timeSeriesRequest(timeSeriesBody('CONCEPT', orgPath)).then(
export const conceptTimeSeriesRequest = () =>
timeSeriesRequest(timeSeriesBody('CONCEPT', undefined)).then(
extractLabelsAndData
);

export const dataServiceTimeSeriesRequest = (orgPath: string | undefined) =>
timeSeriesRequest(timeSeriesBody('DATA_SERVICE', orgPath)).then(
export const dataServiceTimeSeriesRequest = () =>
timeSeriesRequest(timeSeriesBody('DATA_SERVICE', undefined)).then(
extractLabelsAndData
);

export const datasetTimeSeriesRequest = (orgPath: string | undefined) =>
timeSeriesRequest(timeSeriesBody('DATASET', orgPath)).then(
export const datasetTimeSeriesRequest = () =>
timeSeriesRequest(timeSeriesBody('DATASET', undefined)).then(
extractLabelsAndData
);

export const infoModelTimeSeriesRequest = (orgPath: string | undefined) =>
timeSeriesRequest(timeSeriesBody('INFORMATION_MODEL', orgPath)).then(
export const infoModelTimeSeriesRequest = () =>
timeSeriesRequest(timeSeriesBody('INFORMATION_MODEL', undefined)).then(
extractLabelsAndData
);
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ const ConceptReport: FC<Props> = ({
conceptsTimeSeries = []
}) => {
conceptsTimeSeries.push([Date.now(), totalObjects]);

const hasOrgPath = searchParams ? searchParams.includes('orgPath') : false;

return (
<ThemeProvider theme={theme.extendedColors[Entity.CONCEPT]}>
<main id='content'>
Expand Down Expand Up @@ -97,22 +100,24 @@ const ConceptReport: FC<Props> = ({
</div>
</div>

{conceptsTimeSeries?.length > 0 && conceptsTimeSeries?.length > 0 && (
<div className='row'>
<div className='col-12'>
<BoxRegular
header={localization.report.growth}
subHeader={localization.report.conceptGrowthFromFirstPublish}
>
<Line
name={localization.conceptLabel}
data={conceptsTimeSeries}
lineColor={theme.extendedColors[Entity.CONCEPT].dark}
/>
</BoxRegular>
{conceptsTimeSeries?.length > 0 &&
conceptsTimeSeries?.length > 0 &&
!hasOrgPath && (
<div className='row'>
<div className='col-12'>
<BoxRegular
header={localization.report.growth}
subHeader={localization.report.conceptGrowthFromFirstPublish}
>
<Line
name={localization.conceptLabel}
data={conceptsTimeSeries}
lineColor={theme.extendedColors[Entity.CONCEPT].dark}
/>
</BoxRegular>
</div>
</div>
</div>
)}
)}

{allReferencedConcepts?.length > 0 && (
<div className='row'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ const DataserviceReport: FC<Props> = ({
const { search: searchParams } = location;
dataServicesTimeSeries.push([Date.now(), totalObjects]);

const hasOrgPath = searchParams ? searchParams.includes('orgPath') : false;

const topMostUsedFormats: KeyWithCountObject[] = sortKeyWithCount(formats)
.filter(
({ key }: KeyWithCountObject) =>
Expand Down Expand Up @@ -111,7 +113,8 @@ const DataserviceReport: FC<Props> = ({
</div>

{dataServicesTimeSeries?.length > 0 &&
dataServicesTimeSeries?.length > 0 && (
dataServicesTimeSeries?.length > 0 &&
!hasOrgPath && (
<div className='row'>
<div className='col-12'>
<BoxRegular
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ const DatasetReport: FC<Props> = ({
)
).slice(0, 10);

const hasOrgPath = searchParams ? searchParams.includes('orgPath') : false;

const theme = getConfig().isNapProfile ? themeNAP : themeFDK;

return (
Expand Down Expand Up @@ -175,22 +177,24 @@ const DatasetReport: FC<Props> = ({
</div>
</div>

{datasetsTimeSeries?.length > 0 && datasetsTimeSeries?.length > 0 && (
<div className='row'>
<div className='col-12'>
<BoxRegular
header={localization.report.growth}
subHeader={localization.report.growthFromFirstPublish}
>
<Line
name={localization.datasetLabel}
data={datasetsTimeSeries}
lineColor={theme.extendedColors[Entity.DATASET].dark}
/>
</BoxRegular>
{datasetsTimeSeries?.length > 0 &&
datasetsTimeSeries?.length > 0 &&
!hasOrgPath && (
<div className='row'>
<div className='col-12'>
<BoxRegular
header={localization.report.growth}
subHeader={localization.report.growthFromFirstPublish}
>
<Line
name={localization.datasetLabel}
data={datasetsTimeSeries}
lineColor={theme.extendedColors[Entity.DATASET].dark}
/>
</BoxRegular>
</div>
</div>
</div>
)}
)}

{Number(totalObjects) > 0 && (
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ const InformationModelReport: FC<Props> = ({
informationModelsTimeSeries = []
}) => {
informationModelsTimeSeries.push([Date.now(), totalObjects]);

const hasOrgPath = searchParams ? searchParams.includes('orgPath') : false;

return (
<ThemeProvider theme={theme.extendedColors[Entity.INFORMATION_MODEL]}>
<main id='content'>
Expand Down Expand Up @@ -94,7 +97,8 @@ const InformationModelReport: FC<Props> = ({
</div>

{informationModelsTimeSeries?.length > 0 &&
informationModelsTimeSeries?.length > 0 && (
informationModelsTimeSeries?.length > 0 &&
!hasOrgPath && (
<div className='row'>
<div className='col-12'>
<BoxRegular
Expand Down
20 changes: 4 additions & 16 deletions src/pages/report-page/report-page-resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,12 @@ const mapProps = {
const { orgPath, losTheme: los } = parseSearchParams(location);
return memoizedGetDatasetsReport({ orgPath, los });
},
datasetsTimeSeries: ({ location }) => {
const { orgPath } = parseSearchParams(location);
return memoizedGetDatasetsTimeSeries(orgPath);
},
datasetsTimeSeries: () => memoizedGetDatasetsTimeSeries(),
dataServicesReport: ({ location }) => {
const { orgPath } = parseSearchParams(location);
return memoizedGetDataServicesReport({ orgPath });
},
dataServicesTimeSeries: ({ location }) => {
const { orgPath } = parseSearchParams(location);
return memoizedGetDataServicesTimeSeries(orgPath);
},
dataServicesTimeSeries: () => memoizedGetDataServicesTimeSeries(),
conceptsReport: async ({ location }) => {
const { orgPath, losTheme: los } = parseSearchParams(location);

Expand All @@ -59,18 +53,12 @@ const mapProps = {

return { ...reportItems, allReferencedConcepts };
},
conceptsTimeSeries: ({ location }) => {
const { orgPath } = parseSearchParams(location);
return memoizedGetConceptsTimeSeries(orgPath);
},
conceptsTimeSeries: () => memoizedGetConceptsTimeSeries(),
informationModelsReport: ({ location }) => {
const { orgPath, losTheme: los } = parseSearchParams(location);
return memoizedGetInformationModelsReport({ orgPath, los });
},
informationModelsTimeSeries: ({ location }) => {
const { orgPath } = parseSearchParams(location);
return memoizedGetInformationModelsTimeSeries(orgPath);
}
informationModelsTimeSeries: () => memoizedGetInformationModelsTimeSeries()
};

export const reportPageResolver = resolve(mapProps);

0 comments on commit ad8d30c

Please sign in to comment.