Skip to content

Commit

Permalink
Replaced SimpleCRUDStore with CRUDStore
Browse files Browse the repository at this point in the history
  • Loading branch information
punith300i committed Nov 15, 2023
1 parent 7743a2a commit a2b294d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
6 changes: 5 additions & 1 deletion www/src/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ export function useStores(): IStore {
export type { Property, DataType } from "./ontology/Property";
export type { SMEdge, SMNode } from "./sm/SMGraph";
export type { Table, TableRow } from "./table";
export type { TransformationResult, Transformation } from "./transformation";
export type {
TransformationResult,
Transformation,
DraftCreateTransformation,
} from "./transformation";
export {
ProjectStore,
TableStore,
Expand Down
15 changes: 12 additions & 3 deletions www/src/models/transformation/TransformationStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,30 @@ export interface Transformation extends Record<number> {
tableId: number;
datapath: string[];
code: string | undefined;
onError: string;
outputpath: string[] | undefined;
}

export interface DraftCreateTransformation extends Transformation {
tolerance: number;
rows: number;
}

export class TransformationStore extends SimpleCRUDStore<
export class TransformationStore extends CRUDStore<
number,
Transformation
Omit<DraftCreateTransformation, "id"> & { draftID: string },
DraftCreateTransformation & {
markSaved(): void;
toModel(): DraftCreateTransformation | undefined;
},
DraftCreateTransformation
> {
constructor() {
super(`${SERVER}/api/transformation`, undefined, false);
}

async testTransformation(
payload: Transformation
payload: DraftCreateTransformation
): Promise<TransformationResult[] | undefined> {
let resp: any = await axios
.post(`${SERVER}/api/transformation/test`, {
Expand Down
5 changes: 3 additions & 2 deletions www/src/pages/table/forms/TransformationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Editor from "@monaco-editor/react";
import {
TransformationResult,
useStores,
Transformation,
DraftCreateTransformation,
Table as TableModel,
} from "../../../models";

Expand Down Expand Up @@ -83,12 +83,13 @@ export const TransformationForm = observer(
];

const onExecute = async () => {
const transformationPayload: Transformation = {
const transformationPayload: DraftCreateTransformation = {
id: -1,
tableId: table.id,
type: form.getFieldValue("type"),
code: form.getFieldValue("code"),
mode: "restrictedpython",
onError: form.getFieldValue("onerror"),
datapath: form.getFieldValue("datapath"),
outputpath: form.getFieldValue("outputpath"),
tolerance: form.getFieldValue("tolerance"),
Expand Down

0 comments on commit a2b294d

Please sign in to comment.