Skip to content

Commit af23d25

Browse files
committed
v0.3.0
1 parent fa93356 commit af23d25

21 files changed

+315
-219
lines changed

CHANGELOG.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
## 0.2.2
2-
- Bug fixes
3-
- Removed animation
1+
## 0.3.0
2+
- Bug fixes, the usual; variable resolution and linked templates
3+
- Much improved handling of multi-level linked templates (links within links)
4+
- New layout modes; tree and grid
5+
- Animation removed in most situations, it was annoying
6+
- Support for multi-line strings (I think!)
7+
48

5-
- ## 0.2.1
9+
## 0.2.1
610
- Bug fixes
711

12+
813
## 0.2.0
914
- Support for loading a parameters file and applying values to the output
1015
- Filter out resources by type, helps de-clutter the view on very busy templates, or when you have many similar resources you want to hide (e.g. NSG rules)
@@ -16,48 +21,58 @@
1621
- Many new icons; automation, SQL Server, blobservices, and more
1722
- A bunch more bugs I expect ;)
1823

24+
1925
## 0.1.1
2026
- Several fixes & improvements to how linked templates are handled and searched for
2127

28+
2229
## 0.1.0
2330
- Support for linked & nested templates! See readme for limitations
2431
- Support for the new vscode-azurearmtools extension language server and 'ARM Template' language type
2532
- displayName tag if present will be used in place of the resource name
2633

34+
2735
## 0.0.9
2836
- Many fixes to parameter & variable resolution
2937
- Improved error messages and logging
3038
- Tested successfully against ALL templates on https://github.com/Azure/azure-quickstart-templates
3139

40+
3241
## 0.0.8
3342
- Parameter & variable values which are objects now resolved
3443
- Parameters defaultValues detected picked up and used
3544
- Display unresolvable properties in italics and inside {}
3645

46+
3747
## 0.0.7
3848
- Many, many new icons added!
3949
- Support for JSON comments, which is allowed by ARM
4050
- Custom default icon for API Management sub-resources
4151

52+
4253
## 0.0.6
4354
- Fix for SKU evaluation error (exp.trim)
4455
- Nicer error messages
45-
56+
57+
4658
## 0.0.5
4759
- Snap to grid added
4860
- Telemetry tracking added
4961
- Fix for handling resource tags
5062
- Added resource SKU details to info box
5163
- Smarter handling of updates when user is editing JSON
5264

65+
5366
## 0.0.4
5467
- Fixed initialization & first display problems
5568
- Added preview icon to top right of editor menu bar
5669
- More robust activation options/filters
5770
- Extension is now a singleton panel
5871

72+
5973
## 0.0.3
6074
- Super minor readme fixes, added this changelog
6175

76+
6277
## 0.0.2
6378
- Initial release. We don't talk about v0.0.1

README.md

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,18 @@ Extension as been tested successfully against all 890+ [Azure Quickstart Templat
2626
- Use keyboard shortcut `Ctrl+Alt+Q`
2727

2828
## Basic Features
29-
- Click on a resource to show popup 'infobox' for that resource
29+
- Click on a resource to show popup 'infobox' for that resource, a selected subset of details will be shown
30+
- Click and drag on background to move and pan the view around
31+
- Zoom in and out with the mouse wheel
32+
- Drag icons around to layout as your wish, one tip is to click 'Re-fit' after moving to get the best view & zoom level
33+
34+
## Toolbar
3035
- Click the 'Labels' toolbar button to toggle labels from resource names to resource types
3136
- Click the 'Re-fit' toolbar button to refit the view to the best zoom level
3237
- Click the 'Snap' toolbar button to toggle snap to grid mode on/off
33-
- Click the 'Layout' toolbar button to re-layout icons in default
38+
- Two auto layout modes are available:
39+
- 'Tree' lays out the nodes in a hierarchical manner, ok for small templates, also the default
40+
- 'Grid' puts the nodes on a grid, better for large templates but will often not make logical sense
3441

3542
## Parameter Files
3643
By default the extension will try to use any `defaultValues` found in the parameters section of the template.
@@ -49,7 +56,7 @@ The extension will attempt to locate and display linked templates, these resourc
4956
- If the resolved linked template URL is externally accessible, it will be downloaded and used.
5057
- If the URL is not accessible, then an attempt is made to load the file locally based on a guess from the filename and parent dir extracted from the URL, e.g. `nested/linked.json`
5158
- If that fails, then the local filesystem of the VS Code workspace will be searched for the file. Some assumptions are made in this search:
52-
- The search will only happen if the linked file has a *different* filename from the main/master template being viewed
59+
- The search will only happen if the linked file has a *different* filename from the main/master template being viewed. Otherwise the search would just find the main template being viewed
5360
- The linked template file should located somewhere under the path of the main template, sub-folders will be searched. If the file resides elsewhere outside this path it will not be located.
5461
- The first matching file will be used
5562
- If linked template URL or filename is dynamic based on template parameters it is very likely not to resolve, and will not be found.
@@ -62,16 +69,15 @@ This is a port of a older *ARM Viewer* project, which was a standalone Node.js w
6269

6370
This project was created as a learning exercise, but was heavily inspired & influenced by the old ARMViz tool. ARMViz sadly seems to have been abandoned, it often has problems displaying some templates. Personally I wasn't a fan of look of the output, and found it hard to read. These are a few of the reasons why I created this project
6471

72+
## ARM Template JSON Support
73+
ARM templates go outside the JSON specification and break it in a couple of areas:
74+
- Support for comments in the JSON file (aka JSONC)
75+
- Allowing the use of multi-line strings
76+
The extension supports both of these as far as is reasonably possible, multi-line strings in particular has no known spec on how it should be supported. The extension is also aware of the language server provided by the 'Azure Resource Manager Tools' extension and will accept files set to 'arm-template' as the language type.
77+
6578

66-
# Limitations & Known Issues
79+
## Limitations & Known Issues
6780
- The code attempts to find the links (`dependsOn` relationships) between ARM resources, however due to the *many* subtle and complex ways these relationships can be defined & expressed, certain links may not be picked up & displayed.
6881
- Icons for the most commonly used & popular resource types have been added, however not every resource is covered (There's simply too many and no canonical source). The default ARM cube icon will be shown as a fallback. Get in touch if you want a icon added for a particular resource type.
6982
- Resolving names & other properties for resources is attempted, but due to programmatic way these are generally defined with ARM functions and expressions, full name resolution is not always possible
7083
- Templates using the loop functions `copy` & `copyIndex` to create multiple resources will not be rendered correctly due to limitations on evaluating the dynamic iterative state of the template
71-
72-
73-
# Running/Debugging Locally
74-
- Clone/fork repo and open project in VS Code 1.25+
75-
- `npm install`
76-
- `npm run watch` or `npm run compile`
77-
- `F5` to start debugging

assets/css/main.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ button {
5656
margin: 2px;
5757
border-radius: 3px;
5858
font-size: 95%;
59-
min-width: 70px;
59+
/* min-width: 70px; */
6060
text-align: center;
6161
}
6262

assets/img/toolbar/cose.svg

Lines changed: 1 addition & 0 deletions
Loading

assets/img/toolbar/grid.svg

Lines changed: 1 addition & 0 deletions
Loading

assets/img/toolbar/tree.svg

Lines changed: 1 addition & 0 deletions
Loading

assets/js/main.js

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ function init(prefix) {
8383
//
8484
function displayData(data) {
8585
console.log("### ArmView: Displaying received data");
86+
//console.dir(JSON.stringify(data, null, 3));
87+
8688
cy.remove('*');
8789
cy.add(data);
8890

@@ -99,7 +101,7 @@ function displayData(data) {
99101
}
100102
}
101103

102-
reLayout();
104+
reLayout('breadthfirst', false);
103105
}
104106

105107
//
@@ -113,20 +115,17 @@ function _addInfo(name, value) {
113115

114116
table = document.getElementById('infotable');
115117

116-
if(value.startsWith('http')) {
117-
table.insertAdjacentHTML('beforeend', `<tr><td>${_utilTitleCase(name)}</td><td><a href='/view?url=${encodeURIComponent(value)}' target='_blank'>${value}</a></td></tr>`)
118-
} else {
119-
let valClass = '';
120-
if(value.startsWith('{') && value.endsWith('}'))
121-
valClass = 'italic';
122-
table.insertAdjacentHTML('beforeend', `<tr><td>${_utilTitleCase(name)}</td><td class='${valClass}'>${value}</td></tr>`);
123-
}
118+
let valClass = '';
119+
if(value.startsWith('{') && value.endsWith('}'))
120+
valClass = 'italic';
121+
122+
table.insertAdjacentHTML('beforeend', `<tr><td>${_utilTitleCase(name)}</td><td class='${valClass}'>${value}</td></tr>`);
124123
}
125124

126125
//
127126
// Layout the view of nodes given current data
128127
//
129-
function reLayout() {
128+
function reLayout(mode, animate) {
130129
// Set colors in keeping with VS code theme (might be dark or light)
131130
let bgColor = window.getComputedStyle(document.getElementsByTagName('body')[0]).getPropertyValue('background-color');
132131
let textColor = '#eeeeee';
@@ -180,7 +179,7 @@ function reLayout() {
180179
// Bounding box for groups
181180
cy.style().selector(':parent').style({
182181
'background-image': null,
183-
'label': node => { return decodeURIComponent(node.data(labelField)) },
182+
'label': node => { return getLabel(node) }, //decodeURIComponent(node.data(labelField)) },
184183
'border-width': '4',
185184
'border-color': '#000',
186185
'border-opacity': 0.5,
@@ -204,14 +203,24 @@ function reLayout() {
204203
else
205204
cy.snapToGrid('snapOff');
206205

207-
// Re-layout nodes in breadthfirst mode, resizing and fitting too
206+
// Re-layout nodes in given mode, resizing and fitting too
208207
cy.style().update()
209208
cy.resize();
209+
210+
if(!mode) mode = 'breadthfirst'
211+
if(!animate) animate = false
212+
let spacing = 1.5
213+
if(mode == 'grid')
214+
spacing = 1.75
215+
210216
cy.layout({
211-
name: 'breadthfirst',
212-
nodeDimensionsIncludeLabels: false
213-
//animate: true
217+
avoidOverlap: true,
218+
name: mode,
219+
nodeDimensionsIncludeLabels: false,
220+
spacingFactor: spacing,
221+
animate: animate
214222
}).run();
223+
215224
cy.fit();
216225
}
217226

@@ -221,7 +230,7 @@ function reLayout() {
221230
function toggleLabels() {
222231
labelField = labelField == 'label' ? 'name' : 'label'
223232
cy.style().selector('node').style({
224-
'label': node => { return decodeURIComponent(node.data(labelField)) },
233+
'label': node => { return getLabel(node) } //decodeURIComponent(node.data(labelField)) },
225234
}).update();
226235
}
227236

@@ -356,14 +365,10 @@ function sendMessage(msg) {
356365
//
357366
// Get label for resource
358367
//
359-
// function getLabel(node) {
360-
// // Special case - if resource has displayName tag
361-
// if(labelField == 'name') {
362-
// for(let extraField in node.data('extra')) {
363-
// if(extraField.toLowerCase() == 'tag displayname') {
364-
// return decodeURIComponent(node.data('extra')['tag displayname']);
365-
// }
366-
// }
367-
// }
368-
// return decodeURIComponent(node.data(labelField));
369-
// }
368+
function getLabel(node) {
369+
let label = decodeURIComponent(node.data(labelField));
370+
if(label.length > 24) {
371+
label = label.substr(0, 24) + "…"
372+
}
373+
return label;
374+
}

package-lock.json

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

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "armview",
33
"displayName": "ARM Template Viewer",
44
"description": "Graphically display ARM templates in an interactive map view",
5-
"version": "0.2.2",
5+
"version": "0.3.0",
66
"icon": "assets/img/icons/main.png",
77
"publisher": "bencoleman",
88
"author": {
@@ -90,7 +90,6 @@
9090
},
9191
"dependencies": {
9292
"axios": "^0.19.0",
93-
"jsonc-parser": "^2.1.1",
9493
"jsonlint": "^1.6.3",
9594
"strip-bom": "^3.0.0",
9695
"strip-json-comments": "^3.0.1",
@@ -104,7 +103,6 @@
104103
"chai-subset": "^1.6.0",
105104
"jsonlint": "^1.6.3",
106105
"mocha": "^6.2.0",
107-
"strip-bom": "^3.0.0",
108106
"ts-loader": "^6.1.2",
109107
"tslint": "^5.16.0",
110108
"typescript": "^3.5.1"

src/extension.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,10 @@ function getWebviewContent() {
263263
<button onclick="toggleLabels()"><img src="${assetsPath}/img/toolbar/labels.svg">&nbsp; Labels</button>
264264
<button onclick="cy.fit()"><img src="${assetsPath}/img/toolbar/fit.svg">&nbsp; Re-fit</button>
265265
<button onclick="toggleSnap()" id="snapbut"><img src="${assetsPath}/img/toolbar/snap.svg">&nbsp; Snap</button>
266-
<button onclick="reLayout()"><img src="${assetsPath}/img/toolbar/layout.svg">&nbsp; Layout</button>
266+
Layout:
267+
<button onclick="reLayout('breadthfirst', true)"><img src="${assetsPath}/img/toolbar/tree.svg"></button>
268+
<button onclick="reLayout('grid', true)"><img src="${assetsPath}/img/toolbar/grid.svg"></button>
269+
<!--button onclick="reLayout('cose', true)"><img src="${assetsPath}/img/toolbar/cose.svg"></button-->
267270
&nbsp;&nbsp;
268271
<button onclick="sendMessage('paramsClicked')"><img src="${assetsPath}/img/toolbar/params.svg">&nbsp; Params</button>
269272
<button onclick="sendMessage('filtersClicked')"><img src="${assetsPath}/img/toolbar/filter.svg">&nbsp; Filter</button>

0 commit comments

Comments
 (0)