datajunction-ui 0.0.1-rc.15 → 0.0.1-rc.16
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.
package/package.json
CHANGED
|
@@ -11,8 +11,25 @@ SyntaxHighlighter.registerLanguage('sql', sql);
|
|
|
11
11
|
foundation.hljs['padding'] = '2rem';
|
|
12
12
|
|
|
13
13
|
export default function NodeInfoTab({ node }) {
|
|
14
|
+
const [compiledSQL, setCompiledSQL] = useState('');
|
|
14
15
|
const [checked, setChecked] = useState(false);
|
|
15
16
|
const nodeTags = node?.tags.map(tag => <div>{tag}</div>);
|
|
17
|
+
const djClient = useContext(DJClientContext).DataJunctionAPI;
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
const fetchData = async () => {
|
|
20
|
+
if (checked === true) {
|
|
21
|
+
const data = await djClient.compiledSql(node.name);
|
|
22
|
+
if (data.sql) {
|
|
23
|
+
setCompiledSQL(data.sql);
|
|
24
|
+
} else {
|
|
25
|
+
setCompiledSQL(
|
|
26
|
+
'/* Ran into an issue while generating compiled SQL */',
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
fetchData().catch(console.error);
|
|
32
|
+
}, [node, djClient, checked]);
|
|
16
33
|
function toggle(value) {
|
|
17
34
|
return !value;
|
|
18
35
|
}
|
|
@@ -25,8 +42,18 @@ export default function NodeInfoTab({ node }) {
|
|
|
25
42
|
}}
|
|
26
43
|
>
|
|
27
44
|
<h6 className="mb-0 w-100">Query</h6>
|
|
45
|
+
{['metric', 'dimension', 'transform'].indexOf(node?.type) > -1 ? (
|
|
46
|
+
<ToggleSwitch
|
|
47
|
+
id="toggleSwitch"
|
|
48
|
+
checked={checked}
|
|
49
|
+
onChange={() => setChecked(toggle)}
|
|
50
|
+
toggleName="Show Compiled SQL"
|
|
51
|
+
/>
|
|
52
|
+
) : (
|
|
53
|
+
<></>
|
|
54
|
+
)}
|
|
28
55
|
<SyntaxHighlighter language="sql" style={foundation}>
|
|
29
|
-
{node?.query}
|
|
56
|
+
{checked ? compiledSQL : node?.query}
|
|
30
57
|
</SyntaxHighlighter>
|
|
31
58
|
</div>
|
|
32
59
|
</div>
|