Commit 9d5a11c3 authored by Irving David's avatar Irving David

Cambia el mensaje de la barra de progreso de acuerdo al log

parent 6f3bcc74
...@@ -25,9 +25,8 @@ function refresh() { ...@@ -25,9 +25,8 @@ function refresh() {
dataType: "json", dataType: "json",
url: '../reports/ws/process_progress', url: '../reports/ws/process_progress',
success: function (data) { success: function (data) {
$.each(data, function (key, val) { $.each(data, function (key, val) {
//console.log(key+ " purchase_id:"+val.purchase_id+", progress: "+val.progress); //~ console.log(key+ " purchase_id:"+val.purchase_id+", progress: "+val.progress);
if (val.progress != 100) { if (val.progress != 100) {
$('#progress_bar' + val.purchase_id).attr("aria-valuenow", val.progress); $('#progress_bar' + val.purchase_id).attr("aria-valuenow", val.progress);
$('#progress_bar' + val.purchase_id).attr('style', 'width:' + val.progress + '%'); $('#progress_bar' + val.purchase_id).attr('style', 'width:' + val.progress + '%');
...@@ -37,6 +36,8 @@ function refresh() { ...@@ -37,6 +36,8 @@ function refresh() {
$('#action_buttons' + val.purchase_id).attr("class", "hidden"); $('#action_buttons' + val.purchase_id).attr("class", "hidden");
$('#main_progess' + val.purchase_id).removeClass("hidden"); $('#main_progess' + val.purchase_id).removeClass("hidden");
$('#main_progess' + val.purchase_id).attr("class", "progress"); $('#main_progess' + val.purchase_id).attr("class", "progress");
$('#textprogress'+ val.purchase_id).empty();
$('#textprogress'+ val.purchase_id).append(val.progress_text);
} }
else { else {
//$('#progress_bar' + val.purchase_id).attr("class", "progress-bar progress-bar-success progress-bar-striped"); //$('#progress_bar' + val.purchase_id).attr("class", "progress-bar progress-bar-success progress-bar-striped");
......
...@@ -215,8 +215,8 @@ ...@@ -215,8 +215,8 @@
class="progress-bar progress-bar-warning progress-bar-striped active" class="progress-bar progress-bar-warning progress-bar-striped active"
aria-valuemin="0" aria-valuemax="100" aria-valuemin="0" aria-valuemax="100"
style="width:{{ product.progress }}%"> style="width:{{ product.progress }}%">
<p style="color: #0a0a0a"> <p id="textprogress{{ product.purchase_id }}" style="color: #0a0a0a">
Downloading Downloading...
</p> </p>
</div> </div>
</div> </div>
......
...@@ -210,6 +210,7 @@ def Reports(request): ...@@ -210,6 +210,7 @@ def Reports(request):
# ------------------------------------------------------------------------ # ------------------------------------------------------------------------
def wsProcessProgress(request): def wsProcessProgress(request):
print(request);
if request.is_ajax(): if request.is_ajax():
progress = 0 progress = 0
productList2 = [] productList2 = []
...@@ -223,19 +224,37 @@ def wsProcessProgress(request): ...@@ -223,19 +224,37 @@ def wsProcessProgress(request):
##################################################### #####################################################
# progress bar # # progress bar #
##################################################### #####################################################
progress_text = ""
if os.stat(log_info).st_size == 0: if os.stat(log_info).st_size == 0:
progress = 0 progress = 0
else: else:
if 'Linking Products...' in open(log_info).read(): if 'Starting Process...' in open(log_info).read():
progress = 10
progress_text = 'Processing...'
if 'Creating Shape file...' in open(log_info).read():
progress = 20 progress = 20
progress_text = 'Creating Shape file...'
if 'Linking Products...' in open(log_info).read():
progress = 30
progress_text = 'Linking Products...'
if 'Merging Images...' in open(log_info).read(): if 'Merging Images...' in open(log_info).read():
progress = 40 progress = 40
if 'Deleting Images...' in open(log_info).read(): progress_text = 'Merging Images...'
if 'Applying Mask...' in open(log_info).read():
progress = 50 progress = 50
progress_text = 'Applying Mask...'
if 'Extracting SCL information...' in open(log_info).read(): if 'Extracting SCL information...' in open(log_info).read():
progress = 60 progress = 60
progress_text = 'Extracting SCL information...'
if 'Spliting SCL image...' in open(log_info).read():
progress = 70
progress_text = 'Spliting SCL image...'
if 'Creating Tiles...' in open(log_info).read():
progress = 90
progress_text = 'Creating Tiles...'
if 'Finalizing...' in open(log_info).read(): if 'Finalizing...' in open(log_info).read():
progress = 100 progress = 100
progress_text = 'Finalizing...'
# item = Purchase.objects.get(pk=producto['id']) # item = Purchase.objects.get(pk=producto['id'])
# item.progress = progress # item.progress = progress
...@@ -244,6 +263,7 @@ def wsProcessProgress(request): ...@@ -244,6 +263,7 @@ def wsProcessProgress(request):
productList2.append({ productList2.append({
"purchase_id": producto['id'], "purchase_id": producto['id'],
"progress": progress, "progress": progress,
"progress_text":progress_text,
}) })
progress = 0 progress = 0
...@@ -258,6 +278,7 @@ def wsProcessProgress(request): ...@@ -258,6 +278,7 @@ def wsProcessProgress(request):
# }) # })
return HttpResponse(json.dumps(productList2)) return HttpResponse(json.dumps(productList2))
else: else:
print("Error Http404")
raise Http404 raise Http404
......
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