Skip to content

Commit

Permalink
Fixed refreshing bug
Browse files Browse the repository at this point in the history
  • Loading branch information
leowyy committed Apr 14, 2017
1 parent 9b4f5eb commit 32f4b53
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 51 deletions.
56 changes: 10 additions & 46 deletions app-main/scripts/controllers/Completed.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,63 +17,26 @@ angular.module('sbAdminApp')
});
$scope.tempBought = [];
$scope.tempSold = [];

txService.getTransactions(function(txs) {
for (var i = 0; i<txs.pendingAgrees.length; i++) {
txs.pendingAgrees[i].agreeing = true;
txs.pendingAgrees[i].pending = true;
if (txs.pendingAgrees[i].sell) {
if (txs.pendingAgrees[i].sell && txs.pendingAgrees[i].price != 0) {
$scope.tempSold.push(txs.pendingAgrees[i]);
}
else {
else if (!txs.pendingAgrees[i].sell && txs.pendingAgrees[i].price != 0) {
$scope.tempBought.push(txs.pendingAgrees[i]);
}
}
});
txService.getBought(function(txs) {
$scope.bought = $scope.tempBought.concat(txs);
$scope.bought = $scope.bought.filter($scope.filterOutDonations);
}, function() {
$scope.bought = [
{
accepter:{name:'NTUC'},
item: 'Apples',
quantity: 300,
price: 2,
txDate: 1492003145123,
expiry: 1492503145123
},{
accepter:{name:'Giant'},
item: 'Oranges',
quantity: 300,
price: 2,
txDate: 1491903145123,
expiry: 1492503145123
}
];
})
$scope.tempBought = $scope.tempBought.concat(txs);
$scope.bought = $scope.tempBought;
});
txService.getSold(function(txs) {
$scope.sold = $scope.tempSold.concat(txs);
$scope.sold = $scope.sold.filter($scope.filterOutDonations);
}, function() {
$scope.sold = [
{
accepter:{name:'NTUC'},
item: 'Apples',
quantity: 300,
price: 2,
txDate: 1491503145123,
expiry: 1492303145123
},{
accepter:{name:'Cold Storage'},
item: 'Oranges',
quantity: 300,
price: 2,
txDate: 1491503145123,
expiry: 1492303145123
}
];
})
$scope.tempSold = $scope.tempSold.concat(txs);
$scope.sold = $scope.tempSold;
});
}

$scope.filterOutDonations = function(item){
Expand All @@ -85,7 +48,8 @@ angular.module('sbAdminApp')

$interval(function() {
reloadData();
}, 5000)
console.log($scope.sold);
}, 3000)
reloadData();

}]);
4 changes: 1 addition & 3 deletions app-main/scripts/controllers/Donations.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,14 @@ angular.module('sbAdminApp')
for (var i = 0; i<txs.pendingAgrees.length; i++) {
txs.pendingAgrees[i].agreeing = true;
txs.pendingAgrees[i].pending = true;
if (txs.pendingAgrees[i].sell) {
if (txs.pendingAgrees[i].sell && txs.pendingAgrees[i].price == 0) {
$scope.tempDonationsCompleted.push(txs.pendingAgrees[i]);
}
}
//$scope.agrees = txs.pendingAgrees.concat(txs.offersAccepted);
$scope.offers = $scope.offers.concat($scope.agrees);

// Get donations
$scope.donations = $scope.offers.filter($scope.getDonations);

$scope.reloaded = true;

});
Expand Down
1 change: 0 additions & 1 deletion app-main/scripts/controllers/InProgress.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ angular.module('sbAdminApp')
$scope.agrees = $scope.agrees.filter($scope.filterOutDonations);
$scope.offers = $scope.offers.filter($scope.filterOutDonations);
$scope.reloaded = true;
console.log($scope.offers);

}, function() {
//add mock data here when server not running
Expand Down
2 changes: 1 addition & 1 deletion app-main/views/dashboard/mainpage.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ <h1 class="page-header">Crumbs <em>Dashboard</em></h1>
<stats ng-if="valid" number="{{ excess }}" comments="New Excess" colour="red" type="bar-chart-o" goto="dashboard.MyPredictions"></stats>
<stats ng-if="valid" number="{{ shortage }}" comments="New Shortage" colour="yellow" type="bar-chart-o" goto="dashboard.MyPredictions"></stats>
<stats ng-if="!valid" number="-" comments="New Excess" colour="red" type="bar-chart-o" goto="dashboard.MyPredictions"></stats>
<stats ng-if="!valid" number="-" comments="New Shortage" colour="green" type="bar-chart-o" goto="dashboard.MyPredictions"></stats>
<stats ng-if="!valid" number="-" comments="New Shortage" colour="yellow" type="bar-chart-o" goto="dashboard.MyPredictions"></stats>
<stats number="{{ numOfSalesToApprove }}" comments="Sales to Approve" colour="green" type="shopping-cart" goto="dashboard.InProgressSelling"></stats>
<stats number="{{ numOfPurchasesToApprove }}" comments="Purchases to Approve" colour="primary" type="shopping-cart" goto="dashboard.InProgressBuying"></stats>
</div>
Expand Down

0 comments on commit 32f4b53

Please sign in to comment.