Skip to content

Commit

Permalink
Feature/dataset explorer chart (#348)
Browse files Browse the repository at this point in the history
* [cccs-2.0] updating docker file (#188)

* [CLDN-1565] Fixing bugs (#189)

* [CLDN-1565] Fixing bugs

* removing uneeded import

* Feature/cldn 1565 (#192)

* [CLDN-1565] Fixing bugs

* removing uneeded import

* [CLDN-1565] Adding new image

* Feature/cldn 1609 (#195)

* Add row number option to CCCS-Grid (#181)

* Add row number option to CCCS-Grid

* Have row numbers show by default

Co-authored-by: cccs-Dustin <96579982+cccs-Dustin@users.noreply.github.com>

Co-authored-by: cccs-Dustin <96579982+cccs-Dustin@users.noreply.github.com>

* Use new build agent (#187)

* Use new build agent

* Remove quotes

* Display datahub link for datasets with defined URN (#177)

* Display datahub link for datasets with defined URN

* Add datahub SVG

* Reorder imports

* Add datahub link to dashboards

* Convert to camel case

* Add tests for DatasetList

* Add tests for dashboard header

* Provide explanation for empty catch

* [CLDN-1540] Added ability for multiple user emails to be filtered on at once

* [CLDN-1540] temp update to docker image tag so that we can deploy code changes to PB-stg

* [CLDN-1540] revert of temp update to docker image tag so that we can deploy code changes to PB-stg

* Add path to url (#193)

* [CLDN-1609] Fixing post merge build errors

* Update cccs-build/superset-base/azure-pipelines.yml

Co-authored-by: Reese <10563996+reesercollins@users.noreply.github.com>

* Update superset-frontend/src/cccs-viz/plugins/plugin-chart-at-a-glance-user-id/src/styles.js

Co-authored-by: Reese <10563996+reesercollins@users.noreply.github.com>

Co-authored-by: Reese <10563996+reesercollins@users.noreply.github.com>
Co-authored-by: cccs-Dustin <96579982+cccs-Dustin@users.noreply.github.com>

* [CLDN-1609] Updating image (#196)

* [CLDN-1620] Making rendering use advanced type (#197)

* updating image (#198)

* [CLDN-1609] Fixing all QA bugs (#201)

* [CLDN-1609] Fixing all QA bugs

* [CLDN-1609] Fixing build errors

* [CLDN-1609] adding additional fixes

* [CLDN-1609] Removing log files

* [CLDN-1609] Fixing build error

Co-authored-by: reesercollins <10563996+reesercollins@users.noreply.github.com>

* Feature/cldn 1541 (#200)

* [CLDN-1541] Added the ability to filter on multiple user ID's and IP's at the same time in the Application Links custom viz

* Temp update to image for deploying to PB-stg

* Reverting change to image

* [CLDN-1541] Added a tooltip to the Alfred icon

* Temp update to base image

* Reverting temporary change to image tag

* Update superset-frontend/src/cccs-viz/plugins/plugin-chart-application-links/src/ApplicationLinks.tsx

Co-authored-by: cccs-rc <62034438+cccs-rc@users.noreply.github.com>

* Update superset-frontend/src/cccs-viz/plugins/plugin-chart-application-links/src/ApplicationLinks.tsx

Co-authored-by: cccs-rc <62034438+cccs-rc@users.noreply.github.com>

* [CLDN-1541] Changed the logic around creating the proper links/URL

* Temp update to img

* Undo temp img change

Co-authored-by: cccs-rc <62034438+cccs-rc@users.noreply.github.com>

* [CLDN-1609] Updating docker image (#202)

* [cccs-2.0] Fixing case sensitivity (#203)

* [cccs-2.0] Fixing case sensitivity

* [cccs-2.0] Pusing temp image

* [cccs-2.0] fixing two order bys

* [cccs-2.0] fixing verbose names, fixing sizing, fixing ordering

* [cccs-2.0] fixing build error

* [cccs-2.0] updating image

* [cccs-2.0] fixing time columns

* [cccs-2.0] Fixing build errors

* [cccs-2.0] updating docker file

* [cccs-2.0] Fixing time column to populate default time col

* Fixing default time col

* [cccs-2.0] updating image

* Fix issue where datasets without a date/datetime column would not load in the explore view

* Time column dropdown list is now properly populated with either the default temporal column, or the first temporal column (if a default is not set)

* Temp update to base image tag

* Fixed the bug where when there are no dttm columns, the non-dttm columns were being displayed

* Temp update to base image tag

* Reverting changes to the img

Co-authored-by: cccs-Dustin <96579982+cccs-Dustin@users.noreply.github.com>

* Fix/cccs 2.0 (#204)

* [cccs-2.0] Fixing case sensitivity

* [cccs-2.0] Pusing temp image

* [cccs-2.0] fixing two order bys

* [cccs-2.0] fixing verbose names, fixing sizing, fixing ordering

* [cccs-2.0] fixing build error

* [cccs-2.0] updating image

* [cccs-2.0] fixing time columns

* [cccs-2.0] Fixing build errors

* [cccs-2.0] updating docker file

* [cccs-2.0] Fixing time column to populate default time col

* Fixing default time col

* [cccs-2.0] updating image

* Fix issue where datasets without a date/datetime column would not load in the explore view

* Time column dropdown list is now properly populated with either the default temporal column, or the first temporal column (if a default is not set)

* Temp update to base image tag

* Fixed the bug where when there are no dttm columns, the non-dttm columns were being displayed

* Temp update to base image tag

* Reverting changes to the img

* Updating image tag

Co-authored-by: cccs-RyanS <71385290+cccs-RyanS@users.noreply.github.com>

* Fixed issue with Typescript (#205)

* Fix cccs 2.0 (#206)

* Fixed issue with Typescript

* Update image tag

* Feature/cldn 1563 (#207)

* Ran pre-commit hook on the front-end

* Removed unused file & removed duplicate method

* Made changes so that the pre-commit hook would pass all tests

* Temp update to build img

* revert temp change to build img

* Updated image (#208)

* [CLDN-1683] Added code to show column descriptions as tooltips in the… (#209)

* [CLDN-1683] Added code to show column descriptions as tooltips in the Hogwarts Table custom visualisation

* [CLDN-1683] Temp update to build image

* [CLDN-1683] Revert update to image tag

* Feature/cldn 1676 (#210)

* [CLDN-1676] Added ability to search for the IPv4 rendered value of an IP address instead of the raw value

* [CLDN-1676] Temp update to img for deploying to UDev

* [CLDN-1676] Undo temp update to img for deploying to UDev

* Updating Superset Base Image Tag (#211)

* added adhoc filter plugin files

* Made sure that adhoc filter uses the adhoc filter object

* added adhocfiltercontrol to native adhoc filter

* fixed hook that made too many requests

* fixed applied filter label

* removed duplicate files

* Removed uneeded functions

* Removed uneeded functions and variables

* Removed unused props variables

* modifying base image tag

* Removed unused config settings

* removed column for filter config form

* Improved the applied filter(s) modal

* Temp update to build image

* fixed string formatting issue:

* updating superset base image tag

* added setFocused hooks to filter when hovering

* Fixed the right click to emit dashboard cross-filters (#213)

* Fixed the right click to emit filters through the context menu as it was not working

* Temp update to build image

* Revert temp update to build image

* Updated superset base image (#214)

* fixed unused declaration error

* updating image

* Prevent invalid filter values from being saved (#215)

By assuming that all input is invalid until the api tells us otherwise,
we can prevent the user from clicking the save button in the time between
the value being entered and the api returning.

* [cccs-2.0] fixing trino req (#216)

* updating superset-base image tag

* added option to emit a filter from a default column for a row in ag grid

* Update trino python client (#219)

* Updated trino python client from 0.316.0 to 0.318.0

* Temp update to base image tag

* Removing temp change to build image

* Updated superset's base image tag (#221)

* Update superset-frontend/src/cccs-viz/plugins/plugin-chart-cccs-grid/src/CccsGrid.tsx

Co-authored-by: cccs-Dustin <96579982+cccs-Dustin@users.noreply.github.com>

* changed control panel to plural

* disallow columns that are not a part of the chart to be selected as default emit filters

* updated image tag

* updated control panel logic for agg mode

* update image tag

* fixed issues

* updating base image

* fixed refactor error

* updating base image

* fixed so that option disables properly

* updating base image

* Add users API to get and delete users (#223)

* Add users API to get and delete users

* Allow browser login for users api

* updating image

* Update cccs-build/superset/Dockerfile

Co-authored-by: cccs-Dustin <96579982+cccs-Dustin@users.noreply.github.com>

* Added ability to certify entities with multiple values (#224)

* Added ability to certify entities with multiple values

* Update description text to reflect new feature

* Add tests for multiple certified by values

* Feature/cldn 1749 (#222)

* [CLDN-1749] adding new viz

* chanigng to work with standard filters

* Adding generic filter extraction

* Removing unused imports

* [CLDN-1749] Cleaning up code for reusablility

* [CLDN-1749] removing unused files

* [CLDN-1746] fixing case

* [CLDN-1749] adding parameter validation

* [CLDN-1749] adding error message and prefix parameter

* [CLDN-1749] removing unused files

* [CLDN-1749] adding temp base image for docker deployment

* [CLDN-1749] Better error handling and new icon

* [CLDN-1749] remove unused imports

* temp dockerfile change

* [CLDN-1749] Adding the adhoc filters back in

* [CLDN-1749] Updating image

* [CLDN-1749] Adding new thumbnail

* Updating dockerfile

* [CLDN-1749] Removing uneeded control panel elements

* [CLDN-1749] Fixing build errors

* [CLDN-1749] New image

* Change to use data from dataset

* Removing unsed function

* Fixing typos

* renove unused import

* updating image

* error message and label fixes

* updating image

* Update cccs-build/superset/Dockerfile

Co-authored-by: cccs-Dustin <96579982+cccs-Dustin@users.noreply.github.com>

* Update superset-frontend/src/cccs-viz/plugins/plugin-chart-iframe/src/plugin/transformProps.ts

Co-authored-by: cccs-RyanK <102618419+cccs-RyanK@users.noreply.github.com>

* Update superset-frontend/src/cccs-viz/plugins/plugin-chart-iframe/src/plugin/transformProps.ts

Co-authored-by: cccs-RyanK <102618419+cccs-RyanK@users.noreply.github.com>

Co-authored-by: cccs-Dustin <96579982+cccs-Dustin@users.noreply.github.com>
Co-authored-by: cccs-RyanK <102618419+cccs-RyanK@users.noreply.github.com>

* Prevent non-admins from using users api (#236)

* Prevent non-admins from using users api

* Add tests

* added styles to highlight adhoc filter when focused and fix awkward empty header

* removed suggestions from popping up

* added comment

* fixed unused import error

* updating base image

* Update Dockerfile

* [CLDN-1829] fixing principle filter logic with state (#234) (#244)

* [CLDN-1829] fixing principle filter logic with state

* [CLDN-1829] Fixing build error

* [cccs-2.0] Updating image (#245)

* value set to empty list instead of undefined

* updating base image

* Feature/cldn 1748 (#243)

* [CLDN-1748] adding base component

* [CLDN-1748] changing state to use advanced data type

* [CLDN-1748] add multi select for musiness type

* [CLDN-1748] adding config manager

* [CLDN-1748] fixing build errors

* temp update of base image

* [CLDN-1748] Fixing Url parameter encoding and show name of dashboard drilling to

* temp update of image

* Pulling extra data from dashboard endpoint

* Adding more data to filters object

* [CLDN-1748] passing mroe fitler information

* [CLDN-1748] QA feedback

* [CLDN-1748] Fixing build issues

* [CLDN-1748] Updating dockerfile

* [CLDN-1748] Updating dockerfile

* fixing props name

* update image

* updating docker file

* [CLDN-1748] Name changes

* [CLDN-1748] updating image

* [CLDN-1748] Adding icon

* [CLDN-1748] fixing build errors

* [CLDN-1748] update image

* [CLDN-1748] fixing context menue to renderering

* UPdating docker file

* CLDN-1710 including schema in search columns for datasets api (#253)

* Update Dockerfile

* CLDN-1710 tag update (#255)

* update image tag

* updating image tag

* Update vault image to get new CAs

* update image tag

* Update Dockerfile

* Update Dockerfile

* Feature/cldn 1773 (#269)

* [CLDN-1773] Adding default group by

* Updating DockerFile

* Fixing Groupby

* Updating base image

* [CLDN-1773] Saving Group by order

* Updating dockerfile

* Update controlPanel.tsx

* Update superset-frontend/src/cccs-viz/plugins/plugin-chart-cccs-grid/src/plugin/transformProps.ts

Co-authored-by: cccs-tom <59839056+cccs-tom@users.noreply.github.com>

* Update superset-frontend/src/cccs-viz/plugins/plugin-chart-cccs-grid/src/plugin/transformProps.ts

Co-authored-by: cccs-tom <59839056+cccs-tom@users.noreply.github.com>

* Update superset-frontend/src/cccs-viz/plugins/plugin-chart-cccs-grid/src/plugin/transformProps.ts

Co-authored-by: cccs-RyanK <102618419+cccs-RyanK@users.noreply.github.com>

---------

Co-authored-by: cccs-tom <59839056+cccs-tom@users.noreply.github.com>
Co-authored-by: cccs-RyanK <102618419+cccs-RyanK@users.noreply.github.com>

* Updating docker file (#270)

* Feature/cldn 1968 (Display JSON data inline) (#268)

* Add buttons to expand and minimize JSON data as well as ability to expand and/or collapse all rows in a certain column

* [CLDN-1968] Added expand button for full row

* [CLDN-1968] Resize JSON columns

* [CLDN-1968] Added new array which tracks JSON cell state

* Revert "[CLDN-1968] Added new array which tracks JSON cell state"

This reverts commit dabc3da.

* [CLDN-1968] Added ability for row level expand all button to track if cells are expanded or not

* [CLDN-1968] Ran pre-commit hook

* [CLDN-1968] Improved UI

* [CLDN-1968] Update image tag for testing

* [CLDN-1968] Revert image tag for testing

* [CLDN-1968] Added multiple UI/UX changes based on QA feedback

* [CLDN-1968] Added more UI/UX changes based on QA feedback

* [CLDN-1968] Temp change to image

* Revert "[CLDN-1968] Temp change to image"

This reverts commit 57490bd.

* Update superset-frontend/src/cccs-viz/plugins/plugin-chart-cccs-grid/src/CccsGrid.tsx

Co-authored-by: cccs-rc <62034438+cccs-rc@users.noreply.github.com>

* [CLDN-1968] Remove 'TODO's as they are no longer needed

* [CLDN-1968] Changed a variable name, and condensed a few lines

* [CLDN-1968] Modified a setState so that only one is needed instead of 2

---------

Co-authored-by: cccs-rc <62034438+cccs-rc@users.noreply.github.com>

* Feature/cldn 1968 (#272)

* Add buttons to expand and minimize JSON data as well as ability to expand and/or collapse all rows in a certain column

* [CLDN-1968] Added expand button for full row

* [CLDN-1968] Resize JSON columns

* [CLDN-1968] Added new array which tracks JSON cell state

* Revert "[CLDN-1968] Added new array which tracks JSON cell state"

This reverts commit dabc3da.

* [CLDN-1968] Added ability for row level expand all button to track if cells are expanded or not

* [CLDN-1968] Ran pre-commit hook

* [CLDN-1968] Improved UI

* [CLDN-1968] Update image tag for testing

* [CLDN-1968] Revert image tag for testing

* [CLDN-1968] Added multiple UI/UX changes based on QA feedback

* [CLDN-1968] Added more UI/UX changes based on QA feedback

* [CLDN-1968] Temp change to image

* Revert "[CLDN-1968] Temp change to image"

This reverts commit 57490bd.

* Update superset-frontend/src/cccs-viz/plugins/plugin-chart-cccs-grid/src/CccsGrid.tsx

Co-authored-by: cccs-rc <62034438+cccs-rc@users.noreply.github.com>

* [CLDN-1968] Remove 'TODO's as they are no longer needed

* [CLDN-1968] Changed a variable name, and condensed a few lines

* [CLDN-1968] Modified a setState so that only one is needed instead of 2

* Update superset base image

---------

Co-authored-by: cccs-rc <62034438+cccs-rc@users.noreply.github.com>

* Adding componenets

* [CLDN-2142] Finish Dateetime Picker and reorg control panael

* added changes to align cccs-viz with upstream cross-filtering

* fixed column sorting being reset on emit filters

* fixed errors

* [CLDN-2142] Adding validation for advanced type input

* update base image

* update base image

* advanced type null fix

* removed legacy time section

* removed unused import

* updating docker image

* fixed bootstrap data

* update docker file

* [CLDN-2064] Fixed column header reset bug

* fix column sorting not updating columns

* updating base image

* updating base image

* [expore++] Fixing bugs with page reload

* fixing build errors

* Dockerfile update

* CLDN-2198 updated formatting and removed change dataset button from cccs-grid

* CLDN-2202 updated formatting and  fixed time range validation errors

* CLDN-2195 prevent running an emtpy query aggregate mode

* CLDN-2203 make wording in date errors consistent with labels

* CLDN-2205 make time range invisible when no time column is selected

* CLDN-2206 Fixed formatting, labelling, classname, and disable selector values when there is no selector

* CLDN-2207 show advanced type labels and not ids in selector dropdown

* CLDN-2208 clear values when selector is changed

* CLDN-2210 change button name to Swap Dataset

* CLDN-2211 fix query builder to use actual values rather than strings

* fixed npm errors

* update image tag

* merge fixes and tool tip update

* CLDN-2209 fix incorrect dimensions after swapping datasets

* Select All not working on swap datasets, default to no selection

* fixed npm build errros

* update base image

* CLDN-2208 Mandatory to have a value if selector is selected and invalid entries disable run query button

* disable time range when no time column is selected

* change selector to advanced data type and values now saved in form data properly

* fix refactor mistake and allow querying ranges of advanced types

* added comments and removed debugging lines

* remove unecessary tool tip and fix npm issues

* validation in progress to prevent running query on bad values

* update base image

* fix for temporarily caching form data

* readded tooltip

* fixed tooltip, added order by

* npm error fix

* update base image

* removed changes from hogwarts table viz

* fix error in tooltip for adt value

* update image  tag

* removed unused adhoc time filter

* fixed import order

* update docker file

* [dataset explorer] pr feedback

---------

Co-authored-by: Reese <10563996+reesercollins@users.noreply.github.com>
Co-authored-by: cccs-Dustin <96579982+cccs-Dustin@users.noreply.github.com>
Co-authored-by: cccs-rc <62034438+cccs-rc@users.noreply.github.com>
Co-authored-by: cccs-RyanK <102618419+cccs-RyanK@users.noreply.github.com>
Co-authored-by: GITHUB_USERNAME <EMAIL>
Co-authored-by: cccs-nik <68961854+cccs-nik@users.noreply.github.com>
Co-authored-by: cccs-RyanK <ryan.kane@cyber.gc.ca>
Co-authored-by: cccs-tom <59839056+cccs-tom@users.noreply.github.com>
  • Loading branch information
8 people authored Jul 5, 2023
1 parent cb5da12 commit 14c81c8
Show file tree
Hide file tree
Showing 17 changed files with 1,541 additions and 16 deletions.
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

0 comments on commit 14c81c8

Please sign in to comment.