[SEBA-747] Upgraded loader to show real-time progress istead of using a time-out
Change-Id: Iafea32e3b15461dc8b6859f0e4b1813150e362d5
diff --git a/src/app/core/loader/loader.spec.ts b/src/app/core/loader/loader.spec.ts
index 0744c11..1a2d553 100644
--- a/src/app/core/loader/loader.spec.ts
+++ b/src/app/core/loader/loader.spec.ts
@@ -29,6 +29,7 @@
const MockDiscover = {
areModelsLoaded: () => loaded,
+ getStatusMessage: () => 'Test Message',
discover: null
};
diff --git a/src/app/core/loader/loader.ts b/src/app/core/loader/loader.ts
index 3606ca8..c8def42 100644
--- a/src/app/core/loader/loader.ts
+++ b/src/app/core/loader/loader.ts
@@ -27,6 +27,7 @@
'$rootScope',
'$location',
'$timeout',
+ '$interval',
'$state',
'AuthService',
'XosConfig',
@@ -35,20 +36,24 @@
];
public loader: boolean = true;
+ public message: string = 'Loading data...';
public error: string;
+ private getMessageInterval: ng.IPromise<any>;
+
constructor (
private $log: ng.ILogService,
private $rootScope: ng.IScope,
private $location: ng.ILocationService,
private $timeout: ng.ITimeoutService,
+ private $interval: ng.IIntervalService,
private $state: ng.ui.IStateService,
private XosAuthService: IXosAuthService,
private XosConfig: any,
private XosModelDiscoverer: IXosModelDiscovererService,
private XosOnboarder: IXosOnboarder
) {
-
+ this.getMessage();
this.run();
}
@@ -119,11 +124,34 @@
break;
}
}
+
+ /**
+ * This method query the model-discoverer service to have the status of the loading
+ */
+ public getMessage() {
+ this.getMessageInterval = this.$interval(() => {
+ this.message = this.XosModelDiscoverer.getStatusMessage();
+ }, 1000);
+ this.message = this.XosModelDiscoverer.getStatusMessage();
+ }
+
+ $onDestroy() {
+ this.$interval.cancel(this.getMessageInterval);
+ }
}
export const xosLoader: angular.IComponentOptions = {
template: `
- <div ng-show="vm.loader" class="loader"></div>
+ <div class="loader-container">
+ <div ng-show="vm.loader" class="loader"></div>
+ </div>
+ <div class="row">
+ <div class="col-sm-6 col-sm-offset-3">
+ <div class="alert alert-accent">
+ {{ vm.message }}
+ </div>
+ </div>
+ </div>
<div class="row" ng-show="vm.error == 'chameleon'">
<div class="col-sm-6 col-sm-offset-3">
<div class="alert alert-danger">