1'use strict'; 2 3(function(angular) { 4 5 angular.module('BruSo.visitor').controller('ResultsController', ['$location', '$routeParams', '$scope', '$http', '$translate', 'Results','Maps', 'TRANSLATE', 'MyFolders', 'Spinner', 6 function ($location, $routeParams, $scope, $http, $translate, Results,Maps, TRANSLATE, MyFolders, Spinner) { 7 8 $scope.organisations = Results.getOrganisations(); 9 $scope.categories = Results.getCategories(); 10 $scope.filters = Results.getFilters(); 11 $scope.selection = {}; 12 $scope.hasSelectedAllOrganisations =true; 13 if(!$scope.myfolders) { 14 $scope.myfolders = []; 15 } 16 $scope.show = Results.getShowOptions(); 17 18 // If only 1, redirect to the organisation page instead of results. 19 if( $scope.organisations && $scope.organisations.length === 1 && ($scope.filters.organisationName 20 || ($scope.filters.numberCompany && $scope.filters.numberCompany.length > 0) 21 ||($scope.filters.organisationIds && $scope.filters.organisationIds.length == 1)) ) { 22 $location.path( "/organisation/" + $scope.organisations[0].id); 23 } 24 25 // Get MyBruso 26 MyFolders.updateMyFolders($scope); 27 28 $scope.organisationListId = []; 29 $scope.postPrintOptions = postPrintOptions; 30 $scope.filteredOrganisations = []; 31 $scope.hideSpinner = function(){ 32 Spinner.hideSpinner(); 33 } 34 35 console.log(" Results Controller"); 36 $scope.$on('startPostRequestTest', function(event,args){ 37 console.log("YES"); 38 console.log(args); 39 $scope.$emit('showMapToggle',{array : args.array}); 40 $scope.$broadcast('showMapToggle',{array : args.array}); 41 42 }); 43 $scope.$on('startPostRequest', function(event,args){ 44 console.log("Printing",args.array); 45 46 postPrintOptions(args.array); 47 }); 48 49 $scope.$on('updatedOrganisationsList', function(event,args){ 50 51 if($scope.organisationListId.includes(args.organisation.id)){ 52 console.log("to delete",args.organisation); 53 $scope.organisationListId.splice( 54 $scope.organisationListId.indexOf(args.organisation.id),1 ); 55 56 var index = $scope.filteredOrganisations.map(function(item) { 57 console.log("item in delete", item); 58 return item.id; 59 }).indexOf(args.organisation.id); 60 61 $scope.filteredOrganisations.splice(index, 1); 62 63 console.log("AFTER FILTER"); 64 console.log("$scope.organisationListId",$scope.organisationListId,$scope.organisationListId.length); 65 console.log(" $scope.filteredOrganisations ", $scope.filteredOrganisations, $scope.filteredOrganisations.length); 66 67 $scope.hasSelectedAllOrganisations = false; 68 document.getElementById("printAllCheckbox").checked = false; 69 }else{ 70 $scope.organisationListId.push(args.organisation.id); 71 $scope.filteredOrganisations.push(args.organisation); 72 } 73 console.log("adding :",$scope.filteredOrganisations); 74 Maps.addOrganisationsToMap(Maps.miniMap,$scope.filteredOrganisations); 75 76 }); 77 $scope.$on('startPostRequestBooklet', function(event,args){ 78 console.log("received booklet"); 79 printBooklet(args.array); 80 }); 81 82 function printBooklet(optionsToPrint){ 83 console.log("before if",optionsToPrint); 84 console.log(Results.getFilters()); 85 86 var printOptions = optionsToPrint; 87 if(!$scope.hasSelectedAllOrganisations){ 88 printOptions.organisationListId = []; 89 } 90 91 if( $scope.organisationListId && $scope.organisationListId.length > 0) 92 { 93 printOptions.organisationListId = $scope.organisationListId; 94 } 95 96 if($scope.organisation && $scope.organisation.id){ 97 printOptions.organisationListId = []; 98 printOptions.organisationListId[0] = $scope.organisation.id; 99 } 100 101 if(printOptions.organisationListId && printOptions.organisationListId.length>0){ 102 103 printOptions.topicTree = Results.getFilters().topicTree; 104 var apiPath = $location.absUrl().replace($location.url(), '') + '/rest/organisation/createSocialeGuidsDoc'; 105 $http({ 106 url: apiPath, 107 method: 'POST', 108 responseType: 'blob', 109 data: printOptions, 110 headers: {'Accept-Language' : $scope.lang()}}) 111 112 .then(function(response){ 113 var content = response.data; 114 115 //Creating a bloc containing the file data 116 var blob = new Blob([ content ], { type : 'application/octet-stream; charset=utf-8',encoding: 'utf-8'}); 117 118 //Getting the file name out of the header 119 var contentDisposition = response.headers('Content-Disposition'); 120 var filename = contentDisposition.split(';')[1].split('filename')[1].split('=')[1].trim(); 121 filename = filename.slice(1); 122 filename = filename.slice(0, filename.length - 1); 123 124 //Creating a link to provoke the downloading 125 var a = document.createElement("a"); 126 a.href = window.URL.createObjectURL(blob); 127 a.download = filename; 128 a.click(); 129 angular.element('#spinnerModal').modal('hide'); 130 }); 131 } else if(!printOptions.organisationListId || printOptions.organisationListId.length == 0) { 132 alert($translate.instant('printOptions.NoOrganisationSelected')); 133 } 134 135 } 136 137 138 $scope.$on('updateSelectAll',function(){ 139 if($scope.hasSelectedAllOrganisations){ 140 $scope.hasSelectedAllOrganisations = false;
141 $scope.organisationListId = []; 142 $scope.filteredOrganisations = []; 143 $scope.organisations.forEach(element => { 144 145 var checkbox = document.getElementById(element.id); 146 if(checkbox != null){ 147 document.getElementById(element.id).checked = false; 148 } 149 }); 150 151 }else{ 152 $scope.hasSelectedAllOrganisations = true; 153 154 $scope.organisationListId = []; 155 $scope.organisations.forEach(element => { 156 console.log("element",element); 157 var checkbox = document.getElementById(element.id); 158 if(checkbox != null){ 159 document.getElementById(element.id).checked = true; 160 } 161 $scope.organisationListId.push(element.id); 162 163 $scope.filteredOrganisations.push(element); 164 console.log("org",element.organisation); 165 }); 166 $scope.$broadcast('showClustersSelectAll'); 167 } 168 Maps.addOrganisationsToMap(Maps.miniMap,$scope.filteredOrganisations); 169 170 }); 171 172 function postPrintOptions(optionsToPrint){ 173 console.log("addedOrganisations",Maps.addedOrganisaitons); 174 175 var printOptions = optionsToPrint; 176 if(!$scope.hasSelectedAllOrganisations){ 177 printOptions.organisationListId = []; 178 } 179 if( $scope.organisationListId && $scope.organisationListId.length > 0) 180 { 181 printOptions.organisationListId = $scope.organisationListId; 182 } 183 184 185 186 if($scope.organisation && $scope.organisation.id){ 187 printOptions.organisationListId = []; 188 printOptions.organisationListId[0] = $scope.organisation.id; 189 } 190 191 192 if(printOptions.organisationListId && printOptions.organisationListId.length>0){ 193 console.log(printOptions); 194 195 var apiPath = $location.absUrl().replace($location.url(), '') + '/rest/organisation/detailsOrganisations/'; 196 $http({ 197 url: apiPath, 198 method: 'POST', 199 responseType: 'blob', 200 data: printOptions, 201 headers: {'Accept-Language' : $scope.lang()}}) 202 .then(function(response){ 203 var content = response.data; 204 205 //Creating a bloc containing the file data 206 var blob = new Blob([ content ], { type : 'application/octet-stream'}); 207 208 //Getting the file name out of the header 209 var contentDisposition = response.headers('Content-Disposition'); 210 var filename = contentDisposition.split(';')[1].split('filename')[1].split('=')[1].trim(); 211 filename = filename.slice(1); 212 filename = filename.slice(0, filename.length - 1); 213 214 //Creating a link to provoque the downloading 215 var a = document.createElement("a"); 216 a.href = window.URL.createObjectURL(blob); 217 a.download = filename; 218 a.click(); 219 angular.element('#spinnerModal').modal('hide'); 220 221 222 }); 223 } else if(!printOptions.organisationListId || printOptions.organisationListId.length == 0) { 224 alert($translate.instant('printOptions.NoOrganisationSelected')); 225 } 226 227 228 } 229 } 230 ] 231 ); 232})(angular);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.