// env fetcher
.factory('egEnv',
- ['$q','egAuth','egPCRUD','egIDL',
-function($q, egAuth, egPCRUD, egIDL) {
+ ['$q','$window','egAuth','egPCRUD','egIDL',
+function($q, $window , egAuth, egPCRUD, egIDL) {
var service = {
// collection of custom loader functions
*/
service.classLoaders = {
aou : function() {
+
+ // EXPERIMENT: cache the org tree in session storage.
+ // This means that if the org tree changes, users will have to
+ // open the client in a new browser tab to clear the cached tree.
+ var treeJSON = $window.sessionStorage.getItem('eg.env.aou.tree');
+ if (treeJSON) {
+ console.debug('serving org tree from cache');
+ var tree = JSON2js(treeJSON);
+ service.absorbTree(tree, 'aou')
+ return $q.when(tree);
+ }
+
return egPCRUD.search('aou', {parent_ou : null},
{flesh : -1, flesh_fields : {aou : ['children', 'ou_type']}}
).then(
- function(tree) {service.absorbTree(tree, 'aou')}
+ function(tree) {
+ $window.sessionStorage.setItem(
+ 'eg.env.aou.tree', js2JSON(tree));
+ service.absorbTree(tree, 'aou')
+ }
);
},
};