Major update to code structure

   * Split files into independent files based on functionality.
   * Switch to bower/gulp for build.

Change-Id: Ibc775dd9b7f6a0a49f63c22162b7582e781e2d9c
Signed-off-by: Iftekharul Islam <iislam@us.ibm.com>
diff --git a/app/common/services/apiInterceptor.js b/app/common/services/apiInterceptor.js
new file mode 100644
index 0000000..5a715ec
--- /dev/null
+++ b/app/common/services/apiInterceptor.js
@@ -0,0 +1,46 @@
+/**
+ * api Interceptor
+ *
+ * @module app/common/services/apiInterceptor
+ * @exports apiInterceptor
+ * @name apiInterceptor
+
+ * @version 0.0.1
+ */
+
+window.angular && (function (angular) {
+    'use strict';
+
+    angular
+        .module('app.common.services')
+        .service('apiInterceptor', ['$q', '$rootScope', 'dataService', function($q, $rootScope, dataService){
+            return {
+                'request': function(config){
+                    dataService.server_unreachable = false;
+                    dataService.loading = true;
+                    return config;
+                },
+                'response': function(response){
+                    dataService.loading = false;
+                    dataService.last_updated = new Date();
+
+                    if(response == null){
+                        dataService.server_unreachable = true;
+                    }
+
+                    if(response && response.status == 'error' &&
+                       dataService.path != '/login'){
+                        $rootScope.$emit('timedout-user', {});
+                    }
+
+                    return response;
+                },
+                'responseError': function(rejection){
+                    dataService.server_unreachable = true;
+                    dataService.loading = false;
+                    return $q.reject(rejection);
+                }
+            };
+        }]);
+
+})(window.angular);
\ No newline at end of file