Skip to content

Commit 7bde842

Browse files
committed
added model creation step to local model creation path
1 parent 00b5986 commit 7bde842

File tree

2 files changed

+38
-7
lines changed

2 files changed

+38
-7
lines changed

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

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@
44
import * as React from "react";
55
import { useAppDispatch, useAppSelector } from "./wizard-store/hooks";
66
import { produce } from "immer";
7+
import server_root from "js/slycat-server-root";
78
import {
89
Attribute,
910
resetCCAWizard,
1011
selectAttributes,
1112
selectDataLocation,
13+
selectDescription,
1214
selectFileUploaded,
15+
selectMarking,
1316
selectMid,
17+
selectName,
1418
selectPid,
1519
selectScaleInputs,
1620
selectTab,
@@ -35,6 +39,7 @@ export const useCCAWizardFooter = () => {
3539
const fileUploaded = useAppSelector(selectFileUploaded);
3640
const dispatch = useAppDispatch();
3741
const uploadSelection = useUploadSelection();
42+
const finishModel = useFinishModel();
3843

3944
/**
4045
* handle continue operation
@@ -49,6 +54,9 @@ export const useCCAWizardFooter = () => {
4954
if (tabName === TabNames.CCA_TABLE_INGESTION) {
5055
uploadSelection();
5156
}
57+
if (tabName === TabNames.CCA_FINISH_MODEL) {
58+
finishModel();
59+
}
5260
}, [dispatch, uploadSelection, fileUploaded, setTabName, tabName]);
5361

5462
/**
@@ -145,7 +153,6 @@ export const useHandleClosingCallback = (
145153
return React.useCallback(() => {
146154
setModalOpen(false);
147155
if (stateMid) {
148-
console.log("delete");
149156
client.delete_model_fetch({ mid: stateMid });
150157
}
151158
dispatch(resetCCAWizard());
@@ -250,7 +257,6 @@ export const useHandleLocalFileSubmit = (): [
250257
progress_status: progressStatusCallback,
251258
progress_final: 90,
252259
success: function () {
253-
console.log("uploaded");
254260
setProgress(100);
255261
setProgressStatus("File upload complete");
256262
setUploadStatus(true);
@@ -291,7 +297,6 @@ export const useSetUploadStatus = () => {
291297
const dispatch = useAppDispatch();
292298
return React.useCallback(
293299
(status: boolean) => {
294-
console.log("dispatching", status);
295300
dispatch(setFileUploaded(status));
296301
},
297302
[dispatch],
@@ -332,6 +337,36 @@ export const useHandleTableIngestionOnChange = (attributes: Attribute[]) => {
332337
);
333338
};
334339

340+
/**
341+
* Hook for dealing with submission to the server of the final model values such as name and description
342+
* @returns a function for finalizing the cca model
343+
*/
344+
export const useFinishModel = () => {
345+
const mid = useAppSelector(selectMid);
346+
const description = useAppSelector(selectDescription);
347+
const name = useAppSelector(selectName);
348+
const marking = useAppSelector(selectMarking);
349+
return React.useCallback(() => {
350+
// update the final model meta data and trigger the post model finish script
351+
client.put_model({
352+
mid: mid,
353+
name: name,
354+
description: description,
355+
marking: marking,
356+
success: () => {
357+
client.post_model_finish({
358+
mid: mid,
359+
success: () => {
360+
location.href = server_root + "models/" + mid;
361+
},
362+
});
363+
},
364+
// throw up a dialog if we get into an error state
365+
error: dialog.ajax_error("Error updating model."),
366+
});
367+
}, [mid, name, description, marking, server_root]);
368+
};
369+
335370
/**
336371
* Hook for dealing with submission to the server of the inputs, outputs, and scale inputs to the server.
337372
* @returns a function for updating inputs and outputs
@@ -348,9 +383,6 @@ export const useUploadSelection = () => {
348383
const outputs = attributes
349384
.filter((attribute) => attribute["Axis Type"] === "Output")
350385
.map((attribute) => attribute.index);
351-
console.log("attributes", attributes);
352-
console.log("inputs", inputs);
353-
console.log("outputs", outputs);
354386
if (inputs.length === 0) {
355387
dialog.dialog({
356388
message: "The number of inputs must be at least one.",

web-server/plugins/slycat-cca/js/components/slycat-parser-controls/SlycatParserControls.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ export const SlycatParserControls = (props: {
1515
?.filter((parser: { categories: () => string }) => includes(parser.categories(), "table"));
1616
React.useEffect(() => {
1717
if (filteredParsers !== undefined && filteredParsers.length > 0) {
18-
console.log("reset", filteredParsers[0].type());
1918
setParser(filteredParsers[0].type());
2019
}
2120
}, [filteredParsers.length]);

0 commit comments

Comments
 (0)