Skip to content
Snippets Groups Projects
Commit 11bb0ba4 authored by Behrisch, M. (Michael)'s avatar Behrisch, M. (Michael)
Browse files

fix(vis-schema): catching up with develop

parent 1615de14
No related branches found
No related tags found
1 merge request!13merge develop into main
...@@ -3,7 +3,6 @@ import { ...@@ -3,7 +3,6 @@ import {
SchemaFromBackend, SchemaFromBackend,
schemaSlice, schemaSlice,
setSchema, setSchema,
store,
} from '@graphpolaris/shared/data-access/store'; } from '@graphpolaris/shared/data-access/store';
import { import {
movieSchema, movieSchema,
...@@ -44,6 +43,111 @@ const Mockstore = configureStore({ ...@@ -44,6 +43,111 @@ const Mockstore = configureStore({
export const TestWithSchema = Template.bind({}); export const TestWithSchema = Template.bind({});
TestWithSchema.play = async () => { TestWithSchema.play = async () => {
const parsed = parseSchemaFromBackend(twitterSchema as SchemaFromBackend); const dispatch = Mockstore.dispatch;
Mockstore.dispatch(setSchema(parsed.export()));
const schema = SchemaUtils.ParseSchemaFromBackend({
nodes: [
{
name: 'Thijs',
attributes: [],
},
{
name: 'Airport',
attributes: [
{ name: 'city', type: 'string' },
{ name: 'vip', type: 'bool' },
{ name: 'state', type: 'string' },
],
},
{
name: 'Airport2',
attributes: [
{ name: 'city', type: 'string' },
{ name: 'vip', type: 'bool' },
{ name: 'state', type: 'string' },
],
},
{
name: 'Plane',
attributes: [
{ name: 'type', type: 'string' },
{ name: 'maxFuelCapacity', type: 'int' },
],
},
{ name: 'Staff', attributes: [] },
],
edges: [
{
name: 'Airport2:Airport',
from: 'Airport2',
to: 'Airport',
collection: 'flights',
attributes: [
{ name: 'arrivalTime', type: 'int' },
{ name: 'departureTime', type: 'int' },
],
},
{
name: 'Airport:Staff',
from: 'Airport',
to: 'Staff',
collection: 'flights',
attributes: [{ name: 'salary', type: 'int' }],
},
{
name: 'Plane:Airport',
from: 'Plane',
to: 'Airport',
collection: 'flights',
attributes: [],
},
{
name: 'Airport:Thijs',
from: 'Airport',
to: 'Thijs',
collection: 'flights',
attributes: [{ name: 'hallo', type: 'string' }],
},
{
name: 'Thijs:Airport',
from: 'Thijs',
to: 'Airport',
collection: 'flights',
attributes: [{ name: 'hallo', type: 'string' }],
},
{
name: 'Staff:Plane',
from: 'Staff',
to: 'Plane',
collection: 'flights',
attributes: [{ name: 'hallo', type: 'string' }],
},
{
name: 'Staff:Airport2',
from: 'Staff',
to: 'Airport2',
collection: 'flights',
attributes: [{ name: 'hallo', type: 'string' }],
},
{
name: 'Airport2:Plane',
from: 'Airport2',
to: 'Plane',
collection: 'flights',
attributes: [{ name: 'hallo', type: 'string' }],
},
{
name: 'Airport:Airport',
from: 'Airport',
to: 'Airport',
collection: 'flights',
attributes: [{ name: 'test', type: 'string' }],
},
],
});
console.info('dispatch dummy schema', schema.order);
dispatch(setSchema(schema.export()));
// handleSchemaLayout(schema);
}; };
import { createReactFlowElements } from '@graphpolaris/schema/schema-usecases'; import { AllLayoutAlgorithms, LayoutFactory } from '@graphpolaris/graph-layout';
import { createReactFlowElements } from '@graphpolaris/schema/usecases';
import { import {
useSchema, useSchema,
useSchemaLayout, useSchemaLayout,
} from '@graphpolaris/shared/data-access/store'; } from '@graphpolaris/shared/data-access/store';
import { import { MultiGraph } from 'graphology';
AllLayoutAlgorithms, // import { AllLayoutAlgorithms, LayoutFactory } from '@graphpolaris/graph-layout';
LayoutFactory,
} from '@graphpolaris/shared/graph-layout';
import { Attributes } from 'graphology-types';
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import ReactFlow, { import ReactFlow, {
Node, Node,
...@@ -32,9 +30,15 @@ const Schema = (props: Props) => { ...@@ -32,9 +30,15 @@ const Schema = (props: Props) => {
const schemaLayout = useSchemaLayout(); const schemaLayout = useSchemaLayout();
useEffect(() => { useEffect(() => {
const layoutFactory = new LayoutFactory(); console.log('dbSchema', dbschema, dbschema.order);
}, [dbschema]);
// console.log('schema Layout', schemaLayout); useEffect(() => {
if (dbschema == undefined || dbschema.order == 0) {
return;
}
const layoutFactory = new LayoutFactory();
console.log('schema Layout', schemaLayout, 'order', dbschema.order);
const layout = layoutFactory.createLayout( const layout = layoutFactory.createLayout(
// schemaLayout as AllLayoutAlgorithms // schemaLayout as AllLayoutAlgorithms
'Graphology_noverlap' 'Graphology_noverlap'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment