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

Feature/dataset explorer chart #348

Merged
merged 173 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
173 commits
Select commit Hold shift + click to select a range
daace7f
Merge tag '2.0.0' into cccs-2.0
cccs-RyanS Jul 25, 2022
928d983
[cccs-2.0] updating docker file (#188)
cccs-RyanS Jul 29, 2022
6fe7950
[CLDN-1565] Fixing bugs (#189)
cccs-RyanS Aug 8, 2022
53d4005
Feature/cldn 1565 (#192)
cccs-RyanS Aug 9, 2022
497e761
Feature/cldn 1609 (#195)
cccs-RyanS Aug 16, 2022
685d621
[CLDN-1609] Updating image (#196)
cccs-RyanS Aug 16, 2022
bbec5b2
[CLDN-1620] Making rendering use advanced type (#197)
cccs-RyanS Aug 17, 2022
163e440
updating image (#198)
cccs-RyanS Aug 18, 2022
8bc4533
[CLDN-1609] Fixing all QA bugs (#201)
cccs-RyanS Aug 23, 2022
3ecbde1
Feature/cldn 1541 (#200)
cccs-Dustin Aug 23, 2022
4346c25
[CLDN-1609] Updating docker image (#202)
cccs-RyanS Aug 23, 2022
44fbf92
[cccs-2.0] Fixing case sensitivity (#203)
cccs-RyanS Sep 12, 2022
8e95aa8
Fix/cccs 2.0 (#204)
cccs-Dustin Sep 12, 2022
29f2ff6
Fixed issue with Typescript (#205)
cccs-Dustin Sep 14, 2022
0b28483
Fix cccs 2.0 (#206)
cccs-Dustin Sep 14, 2022
6e68cd9
Feature/cldn 1563 (#207)
cccs-Dustin Sep 16, 2022
516b9db
Updated image (#208)
cccs-Dustin Sep 16, 2022
9e99e8c
[CLDN-1683] Added code to show column descriptions as tooltips in the…
cccs-Dustin Sep 20, 2022
5788b73
Feature/cldn 1676 (#210)
cccs-Dustin Sep 22, 2022
85719e6
Updating Superset Base Image Tag (#211)
cccs-Dustin Sep 23, 2022
30ecdf3
added adhoc filter plugin files
cccs-RyanK Sep 23, 2022
5b9d83d
Made sure that adhoc filter uses the adhoc filter object
cccs-Dustin Sep 23, 2022
22285cd
added adhocfiltercontrol to native adhoc filter
cccs-RyanK Sep 27, 2022
080d279
fixed hook that made too many requests
cccs-RyanK Sep 27, 2022
99d9f5a
fixed applied filter label
cccs-RyanK Sep 27, 2022
80151b6
removed duplicate files
cccs-RyanK Sep 28, 2022
3a66d93
Removed uneeded functions
cccs-Dustin Sep 28, 2022
1e04870
Merge branch 'Adding-Dashboard-Adhoc-Filters' of github.com:Cybercent…
cccs-Dustin Sep 28, 2022
8e310c6
Removed uneeded functions and variables
cccs-Dustin Sep 28, 2022
ac5e203
Removed unused props variables
cccs-Dustin Sep 28, 2022
be85fab
modifying base image tag
cccs-RyanK Sep 28, 2022
c53c43d
Merge branch 'Adding-Dashboard-Adhoc-Filters' of github.com:Cybercent…
cccs-RyanK Sep 28, 2022
673ffac
Removed unused config settings
cccs-Dustin Sep 28, 2022
7c681b5
Merge branch 'Adding-Dashboard-Adhoc-Filters' of github.com:Cybercent…
cccs-Dustin Sep 28, 2022
c796777
removed column for filter config form
cccs-RyanK Sep 29, 2022
157aaae
Improved the applied filter(s) modal
cccs-Dustin Sep 29, 2022
257eec8
Temp update to build image
cccs-Dustin Sep 29, 2022
14c936a
fixed string formatting issue:
cccs-RyanK Sep 29, 2022
3a6b4bf
updating superset base image tag
cccs-RyanK Sep 29, 2022
94de584
added setFocused hooks to filter when hovering
cccs-RyanK Oct 4, 2022
1c8ab53
Fixed the right click to emit dashboard cross-filters (#213)
cccs-Dustin Oct 5, 2022
69aef0d
Updated superset base image (#214)
cccs-Dustin Oct 5, 2022
3fe2450
Merge branch 'cccs-2.0' of github.com:CybercentreCanada/superset into…
cccs-RyanK Oct 7, 2022
58be3bb
fixed unused declaration error
cccs-RyanK Oct 7, 2022
ab53b1e
updating image
cccs-RyanK Oct 7, 2022
37daf44
Prevent invalid filter values from being saved (#215)
reesercollins Oct 7, 2022
ddfc44d
Merge branch 'cccs-2.0' of github.com:CybercentreCanada/superset into…
cccs-RyanK Oct 11, 2022
41f25ef
[cccs-2.0] fixing trino req (#216)
cccs-RyanS Oct 11, 2022
9d9a0d3
Merge branch 'cccs-2.0' of github.com:CybercentreCanada/superset int…
cccs-RyanK Oct 11, 2022
0b71bbf
updating superset-base image tag
cccs-RyanK Oct 11, 2022
b522737
added option to emit a filter from a default column for a row in ag grid
cccs-RyanK Oct 14, 2022
87b70ad
Update trino python client (#219)
cccs-Dustin Oct 14, 2022
cf6e97e
Updated superset's base image tag (#221)
cccs-Dustin Oct 14, 2022
ed0c5f4
Update superset-frontend/src/cccs-viz/plugins/plugin-chart-cccs-grid/…
cccs-RyanK Oct 19, 2022
9c7efc4
changed control panel to plural
cccs-RyanK Oct 31, 2022
dc52e1d
Merge branch 'emit-a-filter-for-a-default-column-in-aggrid-context-me…
cccs-RyanK Oct 31, 2022
518248b
disallow columns that are not a part of the chart to be selected as d…
cccs-RyanK Nov 2, 2022
f706484
updated image tag
cccs-RyanK Nov 4, 2022
94252a5
updated control panel logic for agg mode
cccs-RyanK Nov 7, 2022
c111044
update image tag
cccs-RyanK Nov 7, 2022
2d6c805
fixed issues
cccs-RyanK Nov 9, 2022
cacf040
updating base image
cccs-RyanK Nov 9, 2022
8d74228
fixed refactor error
cccs-RyanK Nov 10, 2022
9d0f6cd
updating base image
cccs-RyanK Nov 10, 2022
fcc6a8d
fixed so that option disables properly
cccs-RyanK Nov 14, 2022
609b2ab
updating base image
cccs-RyanK Nov 14, 2022
f0b4db2
Merge branch 'cccs-2.0' into emit-a-filter-for-a-default-column-in-ag…
cccs-RyanK Nov 14, 2022
6d8dc99
Merge pull request #220 from CybercentreCanada/emit-a-filter-for-a-de…
cccs-RyanK Nov 15, 2022
5512ded
Add users API to get and delete users (#223)
reesercollins Nov 18, 2022
953531f
Merge branch 'cccs-2.0' of github.com:CybercentreCanada/superset into…
cccs-RyanK Nov 21, 2022
fc2207b
updating image
cccs-RyanK Nov 21, 2022
330f3e5
Update cccs-build/superset/Dockerfile
cccs-RyanK Nov 22, 2022
0635660
Merge pull request #218 from CybercentreCanada/Adding-Dashboard-Adhoc…
cccs-RyanK Nov 23, 2022
0d5fee8
Added ability to certify entities with multiple values (#224)
reesercollins Nov 24, 2022
2cee63f
Feature/cldn 1749 (#222)
cccs-RyanS Dec 1, 2022
7ef6d75
Prevent non-admins from using users api (#236)
reesercollins Dec 8, 2022
e0ec100
added styles to highlight adhoc filter when focused and fix awkward e…
cccs-RyanK Dec 30, 2022
90aa381
removed suggestions from popping up
cccs-RyanK Dec 30, 2022
b14a496
added comment
cccs-RyanK Dec 30, 2022
bebe51a
fixed unused import error
cccs-RyanK Jan 3, 2023
4e9562b
updating base image
cccs-RyanK Jan 5, 2023
8aaf728
Update Dockerfile
cccs-RyanK Jan 17, 2023
f26f285
Merge pull request #242 from CybercentreCanada/CLDN-1828-Fix-minor-is…
cccs-RyanK Jan 17, 2023
5a67b21
[CLDN-1829] fixing principle filter logic with state (#234) (#244)
cccs-RyanS Jan 17, 2023
263ace7
[cccs-2.0] Updating image (#245)
cccs-RyanS Jan 19, 2023
eee6b9b
value set to empty list instead of undefined
Feb 3, 2023
eb317db
Merge branch 'cccs-2.0' into CLDN-1928-filter-incorrectly-displays-as…
cccs-RyanK Feb 3, 2023
fba5e3e
updating base image
Feb 6, 2023
99b808a
Feature/cldn 1748 (#243)
cccs-RyanS Feb 6, 2023
22c8982
CLDN-1710 including schema in search columns for datasets api (#253)
cccs-nik Feb 6, 2023
6538a68
Update Dockerfile
cccs-RyanK Feb 6, 2023
cf3eea4
Merge branch 'cccs-2.0' into CLDN-1928-filter-incorrectly-displays-as…
cccs-RyanK Feb 6, 2023
aa4db47
Merge pull request #252 from CybercentreCanada/CLDN-1928-filter-incor…
cccs-RyanK Feb 6, 2023
6165862
CLDN-1710 tag update (#255)
cccs-nik Feb 6, 2023
7657bc9
update image tag
cccs-RyanK Feb 14, 2023
e415cb2
Merge pull request #260 from CybercentreCanada/update-image-tag
cccs-RyanK Feb 15, 2023
1ec3298
Merge remote-tracking branch 'origin/cccs-2.0.1' into merge-cccs-2.0.1
cccs-RyanK Feb 15, 2023
9dea21a
updating image tag
cccs-RyanK Feb 16, 2023
3f1c735
Update vault image to get new CAs
cccs-RyanK Feb 20, 2023
7d8647d
update image tag
cccs-RyanK Feb 23, 2023
763e0dd
Merge pull request #263 from CybercentreCanada/cccs-RyanK-Update-Vaul…
cccs-RyanK Feb 23, 2023
8eeaef0
Merge branch 'cccs-2.0' into merge-cccs-2.0.1
cccs-RyanK Feb 23, 2023
6104740
Merge pull request #261 from CybercentreCanada/merge-cccs-2.0.1
cccs-RyanK Feb 23, 2023
4c098df
Update Dockerfile
cccs-RyanK Feb 23, 2023
1519293
Merge branch 'cccs-2.0' into update-2.0-image-tag
cccs-RyanK Feb 23, 2023
aa96651
Update Dockerfile
cccs-RyanK Feb 24, 2023
b0cd852
Merge pull request #265 from CybercentreCanada/update-2.0-image-tag
cccs-RyanK Feb 24, 2023
aa270f2
Feature/cldn 1773 (#269)
cccs-RyanS Mar 10, 2023
c088022
Updating docker file (#270)
cccs-RyanS Mar 13, 2023
592337e
Feature/cldn 1968 (Display JSON data inline) (#268)
cccs-Dustin Mar 15, 2023
b269270
Feature/cldn 1968 (#272)
cccs-Dustin Mar 15, 2023
dbbdaaf
Adding componenets
cccs-RyanS May 1, 2023
7a334b4
[CLDN-2142] Finish Dateetime Picker and reorg control panael
cccs-RyanS May 4, 2023
51f83e3
added changes to align cccs-viz with upstream cross-filtering
cccs-RyanK May 4, 2023
4340877
fixed column sorting being reset on emit filters
cccs-RyanK May 4, 2023
d4b6937
fixed errors
cccs-RyanK May 4, 2023
0c44cca
[CLDN-2142] Adding validation for advanced type input
cccs-RyanS May 4, 2023
1361ed9
update base image
cccs-RyanK May 8, 2023
2f3bea1
update base image
cccs-RyanK May 8, 2023
f6b3cfd
advanced type null fix
cccs-RyanK May 11, 2023
cf711d1
removed legacy time section
cccs-RyanK May 3, 2023
2004bdd
removed unused import
cccs-RyanK May 3, 2023
a7238a2
updating docker image
cccs-RyanK May 12, 2023
1d06ec6
fixed bootstrap data
cccs-RyanK May 15, 2023
8a6d0ab
update docker file
cccs-RyanK May 15, 2023
2f1cb1b
[CLDN-2064] Fixed column header reset bug
cccs-Dustin Apr 19, 2023
52d302d
fix column sorting not updating columns
cccs-RyanK May 15, 2023
e97e267
updating base image
cccs-RyanK May 15, 2023
2958c8b
updating base image
cccs-RyanK May 15, 2023
57a8d4b
[expore++] Fixing bugs with page reload
cccs-RyanS May 16, 2023
f2c287a
Merge branch 'cccs-2.1' into feature/dataset-explorer-chart
cccs-RyanS May 16, 2023
20b6288
Merge remote-tracking branch 'origin/fix/CLDN-2009-emiting-filters-re…
cccs-RyanS May 18, 2023
fc40300
fixing build errors
cccs-RyanS May 18, 2023
0974145
Dockerfile update
cccs-RyanS May 18, 2023
ff4f94e
CLDN-2198 updated formatting and removed change dataset button from c…
cccs-RyanK Jun 7, 2023
3b85b5d
CLDN-2202 updated formatting and fixed time range validation errors
cccs-RyanK Jun 7, 2023
0d866b8
CLDN-2195 prevent running an emtpy query aggregate mode
cccs-RyanK Jun 7, 2023
25303c5
CLDN-2203 make wording in date errors consistent with labels
cccs-RyanK Jun 7, 2023
d1b7a26
CLDN-2205 make time range invisible when no time column is selected
cccs-RyanK Jun 7, 2023
6dffa90
CLDN-2206 Fixed formatting, labelling, classname, and disable selecto…
cccs-RyanK Jun 7, 2023
5a7edd9
CLDN-2207 show advanced type labels and not ids in selector dropdown
cccs-RyanK Jun 8, 2023
34c0af6
CLDN-2208 clear values when selector is changed
cccs-RyanK Jun 8, 2023
cf57f5b
CLDN-2210 change button name to Swap Dataset
cccs-RyanK Jun 8, 2023
ec58e0e
CLDN-2211 fix query builder to use actual values rather than strings
cccs-RyanK Jun 8, 2023
09e92d6
fixed npm errors
cccs-RyanK Jun 8, 2023
e3e29c7
update image tag
cccs-RyanK Jun 8, 2023
1b2246f
Merge branch 'cccs-2.1' into feature/dataset-explorer-chart
cccs-RyanK Jun 8, 2023
71e05bd
merge fixes and tool tip update
cccs-RyanK Jun 8, 2023
da54e58
CLDN-2209 fix incorrect dimensions after swapping datasets
cccs-RyanK Jun 9, 2023
adb7fa4
Select All not working on swap datasets, default to no selection
cccs-RyanK Jun 9, 2023
49711f1
fixed npm build errros
cccs-RyanK Jun 9, 2023
596340e
update base image
cccs-RyanK Jun 9, 2023
c5f4bcd
CLDN-2208 Mandatory to have a value if selector is selected and inval…
cccs-RyanK Jun 12, 2023
212b47b
disable time range when no time column is selected
cccs-RyanK Jun 12, 2023
b34b629
change selector to advanced data type and values now saved in form da…
cccs-RyanK Jun 13, 2023
f02e228
fix refactor mistake and allow querying ranges of advanced types
cccs-RyanK Jun 13, 2023
887762b
added comments and removed debugging lines
cccs-RyanK Jun 13, 2023
aa1e2ca
remove unecessary tool tip and fix npm issues
cccs-RyanK Jun 14, 2023
74b776c
validation in progress to prevent running query on bad values
cccs-RyanK Jun 14, 2023
641133e
update base image
cccs-RyanK Jun 14, 2023
d1a73eb
fix for temporarily caching form data
cccs-RyanK Jun 14, 2023
ecc9113
readded tooltip
cccs-RyanK Jun 14, 2023
ec14ee4
fixed tooltip, added order by
cccs-RyanK Jun 14, 2023
aa50127
npm error fix
cccs-RyanK Jun 14, 2023
d81c384
update base image
cccs-RyanK Jun 14, 2023
631277a
removed changes from hogwarts table viz
cccs-RyanK Jun 16, 2023
6a3210c
fix error in tooltip for adt value
cccs-RyanK Jun 19, 2023
41538c6
update image tag
cccs-RyanK Jun 19, 2023
a2c3502
removed unused adhoc time filter
cccs-RyanK Jun 21, 2023
f14e5a5
fixed import order
cccs-RyanK Jun 21, 2023
f877f4f
update docker file
cccs-RyanK Jun 21, 2023
b2850d0
Merge branch 'cccs-2.1' into feature/dataset-explorer-chart
cccs-RyanS Jul 5, 2023
846ec1e
[dataset explorer] pr feedback
cccs-RyanS Jul 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions superset-frontend/src/cccs-viz/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ export { default as AtAGlanceUserIdChartPlugin } from './plugin-chart-at-a-glanc
export { default as AtAGlanceUserIDSasChartPlugin } from './plugin-chart-at-a-glance-user-id-sas/src/plugin';
export { default as ApplicationLinksChartPlugin } from './plugin-chart-application-links/src/plugin';
export { default as IFrameVisualizationChartPlugin } from './plugin-chart-iframe/src/plugin';
export { default as DatasetExplorerChartPlugin } from './plugin-chart-dataset-explorer/src/plugin';
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
import React, { useEffect, useState } from 'react';
import { ensureIsArray, withTheme } from '@superset-ui/core';
import { connect } from 'react-redux';
import SelectControl from 'src/explore/components/controls/SelectControl';
import useAdvancedDataTypes from 'src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent/useAdvancedDataTypes';

export interface Props {
colorScheme: string;
annotationError: object;
annotationQuery: object;
vizType: string;
theme: any;
validationErrors: string[];
externalValidationErrors: string[];
name: string;
actions: object;
label: string;
value?: any[] | any;
datasource: any;
multi: boolean;
freeForm: boolean;
advancedDataType: string;
onChange: (values: any, errors: any[]) => void;
disabled: boolean;
description: any;
}

const AdvancedDataTypeValueControlValueControl: React.FC<Props> = ({
onChange,
externalValidationErrors,
datasource,
multi,
freeForm,
advancedDataType,
label,
disabled,
value = [],
description,
}) => {
const [rawValues, setRawValues] = useState([]);
const [validationErrors, setValidationErrors] = useState<string[]>([]);
const [currentAdvancedDataType, setCurrentAdvancedDataType] =
useState<string>();

const {
advancedDataTypesState,
subjectAdvancedDataType,
fetchAdvancedDataTypeValueCallback,
} = useAdvancedDataTypes(() => {});

const onChangeWrapper = (selection: any) => {
setValidationErrors([...validationErrors, 'Validation in progress']);
setRawValues(selection);
};

// clear selection on advancedDataType change
useEffect(() => {
const rawData = value[0] ? value[0].rawData : [];
onChangeWrapper(
(currentAdvancedDataType &&
currentAdvancedDataType !== advancedDataType) ||
!advancedDataType
? []
: rawData,
);
setCurrentAdvancedDataType(advancedDataType);
}, [advancedDataType]);

useEffect(() => {
const data =
advancedDataTypesState.parsedAdvancedDataType.length > 0 &&
advancedDataTypesState.parsedAdvancedDataType.split(',').length > 0
? {
data: advancedDataTypesState.values,
columns: datasource.columns
.filter((col: any) => col.advanced_data_type === advancedDataType)
.map((col: any) => col.column_name),
rawData: rawValues,
}
: { data: [], columns: [], rawData: [] };
onChange(data, validationErrors);
}, [advancedDataTypesState, validationErrors]);

useEffect(() => {
fetchAdvancedDataTypeValueCallback(
rawValues,
advancedDataTypesState,
ensureIsArray(advancedDataType)[0],
);
}, [advancedDataType, rawValues, subjectAdvancedDataType]);

useEffect(() => {
setValidationErrors(
advancedDataTypesState.errorMessage
? [advancedDataTypesState.errorMessage]
: [],
);
}, [advancedDataTypesState]);

return (
<SelectControl
hovered
description={advancedDataTypesState.parsedAdvancedDataType || description}
value={rawValues}
validationErrors={ensureIsArray(
[...validationErrors, ...externalValidationErrors].at(0),
)}
onChange={onChangeWrapper}
multi={multi}
freeForm={disabled ? false : freeForm}
label={label}
disabled={disabled}
/>
);
};

function mapStateToProps({ charts, explore }: any) {
return {
// eslint-disable-next-line camelcase
colorScheme: explore.controls?.color_scheme?.value,
vizType: explore.controls.viz_type.value,
};
}

const themedAdvancedDataTypeValueControlValueControl = withTheme(
AdvancedDataTypeValueControlValueControl,
);

export default connect(mapStateToProps)(
themedAdvancedDataTypeValueControlValueControl,
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import React, { useState } from 'react';
import { ChangeDatasourceModal } from 'src/components/Datasource';
import { withTheme } from '@superset-ui/core';
import { connect, useDispatch } from 'react-redux';
import Button from 'src/components/Button';
import { updateFormDataByDatasource } from 'src/explore/actions/exploreActions';

export interface Props {
colorScheme: string;
annotationError: object;
annotationQuery: object;
vizType: string;
theme: any;
validationErrors: string[];
name: string;
actions: object;
label: string;
value?: object[];
datasource: any;
onChange: (a: any) => void;
}

const ChangeDatasourceButtonControll: React.FC<Props> = ({
onChange,
datasource,
}) => {
const dispatch = useDispatch();
const [showChangeDatasourceModal, setShowChangeDatasourceModal] =
useState<Boolean>(false);

const toggleChangeDatasourceModal = () => {
setShowChangeDatasourceModal(!showChangeDatasourceModal);
};
const onDatasourceSave = (new_datasource: any) => {
dispatch(updateFormDataByDatasource(datasource, new_datasource));
};
const onChangeWrapper = (a: any) => {
onChange(a);
};

return (
<>
<Button
buttonStyle="primary"
onClick={() => setShowChangeDatasourceModal(true)}
>
Swap dataset
</Button>
{showChangeDatasourceModal && (
<ChangeDatasourceModal
onDatasourceSave={onDatasourceSave}
onHide={toggleChangeDatasourceModal}
show={showChangeDatasourceModal}
onChange={onChangeWrapper}
/>
)}
</>
);
};

function mapStateToProps({ explore }: any) {
return {
// eslint-disable-next-line camelcase
colorScheme: explore.controls?.color_scheme?.value,
vizType: explore.controls.viz_type.value,
};
}

const themedChangeDatasourceButtonControll = withTheme(
ChangeDatasourceButtonControll,
);

export default connect(mapStateToProps)(themedChangeDatasourceButtonControll);
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
import React, { useEffect, useState } from 'react';
import { SLOW_DEBOUNCE, SupersetClient, t, withTheme } from '@superset-ui/core';
import {
buildTimeRangeString,
formatTimeRange,
} from 'src/explore/components/controls/DateFilterControl/utils';
import { Input } from 'src/components/Input';
import { connect } from 'react-redux';
import rison from 'rison';
import ControlHeader from 'src/explore/components/ControlHeader';
import { getClientErrorObject } from 'src/utils/getClientErrorObject';
import { useDebouncedEffect } from 'src/explore/exploreUtils';

export interface Props {
colorScheme: string;
annotationError: object;
annotationQuery: object;
vizType: string;
theme: any;
validationErrors: string[];
name: string;
actions: object;
label: string;
value?: object[];
onChange: (value: any, errors: any[]) => void;
default: string;
disabled: boolean;
}

const SEPARATOR = ' : ';
const fetchTimeRange = async (timeRange: string) => {
const query = rison.encode_uri(timeRange);
const endpoint = `/api/v1/time_range/?q=${query}`;
try {
const response = await SupersetClient.get({ endpoint });
const timeRangeString = buildTimeRangeString(
response?.json?.result?.since || '',
response?.json?.result?.until || '',
);
return {
value: formatTimeRange(timeRangeString),
};
} catch (response) {
const clientError = await getClientErrorObject(response);
return {
// keep labelling consistent in error messages
error: (clientError.message || clientError.error)
.replace('From date', 'Start date')
.replace('to date', 'end date'),
};
}
};

const DatetimeControl: React.FC<Props> = props => {
const [timeRange, setTimeRange] = useState(props.default);
const [validationErrors, setValidationErrors] = useState<string[]>([]);
const [actualTimeRange, setactualTimeRange] = useState<string>();

const [since, until] = timeRange.split(SEPARATOR);

useEffect(() => {
props.onChange(timeRange, validationErrors);
}, [timeRange, since, until, validationErrors]);

function onChange(control: 'since' | 'until', value: string) {
if (control === 'since') {
setTimeRange(`${value}${SEPARATOR}${until}`);
} else {
setTimeRange(`${since}${SEPARATOR}${value}`);
}
}

useDebouncedEffect(
() => {
fetchTimeRange(timeRange)
.then(value => {
setactualTimeRange(
value?.value ? `Actual Time Range ${value?.value}` : '',
);
setValidationErrors(value?.error ? [value?.error] : []);
})
.catch(error => {
setValidationErrors(error);
});
},
SLOW_DEBOUNCE,
[timeRange],
);

const headerProps = {
name: props.name,
label: props.label,
validationErrors,
description: actualTimeRange,
hovered: true,
};

return (
<>
<ControlHeader {...headerProps} />
<div className="control-label">{t('START (INCLUSIVE)')} </div>
<Input
key="since"
value={since}
onChange={e => onChange('since', e.target.value)}
disabled={props.disabled}
/>
<div className="control-label">{t('END (EXCLUSIVE)')} </div>
<Input
key="until"
value={until}
onChange={e => onChange('until', e.target.value)}
disabled={props.disabled}
/>
</>
);
};

// Tried to hook this up through stores/control.jsx instead of using redux
// directly, could not figure out how to get access to the color_scheme
function mapStateToProps({ charts, explore }: any) {
return {
// eslint-disable-next-line camelcase
colorScheme: explore.controls?.color_scheme?.value,
vizType: explore.controls.viz_type.value,
};
}

const themedDrillActionConfigControl = withTheme(DatetimeControl);

export default connect(mapStateToProps)(themedDrillActionConfigControl);
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ import {
DEFAULT_FORM_DATA,
} from '../types';

import {rendererMap, formatIpV4} from '../utils/advancedDataTypes'


export default function transformProps(chartProps: CccsGridChartProps) {
/**
* This function is called after a successful response has been
Expand Down Expand Up @@ -176,22 +179,7 @@ export default function transformProps(chartProps: CccsGridChartProps) {
},
sortingColumnMap);

// Key is column advanced type, value is renderer name
const rendererMap = {
IPV4: 'ipv4ValueRenderer',
IPV6: 'ipv6ValueRenderer',
DOMAIN: 'domainValueRenderer',
COUNTRY: 'countryValueRenderer',
JSON: 'jsonValueRenderer',
};

const formatIpV4 = (v: any) => {
const converted = `${(v >> 24) & 0xff}.${(v >> 16) & 0xff}.${
(v >> 8) & 0xff
}.${v & 0xff}`;
return converted;
};


const valueFormatter = (params: any) => {
if (
params.value != null &&
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

// Key is column advanced type, value is renderer name
export const rendererMap = {
IPV4: 'ipv4ValueRenderer',
IPV6: 'ipv6ValueRenderer',
DOMAIN: 'domainValueRenderer',
COUNTRY: 'countryValueRenderer',
JSON: 'jsonValueRenderer',
};

export const formatIpV4 = (v: any) => {
const converted = `${(v >> 24) & 0xff}.${(v >> 16) & 0xff}.${
(v >> 8) & 0xff
}.${v & 0xff}`;
return converted;
};
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading