diff --git a/app/modules/auth/scripts/init.js b/app/modules/auth/scripts/init.js index 127eca9..9f6c680 100644 --- a/app/modules/auth/scripts/init.js +++ b/app/modules/auth/scripts/init.js @@ -40,7 +40,6 @@ var auth = localStorageService.get('auth'); if (0 < (Math.floor(Date.now() / 1000) - auth.token_start) < auth.expires_in) { _setToken(auth.access_token); - _startTimer(); _setUserData(); } else { signOut(); @@ -55,7 +54,6 @@ expires_in: params.expires_in * 1000 }); _setToken(params.access_token); - _startTimer(); return _setUserData() .then(function () { $window.location.href = localStorageService.get('redirectOnSignIn'); @@ -64,13 +62,7 @@ function signIn() { localStorageService.set('redirectOnSignIn', $location.absUrl()); - $window.location.href = zooAPI.root.match(/^(.*)\/[^/]*$/)[1] + - '/oauth/authorize' + - '?response_type=token' + - '&client_id=' + - zooAPIConfig.app_id + - '&redirect_uri=' + - $location.absUrl().match(/.+?(?=\#\/)/)[0]; + $window.zooOAuth.signIn($location.absUrl().match(/.+?(?=\#\/)/)[0]); } function _setToken(token) { @@ -108,18 +100,6 @@ $rootScope.$broadcast('auth:signout'); } - function _startTimer() { - var auth = localStorageService.get('auth'); - var expiry = auth.token_start + auth.expires_in - Date.now(); - $interval(function () { - signOut(); - $modal.open({ - templateUrl: 'templates/auth/session-expired.html', - controller: 'SessionExpiredModalController' - }); - }, expiry, 1); - } - return { signIn: signIn, signOut: signOut, diff --git a/app/modules/zoo-api/scripts/project-service.js b/app/modules/zoo-api/scripts/project-service.js index 38f8d4c..6e8b9d8 100644 --- a/app/modules/zoo-api/scripts/project-service.js +++ b/app/modules/zoo-api/scripts/project-service.js @@ -29,8 +29,7 @@ module.factory('zooAPI', function ($window, zooAPIConfig) { console.log('zooAPIConfig = ', zooAPIConfig); - $window.zooAPI.root = zooAPIConfig.url; - $window.zooAPI.appID = zooAPIConfig.app_id; + $window.zooOAuth.init(zooAPIConfig.app_id); return $window.zooAPI; }); @@ -56,16 +55,10 @@ var get = function () { var deferred = $q.defer(); - var cache = localStorageService.get('project'); - if (cache) { - deferred.resolve(cache); - } - zooAPI.type('projects').get({display_name: zooAPIConfig.display_name}) .then(function (response) { var data = $filter('removeCircularDeps')(response[0]); - localStorageService.set('project', data); - deferred.resolve(localStorageService.get('project')); + deferred.resolve(data); }); return deferred.promise; @@ -80,26 +73,9 @@ var get = function (filter) { var deferred = $q.defer(); - var cache = localStorageService.get('workflows'); - if (cache) { - if (filter) { - var cacheByID = _.find(cache, filter); - if (angular.isDefined(cacheByID)) { - deferred.notify([cacheByID]); - } - } else { - deferred.notify(cache); - } - } else { - cache = []; - } - zooAPI.type('workflows').get(filter) .then(function (response) { - upsert(cache, {id: response.id}, response); - cache = $filter('removeCircularDeps')(cache); - localStorageService.set('workflows', cache); - deferred.resolve(response); + deferred.resolve($filter('removeCircularDeps')(response)); }); return deferred.promise; @@ -114,20 +90,6 @@ var get = function (filter) { var deferred = $q.defer(); - var cache = localStorageService.get('subject_sets'); - if (cache) { - if (filter) { - var cacheByID = _.find(cache, filter); - if (angular.isDefined(cacheByID)) { - deferred.notify([cacheByID]); - } - } else { - deferred.notify(cache); - } - } else { - cache = []; - } - zooAPIProject.get() .then(function (response) { var options = { @@ -160,24 +122,7 @@ deferred.notify(subjectSets); loadPages(angular.extend({}, options, {page: meta.next_page})); } else { - angular.forEach(subjectSets, function (s) { - upsert(cache, {'id': s.id}, s); - }); - - // If an item in the cache, is not in the list returned by the server - // and we're not filtering (assuming we're loading all data here!) - if (!filter) { - angular.forEach(cache, function (c) { - if (angular.isUndefined(_.find(subjectSets, {id: c.id}))) { - _.remove(cache, c); - } - }); - } - - cache = $filter('removeCircularDeps')(cache); - localStorageService.set('subject_sets', cache); - - deferred.resolve(subjectSets); + deferred.resolve($filter('removeCircularDeps')(subjectSets)); } }; diff --git a/package.json b/package.json index 0d974b1..4e1e932 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "karma-firefox-launcher": "^0.1.6", "karma-jasmine": "0.3.5", "nib": "1.1.0", - "panoptes-client": "^2.5.1", + "panoptes-client": "^2.5.2", "run-sequence": "^1.1.0", "stylus": "^0.51.1" }, diff --git a/panoptes-client-wrapper/index.js b/panoptes-client-wrapper/index.js index ec506e7..e3c397a 100644 --- a/panoptes-client-wrapper/index.js +++ b/panoptes-client-wrapper/index.js @@ -1,2 +1,3 @@ window.zooAPI = require('panoptes-client/lib/api-client'); -window.zooAuth = require('panoptes-client/lib/auth'); \ No newline at end of file +window.zooAuth = require('panoptes-client/lib/auth'); +window.zooOAuth = require('panoptes-client/lib/oauth'); \ No newline at end of file