datajunction-ui 0.0.1-a47 → 0.0.1-a49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,82 +0,0 @@
1
- import { useContext, useEffect, useState } from 'react';
2
- import Select from 'react-select';
3
- import DJClientContext from '../../providers/djclient';
4
- import { Light as SyntaxHighlighter } from 'react-syntax-highlighter';
5
- import { foundation } from 'react-syntax-highlighter/src/styles/hljs';
6
-
7
- const NodeSQLTab = djNode => {
8
- const djClient = useContext(DJClientContext).DataJunctionAPI;
9
- const [query, setQuery] = useState('');
10
-
11
- const [selection, setSelection] = useState({
12
- dimensions: [],
13
- filters: [],
14
- });
15
-
16
- useEffect(() => {
17
- const fetchData = async () => {
18
- const query = await djClient.sql(djNode.djNode.name, selection);
19
- setQuery(query.sql);
20
- };
21
- fetchData().catch(console.error);
22
- }, [djClient, djNode.djNode.name, selection]);
23
- const dimensionsList = djNode.djNode.dimensions
24
- ? djNode.djNode.dimensions.map(dim => ({
25
- value: dim.name,
26
- label: dim.name + ` (${dim.type})`,
27
- }))
28
- : [''];
29
-
30
- const handleSubmit = event => {
31
- event.preventDefault();
32
- };
33
-
34
- const handleChange = event => {
35
- setSelection({ filters: [], dimensions: event.map(dim => dim.value) });
36
- };
37
-
38
- return (
39
- <form
40
- id="retrieve-sql"
41
- name="retrieve-sql"
42
- onSubmit={handleSubmit.bind(this)}
43
- >
44
- <div>
45
- <h4>Group By</h4>
46
- <Select
47
- name="dimensions"
48
- options={dimensionsList}
49
- isMulti
50
- isClearable
51
- onChange={handleChange}
52
- />
53
- {/*<h4>Filters</h4>*/}
54
- {/*<Select*/}
55
- {/* name="filter_name"*/}
56
- {/* options={dimensionsList}*/}
57
- {/* className="filters_attribute"*/}
58
- {/*/>*/}
59
- {/*<Select*/}
60
- {/* name="filter_operator"*/}
61
- {/* options={options}*/}
62
- {/* className="filters_attribute"*/}
63
- {/*/>*/}
64
- {/*<textarea name="filter_value" className="filters_attribute" />*/}
65
-
66
- <div
67
- style={{
68
- width: window.innerWidth * 0.8,
69
- marginTop: '2rem',
70
- }}
71
- >
72
- <h6 className="mb-0 w-100">Query</h6>
73
- <SyntaxHighlighter language="sql" style={foundation}>
74
- {query}
75
- </SyntaxHighlighter>
76
- </div>
77
- </div>
78
- </form>
79
- );
80
- };
81
-
82
- export default NodeSQLTab;