Dashboard icon

Change-Id: Ibebd10436e18d4b424ba311f9e0c1f4ec385361f
diff --git a/views/ngXosLib/generator-xos/app/index.js b/views/ngXosLib/generator-xos/app/index.js
index 0368fd2..72c6f56 100755
--- a/views/ngXosLib/generator-xos/app/index.js
+++ b/views/ngXosLib/generator-xos/app/index.js
@@ -64,7 +64,7 @@
         {fileName: this._fistCharToUpper(config.name)}
       );
     },
-    css: function(){
+    scss: function(){
       this.fs.copyTpl(
         this.templatePath('src/sass/main.scss'),
         this.destinationPath(`${this.config.get('folder')}/${config.name}/src/sass/main.scss`),
@@ -78,6 +78,11 @@
         { name: config.name, fileName: this._fistCharToUpper(config.name) }
       );
     },
+    image: function(){
+      this.fs.copyTpl(
+        this.templatePath('src/icons/README.md'),
+        this.destinationPath(`${this.config.get('folder')}/${config.name}/src/icons/README.md`));
+    },
     template: function(){
       this.fs.copy(this.templatePath('src/templates/users-list.tpl.html'), this.destinationPath(`${this.config.get('folder')}/${config.name}/src/templates/users-list.tpl.html`));
     },
diff --git a/views/ngXosLib/generator-xos/app/templates/gulp/build.js b/views/ngXosLib/generator-xos/app/templates/gulp/build.js
index b66cdbc..00dc995 100644
--- a/views/ngXosLib/generator-xos/app/templates/gulp/build.js
+++ b/views/ngXosLib/generator-xos/app/templates/gulp/build.js
@@ -41,7 +41,9 @@
     return del(
       [
         options.dashboards + 'xos<%= fileName %>.html',
-        options.static + 'css/xos<%= fileName %>.css'
+        options.static + 'css/xos<%= fileName %>.css',
+        options.static + 'images/<%= name %>-icon.png',
+        options.static + 'images/<%= name %>-icon-active.png'
       ],
       {force: true}
     );
@@ -70,6 +72,12 @@
     .pipe(gulp.dest(options.static + 'css/'))
   });
 
+  // copy images in correct folder
+  gulp.task('copyImages', ['wait'], function(){
+    return gulp.src([`${options.icon}/<%= name %>-icon.png`,`${options.icon}/<%= name %>-icon-active.png`])
+    .pipe(gulp.dest(options.static + 'images/'))
+  });
+
   // compile and minify scripts
   gulp.task('scripts', function() {
     return gulp.src([
@@ -157,6 +165,7 @@
       'wiredep',
       'css',
       'copyCss',
+      'copyImages',
       'copyHtml',
       'cleanTmp'
     );
diff --git a/views/ngXosLib/generator-xos/app/templates/gulpfile.js b/views/ngXosLib/generator-xos/app/templates/gulpfile.js
index 08df554..eca4e45 100644
--- a/views/ngXosLib/generator-xos/app/templates/gulpfile.js
+++ b/views/ngXosLib/generator-xos/app/templates/gulpfile.js
@@ -6,6 +6,7 @@
 var options = {
   src: 'src/',
   css: 'src/css/',
+  icon: 'src/icons',
   sass: 'src/sass/',
   scripts: 'src/js/',
   tmp: 'src/.tmp',
diff --git a/views/ngXosLib/generator-xos/app/templates/src/icons/README.md b/views/ngXosLib/generator-xos/app/templates/src/icons/README.md
new file mode 100644
index 0000000..0d5a787
--- /dev/null
+++ b/views/ngXosLib/generator-xos/app/templates/src/icons/README.md
@@ -0,0 +1,18 @@
+# Set icon for custom dashboard 
+
+## Path to add images : <dashboard-name>/src/icons
+
+### Add two images with name in following format 
+    <dashboard-name>-icon.png
+    <dashboard-name>-icon-active.png
+
+Examples: 
+    If your dashboard name is `slice`
+    then you will add the images with the name as
+        `slice-icon.png`
+        `slice-icon-active.png`
+        
+        
+        
+        
+Note: If you don't add the custom images, then dashboard will use the default images stored at `/xos/core/xoslib/static/images`
\ No newline at end of file
diff --git a/views/ngXosViews/dashboardManager/src/index.html b/views/ngXosViews/dashboardManager/src/index.html
index 371caa2..6df0c5f 100644
--- a/views/ngXosViews/dashboardManager/src/index.html
+++ b/views/ngXosViews/dashboardManager/src/index.html
@@ -14,10 +14,10 @@
 </div>
 
 <!-- bower:js -->
-<script src="vendor/jquery/dist/jquery.js"></script>
-<script src="vendor/angular/angular.js"></script>
 <script src="vendor/angular-drag-and-drop-lists/angular-drag-and-drop-lists.js"></script>
 <script src="vendor/js-yaml/dist/js-yaml.js"></script>
+<script src="vendor/jquery/dist/jquery.js"></script>
+<script src="vendor/angular/angular.js"></script>
 <script src="vendor/angular-mocks/angular-mocks.js"></script>
 <script src="vendor/angular-ui-router/release/angular-ui-router.js"></script>
 <script src="vendor/angular-cookies/angular-cookies.js"></script>
diff --git a/views/ngXosViews/dashboardManager/src/js/dashboard-form.directive.js b/views/ngXosViews/dashboardManager/src/js/dashboard-form.directive.js
index b6751b2..1895856 100644
--- a/views/ngXosViews/dashboardManager/src/js/dashboard-form.directive.js
+++ b/views/ngXosViews/dashboardManager/src/js/dashboard-form.directive.js
@@ -42,7 +42,27 @@
             {
               label: 'Save',
               icon: 'ok',
-              cb: (item) => {
+              cb: (item,form) => {
+
+                if (!form.$valid){
+                  return;
+                }
+                if(item.name && item.url && item.custom_icon){
+                  var indexOfXos = item.url.indexOf('xos');
+                  if (indexOfXos>=0){
+                    var dashboard_name = item.url.slice(indexOfXos+3,item.url.length).toLowerCase();
+                    item.icon =dashboard_name.concat('-icon.png');
+                    item.icon_active =dashboard_name.concat('-icon-active.png');
+                  }
+                  else{
+                    item.icon ='default-icon.png';
+                    item.icon_active ='default-icon-active.png';
+                  }
+                }
+                else{
+                  item.icon ='default-icon.png';
+                  item.icon_active ='default-icon-active.png';
+                }
                 this.createOrUpdateDashboard(item);
               },
               class: 'success'
@@ -77,6 +97,9 @@
             },
             enabled: {
               type: 'boolean'
+            },
+            custom_icon: {
+              type: 'boolean'
             }
           }
         };
@@ -99,7 +122,7 @@
             $log.info(e);
             this.formConfig.feedback.show = true;
             this.formConfig.feedback.message = e;
-            this.formConfig.feedback.type = 'error';
+            this.formConfig.feedback.type='danger';
           })
         };
 
diff --git a/views/ngXosViews/tenant/gulp/build.js b/views/ngXosViews/tenant/gulp/build.js
index 8a7b279..b540fcc 100644
--- a/views/ngXosViews/tenant/gulp/build.js
+++ b/views/ngXosViews/tenant/gulp/build.js
@@ -41,7 +41,8 @@
     return del(
       [
         options.dashboards + 'xosTenant.html',
-        options.static + 'css/xosTenant.css'
+        options.static + 'css/xosTenant.css',
+        options.static + 'images/*'
       ],
       {force: true}
     );
@@ -70,6 +71,12 @@
     .pipe(gulp.dest(options.static + 'css/'))
   });
 
+    // copy images in correct folder
+  gulp.task('copyImages', ['wait'], function(){
+    return gulp.src([`${options.icon}/*.png`])
+    .pipe(gulp.dest(options.static + 'images/'))
+  });
+
   // compile and minify scripts
   gulp.task('scripts', function() {
     return gulp.src([
@@ -157,6 +164,7 @@
       'wiredep',
       'css',
       'copyCss',
+      'copyImages',
       'copyHtml',
       'cleanTmp'
     );
diff --git a/views/style/sass/lib/nav.scss b/views/style/sass/lib/nav.scss
index f10a613..b71a7ae 100644
--- a/views/style/sass/lib/nav.scss
+++ b/views/style/sass/lib/nav.scss
@@ -100,7 +100,9 @@
           padding: 5px 0px;
           margin-right: 0;
           border-radius: $nav-pills-border-radius;
-
+          > img {
+            width:20px;
+          }
           &:hover,&:focus  {
             padding-left: 15px;
             text-decoration: none;