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

fix(vis-schema): :bug: regression fix for unmerged files

somehow the merge from feat/schema-refactor did get a regression.
parent 7654d108
No related branches found
No related tags found
1 merge request!13merge develop into main
......@@ -2,6 +2,7 @@ import { SchemaUtils } from '@graphpolaris/schema-utils';
import {
colorPaletteConfigSlice,
schemaSlice,
setSchema,
store,
} from '@graphpolaris/shared/data-access/store';
import { GraphPolarisThemeProvider } from '@graphpolaris/shared/data-access/theme';
......@@ -144,6 +145,7 @@ TestWithSchema.play = async () => {
],
});
//dispatch(setSchema(schema));
console.info('dispatch dummy schema', schema.order);
dispatch(setSchema(schema.export()));
// handleSchemaLayout(schema);
};
......@@ -3,7 +3,7 @@ import {
useSchema,
useSchemaLayout,
} from '@graphpolaris/shared/data-access/store';
import { LayoutFactory } from '@graphpolaris/graph-layout';
import { AllLayoutAlgorithms, LayoutFactory } from '@graphpolaris/graph-layout';
import { useEffect, useState } from 'react';
import ReactFlow, { FlowElement, ReactFlowProvider } from 'react-flow-renderer';
......@@ -19,22 +19,26 @@ const Schema = (props: Props) => {
const [elements, setElements] = useState([] as FlowElement[]);
// In case the schema is updated
const dbschema = useSchema();
const schemaLayout = useSchemaLayout();
// const [dbschema, setSchema] = useState(useSchema());
const [schemaLayout, setSchemaLayout] = useState(useSchemaLayout());
useEffect(() => {
if (dbschema == undefined || dbschema.order == 0) {
return;
}
const layoutFactory = new LayoutFactory();
// console.log('schema Layout', schemaLayout);
console.log('schema Layout', schemaLayout, 'order', dbschema.order);
const layout = layoutFactory.createLayout(
// schemaLayout as AllLayoutAlgorithms
'Graphology_noverlap'
schemaLayout as AllLayoutAlgorithms
// schemaLayout
);
layout?.layout(dbschema);
// dbschema.forEachNode((node, attr) => {
// console.log('x', dbschema.getNodeAttribute(node, 'x'));
// console.log('y', dbschema.getNodeAttribute(node, 'y'));
// });
dbschema.forEachNode((node, attr) => {
console.log('x', dbschema.getNodeAttribute(node, 'x'));
console.log('y', dbschema.getNodeAttribute(node, 'y'));
});
const flowElements = createReactFlowElements(dbschema);
setElements(flowElements);
......
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
import Graph, { MultiGraph } from 'graphology';
import { SerializedGraph } from 'graphology-types';
import { SchemaFromBackend } from 'libs/shared/models/src';
import type { RootState } from './store';
......@@ -16,10 +17,9 @@ export const schemaSlice = createSlice({
// `createSlice` will infer the state type from the `initialState` argument
initialState,
reducers: {
setSchema: (state, action: PayloadAction<Graph>) => {
setSchema: (state, action: PayloadAction<SerializedGraph>) => {
console.log('setSchema', action);
state.graphologySerialized = action.payload.export();
state.graphologySerialized = action.payload;
},
setSchemaLayout: (state, action: PayloadAction<string>) => {
......
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