11
22import type { DiagramAnalysisProps } from "../../analysis" ;
33import type { GraphLayoutConfig } from "../../visualization" ;
4- import { GraphVisualization } from "./graph_visualization" ;
5- import { diagramToGraphviz } from "./diagram_graph" ;
4+ // import { GraphVisualization } from "./graph_visualization";
5+ // import { diagramToGraphviz } from "./diagram_graph";
6+ import { createResource , Switch , Match } from "solid-js" ;
7+
68import axios from 'axios' ;
79
810const config = {
@@ -27,34 +29,32 @@ export default function TabularView(
2729 title ?: string ;
2830 } ,
2931) {
30- const graph = ( ) => {
31- const theory = props . liveDiagram . liveModel . theory ( ) ;
32- const model = props . liveDiagram . liveModel . elaboratedModel ( ) ;
33- const diagram = props . liveDiagram . elaboratedDiagram ( ) ;
34- if ( theory && model && diagram ) {
35- return diagramToGraphviz ( diagram , model , theory ) ;
36- }
37- } ;
38-
39- // const call = async (data: string) => {return await ;}
40-
41- const res = ( ) => {
42- const model = props . liveDiagram . liveModel . elaboratedModel ( ) ;
43- const diagram = props . liveDiagram . elaboratedDiagram ( ) ;
44- const data = axios . post ( "http://127.0.0.1:8080/acsetcolim" , {
45- model :model ?. presentation ( ) , diagram :diagram ?. presentation ( )
46- } , config ) ;
47- return data . then ( res => {
48- console . log ( res ) ; // getting a value
49- return res } ) ;
50- }
5132
33+ const [ res ] = createResource (
34+ ( ) => {
35+ const model = props . liveDiagram . liveModel . elaboratedModel ( ) ;
36+ const diagram = props . liveDiagram . elaboratedDiagram ( ) ;
37+ return model && diagram && [ model , diagram ] ;
38+ } ,
39+ async ( [ model , diagram ] ) => {
40+ const response = await axios . post ( "http://127.0.0.1:8080/acsetcolim" , {
41+ model : model ?. presentation ( ) , diagram : diagram ?. presentation ( )
42+ } , config ) ;
43+ // console.log(response.data);
44+ return response . data ;
45+ }
46+ ) ;
5247 return (
53- < GraphVisualization
54- title = { "TABULAR VIEW: " + res ( ) }
55- graph = { graph ( ) }
56- config = { props . content }
57- changeConfig = { props . changeContent }
58- />
48+ < Switch >
49+ < Match when = { res . loading } >
50+ < div > ⏳ Loading model...</ div >
51+ </ Match >
52+ < Match when = { res . error } >
53+ < div > ❌ Error loading model: { res . error ?. message || "Unknown error" } </ div >
54+ </ Match >
55+ < Match when = { res ( ) } >
56+ { ( res ) => < div > Tabular Instance: { JSON . stringify ( res ( ) ) } </ div > }
57+ </ Match >
58+ </ Switch >
5959 ) ;
6060}
0 commit comments