Subversion Repositories SmartDukaan

Rev

Rev 13557 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 13557 Rev 13563
Line 1... Line 1...
1
angular.module('starter.controllers', [])
1
angular.module('starter.controllers', [])
2
 
2
 
3
.controller('DashCtrl', function($scope, $stateParams, Categories, CategoryProducts, localStorageService, apihost,$location) {  
3
.controller('DashCtrl', function($scope, $stateParams, Categories, CategoryProducts, localStorageService, apihost,$location) {  
4
  $scope.me = $location.search().user_id;
4
  $scope.me = $location.search().user_id;
5
  if($scope.me) {
5
  if($scope.me) {
6
	localStorageService.set('me',$scope.me);
6
	 localStorageService.set('me',$scope.me);
7
  }else{
7
  }else{
8
	$scope.me = localStorageService.get('me');
8
	 $scope.me = localStorageService.get('me');
9
  }
9
  }
10
  $scope.apihost = apihost;
10
  $scope.apihost = apihost;
11
  $scope.curpage = 1;
11
  $scope.curpage = 1;
12
  $scope.maxpages = 10;
12
  $scope.maxpages = 10;
13
  $scope.products = [];
13
  $scope.products = [];
Line 76... Line 76...
76
        return true;
76
        return true;
77
    }
77
    }
78
  }
78
  }
79
})
79
})
80
 
80
 
81
.controller('ChatsCtrl', function($scope, Products, localStorageService, apihost, $location) {
81
.controller('ChatsCtrl', function($scope, $rootScope, Products, localStorageService, apihost, $location, Myactions) {
82
  $scope.me = $location.search().user_id;
82
  $scope.me = $location.search().user_id;
83
  if($scope.me) {
83
  if($scope.me) {
84
	localStorageService.set('me',$scope.me);
84
	localStorageService.set('me',$scope.me);
85
  }else{
85
  }else{
86
	$scope.me = localStorageService.get('me');
86
	$scope.me = localStorageService.get('me');
87
  }
87
  }
88
  $scope.apihost = apihost;
88
  $scope.apihost = apihost;
89
  $scope.curpage = 1;
89
  $scope.curpage = 1;
90
  $scope.maxpages = 10;
90
  $scope.maxpages = 10;
91
  $scope.products = [];
91
  $scope.products = [];
-
 
92
  $rootScope.liked = [];
-
 
93
  $rootScope.disliked = [];
-
 
94
 
-
 
95
  Myactions.all({user_id:$scope.me},
-
 
96
    function( result ) {          
-
 
97
      var userActions = result;   
-
 
98
      if(userActions){
-
 
99
        for(var i in userActions){
-
 
100
          for(var j in userActions[i]) {
-
 
101
            if(userActions[i][j].UserAction){
-
 
102
              if(userActions[i][j].UserAction.action == 'like'){
-
 
103
                $rootScope.liked[userActions[i][j].UserAction.store_product_id] = 1;
-
 
104
              }else{
-
 
105
                $rootScope.disliked[userActions[i][j].UserAction.store_product_id] = 1;
-
 
106
              }
-
 
107
            }            
-
 
108
          }          
-
 
109
        }
-
 
110
      }      
-
 
111
    },
-
 
112
    function( error ) {
-
 
113
        console.log( "Something went wrong!" );
-
 
114
    }
-
 
115
  ),
-
 
116
 
92
  $scope.loadmore = function () {    
117
  $scope.loadmore = function () {    
93
    console.log('Fetch deal products page '+$scope.curpage);
118
    console.log('Fetch deal products page '+$scope.curpage);
94
    Products.all({'me':$scope.me, page: $scope.curpage++},  
119
    Products.all({'me':$scope.me, page: $scope.curpage++},  
95
      function( result ) {          
120
      function( result ) {          
96
        $scope.category = result.category;
121
        $scope.category = result.category;