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 1563 #207

Merged
merged 5 commits into from
Sep 16, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cccs-build/superset/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,3 @@ ENV BUILD_NUMBER_VAR=${BUILD_NUMBER}


USER superset

2 changes: 1 addition & 1 deletion cccs-build/superset/analytical-platform-requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
hogwarts-auth~=1.8.0.7820
hogwarts-auth~=1.8.0.7820
2 changes: 1 addition & 1 deletion cccs-build/superset/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ trino>=0.313.0
mysql-connector-python==8.0.26
elasticsearch-dbapi==0.2.4
cachetools~=5.0.0
typing-extensions<4,>=3.10
typing-extensions<4,>=3.10
1 change: 0 additions & 1 deletion requirements/local.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@

# The following packages are considered to be unsafe in a requirements file:
# setuptools

20 changes: 15 additions & 5 deletions superset-frontend/README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,42 @@
To pull our own superset-ui packages from our Artifacts Feed when building locally, the steps below should be followed.

# How to build locally

## Setup credentials

### Step 1

Copy the code below to your [user .npmrc](https://docs.microsoft.com/en-us/azure/devops/artifacts/npm/npmrc?view=azure-devops).

```
; begin auth token
//pkgs.dev.azure.com/cccs-analytical-platform/99130e50-b4e3-4d7d-873e-2a947f564b87/_packaging/analytical-platform/npm/registry/:username=cccs-analytical-platform
//pkgs.dev.azure.com/cccs-analytical-platform/99130e50-b4e3-4d7d-873e-2a947f564b87/_packaging/analytical-platform/npm/registry/:_password=[BASE64_ENCODED_PERSONAL_ACCESS_TOKEN]
; begin auth token
//pkgs.dev.azure.com/cccs-analytical-platform/99130e50-b4e3-4d7d-873e-2a947f564b87/_packaging/analytical-platform/npm/registry/:username=cccs-analytical-platform
//pkgs.dev.azure.com/cccs-analytical-platform/99130e50-b4e3-4d7d-873e-2a947f564b87/_packaging/analytical-platform/npm/registry/:_password=[BASE64_ENCODED_PERSONAL_ACCESS_TOKEN]
//pkgs.dev.azure.com/cccs-analytical-platform/99130e50-b4e3-4d7d-873e-2a947f564b87/_packaging/analytical-platform/npm/registry/:email=npm requires email to be set but doesn't use the value
//pkgs.dev.azure.com/cccs-analytical-platform/99130e50-b4e3-4d7d-873e-2a947f564b87/_packaging/analytical-platform/npm/:username=cccs-analytical-platform
//pkgs.dev.azure.com/cccs-analytical-platform/99130e50-b4e3-4d7d-873e-2a947f564b87/_packaging/analytical-platform/npm/:_password=[BASE64_ENCODED_PERSONAL_ACCESS_TOKEN]
//pkgs.dev.azure.com/cccs-analytical-platform/99130e50-b4e3-4d7d-873e-2a947f564b87/_packaging/analytical-platform/npm/:username=cccs-analytical-platform
//pkgs.dev.azure.com/cccs-analytical-platform/99130e50-b4e3-4d7d-873e-2a947f564b87/_packaging/analytical-platform/npm/:_password=[BASE64_ENCODED_PERSONAL_ACCESS_TOKEN]
//pkgs.dev.azure.com/cccs-analytical-platform/99130e50-b4e3-4d7d-873e-2a947f564b87/_packaging/analytical-platform/npm/:email=npm requires email to be set but doesn't use the value
; end auth token
```

### Step 2

Generate a [Personal Access Token](https://dev.azure.com/cccs-analytical-platform/_usersSettings/tokens) with Packaging read & write scopes.

### Step 3

Base64 encode the personal access token from Step 2.
One safe and secure method of Base64 encoding a string is to:

1. From a command/shell prompt run:

```
node -e "require('readline') .createInterface({input:process.stdin,output:process.stdout,historySize:0}) .question('PAT> ',p => { b64=Buffer.from(p.trim()).toString('base64');console.log(b64);process.exit(); })"
```

2. Paste your personal access token value and press Enter/Return
3. Copy the Base64 encoded value

### Step 4

Replace both [BASE64_ENCODED_PERSONAL_ACCESS_TOKEN] values in your user .npmrc file with your personal access token from Step 3.
25 changes: 9 additions & 16 deletions superset-frontend/src/cccs-viz/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ specific language governing permissions and limitations
under the License.
-->

CCCS-VIZ for Superset
=====================
# CCCS-VIZ for Superset

<br>
<br>

Creating a custom viz
=====================
# Creating a custom viz

Modified instructions from
https://superset.apache.org/docs/installation/building-custom-viz-plugins
Expand All @@ -36,8 +34,8 @@ cd plugin-chart-data-grid
yo @superset-ui/superset
```


Edit `superset/superset-frontend/src/visualizations/presets/MainPreset.js`

```diff

+ import { DataGridChartPlugin } from 'src/cccs-viz/plugins/';
Expand All @@ -53,6 +51,7 @@ Edit `superset/superset-frontend/src/visualizations/presets/MainPreset.js`
```

Run dev-server

```

cd superset/superset-frontend
Expand All @@ -66,13 +65,10 @@ Develop the custom viz. You can connect to port 9000 to test your modifications.
<br>
<br>



Test your code changes inside the docker container
==================

# Test your code changes inside the docker container

Now ready to test docker build

```bash

cd superset
Expand All @@ -81,6 +77,7 @@ docker build -t 'apache/superset:latest-dev' .
```

You can test your docker image using docker-compose, the docker-compose.yaml uses the image we just built.

```bash

cd superset
Expand All @@ -90,20 +87,16 @@ docker-compose up

You can connect to superset on port 8088 to test the superset server running inside the docker container.



<br>
<br>
<br>



Commiting your code
==================
# Commiting your code

When it works locally from your own docker container you can commit your changes

Add custom viz files and the config files that reference it

```bash

cd superset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export default function ApplicationLinks(props: ApplicationsProps) {
<p style={styles.InlineText}>
Alfred has seen {appVal.length > 1 ? 'these' : 'this'}{' '}
{infoType}
{appVal.length > 1 ? "s" : ''} {alfredCount} time
{appVal.length > 1 ? 's' : ''} {alfredCount} time
{alfredCount > 1 ? 's' : ''}. Search the{' '}
<a href={alfredURL} target="_blank" rel="noreferrer">
Alfred
Expand All @@ -119,7 +119,7 @@ export default function ApplicationLinks(props: ApplicationsProps) {
<p style={styles.InlineText}>
Alfred has not seen {appVal.length > 1 ? 'these' : 'this'}{' '}
{infoType}
{appVal.length > 1 ? "s" : ''}. Search the{' '}
{appVal.length > 1 ? 's' : ''}. Search the{' '}
<a href={alfredURL} target="_blank" rel="noreferrer">
Alfred
</a>{' '}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,26 @@
* specific language governing permissions and limitations
* under the License.
*/
import { ensureIsArray, t, validateNonEmpty } from '@superset-ui/core';
import {
ControlPanelConfig,
ControlPanelState,
ControlState,
ControlStateMapping,
sharedControls,
} from '@superset-ui/chart-controls';
const validateAggControlValues = (
controls: ControlStateMapping,
values: any[],
) => {
const areControlsEmpty = values.every(val => ensureIsArray(val).length === 0);
// @ts-ignore
return areControlsEmpty ? [t('Metrics must have a value')] : [];
};
const config: ControlPanelConfig = {
/**
import { ensureIsArray, t, validateNonEmpty } from '@superset-ui/core';
import {
ControlPanelConfig,
ControlPanelState,
ControlState,
ControlStateMapping,
sharedControls,
} from '@superset-ui/chart-controls';

const validateAggControlValues = (
controls: ControlStateMapping,
values: any[],
) => {
const areControlsEmpty = values.every(val => ensureIsArray(val).length === 0);
// @ts-ignore
return areControlsEmpty ? [t('Metrics must have a value')] : [];
};

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
Expand Down Expand Up @@ -108,59 +108,59 @@
* - 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: 'metrics',
override: {
// visibility: () => true,
validators: [],
mapStateToProps: (
state: ControlPanelState,
controlState: ControlState,
) => {
const { controls } = state;
const originalMapStateToProps =
sharedControls?.metrics?.mapStateToProps;
const newState =
originalMapStateToProps?.(state, controlState) ?? {};
newState.externalValidationErrors = validateAggControlValues(
controls,
[controlState.value],
);
return newState;
},
},
},
],
[
{
name: 'row_limit',
override: {
default: 1,
},
},
],
],
},
],
controlOverrides: {
series: {
validators: [validateNonEmpty],
clearable: false,
},
row_limit: {
default: 1,
},
},
};
export default config;

// For control input types, see: superset-frontend/src/explore/components/controls/index.js
controlPanelSections: [
{
label: t('Query'),
expanded: true,
controlSetRows: [
['adhoc_filters'],
[
{
name: 'metrics',
override: {
// visibility: () => true,
validators: [],
mapStateToProps: (
state: ControlPanelState,
controlState: ControlState,
) => {
const { controls } = state;
const originalMapStateToProps =
sharedControls?.metrics?.mapStateToProps;
const newState =
originalMapStateToProps?.(state, controlState) ?? {};
newState.externalValidationErrors = validateAggControlValues(
controls,
[controlState.value],
);
return newState;
},
},
},
],
[
{
name: 'row_limit',
override: {
default: 1,
},
},
],
],
},
],

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

export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ Configure `key`, which can be any `string`, and register the plugin. This `key`

```js
import AtAGlanceChartPlugin from '@superset-ui/plugin-chart-at-a-glance-dns';
new AtAGlanceChartPlugin()
.configure({ key: 'at_a_glance_dns' })
.register();
new AtAGlanceChartPlugin().configure({ key: 'at_a_glance_dns' }).register();
```

Then use it via `SuperChart`. See [storybook](https://apache-superset.github.io/superset-ui/?selectedKind=plugin-chart-at-a-glance) for more details.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('AtAGlance tranformProps', () => {
data: [{ name: 'Hulk', sum__num: 1 }],
},
],
theme: supersetTheme
theme: supersetTheme,
});

it('should tranform chart props for viz', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
## @superset-ui/plugin-chart-at-a-glance-ip



This plugin provides At A Glance for Superset.

### Usage
Expand All @@ -10,9 +8,7 @@ Configure `key`, which can be any `string`, and register the plugin. This `key`

```js
import AtAGlanceChartPlugin from '@superset-ui/plugin-chart-at-a-glance-ip';
new AtAGlanceChartPlugin()
.configure({ key: 'at_a_glance_ip' })
.register();
new AtAGlanceChartPlugin().configure({ key: 'at_a_glance_ip' }).register();
```

Then use it via `SuperChart`. See [storybook](https://apache-superset.github.io/superset-ui/?selectedKind=plugin-chart-at-a-glance) for more details.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ const validateAggControlValues = (
const columnChoices = (datasource: any) => {
if (datasource?.columns) {
return datasource.columns
.map((col : any) => [col.column_name, col.verbose_name || col.column_name])
.map((col: any) => [col.column_name, col.verbose_name || col.column_name])
.sort((opt1: any, opt2: any) =>
opt1[1].toLowerCase() > opt2[1].toLowerCase() ? 1 : -1,
);
}
return [];
}
};
const config: ControlPanelConfig = {
// For control input types, see: superset-frontend/src/explore/components/controls/index.js
controlPanelSections: [
Expand Down
Loading