[CORD-3186] Adding CORD version to the gui

Change-Id: I4512ed6fce7f5dc2bb70dc1df6f5a919456fc60a
diff --git a/src/app/core/header/header.spec.ts b/src/app/core/header/header.spec.ts
index 023bb7d..720392a 100644
--- a/src/app/core/header/header.spec.ts
+++ b/src/app/core/header/header.spec.ts
@@ -104,6 +104,13 @@
       .value('toastrConfig', MockToastrConfig)
       .value('AuthService', MockAuth)
       .value('XosNavigationService', {})
+      .value('XosVersionReaderService', {
+        getVersion: () => {
+          return {
+            then: (cb) => cb('version')
+          };
+        }
+      })
       .value('ConfigHelpers', {
         stateWithParamsForJs: () => null
       })
diff --git a/src/app/core/header/header.ts b/src/app/core/header/header.ts
index 5ef9459..0e55dee 100644
--- a/src/app/core/header/header.ts
+++ b/src/app/core/header/header.ts
@@ -27,6 +27,7 @@
 import {Subscription} from 'rxjs';
 import {IXosConfigHelpersService} from '../services/helpers/config.helpers';
 import {IXosDebugService} from '../debug/debug.service';
+import {IXosVersionReaderService} from '../services/version-reader';
 
 export interface INotification extends IWSEvent {
   viewed?: boolean;
@@ -47,7 +48,8 @@
     'SearchService',
     'XosKeyboardShortcut',
     'ConfigHelpers',
-    'XosDebug'
+    'XosDebug',
+    'XosVersionReaderService'
   ];
   public notifications: INotification[] = [];
   public newNotifications: INotification[] = [];
@@ -74,14 +76,20 @@
     private SearchService: IXosSearchService,
     private XosKeyboardShortcut: IXosKeyboardShortcutService,
     private ConfigHelpers: IXosConfigHelpersService,
-    private XosDebugService: IXosDebugService
+    private XosDebugService: IXosDebugService,
+    private XosVersionReaderService: IXosVersionReaderService
   ) {
 
   }
 
   $onInit() {
     this.$log.info('[XosHeader] Setup');
-    this.version = require('../../../../package.json').version;
+
+    this.XosVersionReaderService.getVersion()
+    .then((version: string) => {
+      this.version = version;
+    });
+
     angular.extend(this.toastrConfig, {
       newestOnTop: false,
       positionClass: 'toast-top-right',
diff --git a/src/app/core/index.ts b/src/app/core/index.ts
index ae5796c..e3d05e6 100644
--- a/src/app/core/index.ts
+++ b/src/app/core/index.ts
@@ -50,6 +50,7 @@
 import {xosConfirm} from './confirm/confirm';
 import {XosConfirm} from './confirm/confirm.service';
 import {xosServiceStatus} from './service-status/service-status';
+import {XosVersionReaderService} from './services/version-reader';
 
 export const xosCore = 'xosCore';
 
@@ -73,6 +74,7 @@
   .service('XosDebouncer', XosDebouncer)
   .service('XosDebug', XosDebugService)
   .service('XosConfirm', XosConfirm)
+  .service('XosVersionReaderService', XosVersionReaderService)
   .directive('xosLinkWrapper', xosLinkWrapper)
   .component('xosHeader', xosHeader)
   .component('xosFooter', xosFooter)
diff --git a/src/app/core/key-binding/key-binding-panel.html b/src/app/core/key-binding/key-binding-panel.html
index ed198fd..e870679 100644
--- a/src/app/core/key-binding/key-binding-panel.html
+++ b/src/app/core/key-binding/key-binding-panel.html
@@ -51,4 +51,11 @@
     <div class="col-xs-12">
         <xos-debug-summary></xos-debug-summary>
     </div>
+</div>
+<div class="row">
+    <div class="col-xs-12 text-right ">
+        <span class="text-accent small">
+            XOS-GUI version: {{vm.version}}
+        </span>
+    </div>
 </div>
\ No newline at end of file
diff --git a/src/app/core/key-binding/key-binding-panel.ts b/src/app/core/key-binding/key-binding-panel.ts
index c77f6b6..9984d76 100644
--- a/src/app/core/key-binding/key-binding-panel.ts
+++ b/src/app/core/key-binding/key-binding-panel.ts
@@ -20,11 +20,13 @@
 class XosKeyBindingPanelController {
   static $inject = ['$scope', 'XosKeyboardShortcut'];
   public bindings: IXosKeyboardShortcutMap;
+  public version: string;
 
   constructor (
     private $scope: ng.IScope,
     private XosKeyboardShortcut: IXosKeyboardShortcutService
   ) {
+    this.version = require('../../../../package.json').version;
     this.bindings = this.XosKeyboardShortcut.keyMapping;
   }
 }
diff --git a/src/app/core/services/version-reader.ts b/src/app/core/services/version-reader.ts
new file mode 100644
index 0000000..3293fbc
--- /dev/null
+++ b/src/app/core/services/version-reader.ts
@@ -0,0 +1,55 @@
+
+
+/*
+ * Copyright 2017-present Open Networking Foundation
+
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import IPromise = angular.IPromise;
+
+export interface IXosVersionReaderService {
+  getVersion(): IPromise<string>;
+}
+
+interface ICORDVersion {
+    data: {
+        version: string;
+    };
+}
+
+export class XosVersionReaderService implements IXosVersionReaderService {
+
+    static $inject = ['$http', '$q', '$log'];
+
+    constructor(
+    private $http: angular.IHttpService,
+    private $q: angular.IQService,
+    private $log: angular.ILogService
+    ) {
+    }
+
+    public getVersion(): IPromise<string> {
+        const d = this.$q.defer();
+        this.$http.get(`/version.json`)
+          .then((res: ICORDVersion) => {
+            d.resolve(res.data.version);
+          })
+          .catch(e => {
+            this.$log.warn(`[XosVersionReaderService] Cannot read version`, e);
+            d.resolve('unknown');
+          });
+        return d.promise;
+      }
+
+}