Skip to content

Instantly share code, notes, and snippets.

@zechtz
Created September 21, 2017 11:57
Show Gist options
  • Save zechtz/1d93538ac826eba8ecb9db4deb196bb1 to your computer and use it in GitHub Desktop.
Save zechtz/1d93538ac826eba8ecb9db4deb196bb1 to your computer and use it in GitHub Desktop.
Dashboard Service
(function() {
'use strict';
var dashboardModels = angular.module('dashboardModels', ['ngResource']);
dashboardModels.factory('DashboardStats', ['$resource', '$http', function($resource, $http) {
return {
/**
*
* pie chart based on current user's admin hierarch id (poralg & region)
*
*/
getAdminLevelStats: function(admin_hierarchy_id) {
return $http.get('/json/dashBoard/getDashboardData/' + admin_hierarchy_id)
.then(function(response) {
return response.data;
});
},
/**
*
* table with admin areas (poralg & region)
*/
getPoralgLevelStats: function(admin_hierarchy_id) {
return $http.get('/json/dashBoard/getDashboardData/' + admin_hierarchy_id)
.then(function(response) {
return response.data;
});
},
/**
*
* table with admin areas (poralg & region)
*/
getAdminHeirarchyBudgetWithChildren : function(admin_hierarchy_id) {
return $http.get('/json/dashBoard/getAdminHierarchyBudgetWithChildren/' + admin_hierarchy_id)
.then(function(response) {
return response.data;
});
},
/**
*
* pie chart based on current user's admin hierarch id (poralg & region)
*/
getPercentageByDecisionLevel : function(admin_hierarchy_id) {
return $http.get('/json/dashBoard/getPercentageByDecisionLevel/' + admin_hierarchy_id)
.then(function(response) {
return response.data;
});
},
/**
*
* pie chart based on current user's admin hierarch id (poralg & region)
*
*/
getPercentageByStatus : function(admin_hierarchy_id) {
return $http.get('/json/dashBoard/getPercentageByStatus/' + admin_hierarchy_id)
.then(function(response) {
return response.data;
});
},
/**
*
* pie chart based on current user's admin hierarch id (poralg & region)
*
*/
getDashboardData : function(admin_hierarchy_id) {
return $http.get('/json/dashBoard/getDashboardData/' + admin_hierarchy_id)
.then(function(response) {
return response.data;
});
},
/**
*
* pie chart based on current user's admin hierarch id (council user)
*
*/
getBudgetBySector : function(admin_hierarchy_id) {
return $http.get('/json/dashBoard/getBudgetBySector/' + admin_hierarchy_id)
.then(function(response) {
return response.data;
});
},
/**
*
* pie chart based on current user's admin hierarch id (council user)
*
*/
getBudgetByBudgetClass : function(admin_hierarchy_id) {
return $http.get('/json/dashBoard/getBudgetByBudgetClass/' + admin_hierarchy_id)
.then(function(response) {
return response.data;
});
},
/**
*
* pie chart based on current user's admin hierarch id (council user)
*
*/
getBudgetByBudgetByCostCenter: function(admin_hierarchy_id) {
return $http.get('/json/dashBoard/getBudgetByBudgetByCostCenter/' + admin_hierarchy_id)
.then(function(response) {
return response.data;
});
}
};
}]);
dashboardModels.factory('SocketIO', ['$rootScope', function($rootScope) {
var socket = io('http://localhost:3000');
return {
on : function(eventName, callback) {
socket.on(eventName, function() {
var args = arguments;
$rootScope.$apply(function() {
callback.apply(socket, args);
});
});
},
emit : function(eventName, data, callback) {
socket.emit(eventName, data, function() {
var args = arguments;
$rootScope.$apply(function() {
if (callback) {
callback.apply(socket, args);
}
});
});
}
};
}]);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment