Create loading service
This commit is contained in:
parent
e9108d4b97
commit
2d99f1ecf2
4 changed files with 49 additions and 3 deletions
|
@ -3,24 +3,28 @@
|
|||
*
|
||||
* @param {$scope} $scope The $scope service from angular
|
||||
*/
|
||||
mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', function ($scope, Compute, $rootScope)
|
||||
mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', 'Loading', function ($scope, Compute, $rootScope, Loading)
|
||||
{
|
||||
|
||||
var callMeAfterPullData=function(data){
|
||||
$scope.machines=Compute.getData().machines;
|
||||
Loading.stop();
|
||||
}
|
||||
|
||||
|
||||
Loading.start();
|
||||
Compute.pullData(callMeAfterPullData);
|
||||
|
||||
|
||||
|
||||
$scope.raiseShowMachineDetailsEvent=function(id){
|
||||
|
||||
var callback=function(){
|
||||
Loading.stop();
|
||||
var data=Compute.getData();
|
||||
$rootScope.$broadcast("showMachineDetailsEvent", data.machines[id], data.axioms);
|
||||
|
||||
}
|
||||
Loading.start();
|
||||
Compute.pullMachines(callback);
|
||||
}
|
||||
|
||||
|
|
22
client/js/services/Loading.js
Normal file
22
client/js/services/Loading.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
|
||||
mainApp.factory('Loading',[ '$http', 'Identity', function($http, Identity){
|
||||
|
||||
|
||||
|
||||
|
||||
var start=function(){
|
||||
$('#loadingModal').modal({backdrop: 'static', keyboard: false});
|
||||
};
|
||||
|
||||
var stop=function(){
|
||||
$('#loadingModal').modal('hide');
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
start:start,
|
||||
stop:stop
|
||||
};
|
||||
|
||||
|
||||
}]);
|
Loading…
Add table
Add a link
Reference in a new issue