angular.module('omniControllers')
	.controller('WalletHistoryController', ["$scope", "$location", "$http", "hashExplorer", "$translate",
		function WalletHistoryController($scope, $location, $http, hashExplorer, $translate) {
  			$scope.showtesteco = $scope.account.getSetting('showtesteco');
			$scope.history=[]
			$scope.wallet.transactions($scope.showtesteco).forEach(function(adrtx){
				adrtx.then(function(txs){
					//console.log(txs);
					txs.forEach(function(tx){
						$scope.history.push(tx);
					});
				});
			});


		    $scope.changeAddress=function(address){
			  	if(address){
					//address=address.updateTransactions();
					$scope.selectedAddress = address;
					$scope.history = [];
					address.transactions($scope.showtesteco).then(function(txs){
						txs.forEach(function(tx){
							$scope.history.push(tx);
						});
				    });
			  	} else {
			  		$scope.selectedAddress = undefined;
					$scope.history=[]
					$scope.wallet.transactions($scope.showtesteco).forEach(function(adrtx){
						adrtx.then(function(txs){
							//console.log(txs);
							txs.forEach(function(tx){
								$scope.history.push(tx);
							});
						});
					});			  	
			  	}
		    }

		    $scope.setHashExplorer=function(transaction){
		    	$http.get('/v1/transaction/tx/' + transaction + '.json'). success(function(data) {
			      hashExplorer.setHash(data[0]);
			      $location.url('/explorer/inspector?view='+transaction)
			    });
		    }
		}])

@@ -308,16 +308,42 @@
 tory=%5B%5D%0A
+%09%09%09$scope.isLoading=true;%0A
 %09%09%09$scop
@@ -402,24 +402,38 @@
 nction(adrtx
+, index, array
 )%7B%0A%09%09%09%09adrtx
@@ -545,24 +545,99 @@
 );%0A%09%09%09%09%09%7D);%0A
+%09%09%09%09%09if ( index == array.length-1 ) %7B%0A%09%09%09%09%09%09$scope.isLoading=false;%0A%09%09%09%09%09%7D%0A
 %09%09%09%09%7D);%0A%09%09%09%7D
@@ -816,16 +816,44 @@
 y = %5B%5D;%0A
+%09%09%09%09%09$scope.isLoading=true;%0A
 %09%09%09%09%09add
@@ -988,20 +988,47 @@
 %7D);%0A%09%09%09%09
-    
+%09%09$scope.isLoading=false;%0A%09%09%09%09%09
 %7D);%0A%09%09%09 
@@ -1104,16 +1104,44 @@
 tory=%5B%5D%0A
+%09%09%09%09%09$scope.isLoading=true;%0A
 %09%09%09%09%09$sc
@@ -1206,16 +1206,30 @@
 on(adrtx
+, index, array
 )%7B%0A%09%09%09%09%09
@@ -1344,24 +1344,24 @@
 y.push(tx);%0A
-
 %09%09%09%09%09%09%09%7D);%0A%09
@@ -1355,24 +1355,105 @@
 %0A%09%09%09%09%09%09%09%7D);%0A
+%09%09%09%09%09%09%09if ( index == array.length-1 ) %7B%0A%09%09%09%09%09%09%09%09$scope.isLoading=false;%0A%09%09%09%09%09%09%09%7D%0A
 %09%09%09%09%09%09%7D);%0A%09%09

enable loading spinning for history page