Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] add disableDataOperation to dataset #1897

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/actions/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ export type ProtoDataset = {

// table-injected metadata
metadata?: any;
supportedFilterTypes?: string[];
supportedFilterTypes?: string[] | null;
disableDataOperation?: boolean;
};

export type AddDataToMapOptions = {
Expand Down
2 changes: 1 addition & 1 deletion src/schemas/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export type {
export {CURRENT_VERSION, VERSIONS} from './versions';
export type {
ParsedLayer,
ParsedFilter,
ParsedFilter
} from './vis-state-schema';
export {
visStateSchemaV1,
Expand Down
26 changes: 17 additions & 9 deletions src/utils/table-utils/kepler-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ class KeplerTable {
sortOrder?: number[] | null;

pinnedColumns?: string[];
supportedFilterTypes: string[] | undefined;
supportedFilterTypes?: string[] | null;
disableDataOperation?: boolean;

// table-injected metadata
metadata: object;

Expand All @@ -142,13 +144,15 @@ class KeplerTable {
data,
color,
metadata,
supportedFilterTypes
supportedFilterTypes = null,
disableDataOperation = false
}: {
info?: ProtoDataset['info'];
data: ProtoDataset['data'];
color: RGBColor;
metadata?: ProtoDataset['metadata'];
supportedFilterTypes?: ProtoDataset['supportedFilterTypes'];
disableDataOperation?: ProtoDataset['disableDataOperation'];
}) {
// TODO - what to do if validation fails? Can kepler handle exceptions?
// const validatedData = validateInputData(data);
Expand All @@ -162,7 +166,7 @@ class KeplerTable {
const datasetInfo = {
id: generateHashId(4),
label: 'new dataset',
...(info || {})
...info
};
const dataId = datasetInfo.id;
// @ts-expect-error
Expand All @@ -183,14 +187,19 @@ class KeplerTable {
}));

const allIndexes = dataContainer.getPlainIndex();
const defaultMetadata = {
id: datasetInfo.id,
// @ts-ignore
format: datasetInfo.format || '',
label: datasetInfo.label || ''
};

this.id = datasetInfo.id;
this.label = datasetInfo.label;
this.color = color;
this.metadata = {
...metadata,
id: datasetInfo.id,
label: datasetInfo.label
...defaultMetadata,
...metadata
};

this.dataContainer = dataContainer;
Expand All @@ -200,9 +209,8 @@ class KeplerTable {
this.fieldPairs = findPointFieldPairs(fields);
this.fields = fields;
this.gpuFilter = getGpuFilterProps([], dataId, fields);
if (supportedFilterTypes) {
this.supportedFilterTypes = supportedFilterTypes;
}
this.supportedFilterTypes = supportedFilterTypes;
this.disableDataOperation = disableDataOperation;
}

/**
Expand Down
5 changes: 4 additions & 1 deletion test/fixtures/test-hex-id-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,11 @@ export const expectedMergedDataset = {
color: 'dont test me',
metadata: {
id: 'h3-hex-id',
label: 'new dataset'
label: 'new dataset',
format: ''
},
supportedFilterTypes: null,
disableDataOperation: false,
dataContainer,
allIndexes: indices,
filteredIndex: indices,
Expand Down
10 changes: 8 additions & 2 deletions test/node/reducers/vis-state-merger-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1532,8 +1532,11 @@ test('VisStateMerger.v1 -> mergeFilters -> multiFilters', t => {
[testCsvDataId]: {
metadata: {
id: testCsvDataId,
label: 'hello.csv'
label: 'hello.csv',
format: ''
},
supportedFilterTypes: null,
disableDataOperation: false,
fields: tFields0,
dataContainer: dc0,
allIndexes: [
Expand Down Expand Up @@ -1606,8 +1609,11 @@ test('VisStateMerger.v1 -> mergeFilters -> multiFilters', t => {
[testGeoJsonDataId]: {
metadata: {
id: testGeoJsonDataId,
label: 'zip.geojson'
label: 'zip.geojson',
format: ''
},
supportedFilterTypes: null,
disableDataOperation: false,
fields: tFields1,
filterRecord: {
dynamicDomain: [mergedRateFilter, mergedTripFilter],
Expand Down
40 changes: 31 additions & 9 deletions test/node/reducers/vis-state-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1258,7 +1258,9 @@ test('#visStateReducer -> UPDATE_VIS_DATA.2 -> to empty state', t => {
suffix: ['lat', 'lng']
}
],
metadata: {id: 'smoothie', label: 'exciting dataset', album: 'taro_and_blue'}
metadata: {id: 'smoothie', label: 'exciting dataset', album: 'taro_and_blue', format: ''},
supportedFilterTypes: null,
disableDataOperation: false
}
};

Expand Down Expand Up @@ -1404,8 +1406,11 @@ test('#visStateReducer -> UPDATE_VIS_DATA.3 -> merge w/ existing state', t => {
smoothie: {
metadata: {
id: 'smoothie',
label: 'smoothie and milkshake'
label: 'smoothie and milkshake',
format: ''
},
supportedFilterTypes: null,
disableDataOperation: false,
fields: expectedFields,
dataContainer: createDataContainer(mockRawData.rows, {fields: mockRawData.fields}),
color: 'donnot test me',
Expand Down Expand Up @@ -1526,8 +1531,11 @@ test('#visStateReducer -> UPDATE_VIS_DATA.4.Geojson -> geojson data', t => {
const expectedDatasets = {
metadata: {
id: 'milkshake',
label: 'king milkshake'
label: 'king milkshake',
format: ''
},
supportedFilterTypes: null,
disableDataOperation: false,
id: 'milkshake',
label: 'king milkshake',
color: 'donnot test me',
Expand Down Expand Up @@ -1734,8 +1742,11 @@ test('#visStateReducer -> UPDATE_VIS_DATA -> mergeFilters', t => {
smoothie: {
metadata: {
id: 'smoothie',
label: 'smoothie and milkshake'
label: 'smoothie and milkshake',
format: ''
},
supportedFilterTypes: null,
disableDataOperation: false,
fields: expectedFields.map(f =>
f.name === mockFilter.name
? {
Expand Down Expand Up @@ -2039,8 +2050,11 @@ test('#visStateReducer -> setFilter.dynamicDomain & cpu', t => {
const expectedDataset = {
metadata: {
id: 'smoothie',
label: 'queen smoothie'
label: 'queen smoothie',
format: ''
},
supportedFilterTypes: null,
disableDataOperation: false,
id: 'smoothie',
label: 'queen smoothie',
color: 'donnot test me',
Expand Down Expand Up @@ -2125,7 +2139,9 @@ test('#visStateReducer -> setFilter.dynamicDomain & cpu', t => {
fixedDomain: null,
cpu: {[updatedFilterWValue.id]: 'added'},
gpu: null
}
},
supportedFilterTypes: null,
disableDataOperation: false
};

cmpDataset(t, expectedFilteredDataset, stateWithFilterValue.datasets.smoothie);
Expand Down Expand Up @@ -2349,7 +2365,9 @@ function testSetFilterDynamicDomainGPU(t, setFilter) {
fixedDomain: null,
cpu: null,
gpu: {[filterId]: 'value_changed'}
}
},
supportedFilterTypes: null,
disableDataOperation: false
};

const actualTripField = stateWithFilterValue.datasets.milkshake.fields[4];
Expand Down Expand Up @@ -2547,7 +2565,9 @@ test('#visStateReducer -> setFilter.fixedDomain & DynamicDomain & gpu & cpu', t
fixedDomain: {[filterId]: 'value_changed'},
cpu: null,
gpu: {[filterId]: 'value_changed'}
}
},
supportedFilterTypes: null,
disableDataOperation: false
};

// check filter by ts
Expand Down Expand Up @@ -2617,7 +2637,9 @@ test('#visStateReducer -> setFilter.fixedDomain & DynamicDomain & gpu & cpu', t
fixedDomain: null,
cpu: {[filterId1]: 'added'},
gpu: null
}
},
supportedFilterTypes: null,
disableDataOperation: false
};

cmpDataset(t, expectedFilteredDataset, stateWidthTsAndNameFilter.datasets.smoothie);
Expand Down