Skip to content

Commit 3408ac6

Browse files
committed
adding breadcrumb
1 parent 3b942b9 commit 3408ac6

File tree

5 files changed

+94
-9
lines changed

5 files changed

+94
-9
lines changed

web-server/plugins/slycat-cca/js/components/CCANavItems.tsx

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,26 @@ export const CCAWizardNavItems = () => {
1919
key={"Upload Table"}
2020
name={"Upload Table"}
2121
active={tabName === TabNames.CCA_LOCAL_BROWSER_TAB}
22-
hidden={false}
22+
hidden={tabName === TabNames.CCA_DATA_WIZARD_SELECTION_TAB}
23+
/>
24+
<CCANavItem
25+
key={"Select Columns"}
26+
name={"Select Columns"}
27+
active={tabName === TabNames.CCA_TABLE_INGESTION}
28+
hidden={
29+
tabName === TabNames.CCA_DATA_WIZARD_SELECTION_TAB ||
30+
tabName === TabNames.CCA_LOCAL_BROWSER_TAB
31+
}
32+
/>
33+
<CCANavItem
34+
key={"Name Model"}
35+
name={"Name Model"}
36+
active={tabName === TabNames.CCA_FINISH_MODEL}
37+
hidden={tabName !== TabNames.CCA_FINISH_MODEL}
2338
/>
2439
{/* TODO: the hidden tabs below should be consolidated */}
2540
<CCANavItem key={"Choose Host"} name={"Choose Host"} hidden={true} />
2641
<CCANavItem key={"Select Table"} name={"Select Table"} hidden={true} />
27-
<CCANavItem key={"Select Columns"} name={"Select Columns"} />
28-
<CCANavItem key={"Name Model"} name={"Name Model"} />
2942
</ul>
3043
);
3144
};

web-server/plugins/slycat-cca/js/components/CCAWizardSteps.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export const CCAWizardSteps = () => {
5555
<slycat-parser-controls params="parser:parser,category:'table'"></slycat-parser-controls> */}
5656
</div>
5757
</div>
58-
<div hidden={true}>
58+
<div hidden={!(tabName === TabNames.CCA_FINISH_MODEL)}>
5959
<form data-bind="submit: name_model" id="new-cca-name-model-form" noValidate>
6060
{/* <slycat-model-controls
6161
params="name:model.name,description:model.description,marking:model.marking"

web-server/plugins/slycat-cca/js/components/CCAWizardUtils.tsx

Lines changed: 69 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ import { produce } from "immer";
77
import {
88
Attribute,
99
resetCCAWizard,
10+
selectAttributes,
1011
selectDataLocation,
1112
selectFileUploaded,
1213
selectMid,
1314
selectPid,
15+
selectScaleInputs,
1416
selectTab,
1517
setAttributes,
1618
setFileUploaded,
@@ -22,7 +24,6 @@ import {
2224
import client from "js/slycat-web-client";
2325
import fileUploader from "js/slycat-file-uploader-factory";
2426
import * as dialog from "js/slycat-dialog";
25-
import { useSelector } from "node_modules/react-redux/dist/react-redux";
2627

2728
/**
2829
* A hook for controlling how the back and continue buttons work based on the current redux state
@@ -33,6 +34,7 @@ export const useCCAWizardFooter = () => {
3334
const dataLocation = useAppSelector(selectDataLocation);
3435
const fileUploaded = useAppSelector(selectFileUploaded);
3536
const dispatch = useAppDispatch();
37+
const uploadSelection = useUploadSelection();
3638

3739
/**
3840
* handle continue operation
@@ -45,9 +47,9 @@ export const useCCAWizardFooter = () => {
4547
dispatch(setTabName(TabNames.CCA_TABLE_INGESTION));
4648
}
4749
if (tabName === TabNames.CCA_TABLE_INGESTION) {
48-
dispatch(setTabName(TabNames.CCA_TABLE_INGESTION));
50+
uploadSelection();
4951
}
50-
}, [dispatch, fileUploaded, setTabName, tabName]);
52+
}, [dispatch, uploadSelection, fileUploaded, setTabName, tabName]);
5153

5254
/**
5355
* handle back operation
@@ -59,6 +61,9 @@ export const useCCAWizardFooter = () => {
5961
if (tabName === TabNames.CCA_TABLE_INGESTION) {
6062
dispatch(setTabName(TabNames.CCA_LOCAL_BROWSER_TAB));
6163
}
64+
if (tabName === TabNames.CCA_FINISH_MODEL) {
65+
dispatch(setTabName(TabNames.CCA_TABLE_INGESTION));
66+
}
6267
}, [dispatch, setTabName, tabName]);
6368

6469
const backButton = (
@@ -86,7 +91,7 @@ export const useCCAWizardFooter = () => {
8691
);
8792
return React.useMemo(
8893
() => [backButton, nextButton],
89-
[fileUploaded, tabName, dataLocation, dispatch],
94+
[fileUploaded, handleContinue, handleBack, tabName, dataLocation, dispatch],
9095
);
9196
};
9297

@@ -198,6 +203,7 @@ const useFileUploadSuccess = () => {
198203
);
199204
dispatch(setAttributes(attributes ?? []));
200205
setUploadStatus(true);
206+
dispatch(setTabName(TabNames.CCA_TABLE_INGESTION));
201207
},
202208
});
203209
},
@@ -215,6 +221,7 @@ export const useHandleLocalFileSubmit = (): [
215221
] => {
216222
const mid = useAppSelector(selectMid);
217223
const pid = useAppSelector(selectPid);
224+
const dispatch = useAppDispatch();
218225
const fileUploadSuccess = useFileUploadSuccess();
219226
const [progress, setProgress] = React.useState<number>(0);
220227
const [progressStatus, setProgressStatus] = React.useState("");
@@ -324,3 +331,61 @@ export const useHandleTableIngestionOnChange = (attributes: Attribute[]) => {
324331
[attributes, dispatch],
325332
);
326333
};
334+
335+
/**
336+
* Hook for dealing with submission to the server of the inputs, outputs, and scale inputs to the server.
337+
* @returns a function for updating inputs and outputs
338+
*/
339+
export const useUploadSelection = () => {
340+
const mid = useAppSelector(selectMid);
341+
const scaleInputs = useAppSelector(selectScaleInputs);
342+
const attributes = useAppSelector(selectAttributes);
343+
const dispatch = useAppDispatch();
344+
return React.useCallback(() => {
345+
const inputs = attributes
346+
.filter((attribute) => attribute["Axis Type"] === "Input")
347+
.map((attribute) => attribute.index);
348+
const outputs = attributes
349+
.filter((attribute) => attribute["Axis Type"] === "Output")
350+
.map((attribute) => attribute.index);
351+
console.log("attributes", attributes);
352+
console.log("inputs", inputs);
353+
console.log("outputs", outputs);
354+
if (inputs.length === 0) {
355+
dialog.dialog({
356+
message: "The number of inputs must be at least one.",
357+
});
358+
} else if (outputs.length === 0) {
359+
dialog.dialog({
360+
message: "The number of outputs must be at least one.",
361+
});
362+
} else {
363+
client.put_model_parameter({
364+
mid: mid,
365+
aid: "input-columns",
366+
value: inputs,
367+
input: true,
368+
success: function () {
369+
client.put_model_parameter({
370+
mid: mid,
371+
aid: "output-columns",
372+
value: outputs,
373+
input: true,
374+
success: function () {
375+
client.put_model_parameter({
376+
mid: mid,
377+
aid: "scale-inputs",
378+
value: scaleInputs,
379+
input: true,
380+
success: function () {
381+
// set the tab
382+
dispatch(setTabName(TabNames.CCA_FINISH_MODEL));
383+
},
384+
});
385+
},
386+
});
387+
},
388+
});
389+
}
390+
}, [mid, attributes, scaleInputs, dispatch]);
391+
};

web-server/plugins/slycat-cca/js/components/wizard-store/reducers/cCAWizardSlice.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export enum TabNames {
55
CCA_DATA_WIZARD_SELECTION_TAB = "CCADataWizardSelectionTab",
66
CCA_LOCAL_BROWSER_TAB = "CCSLocalBrowserTab",
77
CCA_TABLE_INGESTION = "CCATableIngestion",
8+
CCA_FINISH_MODEL= "CCAFinishModel"
89
}
910
export enum dataLocationType {
1011
LOCAL = "local",
@@ -29,6 +30,7 @@ export interface CCAWizardState {
2930
pid: string | undefined;
3031
fileUploaded: boolean;
3132
attributes: Attribute[];
33+
scaleInputs: boolean;
3234
}
3335
const initialState: CCAWizardState = {
3436
tab: TabNames.CCA_DATA_WIZARD_SELECTION_TAB,
@@ -37,6 +39,7 @@ const initialState: CCAWizardState = {
3739
pid: undefined,
3840
fileUploaded: false,
3941
attributes: [],
42+
scaleInputs: false
4043
};
4144
export const cCAWizardSlice = createSlice({
4245
name: "cCAWizard",
@@ -60,6 +63,9 @@ export const cCAWizardSlice = createSlice({
6063
setAttributes: (state, action: PayloadAction<Attribute[]>) => {
6164
state.attributes = action.payload;
6265
},
66+
setScaleInputs: (state, action: PayloadAction<boolean>) => {
67+
state.scaleInputs = action.payload;
68+
},
6369
resetCCAWizard: () => initialState,
6470
},
6571
});
@@ -73,6 +79,7 @@ export const {
7379
resetCCAWizard: resetCCAWizard,
7480
setFileUploaded,
7581
setAttributes,
82+
setScaleInputs
7683
} = cCAWizardSlice.actions;
7784
// Other code such as selectors can use the imported `RootState` type
7885
export const selectTab = (state: RootState) => state.cCAWizard.tab;
@@ -81,5 +88,6 @@ export const selectFileUploaded = (state: RootState) => state.cCAWizard.fileUplo
8188
export const selectPid = (state: RootState) => state.cCAWizard.pid;
8289
export const selectMid = (state: RootState) => state.cCAWizard.mid;
8390
export const selectAttributes = (state: RootState) => state.cCAWizard.attributes;
91+
export const selectScaleInputs = (state: RootState) => state.cCAWizard.scaleInputs;
8492

8593
export default cCAWizardSlice.reducer;

web-server/plugins/slycat-cca/js/components/wizard-tabs/CCATableIngestion.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ export const CCATableIngestion = (props: { hidden?: boolean }) => {
2323
];
2424
return (
2525
<div hidden={hidden}>
26-
test
2726
<SlycatTableIngestion
2827
uniqueID="varOptions"
2928
variables={attributes}

0 commit comments

Comments
 (0)