You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ru...@apache.org on 2024/06/17 21:26:14 UTC
(superset) branch control-panel-2.0 created (now d3a8c8341b)
This is an automated email from the ASF dual-hosted git repository.
rusackas pushed a change to branch control-panel-2.0
in repository https://gitbox.apache.org/repos/asf/superset.git
at d3a8c8341b first baby steps
This branch includes the following new commits:
new d3a8c8341b first baby steps
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(superset) 01/01: first baby steps
Posted by ru...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rusackas pushed a commit to branch control-panel-2.0
in repository https://gitbox.apache.org/repos/asf/superset.git
commit d3a8c8341b2fba760c93f62cad3ee17d62ccf6a0
Author: Evan Rusackas <ev...@preset.io>
AuthorDate: Mon Jun 17 15:26:00 2024 -0600
first baby steps
---
superset-frontend/package-lock.json | 20 ++--
.../ControlPanel/ControlPanel.stories.tsx | 49 ++++++++
.../src/components/ControlPanel/index.tsx | 132 +++++++++++++++++++++
3 files changed, 191 insertions(+), 10 deletions(-)
diff --git a/superset-frontend/package-lock.json b/superset-frontend/package-lock.json
index f4159d5764..e22df280ea 100644
--- a/superset-frontend/package-lock.json
+++ b/superset-frontend/package-lock.json
@@ -67695,6 +67695,11 @@
"resolved": "https://registry.npmjs.org/@types/d3-time/-/d3-time-3.0.3.tgz",
"integrity": "sha512-2p6olUZ4w3s+07q3Tm2dbiMZy5pCDfYwtLXXHUnVzXgQlZ/OyPtUz6OL382BkOuGlLXqfT+wqv8Fw2v8/0geBw=="
},
+ "packages/superset-ui-core/node_modules/@types/d3-time-format": {
+ "version": "2.3.1",
+ "resolved": "https://registry.npmjs.org/@types/d3-time-format/-/d3-time-format-2.3.1.tgz",
+ "integrity": "sha512-fck0Z9RGfIQn3GJIEKVrp15h9m6Vlg0d5XXeiE/6+CQiBmMDZxfR21XtjEPuDeg7gC3bBM0SdieA5XF3GW1wKA=="
+ },
"packages/superset-ui-core/node_modules/@types/fetch-mock": {
"version": "7.3.8",
"resolved": "https://registry.npmjs.org/@types/fetch-mock/-/fetch-mock-7.3.8.tgz",
@@ -67705,11 +67710,6 @@
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.0.tgz",
"integrity": "sha512-t7dhREVv6dbNj0q17X12j7yDG4bD/DHYX7o5/DbDxobP0HnGPgpRz2Ej77aL7TZT3DSw13fqUTj8J4mMnqa7WA=="
},
- "packages/superset-ui-core/node_modules/@types/d3-time-format": {
- "version": "2.3.1",
- "resolved": "https://registry.npmjs.org/@types/d3-time-format/-/d3-time-format-2.3.1.tgz",
- "integrity": "sha512-fck0Z9RGfIQn3GJIEKVrp15h9m6Vlg0d5XXeiE/6+CQiBmMDZxfR21XtjEPuDeg7gC3bBM0SdieA5XF3GW1wKA=="
- },
"packages/superset-ui-core/node_modules/@types/math-expression-evaluator": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/@types/math-expression-evaluator/-/math-expression-evaluator-1.3.3.tgz",
@@ -86352,6 +86352,11 @@
"resolved": "https://registry.npmjs.org/@types/d3-time/-/d3-time-3.0.3.tgz",
"integrity": "sha512-2p6olUZ4w3s+07q3Tm2dbiMZy5pCDfYwtLXXHUnVzXgQlZ/OyPtUz6OL382BkOuGlLXqfT+wqv8Fw2v8/0geBw=="
},
+ "@types/d3-time-format": {
+ "version": "2.3.1",
+ "resolved": "https://registry.npmjs.org/@types/d3-time-format/-/d3-time-format-2.3.1.tgz",
+ "integrity": "sha512-fck0Z9RGfIQn3GJIEKVrp15h9m6Vlg0d5XXeiE/6+CQiBmMDZxfR21XtjEPuDeg7gC3bBM0SdieA5XF3GW1wKA=="
+ },
"@types/fetch-mock": {
"version": "7.3.8",
"resolved": "https://registry.npmjs.org/@types/fetch-mock/-/fetch-mock-7.3.8.tgz",
@@ -86362,11 +86367,6 @@
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.0.tgz",
"integrity": "sha512-t7dhREVv6dbNj0q17X12j7yDG4bD/DHYX7o5/DbDxobP0HnGPgpRz2Ej77aL7TZT3DSw13fqUTj8J4mMnqa7WA=="
},
- "@types/d3-time-format": {
- "version": "2.3.1",
- "resolved": "https://registry.npmjs.org/@types/d3-time-format/-/d3-time-format-2.3.1.tgz",
- "integrity": "sha512-fck0Z9RGfIQn3GJIEKVrp15h9m6Vlg0d5XXeiE/6+CQiBmMDZxfR21XtjEPuDeg7gC3bBM0SdieA5XF3GW1wKA=="
- },
"@types/math-expression-evaluator": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/@types/math-expression-evaluator/-/math-expression-evaluator-1.3.3.tgz",
diff --git a/superset-frontend/src/components/ControlPanel/ControlPanel.stories.tsx b/superset-frontend/src/components/ControlPanel/ControlPanel.stories.tsx
new file mode 100644
index 0000000000..e96140a022
--- /dev/null
+++ b/superset-frontend/src/components/ControlPanel/ControlPanel.stories.tsx
@@ -0,0 +1,49 @@
+/**
+ * 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 ControlPanel, { ControlPanelProps } from '.';
+
+export default {
+ title: 'ControlPanel',
+ component: ControlPanel,
+};
+
+export const InteractiveControlPanel = (args: ControlPanelProps) => <ControlPanel {...args} />;
+
+InteractiveControlPanel.args = {
+ // padded: true,
+ // title: 'Card title',
+ // children: 'Card content',
+ // bordered: true,
+ // loading: false,
+ // hoverable: false,
+};
+
+InteractiveControlPanel.argTypes = {
+ // onClick: {
+ // table: {
+ // disable: true,
+ // },
+ // action: 'onClick',
+ // },
+ // theme: {
+ // table: {
+ // disable: true,
+ // },
+ // },
+};
diff --git a/superset-frontend/src/components/ControlPanel/index.tsx b/superset-frontend/src/components/ControlPanel/index.tsx
new file mode 100644
index 0000000000..47edd2fb0a
--- /dev/null
+++ b/superset-frontend/src/components/ControlPanel/index.tsx
@@ -0,0 +1,132 @@
+/**
+ * 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 React, { useState } from 'react';
+import { Tree, Input, InputNumber, Select, Slider } from 'antd';
+
+const { Option } = Select;
+
+const ControlPanel = (props) => {
+ const [treeData, setTreeData] = useState([
+ {
+ title: 'Root Node',
+ key: '0',
+ children: [
+ { title: 'Numeric Input', key: '0-0', value: 10, type: 'number' },
+ { title: 'Slider Input', key: '0-1', value: 50, type: 'number', range: [0, 100] },
+ { title: 'Text Input', key: '0-2', value: 'Initial Text', type: 'string' },
+ {
+ title: 'Select Input',
+ key: '0-3',
+ value: 'option1',
+ type: 'enum',
+ options: ['option1', 'option2', 'option3'],
+ },
+ ],
+ },
+ ]);
+
+ const onInputChange = (key, value) => {
+ const newTreeData = [...treeData];
+ const updateTreeData = (data) => {
+ data.forEach((item) => {
+ if (item.key === key) {
+ item.value = value;
+ }
+ if (item.children) {
+ updateTreeData(item.children);
+ }
+ });
+ };
+ updateTreeData(newTreeData);
+ setTreeData(newTreeData);
+ };
+
+ const renderInputComponent = (node) => {
+ if (node.type === 'number') {
+ if (node.range) {
+ return (
+ <Slider
+ style={{ marginRight: '8px', width: 150 }}
+ value={node.value}
+ min={node.range[0]}
+ max={node.range[1]}
+ onChange={(value) => onInputChange(node.key, value)}
+ />
+ );
+ } else {
+ return (
+ <InputNumber
+ style={{ marginRight: '8px' }}
+ value={node.value}
+ onChange={(value) => onInputChange(node.key, value)}
+ />
+ );
+ }
+ } else if (node.type === 'enum') {
+ return (
+ <Select
+ style={{ marginRight: '8px', width: 120 }}
+ value={node.value}
+ onChange={(value) => onInputChange(node.key, value)}
+ >
+ {node.options &&
+ node.options.map((option) => (
+ <Option key={option} value={option}>
+ {option}
+ </Option>
+ ))}
+ </Select>
+ );
+ } else if (node.type === 'string') {
+ return (
+ <Input
+ style={{ marginRight: '8px' }}
+ value={node.value}
+ onChange={(e) => onInputChange(node.key, e.target.value)}
+ />
+ );
+ } else {
+ return null;
+ }
+ };
+
+ const renderTreeNode = (nodeData) => {
+ return {
+ title: (
+ <div style={{ display: 'flex', alignItems: 'center' }}>
+ {renderInputComponent(nodeData)}
+ {nodeData.title}
+ </div>
+ ),
+ key: nodeData.key,
+ children: nodeData.children ? nodeData.children.map(renderTreeNode) : [],
+ };
+ };
+
+ return (
+ <Tree
+ {...props}
+ showLine
+ treeData={treeData.map(renderTreeNode)}
+ />
+ );
+};
+
+export default ControlPanel;