Skip to content

Commit

Permalink
Load table fields for acceleration index flyout (#137)
Browse files Browse the repository at this point in the history
* load table fields after table is selected

Signed-off-by: Shenoy Pratik <[email protected]>

* simplify the map function

Signed-off-by: Shenoy Pratik <[email protected]>

---------

Signed-off-by: Shenoy Pratik <[email protected]>
  • Loading branch information
ps48 authored Oct 4, 2023
1 parent e8b2212 commit 9a5a20f
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions public/components/acceleration/selectors/index_type_selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ import {
ACCELERATION_INDEX_TYPES,
ACC_INDEX_TYPE_DOCUMENTATION_URL,
} from '../../../../common/constants';
import { AccelerationIndexType, CreateAccelerationForm } from '../../../../common/types';
import {
AccelerationIndexType,
CreateAccelerationForm,
DataTableFieldsType,
} from '../../../../common/types';
import { getJobId, pollQueryStatus } from '../../SQLPage/utils';

interface IndexTypeSelectorProps {
Expand Down Expand Up @@ -48,22 +52,14 @@ export const IndexTypeSelector = ({
};
getJobId(query, http, (id: string) => {
pollQueryStatus(id, http, (data: any[]) => {
const dataTableFields: DataTableFieldsType[] = data.map((field, index) => ({
id: `${idPrefix}${index + 1}`,
fieldName: field.col_name,
dataType: field.data_type,
}));
setAccelerationFormData({
...accelerationFormData,
dataTableFields: [
{ id: `${idPrefix}1`, fieldName: 'Field1', dataType: 'Integer' },
{ id: `${idPrefix}2`, fieldName: 'Field2', dataType: 'Integer' },
{ id: `${idPrefix}3`, fieldName: 'Field3', dataType: 'Integer' },
{ id: `${idPrefix}4`, fieldName: 'Field4', dataType: 'Integer' },
{ id: `${idPrefix}5`, fieldName: 'Field5', dataType: 'Integer' },
{ id: `${idPrefix}6`, fieldName: 'Field6', dataType: 'Integer' },
{ id: `${idPrefix}7`, fieldName: 'Field7', dataType: 'Integer' },
{ id: `${idPrefix}8`, fieldName: 'Field8', dataType: 'Integer' },
{ id: `${idPrefix}9`, fieldName: 'Field9', dataType: 'Integer' },
{ id: `${idPrefix}10`, fieldName: 'Field10', dataType: 'Integer' },
{ id: `${idPrefix}11`, fieldName: 'Field11', dataType: 'Integer' },
{ id: `${idPrefix}12`, fieldName: 'Field12', dataType: 'TimestampType' },
],
dataTableFields: dataTableFields,
});
setLoading(false);
});
Expand Down

0 comments on commit 9a5a20f

Please sign in to comment.