Commit ed1f669f authored by Renán Sosa Guillen's avatar Renán Sosa Guillen

product img error

parent c5a3ec78
...@@ -214,18 +214,16 @@ $(document).ready(function () { ...@@ -214,18 +214,16 @@ $(document).ready(function () {
console.log("DD: ", data); console.log("DD: ", data);
$.ajax({ $.ajax({
type: "POST", type: "GET",
url: img_req_url, url: img_req_url,
data: { data: {
'csrfmiddlewaretoken': document.getElementsByName('csrfmiddlewaretoken')[0].value, // 'csrfmiddlewaretoken': document.getElementsByName('csrfmiddlewaretoken')[0].value,
'value': data.product.link_icon 'value': data.product.link_icon
}, },
dataType: 'text', dataType: 'text',
success: function (response) { success: function (response) {
// console.log("from img response: ", response); var raw_img = response.toString("base64");
} console.log("from img response: ", raw_img);
});
var product_html = '<li id="' + data.id + ' class="hover-me">'+ var product_html = '<li id="' + data.id + ' class="hover-me">'+
'<a href="javascript:void(0)">'+ '<a href="javascript:void(0)">'+
'<i class="menu-icon glyphicon glyphicon-bookmark bg-red"></i>'+ '<i class="menu-icon glyphicon glyphicon-bookmark bg-red"></i>'+
...@@ -239,7 +237,8 @@ $(document).ready(function () { ...@@ -239,7 +237,8 @@ $(document).ready(function () {
// '<div class="col-12">'+ // '<div class="col-12">'+
'<div id="' + data.id + '-hover" class="item-info-view">'+ '<div id="' + data.id + '-hover" class="item-info-view">'+
'<div class="cropped-preview">'+ '<div class="cropped-preview">'+
'<img src="' + data.img + '">'+ // '<img src="' + data.img + '">'+
'<img src="data:image/jpeg;base64, ' + raw_img + '">'+
'</div>'+ '</div>'+
'<div class="polygon-item-data">'+ '<div class="polygon-item-data">'+
'<div class="city">' + data.product.identifier + '</div>'+ '<div class="city">' + data.product.identifier + '</div>'+
...@@ -269,6 +268,53 @@ $(document).ready(function () { ...@@ -269,6 +268,53 @@ $(document).ready(function () {
'</li>'; '</li>';
$('#product-list-globe').append(product_html); $('#product-list-globe').append(product_html);
}
});
// var product_html = '<li id="' + data.id + ' class="hover-me">'+
// '<a href="javascript:void(0)">'+
// '<i class="menu-icon glyphicon glyphicon-bookmark bg-red"></i>'+
// '<div class="menu-info">'+
// '<h4 class="control-sidebar-subheading">' + data.product.producttype + '_' + data.product.tileid + '</h4>'+
// '<p>' + data.product.beginposition + '</p>'+
// '</div>'+
// '</a>'+
// // '</li>'+
// // '<div id="' + data.id + '-hover" class="row">'+
// // '<div class="col-12">'+
// '<div id="' + data.id + '-hover" class="item-info-view">'+
// '<div class="cropped-preview">'+
// // '<img src="' + data.img + '">'+
// '<img src="data:image/jpeg;base64, ' + raw_img + '">'+
// '</div>'+
// '<div class="polygon-item-data">'+
// '<div class="city">' + data.product.identifier + '</div>'+
// '<p class="info">'+
// '<i class="fa fa-sync-alt"></i>'+
// '<span class="type">Size:</span><br>'+
// '<span class="data-info">' + data.product.size + '</span>'+
// '</p>'+
// '<p class="info">'+
// '<i class="fa fa-calendar-gear"></i>'+
// '<span class="type">Instrument:</span><br>'+
// '<span class="data-info">' + data.product.instrumentname + '</span>'+
// '</p>'+
// // '<p class="info">'+
// // '<i class="fa fa-cloud"></i>'+
// // '<span class="type">Cloud percentage:</span><br>'+
// // '<span class="data-info">' + data.product.cloudcoverpercentage + ' %</span>'+
// // '</p>'+
// '</div>'+
// // '<div class="button-add-del">'+
// // '<button type="button" class="btn btn-success">Add to cart</button> '+
// // '<button type="button" class="btn btn-danger">Remove</button>'+
// // '</div>'+
// '</div>'+
// // '</div>'+
// // '</div>'+
// '</li>';
//
// $('#product-list-globe').append(product_html);
}); });
} }
} }
......
...@@ -39,13 +39,15 @@ def map(request): ...@@ -39,13 +39,15 @@ def map(request):
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
def requestToImage(request): def requestToImage(request):
# print("REQUEST: ", request.POST['value']) # print("REQUEST: ", request.GET)
img_link = request.POST['value'] img_link = request.GET['value']
# img_link = img_link[:img_link.find("/") + 2] + "emmhp:geoemm29@" + img_link[img_link.find("/") + 2:] # img_link = img_link[:img_link.find("/") + 2] + "emmhp:geoemm29@" + img_link[img_link.find("/") + 2:]
r = requests.get(img_link, auth=("emmhp", "geoemm29")) r = requests.get(img_link, auth=("emmhp", "geoemm29"), stream=True)
# print("RAAAW: ", r.raw.read())
return JsonResponse({'img': r.content}) # return JsonResponse({'img': "hello"})
return HttpResponse(r.raw.read(), content_type="image/jpeg")
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
def productList(request): def productList(request):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment