Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
GeoInt_SIDT
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Mario Chirinos Colunga
GeoInt_SIDT
Commits
2f2942e8
Commit
2f2942e8
authored
Feb 12, 2019
by
Ulises Morales Ramírez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Log display
parent
0004dd6d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
17 deletions
+92
-17
Reports.html
reports/templates/Reports.html
+70
-13
views.py
reports/views.py
+22
-4
No files found.
reports/templates/Reports.html
View file @
2f2942e8
...
...
@@ -58,7 +58,7 @@
<ul
class=
"menu"
>
<li>
<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>
</li>
...
...
@@ -137,19 +137,19 @@
<th>
Purchase date
</th>
<th>
Start Date
</th>
<th>
End Date
</th>
<
th>
Clouds %
</th
>
<
!--th>Clouds %</th--
>
<th>
Progress %
</th>
<th>
Estimated Size
</th>
<th>
Actions
</th>
</thead>
<tbody>
{% for product in productList
%}
{% for product in productList%}
<tr>
<td>
{{product.process}}
</td>
<td>
{{product.purchase_date}}
</td>
<td>
{{product.startDate}}
</td>
<td>
{{product.endDate}}
</td>
<
td>
{{product.clouds}} %
</td
>
<
!--td>{{product.clouds}} %</td--
>
<td
class=
"text-center"
>
<div
class=
"progress"
>
<div
class=
"progress-bar"
role=
"progressbar"
aria-valuenow=
"{{product.progress}}"
...
...
@@ -159,21 +159,53 @@
</div>
</div>
</td>
<td>
{{product.size}}
MB
</td>
<td>
{{product.size}}
</td>
<td
class=
"text-center"
>
<a
href=
"{{ BASE_URL }}/reports/T15QZD_sclData/{{product.purchase_id}}"
class=
"btn btn-success"
>
<a
title=
"View Report"
{%
if
product
.
progress =
=
100
%}
href=
"{{ BASE_URL }}/reports/T15QZD_sclData/{{product.purchase_id}}"
{%
else
%}
href=
"#"
disabled
{%
endif
%}
class=
"btn btn-success"
>
<i
class=
"fa fa-eye"
></i>
</a>
<a
href=
"{{ BASE_URL }}/reports/T15QZD_sclData/{{product.purchase_id}}"
class=
"btn btn-info"
>
<i
class=
"fa fa-file-archive-o"
></i>
<a
title=
"Download zip"
{%
if
product
.
progress =
=
100
%}
href=
"#"
{%
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>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<ul
class=
"pagination"
>
{% if productList.has_previous %}
<li><a
href=
"?page={{ productList.previous_page_number }}"
>
«
</a></li>
{% else %}
<li
class=
"disabled"
><span>
«
</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 }}"
>
»
</a></li>
{% else %}
<li
class=
"disabled"
><span>
»
</span></li>
{% endif %}
<li
class=
"disabled"
><span>
Page {{ productList.number }} of {{ productList.paginator.num_pages }}.
</span></li>
</ul>
</div>
</div>
...
...
@@ -224,10 +256,35 @@
<!-- Copyright -->
</footer>
<!-- Footer -->
<!-- /.Footer -->
<!-- Modals -->
<div
id=
"myModal"
class=
"modal fade"
role=
"dialog"
>
<div
class=
"modal-dialog"
>
<!-- /.content -->
<!-- Modal content-->
<div
class=
"modal-content"
>
<div
class=
"modal-header"
>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
>
×
</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>
</div>
</div>
<!-- /.modals -->
{% endblock %}
{% block scripts %}
{% block scripts %}
<script>
function
openmodal
(
info
)
{
$
(
"#myModal"
).
modal
();
$
(
"#log_info"
).
append
(
info
);
}
</script>
{% endblock%}
\ No newline at end of file
reports/views.py
View file @
2f2942e8
...
...
@@ -2,6 +2,8 @@
from
__future__
import
unicode_literals
import
io
from
django.core.paginator
import
Paginator
from
django.http
import
FileResponse
from
reportlab.pdfgen
import
canvas
from
django.shortcuts
import
render
...
...
@@ -78,6 +80,7 @@ def report_L2ASCL(request, report,purchase_id):
def
Reports
(
request
):
progress
=
0
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
)
for
producto
in
product_list
:
log_info
=
USERS_PATH
+
request
.
user
.
email
+
"/"
+
str
(
producto
[
'id'
])
+
"/L2ASCL_AreaProcessing.log"
...
...
@@ -93,20 +96,35 @@ def Reports(request):
progress
=
50
if
'Extracting SCL information...'
in
open
(
log_info
)
.
read
():
progress
=
60
size
=
0
with
open
(
log_info
,
'r'
)
as
myfile
:
log
=
myfile
.
read
()
.
replace
(
'
\n
'
,
''
)
for
p
in
json
.
loads
(
producto
[
'productList'
]):
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
({
"process"
:
producto
[
'search__process_id__name'
],
"purchase_date"
:
producto
[
'aggreg_date'
],
"startDate"
:
producto
[
'search__startDate'
],
"endDate"
:
producto
[
'search__endDate'
],
"clouds"
:
producto
[
'search__clouds'
],
"size"
:
size
,
"size"
:
final_
size
,
"purchase_id"
:
producto
[
'id'
],
"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
})
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment