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
39e1bff8
Commit
39e1bff8
authored
Mar 01, 2019
by
Ulises Morales Ramírez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard
parent
09a55449
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
78 additions
and
84 deletions
+78
-84
dashboard.html
administration/templates/dashboard.html
+45
-42
views.py
administration/views.py
+29
-38
views.py
reports/views.py
+4
-4
No files found.
administration/templates/dashboard.html
View file @
39e1bff8
...
...
@@ -334,7 +334,7 @@
<div
class=
"col-md-12"
>
<div
class=
"box box-success"
>
<div
class=
"box-header with-border"
>
<h3
class=
"box-title"
>
Purchases Per Month
</h3>
<h3
class=
"box-title"
id=
"purchases_in"
>
Purchases Per Month
</h3>
<div
class=
"box-tools pull-right"
>
<button
type=
"button"
class=
"btn btn-box-tool"
data-widget=
"collapse"
><i
...
...
@@ -346,29 +346,9 @@
<div
class=
"box-body"
>
<div
class=
"row"
>
<div
class=
"col-md-12"
>
<p
class=
"text-center"
>
<strong>
February
</strong>
</p>
<div>
<table
class=
"table table-hover"
>
<thead>
<tr>
<th>
User
</th>
<th>
Purchases
</th>
<th>
Storage %
</th>
<th>
Downloads in process
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
John
</td>
<td>
12
</td>
<td>
200 MB
</td>
<td>
0
</td>
</tr>
</tbody>
</table>
<div
id=
"mostrar"
>
</div>
<!-- /.chart-responsive -->
</div>
...
...
@@ -456,7 +436,6 @@
</li>
</ul>
<!-- Social buttons -->
</div>
<!-- Footer Elements -->
...
...
@@ -466,6 +445,9 @@
</div>
<!-- Copyright -->
</footer>
{% if messages %}
<div
class=
"container col-md-2 col-lg-2 col-xs-2 col-sm-2"
style=
"bottom: 0; right: 0;position: absolute"
>
...
...
@@ -535,9 +517,10 @@
});
$
(
document
).
ready
(
function
()
{
$
(
'#example'
).
DataTable
/*
$(document).ready(function () {
var table =
$('#example').DataTable
({
"ajax": data,
language:
{
"sProcessing": "Procesando...",
...
...
@@ -581,7 +564,7 @@
}],
order: [1, 'asc']
});
});
});
*/
// mostrar imagen al dar click en los puntos
...
...
@@ -591,32 +574,52 @@
var
firstPoint
=
activePoint
[
0
];
var
label
=
myChart
.
data
.
labels
[
firstPoint
.
_index
];
//if (!firstPoint) return;
$
(
'#purchases_in'
).
empty
();
$
(
'#purchases_in'
).
append
(
"Purchases in "
+
label
);
$
.
ajax
({
type
:
'POST'
,
dataType
:
"json"
,
data
:
{
'title'
:
label
},
data
:
{
'title'
:
label
},
url
:
'../administration/ws/report_table'
,
success
:
function
(
data
)
{
alert
(
data
);
$
(
'#mostrar'
).
empty
();
$
(
'#mostrar'
).
append
(
"<table class=
\"
table table-hover
\"
id=
\"
example
\"
>"
+
"<thead>"
+
"<tr>"
+
"<th class=
\"
text-center
\"
>User ID</th>"
+
"<th class=
\"
text-center
\"
>User</th>"
+
"<th class=
\"
text-center
\"
>E-Mail</th>"
+
"<th class=
\"
text-center
\"
>Purchases</th>"
+
"<th class=
\"
text-center
\"
>Storage</th>"
+
"<th class=
\"
text-center
\"
>Downloads in process</th>"
+
"</tr>"
+
"</thead>"
+
"<tbody id=
\"
tbody
\"
class=
\"
text-center
\"
>"
);
$
.
each
(
data
,
function
(
key
,
val
)
{
$
(
"#tbody"
).
append
(
"<tr>"
+
"<td>"
+
val
[
'user_id'
]
+
"</td>"
+
"<td>"
+
val
[
'username'
]
+
"</td>"
+
"<td>"
+
val
[
'email'
]
+
"</td>"
+
"<td>"
+
val
[
'purchases'
]
+
"</td>"
+
"<td>"
+
val
[
'storage'
]
+
"</td>"
+
"<td>"
+
val
[
'in_process'
]
+
"</td>"
+
"</tr>"
);
});
$
(
'#mostrar'
).
append
(
"</tbody>"
+
"</table>"
);
$
(
'#example'
).
DataTable
({
});
}
});
};
function
refresh
()
{
$
.
ajax
({
type
:
'POST'
,
dataType
:
"json"
,
data
:
{
'title'
:
label
},
url
:
'../administration/ws/report_table'
,
success
:
function
(
data
)
{
alert
(
data
);
}
});
};
</script>
{% endblock %}
\ No newline at end of file
administration/views.py
View file @
39e1bff8
...
...
@@ -19,6 +19,7 @@ from catalog.models import Purchase, Search
from
catalog.views
import
config
USERS_PATH
=
config
[
'PATHS'
][
'PATH_NAS'
]
PATH_USERS
=
config
[
'PATHS'
][
'PATH_USERS'
]
size_sentinel
=
0
size_repsat
=
0
#------------------------------------------------------------
...
...
@@ -52,7 +53,7 @@ def Dashboard(request):
{
'quantity'
:
0
,
'date'
:
'December'
}]
# Obtener el nombre del mes #
for
date
in
Purchase
.
objects
.
filter
()
.
extra
({
'month'
:
"Extract(month from aggreg_date)"
})
.
values_list
(
for
date
in
Purchase
.
objects
.
filter
(
purchased
=
True
)
.
extra
({
'month'
:
"Extract(month from aggreg_date)"
})
.
values_list
(
'month'
)
.
annotate
(
Count
(
'id'
)):
date_name
=
calendar
.
month_name
[
int
(
date
[
0
])]
...
...
@@ -161,46 +162,36 @@ def active_users(request):
# ----------------------------------------------------------------------
# @csrf_exempt
# def wsPurchasesPM (request):
# if request.is_ajax():
# message = "Yes, AJAX!"
# id = request.user.id
#
# else:
# message = "Not Ajax"
#
# #
#
# return HttpResponse(message)
@
csrf_exempt
def
wsPurchasesPM
(
request
):
global
mes
# print(request.POST.get('title'))
if
request
.
is_ajax
():
date_list
=
Purchase
.
objects
.
dates
(
'aggreg_date'
,
'month'
)
for
meses
in
date_list
:
datee
=
datetime
.
datetime
.
strptime
(
str
(
meses
),
"
%
Y-
%
m-
%
d"
)
mes
=
calendar
.
month_name
[
int
(
datee
.
month
)]
# print(mes)
# data =Purchase.objects.filter(Q(date__month=1) | Q(date__month=2) | Q(date__month=3))
# data = Purchase.objects.values('user__username').filter(Q(aggreg_date__month=to_if(mes))|Q(user__purchase_user_id = user__user_id))
# data = Purchase.objects.values('user__username').filter(aggreg_date__month=to_if(mes)).annotate(count=Count('user_id')).order_by('-count')[:1]
data
=
Purchase
.
objects
.
values
(
'id'
,
'user__username'
,
'aggreg_date'
,
'search__clouds'
,
'search__startDate'
,
'search__endDate'
,
'search__process_id__name'
)
.
filter
(
aggreg_date__month
=
to_if
(
mes
))
.
annotate
(
count_purchases
=
Count
(
'id'
))
.
order_by
(
'id'
)
print
(
data
)
for
dato
in
data
:
print
(
dato
[
'count_purchases'
])
# return HttpResponse(json.dumps(request.POST.get('title')))
return
HttpResponse
(
json
.
dumps
(
to_if
(
mes
)))
table_data
=
[]
data
=
Purchase
.
objects
.
values
(
'user__username'
,
'aggreg_date__month'
,
'user_id'
,
'user__email'
)
.
filter
(
purchased
=
True
,
aggreg_date__month
=
to_if
(
request
.
POST
.
get
(
'title'
)))
.
annotate
(
dcount
=
Count
(
'user__username'
))
.
order_by
(
'-dcount'
)
for
user
in
data
:
bytes_size
=
0
for
path
,
directories
,
files
in
os
.
walk
(
PATH_USERS
+
user
[
'user__email'
]):
for
filename
in
files
:
bytes_size
+=
os
.
lstat
(
os
.
path
.
join
(
path
,
filename
))
.
st_size
for
directory
in
directories
:
bytes_size
+=
os
.
lstat
(
os
.
path
.
join
(
path
,
directory
))
.
st_size
bytes_size
+=
os
.
path
.
getsize
(
PATH_USERS
+
user
[
'user__email'
])
storage
=
best_unit_size
(
bytes_size
)
pending
=
Purchase
.
objects
.
filter
(
user_id
=
user
[
'user_id'
],
aggreg_date__month
=
to_if
(
request
.
POST
.
get
(
'title'
)))
.
exclude
(
progress
=
100
)
.
annotate
(
dcount
=
Count
(
'progress'
))
table_data
.
append
({
'user_id'
:
user
[
'user_id'
],
'username'
:
user
[
'user__username'
],
'email'
:
user
[
'user__email'
],
'purchases'
:
user
[
'dcount'
],
'storage'
:
storage
,
'in_process'
:
pending
.
count
(),
})
return
HttpResponse
(
json
.
dumps
(
table_data
))
else
:
raise
Http404
...
...
reports/views.py
View file @
39e1bff8
...
...
@@ -140,10 +140,10 @@ def Reports(request):
progress
=
60
if
'Finalizing...'
in
open
(
log_info
)
.
read
():
progress
=
100
#item = Purchase.objects.filter(pk=producto['id'])
#item = Purchase.objects.get(pk=producto['id'])
#item.progress = progress
#item.save()
#
item = Purchase.objects.filter(pk=producto['id'])
#
item = Purchase.objects.get(pk=producto['id'])
#
item.progress = progress
#
item.save()
with
open
(
log_info
,
'r'
)
as
myfile
:
log
=
myfile
.
read
()
.
replace
(
'
\n
'
,
''
)
...
...
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