datajunction-ui 0.0.1-a86.dev1 → 0.0.1-a86.dev3
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 +1 -1
- package/src/app/components/Search.jsx +1 -1
- package/src/app/pages/AddEditNodePage/ColumnsSelect.jsx +21 -9
- package/src/app/pages/AddEditNodePage/Loadable.jsx +4 -3
- package/src/app/pages/AddEditNodePage/TagsField.jsx +1 -1
- package/src/app/pages/AddEditNodePage/index.jsx +36 -28
- package/src/app/pages/NodePage/AddMaterializationPopover.jsx +24 -25
- package/src/app/services/DJService.js +7 -1
package/package.json
CHANGED
|
@@ -6,7 +6,12 @@ import { useContext, useMemo, useState, useEffect } from 'react';
|
|
|
6
6
|
import DJClientContext from '../../providers/djclient';
|
|
7
7
|
import { FormikSelect } from './FormikSelect';
|
|
8
8
|
|
|
9
|
-
export const ColumnsSelect = ({
|
|
9
|
+
export const ColumnsSelect = ({
|
|
10
|
+
defaultValue,
|
|
11
|
+
fieldName,
|
|
12
|
+
label,
|
|
13
|
+
isMulti = false,
|
|
14
|
+
}) => {
|
|
10
15
|
const djClient = useContext(DJClientContext).DataJunctionAPI;
|
|
11
16
|
|
|
12
17
|
// Used to pull out current form values for node validation
|
|
@@ -32,7 +37,7 @@ export const ColumnsSelect = ({ defaultValue, fieldName, label, isMulti = false
|
|
|
32
37
|
);
|
|
33
38
|
if (json?.columns) {
|
|
34
39
|
setAvailableColumns(
|
|
35
|
-
json.columns.map(col => ({ value: col.name, label: col.name }))
|
|
40
|
+
json.columns.map(col => ({ value: col.name, label: col.name })),
|
|
36
41
|
);
|
|
37
42
|
}
|
|
38
43
|
} catch (error) {
|
|
@@ -44,18 +49,25 @@ export const ColumnsSelect = ({ defaultValue, fieldName, label, isMulti = false
|
|
|
44
49
|
fetchColumns();
|
|
45
50
|
}, [values.type, values.name, values.query]);
|
|
46
51
|
|
|
47
|
-
return selectableOptions === undefined ?
|
|
52
|
+
return selectableOptions === undefined ? (
|
|
53
|
+
''
|
|
54
|
+
) : (
|
|
48
55
|
<div className="CubeCreationInput">
|
|
49
56
|
<ErrorMessage name={fieldName} component="span" />
|
|
50
57
|
<label htmlFor="react-select-3-input">{label}</label>
|
|
51
58
|
<span data-testid={`select-${fieldName}`}>
|
|
52
59
|
<FormikSelect
|
|
53
|
-
className={isMulti ?
|
|
54
|
-
defaultValue={
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
60
|
+
className={isMulti ? 'MultiSelectInput' : 'SelectInput'}
|
|
61
|
+
defaultValue={
|
|
62
|
+
isMulti
|
|
63
|
+
? defaultValue.map(val => {
|
|
64
|
+
return {
|
|
65
|
+
value: val,
|
|
66
|
+
label: val,
|
|
67
|
+
};
|
|
68
|
+
})
|
|
69
|
+
: { value: defaultValue, label: defaultValue }
|
|
70
|
+
}
|
|
59
71
|
selectOptions={selectableOptions}
|
|
60
72
|
formikFieldName={fieldName}
|
|
61
73
|
onFocus={event => fetchColumns(event)}
|
|
@@ -2,18 +2,19 @@
|
|
|
2
2
|
* Asynchronously loads the component for the Node page
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
+
import * as React from 'react';
|
|
5
6
|
import { lazyLoad } from '../../../utils/loadable';
|
|
6
7
|
|
|
7
|
-
export const LazyAddEditNodePage =
|
|
8
|
+
export const LazyAddEditNodePage = props => {
|
|
8
9
|
return lazyLoad(
|
|
9
10
|
() => import('./index'),
|
|
10
11
|
module => module.AddEditNodePage,
|
|
11
12
|
{
|
|
12
13
|
fallback: <div></div>,
|
|
13
14
|
},
|
|
14
|
-
)();
|
|
15
|
+
)(props);
|
|
15
16
|
};
|
|
16
17
|
|
|
17
|
-
export const AddEditNodePage =
|
|
18
|
+
export const AddEditNodePage = props => {
|
|
18
19
|
return <LazyAddEditNodePage {...props} />;
|
|
19
20
|
};
|
|
@@ -31,7 +31,7 @@ export const TagsField = ({ defaultValue }) => {
|
|
|
31
31
|
style={{ width: '25%', margin: '1rem 0 1rem 1.2rem' }}
|
|
32
32
|
>
|
|
33
33
|
<ErrorMessage name="tags" component="span" />
|
|
34
|
-
<label htmlFor="
|
|
34
|
+
<label htmlFor="tags">Tags</label>
|
|
35
35
|
<span data-testid="select-tags">
|
|
36
36
|
<FormikSelect
|
|
37
37
|
isMulti={true}
|
|
@@ -93,10 +93,10 @@ export function AddEditNodePage({ extensions = {} }) {
|
|
|
93
93
|
const staticFieldsInEdit = node => (
|
|
94
94
|
<>
|
|
95
95
|
<div className="NodeNameInput NodeCreationInput">
|
|
96
|
-
<label
|
|
96
|
+
<label>Name</label> {name}
|
|
97
97
|
</div>
|
|
98
98
|
<div className="NodeNameInput NodeCreationInput">
|
|
99
|
-
<label
|
|
99
|
+
<label>Type</label> {node.type}
|
|
100
100
|
</div>
|
|
101
101
|
</>
|
|
102
102
|
);
|
|
@@ -295,13 +295,15 @@ export function AddEditNodePage({ extensions = {} }) {
|
|
|
295
295
|
isMulti={true}
|
|
296
296
|
/>,
|
|
297
297
|
);
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
298
|
+
if (data.required_dimensions) {
|
|
299
|
+
setSelectRequiredDims(
|
|
300
|
+
<RequiredDimensionsSelect
|
|
301
|
+
defaultValue={data.required_dimensions.map(dim => {
|
|
302
|
+
return { value: dim, label: dim };
|
|
303
|
+
})}
|
|
304
|
+
/>,
|
|
305
|
+
);
|
|
306
|
+
}
|
|
305
307
|
setSelectUpstreamNode(
|
|
306
308
|
<UpstreamNodeField
|
|
307
309
|
defaultValue={{
|
|
@@ -330,17 +332,17 @@ export function AddEditNodePage({ extensions = {} }) {
|
|
|
330
332
|
<Formik
|
|
331
333
|
initialValues={initialValues}
|
|
332
334
|
validate={validator}
|
|
333
|
-
onSubmit={
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
335
|
+
onSubmit={(values, { setSubmitting, setStatus }) => {
|
|
336
|
+
try {
|
|
337
|
+
submitHandlers.map(handler =>
|
|
338
|
+
handler(values, { setSubmitting, setStatus }),
|
|
339
|
+
);
|
|
340
|
+
} catch (error) {
|
|
341
|
+
console.error('Error in submission', error);
|
|
342
|
+
} finally {
|
|
343
|
+
setSubmitting(false);
|
|
342
344
|
}
|
|
343
|
-
}
|
|
345
|
+
}}
|
|
344
346
|
>
|
|
345
347
|
{function Render({ isSubmitting, status, setFieldValue }) {
|
|
346
348
|
const [node, setNode] = useState([]);
|
|
@@ -425,15 +427,21 @@ export function AddEditNodePage({ extensions = {} }) {
|
|
|
425
427
|
) : (
|
|
426
428
|
<RequiredDimensionsSelect />
|
|
427
429
|
)}
|
|
428
|
-
{Object.entries(extensions).map(
|
|
429
|
-
|
|
430
|
-
<
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
430
|
+
{Object.entries(extensions).map(
|
|
431
|
+
([key, ExtensionComponent]) => (
|
|
432
|
+
<div key={key} className="mt-4 border-t pt-4">
|
|
433
|
+
<ExtensionComponent
|
|
434
|
+
node={node}
|
|
435
|
+
action={action}
|
|
436
|
+
registerSubmitHandler={onSubmit =>
|
|
437
|
+
submitHandlers.indexOf(onSubmit) === -1
|
|
438
|
+
? submitHandlers.push(onSubmit)
|
|
439
|
+
: null
|
|
440
|
+
}
|
|
441
|
+
/>
|
|
442
|
+
</div>
|
|
443
|
+
),
|
|
444
|
+
)}
|
|
437
445
|
{action === Action.Edit ? selectTags : <TagsField />}
|
|
438
446
|
<NodeModeField />
|
|
439
447
|
|
|
@@ -44,23 +44,22 @@ export default function AddMaterializationPopover({ node, onSubmit }) {
|
|
|
44
44
|
if (!values.job_type) {
|
|
45
45
|
values.job_type = 'spark_sql';
|
|
46
46
|
}
|
|
47
|
-
const { status, json } =
|
|
48
|
-
values.job_type === 'druid_cube'
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
);
|
|
47
|
+
const { status, json } =
|
|
48
|
+
values.job_type === 'druid_cube'
|
|
49
|
+
? await djClient.materializeCube(
|
|
50
|
+
values.node,
|
|
51
|
+
values.job_type,
|
|
52
|
+
values.strategy,
|
|
53
|
+
values.schedule,
|
|
54
|
+
values.lookback_window,
|
|
55
|
+
)
|
|
56
|
+
: await djClient.materialize(
|
|
57
|
+
values.node,
|
|
58
|
+
values.job_type,
|
|
59
|
+
values.strategy,
|
|
60
|
+
values.schedule,
|
|
61
|
+
config,
|
|
62
|
+
);
|
|
64
63
|
if (status === 200 || status === 201) {
|
|
65
64
|
setStatus({ success: json.message });
|
|
66
65
|
window.location.reload();
|
|
@@ -110,9 +109,9 @@ export default function AddMaterializationPopover({ node, onSubmit }) {
|
|
|
110
109
|
<Formik
|
|
111
110
|
initialValues={{
|
|
112
111
|
node: node?.name,
|
|
113
|
-
job_type:
|
|
114
|
-
|
|
115
|
-
|
|
112
|
+
job_type: node?.type === 'cube' ? 'druid_cube' : 'spark_sql',
|
|
113
|
+
strategy:
|
|
114
|
+
timePartitionColumns.length == 1 ? 'incremental_time' : 'full',
|
|
116
115
|
schedule: '@daily',
|
|
117
116
|
lookback_window: '1 DAY',
|
|
118
117
|
spark_config: {
|
|
@@ -133,10 +132,7 @@ export default function AddMaterializationPopover({ node, onSubmit }) {
|
|
|
133
132
|
|
|
134
133
|
<Field as="select" name="job_type">
|
|
135
134
|
<>
|
|
136
|
-
<option
|
|
137
|
-
key={'druid_cube'}
|
|
138
|
-
value={'druid_cube'}
|
|
139
|
-
>
|
|
135
|
+
<option key={'druid_cube'} value={'druid_cube'}>
|
|
140
136
|
Druid
|
|
141
137
|
</option>
|
|
142
138
|
</>
|
|
@@ -153,7 +149,10 @@ export default function AddMaterializationPopover({ node, onSubmit }) {
|
|
|
153
149
|
value={node?.name}
|
|
154
150
|
readOnly={true}
|
|
155
151
|
/>
|
|
156
|
-
{console.log(
|
|
152
|
+
{console.log(
|
|
153
|
+
'timePartitionColumns.length',
|
|
154
|
+
timePartitionColumns.length,
|
|
155
|
+
)}
|
|
157
156
|
<span data-testid="edit-partition">
|
|
158
157
|
<label htmlFor="strategy">Strategy</label>
|
|
159
158
|
<Field as="select" name="strategy">
|
|
@@ -980,7 +980,13 @@ export const DataJunctionAPI = {
|
|
|
980
980
|
);
|
|
981
981
|
return { status: response.status, json: await response.json() };
|
|
982
982
|
},
|
|
983
|
-
materializeCube: async function (
|
|
983
|
+
materializeCube: async function (
|
|
984
|
+
nodeName,
|
|
985
|
+
jobType,
|
|
986
|
+
strategy,
|
|
987
|
+
schedule,
|
|
988
|
+
lookbackWindow,
|
|
989
|
+
) {
|
|
984
990
|
const response = await fetch(
|
|
985
991
|
`${DJ_URL}/nodes/${nodeName}/materialization`,
|
|
986
992
|
{
|