Skip to content

Commit

Permalink
pass template name to layout server
Browse files Browse the repository at this point in the history
  • Loading branch information
nk-coding committed Oct 27, 2024
1 parent 8b9ff1d commit 35c3ee1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
10 changes: 7 additions & 3 deletions .vitepress/util/parseModel.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import { ComponentVersion, Graph, Relation } from "@gropius/graph-editor";
import { Graph } from "@gropius/graph-editor";
import { parse } from "yaml";
import { Model } from "./model";
import { componentStyles, interfaceStyles, relationStyles } from "./styles";

export function parseModel(model: string): Graph {
const parsedModel = parse(model) as Model;
const components: ComponentVersion[] = [];
const relations: Relation[] = [];
const components = [];
const relations = [];
let relationIdCounter = 0;
for (const [key, component] of Object.entries(parsedModel)) {
components.push({
id: key,
name: component?.name ?? key,
style: componentStyles[component?.template ?? "Misc"] ?? componentStyles.Misc,
template: component?.template ?? "Misc",
issueTypes: [],
contextMenu: "",
interfaces: Object.entries(component?.interfaces ?? {}).map(
Expand All @@ -24,13 +25,15 @@ export function parseModel(model: string): Graph {
start: key,
end: relation.to,
style: relationStyles[relation.template ?? "General"] ?? relationStyles.General,
template: relation.template ?? "General",
contextMenu: "",
}))
);
return {
id: key,
name: iface?.name,
style: interfaceStyles[iface?.template ?? "REST"] ?? interfaceStyles.REST,
template: iface?.template ?? "REST",
issueTypes: [],
contextMenu: "",
};
Expand All @@ -44,6 +47,7 @@ export function parseModel(model: string): Graph {
start: key,
end: relation.to,
style: relationStyles[relation.template ?? "General"] ?? relationStyles.General,
template: relation.template ?? "General",
contextMenu: "",
}))
);
Expand Down
3 changes: 3 additions & 0 deletions docs/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,22 @@ interface Graph {
interface ComponentVersion extends Node {
name: string;
style: ShapeStyle;
template: string;
interfaces: Interface[];
}

interface Interface extends Node {
name: string;
style: ShapeStyle;
template: string;
};

interface Relation extends Node {
name: string;
start: string;
end: string;
style: RelationStyle;
template: string;
}

interface Node {
Expand Down

0 comments on commit 35c3ee1

Please sign in to comment.