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/cldn 1749 #222

Merged
merged 35 commits into from
Dec 1, 2022
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
b5ec0de
[CLDN-1749] adding new viz
cccs-RyanS Oct 14, 2022
24d9090
chanigng to work with standard filters
cccs-RyanS Oct 17, 2022
02763ef
Adding generic filter extraction
cccs-RyanS Oct 17, 2022
3ed190c
Removing unused imports
cccs-RyanS Oct 17, 2022
1dc2d51
[CLDN-1749] Cleaning up code for reusablility
cccs-RyanS Oct 18, 2022
bc0419d
[CLDN-1749] removing unused files
cccs-RyanS Oct 18, 2022
ae3aaa4
[CLDN-1746] fixing case
cccs-RyanS Oct 18, 2022
500a899
[CLDN-1749] adding parameter validation
cccs-RyanS Oct 26, 2022
3ac453b
[CLDN-1749] adding error message and prefix parameter
cccs-RyanS Nov 1, 2022
0e5d05b
[CLDN-1749] removing unused files
cccs-RyanS Nov 1, 2022
2a879d9
Merge branch 'cccs-2.0' into feature/CLDN-1749
cccs-RyanS Nov 1, 2022
8cafe2d
[CLDN-1749] adding temp base image for docker deployment
cccs-RyanS Nov 1, 2022
306931d
Merge branch 'feature/CLDN-1749' of github.com:CybercentreCanada/supe…
cccs-RyanS Nov 1, 2022
72157a3
[CLDN-1749] Better error handling and new icon
cccs-RyanS Nov 1, 2022
ff47239
[CLDN-1749] remove unused imports
cccs-RyanS Nov 1, 2022
734a521
temp dockerfile change
cccs-RyanS Nov 1, 2022
12371da
[CLDN-1749] Adding the adhoc filters back in
cccs-RyanS Nov 8, 2022
2f13652
[CLDN-1749] Updating image
cccs-RyanS Nov 8, 2022
265268a
[CLDN-1749] Adding new thumbnail
cccs-RyanS Nov 8, 2022
d186cda
Updating dockerfile
cccs-RyanS Nov 8, 2022
0d40c5e
[CLDN-1749] Removing uneeded control panel elements
cccs-RyanS Nov 8, 2022
29753ce
[CLDN-1749] Fixing build errors
cccs-RyanS Nov 8, 2022
7c212c9
[CLDN-1749] New image
cccs-RyanS Nov 8, 2022
747b8f4
Change to use data from dataset
cccs-RyanS Nov 8, 2022
5fea997
Removing unsed function
cccs-RyanS Nov 8, 2022
dc6f914
Fixing typos
cccs-RyanS Nov 8, 2022
833e0da
renove unused import
cccs-RyanS Nov 8, 2022
cfc151f
updating image
cccs-RyanS Nov 8, 2022
6418431
error message and label fixes
cccs-RyanS Nov 14, 2022
23d1b54
updating image
cccs-RyanS Nov 14, 2022
81b4f41
Update cccs-build/superset/Dockerfile
cccs-RyanS Nov 15, 2022
041f3c1
Merge branch 'cccs-2.0' into feature/CLDN-1749
cccs-RyanS Nov 22, 2022
492167e
Merge branch 'cccs-2.0' into feature/CLDN-1749
cccs-RyanS Dec 1, 2022
3c433c2
Update superset-frontend/src/cccs-viz/plugins/plugin-chart-iframe/src…
cccs-RyanS Dec 1, 2022
31e83ac
Update superset-frontend/src/cccs-viz/plugins/plugin-chart-iframe/src…
cccs-RyanS Dec 1, 2022
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
3 changes: 2 additions & 1 deletion cccs-build/superset/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Vault CA container import
ARG VAULT_CA_CONTAINER=uchimera.azurecr.io/cccs/hogwarts/vault-ca:master_2921_22315d60
FROM $VAULT_CA_CONTAINER AS vault_ca
FROM uchimera.azurecr.io/cccs/superset-base:cccs-2.0_20221014182839_b5135
FROM uchimera.azurecr.io/cccs/superset-base:feature_CLDN-1749_20221114192347_b5421

cccs-RyanS marked this conversation as resolved.
Show resolved Hide resolved


USER root
Expand Down
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 @@ -28,3 +28,4 @@ export { default as AtAGlanceChartDnsPlugin } from './plugin-chart-at-a-glance-d
export { default as AtAGlanceUserIdChartPlugin } from './plugin-chart-at-a-glance-user-id/src/plugin';
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';
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import { IFrameVisualizationProps } from './types';


export default function IFrameVisualization(props: IFrameVisualizationProps) {
const { url, url_parameter_value, parameter_name, parameter_prefix, errorMessage} = props

const parserdUrlParameterName = parameter_name.includes('=') ? parameter_name : `${parameter_name}=${parameter_prefix}`

return (
<>
{ errorMessage ?
<>{errorMessage}</> :
<iframe src={`${url}?${parserdUrlParameterName}${url_parameter_value}`} style={{ position: 'absolute', left:0, top: '50px', width:'95%', height:'100%' }}></iframe> }
</>
);
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[ZoneTransfer]
ZoneId=3
ReferrerUrl=https://github.com/CybercentreCanada/superset/blob/feature/CLDN-750-cccs-1.2/superset-frontend/src/cccs-viz/plugins/plugin-chart-at-a-glance/src/images/thumbnail.png
HostUrl=https://raw.githubusercontent.com/CybercentreCanada/superset/feature/CLDN-750-cccs-1.2/superset-frontend/src/cccs-viz/plugins/plugin-chart-at-a-glance/src/images/thumbnail.png
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as IFrameVisualizationChartPlugin } from './plugin';
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { buildQueryContext, QueryFormData } from '@superset-ui/core';

/**
* The buildQuery function is used to create an instance of QueryContext that's
* sent to the chart data endpoint. In addition to containing information of which
* datasource to use, it specifies the type (e.g. full payload, samples, query) and
* format (e.g. CSV or JSON) of the result and whether or not to force refresh the data from
* the datasource as opposed to using a cached copy of the data, if available.
*
* More importantly though, QueryContext contains a property `queries`, which is an array of
* QueryObjects specifying individual data requests to be made. A QueryObject specifies which
* columns, metrics and filters, among others, to use during the query. Usually it will be enough
* to specify just one query based on the baseQueryObject, but for some more advanced use cases
* it is possible to define post processing operations in the QueryObject, or multiple queries
* if a viz needs multiple different result sets.
*/
export default function buildQuery(formData: QueryFormData) {
/*
We receive an ip as a filter, our job is to find everthing there is to know about that ip
We fire multiple queries to multiple data sets and collect the results here.
*/

const formDataCopy = {
...formData,
result_type: 'post_processed',
};

return buildQueryContext(formDataCopy, baseQueryObject => {
// RAW mode (not aggregated)
// eslint-disable-next-line no-param-reassign
return [
{
...baseQueryObject,
row_limit: 10,
},
];
});
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { ensureIsArray, t, validateNonEmpty } from '@superset-ui/core';
import {
ControlPanelConfig,
ControlPanelState,
ControlState,
sharedControls,
} from '@superset-ui/chart-controls';

const config: ControlPanelConfig = {

/**
* The control panel is split into two tabs: "Query" and
* "Chart Options". The controls that define the inputs to
* the chart data request, such as columns and metrics, usually
* reside within "Query", while controls that affect the visual
* appearance or functionality of the chart are under the
* "Chart Options" section.
*
* There are several predefined controls that can be used.
* Some examples:
* - groupby: columns to group by (tranlated to GROUP BY statement)
* - series: same as groupby, but single selection.
* - metrics: multiple metrics (translated to aggregate expression)
* - metric: sane as metrics, but single selection
* - adhoc_filters: filters (translated to WHERE or HAVING
* depending on filter type)
* - row_limit: maximum number of rows (translated to LIMIT statement)
*
* If a control panel has both a `series` and `groupby` control, and
* the user has chosen `col1` as the value for the `series` control,
* and `col2` and `col3` as values for the `groupby` control,
* the resulting query will contain three `groupby` columns. This is because
* we considered `series` control a `groupby` query field and its value
* will automatically append the `groupby` field when the query is generated.
*
* It is also possible to define custom controls by importing the
* necessary dependencies and overriding the default parameters, which
* can then be placed in the `controlSetRows` section
* of the `Query` section instead of a predefined control.
*
* import { validateNonEmpty } from '@superset-ui/core';
* import {
* sharedControls,
* ControlConfig,
* ControlPanelConfig,
* } from '@superset-ui/chart-controls';
*
* const myControl: ControlConfig<'SelectControl'> = {
* name: 'secondary_entity',
* config: {
* ...sharedControls.entity,
* type: 'SelectControl',
* label: t('Secondary Entity'),
* mapStateToProps: state => ({
* sharedControls.columnChoices(state.datasource)
* .columns.filter(c => c.groupby)
* })
* validators: [validateNonEmpty],
* },
* }
*
* In addition to the basic drop down control, there are several predefined
* control types (can be set via the `type` property) that can be used. Some
* commonly used examples:
* - SelectControl: Dropdown to select single or multiple values,
usually columns
* - MetricsControl: Dropdown to select metrics, triggering a modal
to define Metric details
* - AdhocFilterControl: Control to choose filters
* - CheckboxControl: A checkbox for choosing true/false values
* - SliderControl: A slider with min/max values
* - TextControl: Control for text data
*
* For more control input types, check out the `incubator-superset` repo
* and open this file: superset-frontend/src/explore/components/controls/index.js
*
* To ensure all controls have been filled out correctly, the following
* validators are provided
* by the `@superset-ui/core/lib/validator`:
* - validateNonEmpty: must have at least one value
* - validateInteger: must be an integer value
* - validateNumber: must be an intger or decimal value
*/

// For control input types, see: superset-frontend/src/explore/components/controls/index.js
controlPanelSections: [
{
label: t('Query'),
expanded: true,
controlSetRows: [
['adhoc_filters'],
[
{
name: 'url',
config: {
type: 'TextControl',
label: t('URL'),
mapStateToProps: (
state: ControlPanelState,
controlState: ControlState,
) => {
const originalMapStateToProps =
sharedControls?.groupby?.mapStateToProps;
const newState =
originalMapStateToProps?.(state, controlState) ?? {};
newState.externalValidationErrors = controlState.value ? [] : ["Please add a value for URL."]
return newState;
},
renderTrigger: true,
default: '',
description: t('The Base URL for the Iframe.'),
},
},
],
[
{
name: 'groupby',
override: {
label: t('Parameter Column Name'),
description: "The name of the column that will populate the url parameter value.",
multi: false,
allowAll: false,
default: [],
includeTime: false,
mapStateToProps: (
state: ControlPanelState,
controlState: ControlState,
) => {
const originalMapStateToProps =
sharedControls?.groupby?.mapStateToProps;
const newState =
originalMapStateToProps?.(state, controlState) ?? {};
newState.externalValidationErrors = ensureIsArray(controlState.value).length > 0 ? [] : ["Please add a value for Parameter Column Name."]
return newState;
},
},
},
],
[
{
name: 'parameter_name',
config: {
type: 'TextControl',
label: t('Parameter Name'),
mapStateToProps: (
state: ControlPanelState,
controlState: ControlState,
) => {
const originalMapStateToProps =
sharedControls?.groupby?.mapStateToProps;
const newState =
originalMapStateToProps?.(state, controlState) ?? {};
newState.externalValidationErrors = controlState.value ? [] : ["Please add a value for Parameter Name."]
return newState;
},
default: '',
description: t('The name for the URL parameter.'),
},
},
],
[
{
name: 'parameter_prefix',
config: {
type: 'TextControl',
label: t('Parameter Prefix'),
default: '',
description: t('A value that will be prefix the parameter value.'),
},
},
]
],
},
],

controlOverrides: {
series: {
validators: [validateNonEmpty],
clearable: false,
},
row_limit: {
default: 1,
},
},
};

export default config;
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { t, ChartMetadata, ChartPlugin } from '@superset-ui/core';
import controlPanel from './controlPanel';
import transformProps from './transformProps';
import buildQuery from './buildQuery';
import thumbnail from '../images/thumbnail.png';

export default class IFrameVisualizationChartPlugin extends ChartPlugin {
/**
* The constructor is used to pass relevant metadata and callbacks that get
* registered in respective registries that are used throughout the library
* and application. A more thorough description of each property is given in
* the respective imported file.
*
* It is worth noting that `buildQuery` and is optional, and only needed for
* advanced visualizations that require either post processing operations
* (pivoting, rolling aggregations, sorting etc) or submitting multiple queries.
*/
constructor() {
const metadata = new ChartMetadata({
description: 'IFrame Visualization',
name: t('IFrame Visualization'),
thumbnail,
});

super({
buildQuery,
controlPanel,
loadChart: () => import('../IFrameVisualization'),
metadata,
transformProps,
});
}
}
Loading