Added custom_icons attribute to autogenerated TOSCA for dashboards
Change-Id: I277eebc1913f71eeef798cee661d5fbe4d9fd544
diff --git a/views/ngXosLib/generator-xos/app/templates/gulp/build.js b/views/ngXosLib/generator-xos/app/templates/gulp/build.js
index f916212..6eb20af 100644
--- a/views/ngXosLib/generator-xos/app/templates/gulp/build.js
+++ b/views/ngXosLib/generator-xos/app/templates/gulp/build.js
@@ -28,6 +28,7 @@
var csswring = require('csswring');
var yaml = require('js-yaml');
var colors = require('colors/safe');
+var fs = require('fs');
const TEMPLATE_FOOTER = `
angular.module('xos.<%= name %>')
@@ -76,7 +77,7 @@
// copy images in correct folder
gulp.task('copyImages', ['wait'], function(){
- return gulp.src([`${options.icon}/<%= name %>-icon.png`,`${options.icon}/<%= name %>-icon-active.png`])
+ return gulp.src([`${options.icon}/<%= name %>-icon.png`, `${options.icon}/<%= name %>-icon-active.png`])
.pipe(gulp.dest(options.static + 'images/'))
});
@@ -167,6 +168,15 @@
url: 'template:xos<%= fileName %>'
}
};
+
+ // check for custom icons
+ if(
+ fs.existsSync(`${options.icon}/<%= name %>-icon.png`) &&
+ fs.existsSync(`${options.icon}/<%= name %>-icon-active.png`)
+ ){
+ dashboardJson['<%= fileName %>'].properties.custom_icon = true;
+ }
+
const dashboardTosca = yaml.dump(dashboardJson).replace(/'/gmi, '');
// TOSCA to add the dashboard to the user