You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2014/04/17 09:24:29 UTC

git commit: CB-6285: fixed async issue with downloads

Repository: cordova-registry-web
Updated Branches:
  refs/heads/master 34007dc62 -> e32261638


CB-6285: fixed async issue with downloads


Project: http://git-wip-us.apache.org/repos/asf/cordova-registry-web/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-registry-web/commit/e3226163
Tree: http://git-wip-us.apache.org/repos/asf/cordova-registry-web/tree/e3226163
Diff: http://git-wip-us.apache.org/repos/asf/cordova-registry-web/diff/e3226163

Branch: refs/heads/master
Commit: e3226163850b8a5c753d97f6cbbe390bc48eddf1
Parents: 34007dc
Author: Steven Gill <st...@gmail.com>
Authored: Thu Apr 17 00:24:23 2014 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Thu Apr 17 00:24:23 2014 -0700

----------------------------------------------------------------------
 app.js                                         |  4 ----
 attachments/js/controllers/viewAll.js          | 18 ++++++++++--------
 attachments/js/directives/topbar.js            | 19 ++++++++++++-------
 attachments/partials/views/packageDetails.html |  2 +-
 4 files changed, 23 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/e3226163/app.js
----------------------------------------------------------------------
diff --git a/app.js b/app.js
index b6ffeba..37a3639 100644
--- a/app.js
+++ b/app.js
@@ -32,7 +32,6 @@ function searcher(doc) {
               , platforms: platforms
               , engines: engines 
     };
-    log('emit ' + doc._id);
     emit(doc._id, obj);
   }
 }
@@ -66,7 +65,6 @@ function packageSearch (doc) {
               , platforms: platforms
               , engines: engines 
     };
-    log('packagesearch ' + doc._id);
   }
 
   if (doc.name) { // There aren't any better attributes for check if isPackage()
@@ -79,10 +77,8 @@ function packageSearch (doc) {
       });
     }
     if (doc._id) {
-      //log(doc._id);
       var ids = [doc._id];
       if (doc._id.indexOf('.') !== -1) doc._id.split('.').forEach(function (n) {ids.push(n)});
-      //if (doc.name.indexOf('.') !== -1) doc.name.split('_').forEach(function (n) {names.push(n)});
       ids.forEach(function (id) {
         if (id.length > 1) emit(id.toLowerCase(), obj);
       });

http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/e3226163/attachments/js/controllers/viewAll.js
----------------------------------------------------------------------
diff --git a/attachments/js/controllers/viewAll.js b/attachments/js/controllers/viewAll.js
index 4e67a09..15b076d 100644
--- a/attachments/js/controllers/viewAll.js
+++ b/attachments/js/controllers/viewAll.js
@@ -1,4 +1,4 @@
-angular.module('registry.controllers').controller('ViewAllController', ['$rootScope', '$scope', '$http', function($rootScope, $scope, $http) {
+angular.module('registry.controllers').controller('ViewAllController', ['$rootScope', '$scope', '$http', 'Downloads', function($rootScope, $scope, $http, Downloads) {
     
     $scope.loading = true;    
 
@@ -8,14 +8,16 @@ angular.module('registry.controllers').controller('ViewAllController', ['$rootSc
                     $scope.plugins = data.rows;
                     $scope.loading = false;
                     //hacky way to assign download counts to plugin
-                    $scope.plugins.forEach(function(element, index, array){
-                        if(!($scope.downloads[element.id])){
-                            array[index].downloads = 0;
-                        }else{
-                            array[index].downloads = $scope.downloads[element.id];
-                        }
+                    Downloads.getDownloads().then(function(obj){
+                        $scope.downloads = obj.data;
+                        $scope.plugins.forEach(function(element, index, array){
+                            if(!($scope.downloads[element.id])){
+                                array[index].downloads = 0;
+                            }else{
+                                array[index].downloads = $scope.downloads[element.id];
+                            }
+                        });
                     });
-                    console.log($scope.plugins);
                 }).
                 error(function(data, status){
                     if (status === 404){

http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/e3226163/attachments/js/directives/topbar.js
----------------------------------------------------------------------
diff --git a/attachments/js/directives/topbar.js b/attachments/js/directives/topbar.js
index 3d35ae3..51e0f9f 100644
--- a/attachments/js/directives/topbar.js
+++ b/attachments/js/directives/topbar.js
@@ -1,4 +1,4 @@
-angular.module('registry.controllers').directive('topbar', ['$http', '$location', '$window', '$rootScope', '$routeParams', function ($http, $location, $window, $rootScope, $routeParams) {
+angular.module('registry.controllers').directive('topbar', ['$http', '$location', '$window', '$rootScope', '$routeParams', 'Downloads', function ($http, $location, $window, $rootScope, $routeParams, Downloads) {
     return {
         restrict: 'E',
         templateUrl: '/partials/directives/topbar.html',
@@ -8,6 +8,7 @@ angular.module('registry.controllers').directive('topbar', ['$http', '$location'
             $scope.plugins = [];
 
             $scope.searchText = '';
+
            
             $scope.search = function(evt) {
                 if($location.url().indexOf("search") != -1){
@@ -21,12 +22,16 @@ angular.module('registry.controllers').directive('topbar', ['$http', '$location'
                             $http.get('/_list/search/search?startkey='+JSON.stringify(term)+'&endkey='+JSON.stringify(term+'ZZZZZZZZZZZZZZ')+'&limit=25').
                                 success(function(data, status, headers, config){
                                     $scope.plugins = data.rows;
-                                    $scope.plugins.forEach(function(element, index, array){
-                                        if(!($scope.downloads[element.key])){
-                                            array[index].downloads = 0;
-                                        }else{
-                                            array[index].downloads = $scope.downloads[element.key];
-                                        }
+                                    //hacky way to assign download counts to plugin
+                                    Downloads.getDownloads().then(function(obj){
+                                        $scope.downloads = obj.data;
+                                        $scope.plugins.forEach(function(element, index, array){
+                                            if(!($scope.downloads[element.key])){
+                                                array[index].downloads = 0;
+                                            }else{
+                                                array[index].downloads = $scope.downloads[element.key];
+                                            }     
+                                        });
                                     });
 
                                     //todo: save this in session storage instead of object?

http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/e3226163/attachments/partials/views/packageDetails.html
----------------------------------------------------------------------
diff --git a/attachments/partials/views/packageDetails.html b/attachments/partials/views/packageDetails.html
index 03764d3..02cb2cd 100644
--- a/attachments/partials/views/packageDetails.html
+++ b/attachments/partials/views/packageDetails.html
@@ -106,7 +106,7 @@
                 </div>
                 <div class="row">
                     <div class="column-12--hand">
-                        {{downloads[data._id]}}
+                        {{downloads[packageID]}}
                     </div>
                 </div>
                 <div class="row">