[CORD-1001] Solved race condition in autogeneration of models and tweaks for slow connections

Change-Id: Ifcbc4f9057f04e19703af96f8d8294f2b975be66
diff --git a/src/index.ts b/src/index.ts
index de9d9bf..6c34b57 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -6,6 +6,7 @@
 import 'angular-ui-router';
 import 'angular-resource';
 import 'angular-cookies';
+import '../node_modules/ngprogress/build/ngProgress';
 import routesConfig from './routes';
 
 import {main} from './app/main';
@@ -48,9 +49,10 @@
     xosDataSources,
     xosViews,
     xosExtender,
+    xosTemplate, // template module
     'ui.router',
     'ngResource',
-    xosTemplate // template module
+    'ngProgress'
   ])
   .config(XosLogDecorator)
   .config(routesConfig)
@@ -121,6 +123,8 @@
 
           // after setting up dynamic routes, redirect to previous state
           $location.path(lastRoute).search(lastQueryString);
+        })
+        .finally(() => {
           $rootScope.$emit('xos.core.modelSetup');
         });
     }