Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Users/echong/readme #125

Merged
merged 6 commits into from
Feb 25, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,52 @@ There are three ways of creating a template.
![Image of default template](https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/_assets/SavedList.png)

6. Modify report as you wish and click "Advanced Editor" button from the menu. Copy all contents and create a file like "your custom template name.template". Please make sure file name ends with '.workbook'.

## How to associate any existing template to new category in Workbooks
ericc1103 marked this conversation as resolved.
Show resolved Hide resolved
We are now supporting associating any exiting templates to new category (virtual category). Previously, a category is always associated with templates by a folder structure but this requires to create physical folder structure which requires copying existing templates. This would introduce a lot of maintain overhead of updating duplicated templates.
ericc1103 marked this conversation as resolved.
Show resolved Hide resolved
ericc1103 marked this conversation as resolved.
Show resolved Hide resolved

First, to associate the existing template, we need to create a virtual category first.
1. Go to Workbooks folder and locate "resourceCategory.json" file.
2. Add new category entry under categories array as below:
```
{
"categories": [{
"key": "YourUniqueCategoryKey",
"settings": {
"en-us": {
"name": "Your category name",
"description": "Category description",
"order": 100
}
}
}]
}
```
* key: This should be unique key value. This will be used in a template to link together.
* settings:
* name: This is a name of category. This will be localized.
* description: A description of this category.
* order: The sort order of category.
3. Now we need to modify template settings to associate it together.
4. Go to your template and open settings.json file
```
{
"$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/settings.json",
"name": "Bracket Retention",
"author": "Microsoft",
"galleries": [
{
"type": "workbook",
"resourceType": "microsoft.insights/components",
"order": 400
},
{
"type": "workbook",
"resourceType": "Azure Monitor",
ericc1103 marked this conversation as resolved.
Show resolved Hide resolved
"categoryKey": "YourUniqueCategoryKey"
"order": 400
}
]
}
```
**Note that the second item in the galleries array, it has a "categoryKey". It should be match with a "key" in a virtual category.**
13 changes: 13 additions & 0 deletions Workbooks/categoryResources.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"categories": [{
"key": "YourUniqueCategoryKey",
ericc1103 marked this conversation as resolved.
Show resolved Hide resolved
"settings": {
"en-us": {
"name": "Your category name",
"description": "Category description",
"order": 100
}
}
}
]
}
20 changes: 12 additions & 8 deletions test/jsonValidationTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ describe('Validating Cohorts...', () => {
});

describe('Validating Workbooks...', () => {
ericc1103 marked this conversation as resolved.
Show resolved Hide resolved
const cohortPath = './Workbooks';
const workbookPath = './Workbooks';

it('Verifying .workbook files', function (done) {
let failedList = [];
browseDirectory(cohortPath, (error, results) => {
browseDirectory(workbookPath, (error, results) => {
results.filter(file => file.substr(-9) === '.workbook')
.forEach(file => {
validateJsonStringAndGetObject(file)
Expand All @@ -60,7 +60,7 @@ describe('Validating Workbooks...', () => {
});

it('Verifying workbook settings.json files', function (done) {
browseDirectory(cohortPath, (error, results) => {
browseDirectory(workbookPath, (error, results) => {
if (error) throw error;
results.filter(file => file.substr(-13) === 'settings.json')
.forEach(file => {
Expand All @@ -73,7 +73,7 @@ describe('Validating Workbooks...', () => {
});

it('Verifying workbook category json files', function (done) {
browseDirectory(cohortPath, (error, results) => {
browseDirectory(workbookPath, (error, results) => {
if (error) throw error;
results.filter(file => file.substr(-22) === 'categoryResources.json')
.forEach(file => {
Expand All @@ -82,11 +82,11 @@ describe('Validating Workbooks...', () => {
});

done();
});
}, true, workbookPath);
});
});

var browseDirectory = function (dir, done) {
var browseDirectory = function (dir, done, hasRoot=false, rootDir="") {
var results = [];
fs.readdir(dir, function (err, list) {
if (err) return done(err);
Expand All @@ -102,8 +102,12 @@ var browseDirectory = function (dir, done) {
next();
});
} else {
results.push(file);
next();
if (hasRoot && dir === rootDir) {
next();
} else {
results.push(file);
next();
}
}
});
})();
Expand Down