2020-06-23 03:08:22 -04:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2021-01-26 06:00:59 -05:00
|
|
|
import {
|
|
|
|
ChartDataResponseResult,
|
|
|
|
ChartProps,
|
|
|
|
DatasourceType,
|
|
|
|
GenericDataType,
|
2022-05-04 08:55:22 -04:00
|
|
|
supersetTheme,
|
2021-01-26 06:00:59 -05:00
|
|
|
} from '@superset-ui/core';
|
|
|
|
import { TableChartProps, TableChartFormData } from '../src/types';
|
2020-06-23 03:08:22 -04:00
|
|
|
|
2021-01-26 06:00:59 -05:00
|
|
|
const basicFormData: TableChartFormData = {
|
|
|
|
datasource: '1__abc',
|
|
|
|
viz_type: 'table',
|
|
|
|
align_pn: false,
|
|
|
|
color_pn: false,
|
|
|
|
show_cell_bars: true,
|
|
|
|
include_search: false,
|
|
|
|
order_desc: true,
|
|
|
|
page_length: 20,
|
2020-06-23 03:08:22 -04:00
|
|
|
metrics: [],
|
2021-01-26 06:00:59 -05:00
|
|
|
percent_metrics: null,
|
|
|
|
timeseries_limit_metric: '',
|
|
|
|
table_filter: false,
|
|
|
|
table_timestamp_format: '%Y-%m-%d %H:%M:%S',
|
2020-06-23 03:08:22 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
const basicChartProps = {
|
|
|
|
width: 200,
|
|
|
|
height: 500,
|
|
|
|
datasource: {
|
|
|
|
id: 0,
|
|
|
|
name: '',
|
|
|
|
type: DatasourceType.Table,
|
|
|
|
columns: [],
|
|
|
|
metrics: [],
|
|
|
|
columnFormats: {},
|
|
|
|
verboseMap: {},
|
|
|
|
},
|
|
|
|
hooks: {},
|
|
|
|
initialValues: {},
|
2020-12-29 05:10:39 -05:00
|
|
|
queriesData: [
|
|
|
|
{
|
|
|
|
data: {
|
|
|
|
columns: [],
|
|
|
|
records: [],
|
|
|
|
},
|
2020-06-23 03:08:22 -04:00
|
|
|
},
|
2020-12-29 05:10:39 -05:00
|
|
|
],
|
2020-06-23 03:08:22 -04:00
|
|
|
formData: basicFormData,
|
2022-05-04 08:55:22 -04:00
|
|
|
theme: supersetTheme,
|
2020-06-23 03:08:22 -04:00
|
|
|
};
|
|
|
|
|
2021-01-26 06:00:59 -05:00
|
|
|
const basicQueryResult: ChartDataResponseResult = {
|
|
|
|
annotation_data: null,
|
|
|
|
cache_key: null,
|
2021-12-15 04:15:14 -05:00
|
|
|
cached_dttm: null,
|
2021-01-26 06:00:59 -05:00
|
|
|
cache_timeout: null,
|
|
|
|
data: [],
|
|
|
|
colnames: [],
|
|
|
|
coltypes: [],
|
|
|
|
error: null,
|
|
|
|
is_cached: false,
|
|
|
|
query: 'SELECT ...',
|
|
|
|
rowcount: 100,
|
|
|
|
stacktrace: null,
|
|
|
|
status: 'success',
|
2022-03-27 22:20:06 -04:00
|
|
|
from_dttm: null,
|
|
|
|
to_dttm: null,
|
2021-01-26 06:00:59 -05:00
|
|
|
};
|
|
|
|
|
2020-06-23 03:08:22 -04:00
|
|
|
/**
|
|
|
|
* Basic data input
|
|
|
|
*/
|
2021-01-26 06:00:59 -05:00
|
|
|
const basic: TableChartProps = {
|
2020-06-23 03:08:22 -04:00
|
|
|
...new ChartProps(basicChartProps),
|
2020-12-29 05:10:39 -05:00
|
|
|
queriesData: [
|
|
|
|
{
|
2021-01-26 06:00:59 -05:00
|
|
|
...basicQueryResult,
|
|
|
|
colnames: ['__timestamp', 'name', 'sum__num', 'abc.com'],
|
|
|
|
coltypes: [
|
|
|
|
GenericDataType.TEMPORAL,
|
|
|
|
GenericDataType.STRING,
|
|
|
|
GenericDataType.NUMERIC,
|
|
|
|
GenericDataType.STRING,
|
|
|
|
],
|
|
|
|
data: [
|
|
|
|
{
|
|
|
|
__timestamp: '2020-01-01T12:34:56',
|
|
|
|
name: 'Michael',
|
|
|
|
sum__num: 2467063,
|
|
|
|
'%pct_nice': 0.123456,
|
|
|
|
'abc.com': 'foo',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
__timestamp: 1585932584140,
|
|
|
|
name: 'Joe',
|
|
|
|
sum__num: 2467,
|
|
|
|
'%pct_nice': 0.00001,
|
|
|
|
'abc.com': 'bar',
|
|
|
|
},
|
2022-01-10 13:07:59 -05:00
|
|
|
{
|
|
|
|
__timestamp: null,
|
|
|
|
name: 'Maria',
|
|
|
|
sum__num: 12342,
|
|
|
|
'%pct_nice': 0.341,
|
|
|
|
'abc.com': 'baz',
|
|
|
|
},
|
2021-01-26 06:00:59 -05:00
|
|
|
],
|
2020-06-23 03:08:22 -04:00
|
|
|
},
|
2020-12-29 05:10:39 -05:00
|
|
|
],
|
2020-06-23 03:08:22 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Advanced data input with
|
|
|
|
* - verbose map
|
|
|
|
* - metric columns
|
|
|
|
*/
|
2021-01-26 06:00:59 -05:00
|
|
|
const advanced: TableChartProps = {
|
2020-06-23 03:08:22 -04:00
|
|
|
...basic,
|
|
|
|
datasource: {
|
|
|
|
...basic.datasource,
|
|
|
|
verboseMap: {
|
|
|
|
sum__num: 'Sum of Num',
|
|
|
|
},
|
|
|
|
},
|
2021-01-26 06:00:59 -05:00
|
|
|
rawFormData: {
|
2020-06-23 03:08:22 -04:00
|
|
|
...basicFormData,
|
|
|
|
metrics: ['sum__num'],
|
2021-01-26 06:00:59 -05:00
|
|
|
percent_metrics: ['pct_nice'],
|
2020-06-23 03:08:22 -04:00
|
|
|
},
|
2020-12-29 05:10:39 -05:00
|
|
|
queriesData: [
|
|
|
|
{
|
2021-01-26 06:00:59 -05:00
|
|
|
...basicQueryResult,
|
|
|
|
colnames: ['name', 'sum__num', '%pct_nice'],
|
2021-11-09 07:42:28 -05:00
|
|
|
coltypes: [
|
|
|
|
GenericDataType.STRING,
|
|
|
|
GenericDataType.NUMERIC,
|
|
|
|
GenericDataType.NUMERIC,
|
|
|
|
],
|
2021-01-26 06:00:59 -05:00
|
|
|
data: [...(basic.queriesData[0].data || [])],
|
2020-06-23 03:08:22 -04:00
|
|
|
},
|
2020-12-29 05:10:39 -05:00
|
|
|
],
|
2020-06-23 03:08:22 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
const empty = {
|
|
|
|
...advanced,
|
2020-12-29 05:10:39 -05:00
|
|
|
queriesData: [
|
|
|
|
{
|
|
|
|
...advanced.queriesData[0],
|
2021-01-26 06:00:59 -05:00
|
|
|
data: [],
|
2020-06-23 03:08:22 -04:00
|
|
|
},
|
2020-12-29 05:10:39 -05:00
|
|
|
],
|
2020-06-23 03:08:22 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
export default {
|
|
|
|
basic,
|
|
|
|
advanced,
|
|
|
|
empty,
|
|
|
|
};
|