Skip to content

Commit

Permalink
Separate alldatasets from allexploredataset
Browse files Browse the repository at this point in the history
  • Loading branch information
hanbyul-here committed Apr 25, 2024
1 parent 19f56f7 commit 278125c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { glsp, themeVal } from '@devseed-ui/theme-provider';

import { timelineDatasetsAtom } from '../../atoms/datasets';
import {
allDatasetsWithEnhancedLayers as allDatasets,
allExploreDatasetsWithEnhancedLayers as allDatasets,
reconcileDatasets,
datasetLayers,
findParentDataset
Expand Down Expand Up @@ -157,7 +157,7 @@ export function DatasetSelectorModal(props: DatasetSelectorModalProps) {
const selectedIdsWithParentData = selectedIds.map((selectedId) => {
const parentData = findParentDataset(selectedId);
const exclusiveSource = parentData?.sourceExclusive;
const parentDataSourceValues = parentData?.taxonomy.filter((x) => x.name === 'Source')?.[0]?.values?.map((value) => value.id);
const parentDataSourceValues = parentData?.taxonomy.filter((x) => x.name === 'Source')?.[0]?.values.map((value) => value.id);
return {id: selectedId, values: parentDataSourceValues, sourceExclusive: exclusiveSource?.toLowerCase() || ''};
});

Expand Down
29 changes: 18 additions & 11 deletions app/scripts/components/exploration/data-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,34 @@ export const findDatasetAttribute = ({ datasetId, attr }: {datasetId: string, at
return veda_datasets[datasetId]?.data[attr];
};


export const allDatasets = Object.values(veda_datasets)
.map((d) => d!.data);


export const allExploreDatasets = Object.values(veda_datasets)
.map((d) => d!.data)
.filter((d) => !d.disableExplore);

export interface DatasetDataWithEnhancedLayers extends DatasetData {
layers: EnhancedDatasetLayer[];
}

export const allDatasetsWithEnhancedLayers: DatasetDataWithEnhancedLayers[] = allDatasets.map(currentDataset => {
function enhanceDatasetLayers(dataset) {
return {
...currentDataset,
layers: currentDataset.layers.map(l => ({
...l,
parentDataset: {
id: currentDataset.id,
name: currentDataset.name
}
}))
...dataset,
layers: dataset.layers.map(layer => ({
...layer,
parentDataset: {
id: dataset.id,
name: dataset.name
}
}))
};
});
}

export const allExploreDatasetsWithEnhancedLayers: DatasetDataWithEnhancedLayers[] = allExploreDatasets.map(enhanceDatasetLayers);

export const allDatasetsWithEnhancedLayers: DatasetDataWithEnhancedLayers[] = allDatasets.map(enhanceDatasetLayers);

export const datasetLayers = Object.values(veda_datasets)
.flatMap((dataset) => {
Expand Down

0 comments on commit 278125c

Please sign in to comment.