datajunction-ui 0.0.1-rc.15 → 0.0.1-rc.17

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datajunction-ui",
3
- "version": "0.0.1-rc.15",
3
+ "version": "0.0.1-rc.17",
4
4
  "description": "DataJunction Metrics Platform UI",
5
5
  "module": "src/index.tsx",
6
6
  "repository": {
@@ -20,7 +20,7 @@ export default function NodeColumnTab({ node, djClient }) {
20
20
  </span>
21
21
  </td>
22
22
  <td>
23
- {col.dimension ? (
23
+ {col.dimension !== undefined && col.dimension !== null ? (
24
24
  <>
25
25
  <a href={`/nodes/${col.dimension.name}`}>{col.dimension.name}</a>
26
26
  <ClientCodePopover code={col.clientCode} />
@@ -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>
@@ -141,7 +141,7 @@ export const DataJunctionAPI = {
141
141
  columns: async function (node) {
142
142
  return await Promise.all(
143
143
  node.columns.map(async col => {
144
- if (col.dimension !== null) {
144
+ if (col.dimension) {
145
145
  col.clientCode = await (
146
146
  await fetch(
147
147
  DJ_URL +