Skip to content

Commit

Permalink
Fixed PR reviews, added transformation store
Browse files Browse the repository at this point in the history
  • Loading branch information
punith300i committed Oct 26, 2023
1 parent d741df1 commit 9edaa3e
Show file tree
Hide file tree
Showing 10 changed files with 13,613 additions and 295 deletions.
2 changes: 1 addition & 1 deletion www/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@fortawesome/free-solid-svg-icons": "^6.0.0",
"@fortawesome/react-fontawesome": "^0.1.17",
"@material-ui/styles": "^4.11.4",
"@monaco-editor/react": "^4.4.6",
"@monaco-editor/react": "4.4.6",
"@mui/icons-material": "^5.0.5",
"@mui/material": "^5.0.6",
"@testing-library/jest-dom": "^5.11.4",
Expand Down
3 changes: 2 additions & 1 deletion www/src/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ export function useStores(): IStore {

export type { Property, DataType } from "./ontology/Property";
export type { SMEdge, SMNode } from "./sm/SMGraph";
export type { Table, TransformTable, TableRow } from "./table";
export type { Table, TableRow } from "./table";
export type {TransformationTable} from "./transformationTable";
export {
ProjectStore,
TableStore,
Expand Down
7 changes: 0 additions & 7 deletions www/src/models/table/Table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ export interface Table extends Record<number> {
contextHierarchy: ContentHierarchy[];
}

export interface TransformTable extends Record<number> {
path: number;
value: string;
ok: string;
error: string;
}

export class TableRow implements Record<number> {
id: number;
table: number;
Expand Down
27 changes: 27 additions & 0 deletions www/src/models/transformationTable/TransformationStore.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { RStore } from "gena-app";
import { SERVER } from "../../env";
import {TransformationTable} from "./TransformationTable";
import axios from "axios";


export class TPayload {
public type?: string;
public mode?: string;
public datapath?: string[];
public code?: string | undefined;
public outputpath?: string[] | undefined;
public tolerance?: number;
public rows?: number;
}

const filterErrorMessage = (errorMessage: string) => {
return errorMessage.split(':').splice(1).join(':').trim();
}

export async function postData(id : number, payload: TPayload) : Promise<TransformationTable[]|undefined> {
let resp: any = await axios
.post(`${SERVER}/api/transform/1/transformations`, payload)
.then((res) => res.data)
.catch((error) => filterErrorMessage(error.response.data.message));
return resp;
};
8 changes: 8 additions & 0 deletions www/src/models/transformationTable/TransformationTable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Record } from "gena-app";

export interface TransformationTable extends Record<number> {
path: number;
value: string;
ok: string;
error: string;
}
3 changes: 3 additions & 0 deletions www/src/models/transformationTable/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from "./TransformationStore";
export * from "./TransformationTable"

10 changes: 5 additions & 5 deletions www/src/pages/table/MenuBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export const MenuBar = observer(
}

const sm = semanticmodel.sms[semanticmodel.index];

const tableId = routes.table.useURLParams()!.tableId;
const funcs = {
saveModel: () => {
if (SemanticModel.isDraft(sm)) {
Expand Down Expand Up @@ -120,7 +120,7 @@ export const MenuBar = observer(
openForm({ type: "node", sm });
},
openAddEdgeForm: () => openForm({ type: "edge", sm }),
openTransformFrom: () => openForm({type: "transform"}),
openTransformationFrom: () => openForm({type: "transformation", tableId: tableId}),
predict: () => {
assistantService.predict(table).then(() => {
tableRef.current?.reload();
Expand Down Expand Up @@ -262,15 +262,15 @@ export const MenuBar = observer(
<Button size="small" onClick={graphRef.current?.recenter}>
Center graph (C)
</Button>
<Button size="small" onClick={funcs.openTransformationFrom}>
Add Transformation
</Button>
<Button size="small" onClick={funcs.openAddNodeForm}>
Add node
</Button>
<Button size="small" onClick={funcs.openAddEdgeForm}>
Add edge
</Button>
<Button size="small" onClick={funcs.openTransformFrom}>
Transform
</Button>
<Button size="small" onClick={funcs.predict}>
Predict
</Button>
Expand Down
Loading

0 comments on commit 9edaa3e

Please sign in to comment.