Skip to content

Commit 1e006e4

Browse files
committed
Bugfix: GraphDirection is now saved correctly when saving as Dgml.
1 parent 49a03a5 commit 1e006e4

File tree

5 files changed

+35
-7
lines changed

5 files changed

+35
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
## Version 1.7.3
4+
5+
- Bugfix: GraphDirection is now saved correctly when saving as Dgml.
6+
37
## Version 1.7.2
48

59
- Added missing xml prolog to generated dgml file.

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"displayName": "AngularTools",
55
"description": "AngularTools is a collection of tools for exploring an Angular project, help you with documenting, reverse engineering a project or help when refactoring.",
66
"icon": "logo.png",
7-
"version": "1.7.2",
7+
"version": "1.7.3",
88
"license": "MIT",
99
"repository": "https://github.com/CoderAllan/vscode-angulartools",
1010
"author": {
@@ -410,8 +410,8 @@
410410
"@types/mocha": "^8.2.2",
411411
"@types/node": "^14.14.37",
412412
"@types/vscode": "^1.55.0",
413-
"@typescript-eslint/parser": "^4.21.0",
414413
"@typescript-eslint/eslint-plugin": "^4.21.0",
414+
"@typescript-eslint/parser": "^4.21.0",
415415
"eslint": "^7.23.0",
416416
"glob": "^7.1.6",
417417
"mocha": "^8.3.2",

src/commands/showHierarchyBase.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export class ShowHierarchyBase extends CommandBase {
7474
const direction = message.direction;
7575
const domImpl = new xmldom.DOMImplementation();
7676
const dgmlManager = new DgmlManager();
77-
const xmlDocument = dgmlManager.createNewDirectedGraph(domImpl, direction, "", "-1");
77+
const xmlDocument = dgmlManager.createNewDirectedGraph(domImpl, this.fixGraphDirection(direction), "Sugiyama", "-1");
7878
dgmlManager.addNodesAndLinks(xmlDocument, this.nodes, message.nodes, this.edges);
7979
// Serialize the xml into a string
8080
const xmlAsString = xmlSerializer.serializeToString(xmlDocument.documentElement);
@@ -89,6 +89,28 @@ export class ShowHierarchyBase extends CommandBase {
8989
});
9090
}
9191

92+
private fixGraphDirection(direction: string): string {
93+
let fixedDirection: string;
94+
switch (direction) {
95+
case 'UD':
96+
fixedDirection = 'TopToBottom';
97+
break;
98+
case 'DU':
99+
fixedDirection = 'BottomToTop';
100+
break;
101+
case 'LR':
102+
fixedDirection = 'LeftToRight';
103+
break;
104+
case 'RL':
105+
fixedDirection = 'RightToLeft';
106+
break;
107+
default:
108+
fixedDirection = '';
109+
break;
110+
}
111+
return fixedDirection;
112+
}
113+
92114
protected generateHtmlContent(webview: vscode.Webview, outputJsFilename: string): string {
93115
let htmlContent = fs.readFileSync(this.extensionContext?.asAbsolutePath(path.join('templates', this.templateHtmlFilename)), 'utf8');
94116

src/dgmlManager.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ export class DgmlManager {
55
public createNewDirectedGraph(domImpl: DOMImplementation, direction: string, layout: string, zoomLevel: string) {
66
let xmlDoc: Document = domImpl.createDocument('', null, null);
77
const root = xmlDoc.createElement("DirectedGraph");
8-
root.setAttribute("GraphDirection", direction);
8+
if (direction.length > 0) {
9+
root.setAttribute("GraphDirection", direction);
10+
}
911
root.setAttribute("Layout", layout);
1012
root.setAttribute("ZoomLevel", zoomLevel);
1113
root.setAttribute("xmlns", "http://schemas.microsoft.com/vs/2009/dgml");

0 commit comments

Comments
 (0)