Skip to content

Commit

Permalink
Merge pull request #1271 from visualize-admin/feat/multiple-cubes-met…
Browse files Browse the repository at this point in the history
…adata

feat: Add a way to retrieve metadata from multiple cubes
  • Loading branch information
bprusinowski authored Nov 17, 2023
2 parents 8fe6d16 + 2080e2c commit 099771b
Show file tree
Hide file tree
Showing 40 changed files with 677 additions and 706 deletions.
11 changes: 6 additions & 5 deletions app/browse/datatable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ import {
} from "@/domain/data";
import { useDimensionFormatters } from "@/formatters";
import {
useDataCubeMetadataQuery,
useDataCubeObservationsQuery,
useDataCubesComponentsQuery,
useDataCubesMetadataQuery,
} from "@/graphql/query-hooks";
import SvgIcChevronDown from "@/icons/components/IcChevronDown";
import { useLocale } from "@/locales/use-locale";
Expand Down Expand Up @@ -257,10 +257,10 @@ export const DataSetTable = ({
sourceUrl: dataSource.url,
locale,
};
const [{ data: metadataData }] = useDataCubeMetadataQuery({
const [{ data: metadataData }] = useDataCubesMetadataQuery({
variables: {
...commonQueryVariables,
iri: dataSetIri,
filters: [{ iri: dataSetIri }],
},
});
const [{ data: componentsData }] = useDataCubesComponentsQuery({
Expand Down Expand Up @@ -289,12 +289,13 @@ export const DataSetTable = ({
]);
}, [componentsData?.dataCubesComponents]);

return metadataData?.dataCubeByIri &&
return metadataData?.dataCubesMetadata &&
componentsData?.dataCubesComponents &&
observationsData?.dataCubeByIri ? (
<Box sx={{ maxHeight: "600px", overflow: "auto", ...sx }}>
<PreviewTable
title={metadataData.dataCubeByIri.title}
// FIXME: adapt to design
title={metadataData.dataCubesMetadata.map((d) => d.title).join(", ")}
headers={headers}
observations={observationsData.dataCubeByIri.observations.data}
linkToMetadataPanel={true}
Expand Down
6 changes: 3 additions & 3 deletions app/charts/area/chart-area.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import { LegendColor } from "@/charts/shared/legend-color";
import { InteractionHorizontal } from "@/charts/shared/overlay-horizontal";
import { AreaConfig, DataSource, QueryFilters } from "@/config-types";
import {
useDataCubeMetadataQuery,
useDataCubeObservationsQuery,
useDataCubesComponentsQuery,
useDataCubesMetadataQuery,
} from "@/graphql/query-hooks";
import { useLocale } from "@/locales/use-locale";

Expand All @@ -44,10 +44,10 @@ export const ChartAreasVisualization = ({
sourceUrl: dataSource.url,
locale,
};
const [metadataQuery] = useDataCubeMetadataQuery({
const [metadataQuery] = useDataCubesMetadataQuery({
variables: {
...commonQueryVariables,
iri: dataSetIri,
filters: [{ iri: dataSetIri }],
},
});
const [componentsQuery] = useDataCubesComponentsQuery({
Expand Down
9 changes: 5 additions & 4 deletions app/charts/chart-loading-wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import {
} from "@/components/hint";
import { ChartConfig } from "@/configurator";
import {
DataCubeMetadataQuery,
DataCubeObservationsQuery,
DataCubesComponentsQuery,
DataCubesMetadataQuery,
} from "@/graphql/query-hooks";

type ElementProps<RE> = RE extends React.ElementType<infer P> ? P : never;
Expand All @@ -35,7 +35,7 @@ export const ChartLoadingWrapper = <
ComponentProps,
}: {
metadataQuery: Pick<
UseQueryResponse<DataCubeMetadataQuery>[0],
UseQueryResponse<DataCubesMetadataQuery>[0],
"data" | "fetching" | "error"
>;
componentsQuery: Pick<
Expand Down Expand Up @@ -70,7 +70,7 @@ export const ChartLoadingWrapper = <
error: observationsError,
} = observationsQuery;

const metadata = metadataData?.dataCubeByIri;
const metadata = metadataData?.dataCubesMetadata;
const observations = observationsData?.dataCubeByIri?.observations.data;
const dimensions = componentsData?.dataCubesComponents.dimensions;
const measures = componentsData?.dataCubesComponents.measures;
Expand All @@ -90,7 +90,8 @@ export const ChartLoadingWrapper = <
}, [dimensions, measures]);

if (metadata && dimensions && measures && observations) {
const { title } = metadata;
// FIXME: adapt to design
const title = metadata.map((d) => d.title).join(", ");

return (
<Box
Expand Down
6 changes: 3 additions & 3 deletions app/charts/column/chart-column.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ import { LegendColor } from "@/charts/shared/legend-color";
import { ColumnConfig, DataSource, QueryFilters } from "@/config-types";
import { TimeSlider } from "@/configurator/interactive-filters/time-slider";
import {
useDataCubeMetadataQuery,
useDataCubeObservationsQuery,
useDataCubesComponentsQuery,
useDataCubesMetadataQuery,
} from "@/graphql/query-hooks";
import { useLocale } from "@/locales/use-locale";

Expand All @@ -54,10 +54,10 @@ export const ChartColumnsVisualization = ({
sourceUrl: dataSource.url,
locale,
};
const [metadataQuery] = useDataCubeMetadataQuery({
const [metadataQuery] = useDataCubesMetadataQuery({
variables: {
...commonQueryVariables,
iri: dataSetIri,
filters: [{ iri: dataSetIri }],
},
});
const [componentsQuery] = useDataCubesComponentsQuery({
Expand Down
6 changes: 3 additions & 3 deletions app/charts/combo/chart-combo-line-column.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import {
QueryFilters,
} from "@/config-types";
import {
useDataCubeMetadataQuery,
useDataCubeObservationsQuery,
useDataCubesComponentsQuery,
useDataCubesMetadataQuery,
} from "@/graphql/query-hooks";
import { useLocale } from "@/locales/use-locale";

Expand All @@ -44,10 +44,10 @@ export const ChartComboLineColumnVisualization = (
sourceUrl: dataSource.url,
locale,
};
const [metadataQuery] = useDataCubeMetadataQuery({
const [metadataQuery] = useDataCubesMetadataQuery({
variables: {
...commonQueryVariables,
iri: dataSetIri,
filters: [{ iri: dataSetIri }],
},
});
const [componentsQuery] = useDataCubesComponentsQuery({
Expand Down
6 changes: 3 additions & 3 deletions app/charts/combo/chart-combo-line-dual.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import { Tooltip } from "@/charts/shared/interaction/tooltip";
import { InteractionHorizontal } from "@/charts/shared/overlay-horizontal";
import { ComboLineDualConfig, DataSource, QueryFilters } from "@/config-types";
import {
useDataCubeMetadataQuery,
useDataCubeObservationsQuery,
useDataCubesComponentsQuery,
useDataCubesMetadataQuery,
} from "@/graphql/query-hooks";
import { useLocale } from "@/locales/use-locale";

Expand All @@ -40,10 +40,10 @@ export const ChartComboLineDualVisualization = (
sourceUrl: dataSource.url,
locale,
};
const [metadataQuery] = useDataCubeMetadataQuery({
const [metadataQuery] = useDataCubesMetadataQuery({
variables: {
...commonQueryVariables,
iri: dataSetIri,
filters: [{ iri: dataSetIri }],
},
});
const [componentsQuery] = useDataCubesComponentsQuery({
Expand Down
6 changes: 3 additions & 3 deletions app/charts/combo/chart-combo-line-single.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import {
QueryFilters,
} from "@/config-types";
import {
useDataCubeMetadataQuery,
useDataCubeObservationsQuery,
useDataCubesComponentsQuery,
useDataCubesMetadataQuery,
} from "@/graphql/query-hooks";
import { useLocale } from "@/locales/use-locale";

Expand All @@ -49,10 +49,10 @@ export const ChartComboLineSingleVisualization = (
sourceUrl: dataSource.url,
locale,
};
const [metadataQuery] = useDataCubeMetadataQuery({
const [metadataQuery] = useDataCubesMetadataQuery({
variables: {
...commonQueryVariables,
iri: dataSetIri,
filters: [{ iri: dataSetIri }],
},
});
const [componentsQuery] = useDataCubesComponentsQuery({
Expand Down
6 changes: 3 additions & 3 deletions app/charts/line/chart-lines.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import { LegendColor } from "@/charts/shared/legend-color";
import { InteractionHorizontal } from "@/charts/shared/overlay-horizontal";
import { DataSource, LineConfig, QueryFilters } from "@/config-types";
import {
useDataCubeMetadataQuery,
useDataCubeObservationsQuery,
useDataCubesComponentsQuery,
useDataCubesMetadataQuery,
} from "@/graphql/query-hooks";
import { useLocale } from "@/locales/use-locale";

Expand All @@ -45,10 +45,10 @@ export const ChartLinesVisualization = ({
sourceUrl: dataSource.url,
locale,
};
const [metadataQuery] = useDataCubeMetadataQuery({
const [metadataQuery] = useDataCubesMetadataQuery({
variables: {
...commonQueryVariables,
iri: dataSetIri,
filters: [{ iri: dataSetIri }],
},
});
const [componentsQuery] = useDataCubesComponentsQuery({
Expand Down
6 changes: 3 additions & 3 deletions app/charts/map/chart-map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import { TimeSlider } from "@/configurator/interactive-filters/time-slider";
import { GeoShapes } from "@/domain/data";
import {
GeoCoordinates,
useDataCubeMetadataQuery,
useDataCubeObservationsQuery,
useDataCubesComponentsQuery,
useDataCubesMetadataQuery,
useGeoCoordinatesByDimensionIriQuery,
useGeoShapesByDimensionIriQuery,
} from "@/graphql/query-hooks";
Expand Down Expand Up @@ -46,10 +46,10 @@ export const ChartMapVisualization = ({
sourceUrl: dataSource.url,
locale,
};
const [metadataQuery] = useDataCubeMetadataQuery({
const [metadataQuery] = useDataCubesMetadataQuery({
variables: {
...commonQueryVariables,
iri: dataSetIri,
filters: [{ iri: dataSetIri }],
},
});
const [componentsQuery] = useDataCubesComponentsQuery({
Expand Down
6 changes: 3 additions & 3 deletions app/charts/pie/chart-pie.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import { OnlyNegativeDataHint } from "@/components/hint";
import { DataSource, PieConfig, QueryFilters } from "@/config-types";
import { TimeSlider } from "@/configurator/interactive-filters/time-slider";
import {
useDataCubeMetadataQuery,
useDataCubeObservationsQuery,
useDataCubesComponentsQuery,
useDataCubesMetadataQuery,
} from "@/graphql/query-hooks";
import { useLocale } from "@/locales/use-locale";

Expand All @@ -41,10 +41,10 @@ export const ChartPieVisualization = ({
sourceUrl: dataSource.url,
locale,
};
const [metadataQuery] = useDataCubeMetadataQuery({
const [metadataQuery] = useDataCubesMetadataQuery({
variables: {
...commonQueryVariables,
iri: dataSetIri,
filters: [{ iri: dataSetIri }],
},
});
const [componentsQuery] = useDataCubesComponentsQuery({
Expand Down
6 changes: 3 additions & 3 deletions app/charts/scatterplot/chart-scatterplot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import { InteractionVoronoi } from "@/charts/shared/overlay-voronoi";
import { DataSource, QueryFilters, ScatterPlotConfig } from "@/config-types";
import { TimeSlider } from "@/configurator/interactive-filters/time-slider";
import {
useDataCubeMetadataQuery,
useDataCubeObservationsQuery,
useDataCubesComponentsQuery,
useDataCubesMetadataQuery,
} from "@/graphql/query-hooks";
import { useLocale } from "@/locales/use-locale";

Expand All @@ -49,10 +49,10 @@ export const ChartScatterplotVisualization = ({
sourceUrl: dataSource.url,
locale,
};
const [metadataQuery] = useDataCubeMetadataQuery({
const [metadataQuery] = useDataCubesMetadataQuery({
variables: {
...commonQueryVariables,
iri: dataSetIri,
filters: [{ iri: dataSetIri }],
},
});
const [componentsQuery] = useDataCubesComponentsQuery({
Expand Down
6 changes: 3 additions & 3 deletions app/charts/table/chart-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { Table } from "@/charts/table/table";
import { TableChart } from "@/charts/table/table-state";
import { DataSource, TableConfig } from "@/configurator";
import {
useDataCubeMetadataQuery,
useDataCubeObservationsQuery,
useDataCubesComponentsQuery,
useDataCubesMetadataQuery,
} from "@/graphql/query-hooks";
import { useLocale } from "@/locales/use-locale";

Expand All @@ -30,10 +30,10 @@ export const ChartTableVisualization = ({
sourceUrl: dataSource.url,
locale,
};
const [metadataQuery] = useDataCubeMetadataQuery({
const [metadataQuery] = useDataCubesMetadataQuery({
variables: {
...commonQueryVariables,
iri: dataSetIri,
filters: [{ iri: dataSetIri }],
},
});
const [componentsQuery] = useDataCubesComponentsQuery({
Expand Down
Loading

1 comment on commit 099771b

@vercel
Copy link

@vercel vercel bot commented on 099771b Nov 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

visualization-tool – ./

visualization-tool-git-main-ixt1.vercel.app
visualization-tool-alpha.vercel.app
visualization-tool-ixt1.vercel.app

Please sign in to comment.