Commit 8da5fe05 authored by Ulises Morales Ramírez's avatar Ulises Morales Ramírez

Merge branch 'log_display' into 'dev'

Log display

See merge request !11
parents 0004dd6d 2f2942e8
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
<ul class="menu"> <ul class="menu">
<li> <li>
<a href="#"> <a href="#">
<i class="fa fa-users text-aqua"></i> 5 new members joined today <i class="fa fa-productList text-aqua"></i> 5 new members joined today
</a> </a>
</li> </li>
...@@ -137,19 +137,19 @@ ...@@ -137,19 +137,19 @@
<th>Purchase date</th> <th>Purchase date</th>
<th>Start Date</th> <th>Start Date</th>
<th>End Date</th> <th>End Date</th>
<th>Clouds %</th> <!--th>Clouds %</th-->
<th>Progress %</th> <th>Progress %</th>
<th>Estimated Size</th> <th>Estimated Size</th>
<th>Actions</th> <th>Actions</th>
</thead> </thead>
<tbody> <tbody>
{% for product in productList %} {% for product in productList%}
<tr> <tr>
<td>{{product.process}}</td> <td>{{product.process}}</td>
<td>{{product.purchase_date}}</td> <td>{{product.purchase_date}}</td>
<td>{{product.startDate}}</td> <td>{{product.startDate}}</td>
<td>{{product.endDate}}</td> <td>{{product.endDate}}</td>
<td>{{product.clouds}} %</td> <!--td>{{product.clouds}} %</td-->
<td class="text-center"> <td class="text-center">
<div class="progress"> <div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="{{product.progress}}" <div class="progress-bar" role="progressbar" aria-valuenow="{{product.progress}}"
...@@ -159,21 +159,53 @@ ...@@ -159,21 +159,53 @@
</div> </div>
</div> </div>
</td> </td>
<td>{{product.size}} MB</td> <td>{{product.size}}</td>
<td class="text-center"> <td class="text-center">
<a href="{{ BASE_URL }}/reports/T15QZD_sclData/{{product.purchase_id}}" <a title="View Report" {% if product.progress == 100 %}
class="btn btn-success"> href="{{ BASE_URL }}/reports/T15QZD_sclData/{{product.purchase_id}}"
{% else %}
href="#"
disabled
{% endif %} class="btn btn-success">
<i class="fa fa-eye"></i> <i class="fa fa-eye"></i>
</a> </a>
<a href="{{ BASE_URL }}/reports/T15QZD_sclData/{{product.purchase_id}}" <a title="Download zip" {% if product.progress == 100 %}
class="btn btn-info"> href="#"
<i class="fa fa-file-archive-o"></i> {% else %}
href="#"
disabled
{% endif %} class="btn btn-warning">
<i class="fa fa-file-zip-o"></i>
</a>
<a title="View Log" href="#" class="btn btn-info" onclick="openmodal('{{product.log_info}}')">
<i class="fa fa-file-text"></i>
</a> </a>
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
<ul class="pagination">
{% if productList.has_previous %}
<li><a href="?page={{ productList.previous_page_number }}">&laquo;</a></li>
{% else %}
<li class="disabled"><span>&laquo;</span></li>
{% endif %}
{% for i in productList.paginator.page_range %}
{% if productList.number == i %}
<li class="active"><span>{{ i }} <span class="sr-only">(current)</span></span></li>
{% else %}
<li><a href="?page={{ i }}">{{ i }}</a></li>
{% endif %}
{% endfor %}
{% if productList.has_next %}
<li><a href="?page={{ productList.next_page_number }}">&raquo;</a></li>
{% else %}
<li class="disabled"><span>&raquo;</span></li>
{% endif %}
<li class="disabled"><span>Page {{ productList.number }} of {{ productList.paginator.num_pages }}.</span></li>
</ul>
</div> </div>
</div> </div>
...@@ -224,10 +256,35 @@ ...@@ -224,10 +256,35 @@
<!-- Copyright --> <!-- Copyright -->
</footer> </footer>
<!-- Footer --> <!-- /.Footer -->
<!-- Modals -->
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Log file</h4>
</div>
<div class="modal-body" style="overflow-y: auto; height: 250px;">
<p id="log_info"></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
<!-- /.content --> </div>
</div>
<!-- /.modals -->
{% endblock %} {% endblock %}
{% block scripts %}
{% block scripts %}
<script>
function openmodal(info) {
$("#myModal").modal();
$("#log_info").append(info);
}
</script>
{% endblock%} {% endblock%}
\ No newline at end of file
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import io import io
from django.core.paginator import Paginator
from django.http import FileResponse from django.http import FileResponse
from reportlab.pdfgen import canvas from reportlab.pdfgen import canvas
from django.shortcuts import render from django.shortcuts import render
...@@ -78,6 +80,7 @@ def report_L2ASCL(request, report,purchase_id): ...@@ -78,6 +80,7 @@ def report_L2ASCL(request, report,purchase_id):
def Reports(request): def Reports(request):
progress = 0 progress = 0
productList=[] productList=[]
size = 0
product_list = Purchase.objects.values('id','productList','aggreg_date','search__clouds' ,'search__startDate', 'search__endDate','search__process_id__name').filter(user_id=request.user.id, purchased=1) product_list = Purchase.objects.values('id','productList','aggreg_date','search__clouds' ,'search__startDate', 'search__endDate','search__process_id__name').filter(user_id=request.user.id, purchased=1)
for producto in product_list: for producto in product_list:
log_info = USERS_PATH + request.user.email + "/" + str(producto['id']) + "/L2ASCL_AreaProcessing.log" log_info = USERS_PATH + request.user.email + "/" + str(producto['id']) + "/L2ASCL_AreaProcessing.log"
...@@ -93,20 +96,35 @@ def Reports(request): ...@@ -93,20 +96,35 @@ def Reports(request):
progress = 50 progress = 50
if 'Extracting SCL information...' in open(log_info).read(): if 'Extracting SCL information...' in open(log_info).read():
progress = 60 progress = 60
with open(log_info, 'r') as myfile:
log = myfile.read().replace('\n', '')
size = 0
for p in json.loads(producto['productList']): for p in json.loads(producto['productList']):
size = size + float(p['info']['size'][:-3]) size = size + float(p['info']['size'][:-3])
if size > 1000:
size2 = size/1000
final_size = str(round(size2,2)) + " GB"
else:
final_size = str(round(size,2))+ " MB"
productList.append({ productList.append({
"process" : producto['search__process_id__name'], "process" : producto['search__process_id__name'],
"purchase_date": producto['aggreg_date'], "purchase_date": producto['aggreg_date'],
"startDate": producto['search__startDate'], "startDate": producto['search__startDate'],
"endDate": producto['search__endDate'], "endDate": producto['search__endDate'],
"clouds": producto['search__clouds'], "clouds": producto['search__clouds'],
"size": size, "size": final_size,
"purchase_id": producto['id'], "purchase_id": producto['id'],
"progress": progress, "progress": progress,
"log_info": log,
}) })
##############################################
# paginacion #
##############################################
paginator = Paginator(productList, 10) # Show 25 contacts per page
page = request.GET.get('page')
productList = paginator.get_page(page)
return render(request, 'Reports.html', {"productList": productList}) return render(request, 'Reports.html', {"productList": productList})
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