1/** 2 * @class Product 3 * @classdesc Permet de récupérer des infos sur un produit 4 */ 5ProductKristal.factory('Product', function(API, $http, $httpOnce) { 6 return { 7 getByPN: function(pn) { 8 return $httpOnce(API.getUrl() + '/api/products/search-pn/' + pn, { 9 pn: pn, 10 }); 11 }, 12 getStockByPN: function(pn) { 13 return $httpOnce(API.getUrl() + '/api/products/search-stock-pn/' + pn, { 14 pn: pn, 15 }); 16 }, 17 getAlternatesByPN: function(pn) { 18 return $httpOnce(API.getUrl() + '/api/products/search-alternates-pn/' + pn, { 19 pn: pn, 20 }); 21 }, 22 getSalesByPN: function(pn) { 23 return $httpOnce(API.getUrl() + '/api/products/search-sales-pn/' + pn, { 24 pn: pn, 25 }); 26 } 27 }; 28}) 29 30 31 32 33 34/** @function ProductCtrl 35 * @memberof module:ProductKristal 36 * @namespace ProductCtrl 37 * @description Gère la fiche produit 38 * 39 */ 40ProductKristal.controller('ProductCtrl', function(Analytics, $route, Tools, Translate, $mdDialog, $location, $locale, Product, $routeParams, $cookies, $rootScope, $scope, $timeout, $mdSidenav, $log, $q) { 41 42 43 Translate.init(); 44 $rootScope.title = "Produit"; 45 $scope.lang = Tools.getCurrentLanguage(); 46 $rootScope.search_history = []; 47 $rootScope.header = { header: null, img: null }; 48 $rootScope.stock = []; 49 $rootScope.edito = []; 50 51 $rootScope.alternates = []; 52 $rootScope.selling = []; 53 54 $rootScope.showNotFoundPn = false; 55 $rootScope.spinnerHeader = true; 56 $rootScope.spinnerStock = true; 57 $rootScope.spinnerAlternates = true; 58 $rootScope.spinnerSelling = true; 59 $scope.avatar = Tools.getAvatar(); 60 61 62 $scope.trustAsHtml = function(content) { 63 if (typeof content !== 'undefined' && typeof content !== 'null') { 64 return Tools.trustAsHtml(content); 65 } else { 66 return ""; 67 } 68 69 } 70 71 if (typeof $cookies.getObject('termshistory') != "undefined") { 72 $scope.search_history = $cookies.getObject('termshistory'); 73 } 74 75 $rootScope.$on('$translateChangeEnd', function(event) { 76 $scope.lang = Tools.getCurrentLanguage(); 77 }); 78 79 80 if (typeof $routeParams.pn == "undefined") { 81 $rootScope.showNotFoundPn = true; 82 } else { 83 84 //Analytics.trackEvent('Fiche produit', $routeParams.pn, $routeParams.pn); 85 86 87 88 $rootScope.header = { img: "", category: "" }; 89 90 console.log(Product.getByPN($routeParams.pn)); 91 Product.getByPN($routeParams.pn).then(function(res, status) { 92 $timeout(function() { 93 94 $rootScope.header = res.data.header; 95 $rootScope.tags = res.data.tags; 96 97 $rootScope.spinnerHeader = false;
98 99 if (typeof $rootScope.header != "undefined" && $rootScope.header !== null) { 100 $rootScope.header.img = res.data.img; 101 $rootScope.header.category = res.data.category; 102 103 $rootScope.header.OVHL_FLAG = ($rootScope.header.OVHL_FLAG == 'T' ? true : false); 104 $rootScope.header.REPAIR_FLAG = ($rootScope.header.REPAIR_FLAG == 'T' ? true : false); 105 $rootScope.header.CERT_FLAG = ($rootScope.header.CERT_FLAG == 'T' ? true : false); 106 $rootScope.header.DIST_FLAG = ($rootScope.header.DIST_FLAG == 'T' ? true : false); 107 108 109 110 } else { 111 $rootScope.showNotFoundPn = true; 112 } 113 114 115 116 }, 500); 117 }); 118 119 $timeout(function() { 120 Product.getStockByPN($routeParams.pn).then(function(res, status) { 121 $rootScope.stock = res.data; 122 $rootScope.spinnerStock = false; 123 124 console.log($rootScope.stock); 125 126 }); 127 }, 600); 128 129 130 $timeout(function() { 131 Product.getAlternatesByPN($routeParams.pn).then(function(res, status) { 132 $rootScope.alternates = res.data; 133 $rootScope.spinnerAlternates = false; 134 135 console.log($rootScope.alternates); 136 137 }); 138 }, 1200); 139 140 141 $timeout(function() { 142 Product.getSalesByPN($routeParams.pn).then(function(res, status) { 143 console.log(res); 144 $rootScope.selling = res.data; 145 $rootScope.spinnerSelling = false; 146 }); 147 }, 1800); 148 149 } 150 151 152 153 $rootScope.loadSearchTerm = function($event, value) { 154 console.log(value); 155 $rootScope.widget = 'search'; 156 $rootScope.$broadcast('RELOAD_SEARCH', { 157 term: value, 158 event: $event 159 }); 160 if (value.length == 1) { 161 $location.path('fr/product/' + value[0]); 162 window.location.reload(); 163 164 } else { 165 var alert = $mdDialog.alert() 166 .title($filter('translate')('LOAD_HISTORY')) 167 .content($filter('translate')('LOADING_IMPOSSIBLE')) 168 .ok('OK'); 169 170 $mdDialog.show(alert) 171 .finally(function() { 172 alert = undefined; 173 }); 174 } 175 176 } 177 178 179})
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.