Created
May 17, 2014 02:55
-
-
Save pvamshi/2f6bc001c97e87b30e38 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
angular.module('angularFlaskServices', ['ngResource']) | |
.factory('Post', function($resource) { | |
return $resource('/api/post/:postId', {}, { | |
query: { | |
method: 'GET', | |
params: { postId: '' }, | |
isArray: true | |
} | |
}); | |
}) | |
.factory('HgStatus',function($http){ | |
var projects = []; | |
var project_status= {}; | |
return | |
{ | |
loadProjects : function(callback){ | |
$http({method: 'GET', url: '/projects'}).success(function(data){ | |
projects = data; | |
callback(data); | |
}); | |
}, | |
getProjects : function(){ | |
return projects; | |
}, | |
loadStatus : function(callback){ | |
for(var index = 0 ; index < projects.length; index++){ | |
var project = projects[index]; | |
(function(project) { | |
$http({method:'GET',url:'/hg/'+project}).success(function(hg){ | |
console.log('output fetched for '+project); | |
console.log(hg); | |
var pr = {}; | |
pr.inc_size = hg['incoming'].length; | |
pr.a_size = hg['a'].length; | |
pr.m_size = hg['m'].length; | |
pr.u_size = hg['u'].length; | |
pr.r_size = hg['r'].length; | |
pr.d_size = hg['d'].length; | |
project_status[project]=pr; | |
callback(project,hg); | |
}); | |
})(project); | |
} | |
} | |
}; | |
}) | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment