update client version to handle "musée de l'immigration"
authorrougeronj
Thu, 01 Oct 2015 17:55:23 +0200
changeset 184 4d01c2d04359
parent 183 8e26a5511bb8
child 185 9a08647d9e59
update client version to handle "musée de l'immigration"
client/app/components/app_service.js
client/app/index.html
client/app/search/search_controller.js
client/app/slideshow/slideshow.html
client/app/visites/visites_controller.js
--- a/client/app/components/app_service.js	Thu Jul 16 15:14:27 2015 +0200
+++ b/client/app/components/app_service.js	Thu Oct 01 17:55:23 2015 +0200
@@ -84,21 +84,35 @@
                             params: params,
                             isArray: false,
                             transformResponse: function(data){
+                                var i, j;
                                 // Transform meta list into meta dict
-                                var nb = data.hits.length;
-                                for(var i=0;i<nb;i++){
-                                    var nb_metas = data.hits[i].metas.length;
-                                    data.hits[i].metas_dict = {};
-                                    for(var j=0;j<nb_metas;j++){
-                                        if(typeof data.hits[i].metas[j].images==='undefined'){
-                                            data.hits[i].metas_dict[data.hits[i].metas[j].name] = data.hits[i].metas[j].value;
-                                        }
-                                        else{
-                                            data.hits[i].metas_dict.images = data.hits[i].metas[j].images[0].value;
+                                if (typeof data.hits !== 'undefined'){
+                                    var nb = data.hits.length;
+                                    for(i=0;i<nb;i++){
+                                        var nb_metas = data.hits[i].metas.length;
+                                        data.hits[i].metas_dict = {};
+                                        for(j=0;j<nb_metas;j++){
+                                            if(typeof data.hits[i].metas[j].images==='undefined'){
+                                                data.hits[i].metas_dict[data.hits[i].metas[j].name] = data.hits[i].metas[j].value;
+                                            }
+                                            else{
+                                                data.hits[i].metas_dict.images = data.hits[i].metas[j].images[0].value;
+                                            }
                                         }
                                     }
+                                    return data;   
                                 }
-                                return data;
+                                if (typeof data.response !== 'undefined'){
+                                    var result = [];
+
+                                    angular.forEach(data.response[0].collect, function(value) {
+                                        var temp = {};
+                                        angular.forEach(value, function(value2, key2) {
+                                            temp[key2]= value2;
+                                        });
+                                        result.push(temp);
+                                    });
+                                }
                             }
                         }
                     });
--- a/client/app/index.html	Thu Jul 16 15:14:27 2015 +0200
+++ b/client/app/index.html	Thu Oct 01 17:55:23 2015 +0200
@@ -83,10 +83,10 @@
 			  record: angular.fromJson('{"record": "record value"}'),
               urls: {
                   <!-- build:ammicoUrl -->
-                  ammicoUrl: "http://127.0.0.1:8000/ammico/",
+                  ammicoUrl: "",
                   <!-- endbuild -->
                   <!-- build:searchUrl -->
-                  searchUrl: "http://ammico.labs.exalead.com/search-api"
+                  searchUrl: ""
                   <!-- endbuild -->
               }
           });
--- a/client/app/search/search_controller.js	Thu Jul 16 15:14:27 2015 +0200
+++ b/client/app/search/search_controller.js	Thu Oct 01 17:55:23 2015 +0200
@@ -9,9 +9,12 @@
             controller: 'searchCtrl'
         });
     })
-    .controller('searchCtrl', function($scope, $location, $routeParams, searchApi, $modal, Slide){
+    .controller('searchCtrl', function($scope, $location, $routeParams, searchApi, searchApi2, $modal, Slide){
         $scope.q = $routeParams.q || '';
-        $scope.results = searchApi.searchResource({q:$scope.q, of: 'json', synthesis: 'false', nresults:'10', callback: 'JSON_CALLBACK'}).getJsonp();
+        if ($scope.q !== ''){
+            $scope.results_ = searchApi.searchResource({q:$scope.q, of: 'json', synthesis: 'false', nresults:'10', callback: 'JSON_CALLBACK'}).getJsonp();
+            $scope.results = searchApi2.searchResource({q:$scope.q, of: 'json', synthesis: 'false', nresults:'10', callback: 'JSON_CALLBACK'}).getJsonp();
+        }
         
         $scope.toggleModal = function (index) {
 
@@ -24,7 +27,7 @@
             modalInstance.result.then(function (idBook) {
                 var newSlide = {
                     book: idBook,
-                    id_inventory: $scope.results.hits[index].metas_dict.inventorynumber
+                    research_id: $scope.results.hits[index].metas_dict.inventorynumber
                 };
                 Slide.save(newSlide);
             });
--- a/client/app/slideshow/slideshow.html	Thu Jul 16 15:14:27 2015 +0200
+++ b/client/app/slideshow/slideshow.html	Thu Oct 01 17:55:23 2015 +0200
@@ -4,7 +4,7 @@
                 {{book.title}}
                 <small>par Jonathan Linvingston</small>
             </h1>
-            <h1 class="pull-right poi"><small>{{book.count}} elts.</small></h1>
+            <h1 class="pull-right poi"><small>{{book.count}} objets</small></h1>
     </div>
     <div class="carousel-holder container">
         <carousel>
--- a/client/app/visites/visites_controller.js	Thu Jul 16 15:14:27 2015 +0200
+++ b/client/app/visites/visites_controller.js	Thu Oct 01 17:55:23 2015 +0200
@@ -26,7 +26,7 @@
             modalInstance.result.then(function (idBook) {
                 var newSlide = {
                     book: idBook,
-                    id_inventory: $scope.results.hits[index].metas_dict.inventorynumber
+                    research_id: $scope.results.hits[index].metas_dict.inventorynumber
                 };
                 Slide.save(newSlide);
             });