datajunction-ui 0.0.1-a86.dev0 → 0.0.1-a86.dev2
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 +6 -2
- package/src/app/pages/AddEditNodePage/index.jsx +25 -19
- 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)}
|
|
@@ -5,12 +5,16 @@
|
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import { lazyLoad } from '../../../utils/loadable';
|
|
7
7
|
|
|
8
|
-
export const
|
|
8
|
+
export const LazyAddEditNodePage = props => {
|
|
9
9
|
return lazyLoad(
|
|
10
10
|
() => import('./index'),
|
|
11
11
|
module => module.AddEditNodePage,
|
|
12
12
|
{
|
|
13
13
|
fallback: <div></div>,
|
|
14
14
|
},
|
|
15
|
-
)();
|
|
15
|
+
)(props);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const AddEditNodePage = props => {
|
|
19
|
+
return <LazyAddEditNodePage {...props} />;
|
|
16
20
|
};
|
|
@@ -330,17 +330,17 @@ export function AddEditNodePage({ extensions = {} }) {
|
|
|
330
330
|
<Formik
|
|
331
331
|
initialValues={initialValues}
|
|
332
332
|
validate={validator}
|
|
333
|
-
onSubmit={
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
333
|
+
onSubmit={(values, { setSubmitting, setStatus }) => {
|
|
334
|
+
try {
|
|
335
|
+
submitHandlers.map(handler =>
|
|
336
|
+
handler(values, { setSubmitting, setStatus }),
|
|
337
|
+
);
|
|
338
|
+
} catch (error) {
|
|
339
|
+
console.error('Error in submission', error);
|
|
340
|
+
} finally {
|
|
341
|
+
setSubmitting(false);
|
|
342
342
|
}
|
|
343
|
-
}
|
|
343
|
+
}}
|
|
344
344
|
>
|
|
345
345
|
{function Render({ isSubmitting, status, setFieldValue }) {
|
|
346
346
|
const [node, setNode] = useState([]);
|
|
@@ -425,15 +425,21 @@ export function AddEditNodePage({ extensions = {} }) {
|
|
|
425
425
|
) : (
|
|
426
426
|
<RequiredDimensionsSelect />
|
|
427
427
|
)}
|
|
428
|
-
{Object.entries(extensions).map(
|
|
429
|
-
|
|
430
|
-
<
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
428
|
+
{Object.entries(extensions).map(
|
|
429
|
+
([key, ExtensionComponent]) => (
|
|
430
|
+
<div key={key} className="mt-4 border-t pt-4">
|
|
431
|
+
<ExtensionComponent
|
|
432
|
+
node={node}
|
|
433
|
+
action={action}
|
|
434
|
+
registerSubmitHandler={onSubmit =>
|
|
435
|
+
submitHandlers.indexOf(onSubmit) === -1
|
|
436
|
+
? submitHandlers.push(onSubmit)
|
|
437
|
+
: null
|
|
438
|
+
}
|
|
439
|
+
/>
|
|
440
|
+
</div>
|
|
441
|
+
),
|
|
442
|
+
)}
|
|
437
443
|
{action === Action.Edit ? selectTags : <TagsField />}
|
|
438
444
|
<NodeModeField />
|
|
439
445
|
|
|
@@ -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
|
{
|