Dashboard icon

Change-Id: Ibebd10436e18d4b424ba311f9e0c1f4ec385361f
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'
     );