Commit 64d5f22c authored by Emmanuel René Huchim Puc's avatar Emmanuel René Huchim Puc

Merge branch 'dev' of gitlab.geoint.mx:mario.chirinos/GeoInt_SIDT into images_map

parents 7d8a2ce8 d54b9530
...@@ -25,3 +25,6 @@ venv.bak/ ...@@ -25,3 +25,6 @@ venv.bak/
# pyenv # pyenv
.python-version .python-version
!**/migrations
!**/migrations/__init__.py
\ No newline at end of file
...@@ -43,6 +43,7 @@ INSTALLED_APPS = [ ...@@ -43,6 +43,7 @@ INSTALLED_APPS = [
'reports.apps.ReportsConfig', 'reports.apps.ReportsConfig',
'mail.apps.MailConfig', 'mail.apps.MailConfig',
'administration.apps.AdministrationConfig', 'administration.apps.AdministrationConfig',
'users.apps.UsersConfig',
'django_extensions', 'django_extensions',
] ]
......
...@@ -30,5 +30,6 @@ urlpatterns = [ ...@@ -30,5 +30,6 @@ urlpatterns = [
#url(r'^accounts/', include('registration')), #url(r'^accounts/', include('registration')),
url(r'^mail/', include('mail.urls')), url(r'^mail/', include('mail.urls')),
url(r'^administration/', include('administration.urls')), url(r'^administration/', include('administration.urls')),
url(r'^users/', include('users.urls')),
] ]
# + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) # + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -28,5 +28,14 @@ ...@@ -28,5 +28,14 @@
</span> </span>
</a> </a>
</li> </li>
<li>
<a class="treeview " href="#" onclick="window.history.back();">
<i class="fa fa-backward"></i>
<span>Back</span>
<span class="pull-right-container">
<span class="label label-primary pull-right"></span>
</span>
</a>
</li>
</ul> </ul>
</div> </div>
\ No newline at end of file
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
<script src="{% static 'js/Chart.min.js' %}"></script> <script src="{% static 'js/Chart.min.js' %}"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css"/> <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css"/>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script> <script type="text/javascript" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
{% endblock %} {% endblock %}
{% block messages %} {% block messages %}
...@@ -193,7 +194,7 @@ ...@@ -193,7 +194,7 @@
<!-- /.info-box-content --> <!-- /.info-box-content -->
</div> </div>
<!-- /.info-box --> <!-- /.info-box -->
</div> </div>
<div class="col-md-2 col-sm-6 col-xs-12"> <div class="col-md-2 col-sm-6 col-xs-12">
<div class="info-box"> <div class="info-box">
...@@ -215,7 +216,7 @@ ...@@ -215,7 +216,7 @@
<div class="col-md-2 col-sm-6 col-xs-12"> <div class="col-md-2 col-sm-6 col-xs-12">
<div class="info-box"> <div class="info-box">
<span class="info-box-icon bg-orange"><i class="fa fa-bomb"></i></span> <span class="info-box-icon bg-orange"><i class="fa fa-satellite"></i></span>
<div class="info-box-content"> <div class="info-box-content">
<span class="info-box-text">Sentinel Storage</span> <span class="info-box-text">Sentinel Storage</span>
...@@ -334,7 +335,7 @@ ...@@ -334,7 +335,7 @@
<div class="col-md-12"> <div class="col-md-12">
<div class="box box-success"> <div class="box box-success">
<div class="box-header with-border"> <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"> <div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse"><i <button type="button" class="btn btn-box-tool" data-widget="collapse"><i
...@@ -346,29 +347,9 @@ ...@@ -346,29 +347,9 @@
<div class="box-body"> <div class="box-body">
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<p class="text-center">
<strong>February</strong>
</p>
<div> <div id="mostrar">
<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> </div>
<!-- /.chart-responsive --> <!-- /.chart-responsive -->
</div> </div>
...@@ -456,7 +437,6 @@ ...@@ -456,7 +437,6 @@
</li> </li>
</ul> </ul>
<!-- Social buttons --> <!-- Social buttons -->
</div> </div>
<!-- Footer Elements --> <!-- Footer Elements -->
...@@ -466,6 +446,9 @@ ...@@ -466,6 +446,9 @@
</div> </div>
<!-- Copyright --> <!-- Copyright -->
</footer> </footer>
{% if messages %} {% if messages %}
<div class="container col-md-2 col-lg-2 col-xs-2 col-sm-2" style="bottom: 0; right: 0;position: absolute"> <div class="container col-md-2 col-lg-2 col-xs-2 col-sm-2" style="bottom: 0; right: 0;position: absolute">
...@@ -535,54 +518,6 @@ ...@@ -535,54 +518,6 @@
}); });
$(document).ready(function () {
$('#example').DataTable
({
language:
{
"sProcessing": "Procesando...",
"sLengthMenu": "Mostrar _MENU_ registros",
"sZeroRecords": "No se encontraron resultados",
"sEmptyTable": "Ningún dato disponible en esta tabla",
"sInfo": "Mostrando registros del _START_ al _END_ de un total de _TOTAL_ registros",
"sInfoEmpty": "Mostrando registros del 0 al 0 de un total de 0 registros",
"sInfoFiltered": "(filtrado de un total de _MAX_ registros)",
"sInfoPostFix": "",
"sSearch": "Buscar:",
"sUrl": "",
"sInfoThousands": ",",
"sLoadingRecords": "Cargando...",
"oPaginate":
{
"sFirst": "Primero",
"sLast": "Último",
"sNext": "Siguiente",
"sPrevious": "Anterior"
},
"oAria":
{
"sSortAscending": ": Activar para ordenar la columna de manera ascendente",
"sSortDescending": ": Activar para ordenar la columna de manera descendente"
}
},
responsive:
{
details:
{
type: 'column',
target: 'tr'
}
},
columnDefs:
[{
className: 'control',
orderable: false,
targets: 0
}],
order: [1, 'asc']
});
});
// mostrar imagen al dar click en los puntos // mostrar imagen al dar click en los puntos
document.getElementById("salesChart").onclick = function (evt) { document.getElementById("salesChart").onclick = function (evt) {
...@@ -591,32 +526,52 @@ ...@@ -591,32 +526,52 @@
var firstPoint = activePoint[0]; var firstPoint = activePoint[0];
var label = myChart.data.labels[firstPoint._index]; var label = myChart.data.labels[firstPoint._index];
//if (!firstPoint) return; //if (!firstPoint) return;
$('#purchases_in').empty();
$('#purchases_in').append("Purchases in " + label);
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
dataType: "json", dataType: "json",
data: {'title':label}, data: {'title': label},
url: '../administration/ws/report_table', url: '../administration/ws/report_table',
success: function (data) { 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> </script>
{% endblock %} {% endblock %}
\ No newline at end of file
...@@ -130,7 +130,7 @@ ...@@ -130,7 +130,7 @@
<th>E-mail</th> <th>E-mail</th>
<th>Active</th> <th>Active</th>
<th>Staff</th> <th>Staff</th>
<th>Super</th> <th>Super User</th>
<th>Actions</th> <th>Actions</th>
</thead> </thead>
<tbody> <tbody>
...@@ -152,18 +152,22 @@ ...@@ -152,18 +152,22 @@
</td> </td>
<td> <td>
<input type="checkbox" name="is_staff" value="1" <input type="checkbox" name="is_staff" value="1"
{% if not request.user.is_superuser %}disabled{% endif %}
{% if user.staff == True %}checked{% endif %}> {% if user.staff == True %}checked{% endif %}>
</td> </td>
<td> <td>
<input type="checkbox" name="is_superuser" value="1" <input type="checkbox" name="is_superuser" value="1"
{% if not request.user.is_superuser %}disabled{% endif %}
{% if user.superuser == True %}checked{% endif %}> {% if user.superuser == True %}checked{% endif %}>
</td> </td>
<td> <td>
<button title="save" type="submit" class="btn btn-success"><i <button title="save" type="submit" class="btn btn-success"><i
class="fa fa-save"></i></button> class="fa fa-save"></i></button>
<a href="#" class="btn btn-info" title="View profile"><i {% if Viewname != "Request" %}
class="fa fa-user-circle"></i></a> <a href="{{ BASE_URL }}/users/{{ user.user_id }}" class="btn btn-info"
title="View profile"><i
class="fa fa-user-circle"></i></a>
{% endif %}
</td> </td>
</form> </form>
</tr> </tr>
......
...@@ -2,15 +2,13 @@ import calendar ...@@ -2,15 +2,13 @@ import calendar
import os import os
import datetime
from django.contrib import messages from django.contrib import messages
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.db.models import Count from django.db.models import Count
from django.shortcuts import render, redirect from django.shortcuts import render, redirect
import json import json
from django.http import HttpResponse, HttpResponseRedirect, HttpRequest, Http404 from django.http import HttpResponse, HttpResponseRedirect, HttpRequest, Http404
from PIL import Image
from django.db.models import Q
# Create your views here. # Create your views here.
from django.views.decorators.csrf import csrf_exempt from django.views.decorators.csrf import csrf_exempt
...@@ -19,10 +17,15 @@ from catalog.models import Purchase, Search ...@@ -19,10 +17,15 @@ from catalog.models import Purchase, Search
from catalog.views import config from catalog.views import config
USERS_PATH = config['PATHS']['PATH_NAS'] USERS_PATH = config['PATHS']['PATH_NAS']
PATH_USERS = config['PATHS']['PATH_USERS']
size_sentinel =0 size_sentinel =0
size_repsat=0 size_repsat=0
#------------------------------------------------------------ #------------------------------------------------------------
def Dashboard(request): def Dashboard(request):
if not request.user.is_superuser and not request.user.is_staff:
return redirect('../')
# Total de compras # # Total de compras #
total = Purchase.objects.filter(purchased=True).count() total = Purchase.objects.filter(purchased=True).count()
...@@ -52,7 +55,7 @@ def Dashboard(request): ...@@ -52,7 +55,7 @@ def Dashboard(request):
{'quantity': 0, 'date': 'December'}] {'quantity': 0, 'date': 'December'}]
# Obtener el nombre del mes # # 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')): 'month').annotate(Count('id')):
date_name = calendar.month_name[int(date[0])] date_name = calendar.month_name[int(date[0])]
...@@ -96,30 +99,30 @@ def Dashboard(request): ...@@ -96,30 +99,30 @@ def Dashboard(request):
"Descargando": in_process, "dates": month_lst, "search": Searches, "size_repsat": size_repsat, "Descargando": in_process, "dates": month_lst, "search": Searches, "size_repsat": size_repsat,
"size_sentinel": size_sentinel}) "size_sentinel": size_sentinel})
# ---------------------------------------------------------- # ----------------------------------------------------------
def Request_users(request): def Request_users(request):
if request.user.is_superuser or request.user.is_staff: if not request.user.is_superuser and not request.user.is_staff:
user_list = []
for user in User.objects.filter(is_active=False):
user_list.append({
"user_id": user.id,
"username": user.username,
"first_name": user.first_name,
"last_name": user.last_name,
"email": user.email,
"status": user.is_active,
"staff": user.is_staff,
"superuser": user.is_superuser,
})
# messages.success(request, 'your registration is being processed')
return render(request, 'users_table.html', {'users': user_list, "Viewname": "Request"})
else:
return redirect('../') return redirect('../')
user_list = []
for user in User.objects.filter(is_active=False):
user_list.append({
"user_id": user.id,
"username": user.username,
"first_name": user.first_name,
"last_name": user.last_name,
"email": user.email,
"status": user.is_active,
"staff": user.is_staff,
"superuser": user.is_superuser,
})
# messages.success(request, 'your registration is being processed')
return render(request, 'users_table.html', {'users': user_list, "Viewname": "Request"})
# ------------------------------------------------------------------------ # ------------------------------------------------------------------------
def update_user(request): def update_user(request):
is_active = False is_active = False
is_staff = False is_staff = False
is_superuser = False is_superuser = False
...@@ -141,72 +144,62 @@ def update_user(request): ...@@ -141,72 +144,62 @@ def update_user(request):
return redirect(request.POST.get('request_path')) return redirect(request.POST.get('request_path'))
#------------------------------------------------------------------------
def active_users(request): def active_users(request):
if request.user.is_superuser or request.user.is_staff: if not request.user.is_superuser and not request.user.is_staff:
user_list = [] return redirect('../')
for user in User.objects.filter(is_active=True): user_list = []
user_list.append({ for user in User.objects.filter(is_active=True):
"user_id": user.id, user_list.append({
"username": user.username, "user_id": user.id,
"first_name": user.first_name, "username": user.username,
"last_name": user.last_name, "first_name": user.first_name,
"email": user.email, "last_name": user.last_name,
"status": user.is_active, "email": user.email,
"staff": user.is_staff, "status": user.is_active,
"superuser": user.is_superuser, "staff": user.is_staff,
}) "superuser": user.is_superuser,
# messages.success(request, 'your registration is being processed') })
return render(request, 'users_table.html', {'users': user_list, "Viewname": "Request"}) # messages.success(request, 'your registration is being processed')
return render(request, 'users_table.html', {'users': user_list, "Viewname": "Active Users"})
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# @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 @csrf_exempt
def wsPurchasesPM(request): def wsPurchasesPM(request):
global mes
# print(request.POST.get('title'))
if request.is_ajax(): if request.is_ajax():
date_list = Purchase.objects.dates('aggreg_date', 'month')
for meses in date_list: table_data =[]
datee = datetime.datetime.strptime(str(meses), "%Y-%m-%d") data = Purchase.objects.values('user__username','aggreg_date__month','user_id','user__email').filter(purchased=True,
mes = calendar.month_name[int(datee.month)] aggreg_date__month=to_if(request.POST.get('title'))).annotate(dcount=Count('user__username')).order_by('-dcount')
# print(mes)
# data =Purchase.objects.filter(Q(date__month=1) | Q(date__month=2) | Q(date__month=3)) for user in data:
# data = Purchase.objects.values('user__username').filter(Q(aggreg_date__month=to_if(mes))|Q(user__purchase_user_id = user__user_id)) bytes_size = 0
# data = Purchase.objects.values('user__username').filter(aggreg_date__month=to_if(mes)).annotate(count=Count('user_id')).order_by('-count')[:1] for path, directories, files in os.walk(PATH_USERS+user['user__email']):
for filename in files:
data = Purchase.objects.values('id', 'user__username', 'aggreg_date', 'search__clouds', bytes_size += os.lstat(os.path.join(path, filename)).st_size
'search__startDate', for directory in directories:
'search__endDate', 'search__process_id__name').filter( bytes_size += os.lstat(os.path.join(path, directory)).st_size
aggreg_date__month=to_if(mes)).annotate(count_purchases=Count('id')).order_by('id') bytes_size += os.path.getsize(PATH_USERS+user['user__email'])
storage = best_unit_size(bytes_size)
print(data)
for dato in data:
print(dato['count_purchases']) 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'))
# return HttpResponse(json.dumps(request.POST.get('title'))) table_data.append({
return HttpResponse(json.dumps(to_if(mes))) '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: else:
raise Http404 raise Http404
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
def to_if(name): def to_if(name):
if name == "January": if name == "January":
return 1 return 1
...@@ -234,6 +227,7 @@ def to_if(name): ...@@ -234,6 +227,7 @@ def to_if(name):
return 12 return 12
else: else:
raise ValueError raise ValueError
#----------------------------------------------- #-----------------------------------------------
def best_unit_size(bytes_size): def best_unit_size(bytes_size):
""" """
...@@ -253,3 +247,6 @@ def best_unit_size(bytes_size): ...@@ -253,3 +247,6 @@ def best_unit_size(bytes_size):
60:"EB", 70:"ZB", 80:"YB"}[exp] 60:"EB", 70:"ZB", 80:"YB"}[exp]
break break
return str(round(bu_size,2))+" "+unit return str(round(bu_size,2))+" "+unit
#------------------------------------------------
\ No newline at end of file
# Generated by Django 2.1.5 on 2019-02-27 19:26
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('catalog', '0012_search_process'),
]
operations = [
migrations.AddField(
model_name='purchase',
name='progress',
field=models.IntegerField(default=0),
),
migrations.AddField(
model_name='search',
name='search_name',
field=models.TextField(null=True),
),
]
# Generated by Django 2.1.5 on 2019-02-27 19:43
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('catalog', '0013_auto_20190227_1926'),
]
operations = [
migrations.AlterField(
model_name='search',
name='search_name',
field=models.TextField(default='Drawn polygon'),
),
]
# Generated by Django 2.1.5 on 2019-02-27 21:40
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('catalog', '0014_auto_20190227_1943'),
]
operations = [
migrations.AlterField(
model_name='search',
name='search_name',
field=models.TextField(default='Drawn polygon '),
),
]
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
<div class="navbar-custom-menu"> <div class="navbar-custom-menu">
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
<li> <li>
{% if request.user.is_superuser %} {% if request.user.is_superuser or request.user.is_staff %}
<a href="../../../administration" title="super user"><i <a href="../../../administration" title="super user"><i
class="fa fa-gears"></i></a> class="fa fa-gears"></i></a>
{% endif %} {% endif %}
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<ul class="sidebar-menu" data-widget="tree"> <ul class="sidebar-menu" data-widget="tree">
<!-- History element --> <!-- History element -->
<li> <li>
<a class="treeview " href="#"> <a class="treeview " href="../../../users">
<i class="fa fa-user-circle"></i> <i class="fa fa-user-circle"></i>
<span>Profile</span> <span>Profile</span>
<span class="pull-right-container"> <span class="pull-right-container">
......
...@@ -66,7 +66,6 @@ def requestToImage(request): ...@@ -66,7 +66,6 @@ def requestToImage(request):
img_link = request.GET['value'] img_link = request.GET['value']
#print(img_link) #print(img_link)
r = requests.get(img_link, auth=("emmhp", "geoemm29"), stream=True) r = requests.get(img_link, auth=("emmhp", "geoemm29"), stream=True)
print(r.content)
img_str = base64.b64encode(r.content) img_str = base64.b64encode(r.content)
#print(img_str) #print(img_str)
img_str = img_str.decode('utf-8') img_str = img_str.decode('utf-8')
......
...@@ -19,4 +19,33 @@ body ...@@ -19,4 +19,33 @@ body
.submenu{ .submenu{
padding-right: 140px !important; padding-right: 140px !important;
}
.img-comp-container {
position: relative;
height: 550px; /*should be the same height as the images*/
}
.img-comp-img {
position: absolute;
width: auto;
height: auto;
overflow:hidden;
}
.img-comp-img img {
display: block;
vertical-align: middle;
}
.img-comp-slider {
position: absolute;
z-index:9;
cursor: ew-resize;
/*set the appearance of the slider:*/
width: 40px;
height: 40px;
background-color: #2196F3;
opacity: 0.7;
border-radius: 50%;
} }
\ No newline at end of file
...@@ -11,7 +11,7 @@ function refresh() { ...@@ -11,7 +11,7 @@ function refresh() {
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 + '%');
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -4,6 +4,19 @@ ...@@ -4,6 +4,19 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css"/> <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css"/>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script> <script type="text/javascript" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
<link rel="stylesheet" href="https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.3.0/css/ol.css"
type="text/css">
<style>
.map {
height: 400px;
width: 100%;
}
</style>
<script src="https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.3.0/build/ol.js"></script>
<link rel="stylesheet" href="https://openlayers.org/en/v5.3.0/css/ol.css" type="text/css">
<!-- The line below is only needed for old environments like Internet Explorer and Android 4.x -->
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script>
{% endblock %} {% endblock %}
{% block messages %} {% block messages %}
<a href="#" class="dropdown-toggle" data-toggle="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">
...@@ -113,6 +126,15 @@ ...@@ -113,6 +126,15 @@
</span> </span>
</a> </a>
</li> </li>
<li>
<a class="treeview " href="#" onclick="window.history.back();">
<i class="fa fa-backward"></i>
<span>Back</span>
<span class="pull-right-container">
<span class="label label-primary pull-right"></span>
</span>
</a>
</li>
</ul> </ul>
</div> </div>
<!-- form-group--> <!-- form-group-->
...@@ -123,7 +145,7 @@ ...@@ -123,7 +145,7 @@
{% block content %} {% block content %}
<!-- Content Wrapper. Contains page content --> <!-- Content Wrapper. Contains page content -->
<!-- Main content --> <!-- Main content -->
<div id="reportPage" class="wrapper" style="background-color: #ecf0f5; display: none"> <div id="reportPage" class="wrapper" style="background-color: #ecf0f5;">
<!-- Content Wrapper. Contains page content --> <!-- Content Wrapper. Contains page content -->
<!-- Main content --> <!-- Main content -->
<section class="content"> <section class="content">
...@@ -133,6 +155,7 @@ ...@@ -133,6 +155,7 @@
<table data-toggle="table" id="example" class="table table-striped table-bordered" <table data-toggle="table" id="example" class="table table-striped table-bordered"
style="width:100%"> style="width:100%">
<thead> <thead>
<th>Zone</th>
<th>Process</th> <th>Process</th>
<th>Purchase date</th> <th>Purchase date</th>
<th>Start Date</th> <th>Start Date</th>
...@@ -144,6 +167,9 @@ ...@@ -144,6 +167,9 @@
<tbody id="table_body"> <tbody id="table_body">
{% for product in productList %} {% for product in productList %}
<tr> <tr>
<td><a href="#"
onclick="showMyModalSetTitle('{{ product.search_name }}','{{ product.polygon }}');"> {{ product.search_name }}</a>
</td>
<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>
...@@ -228,9 +254,91 @@ ...@@ -228,9 +254,91 @@
</div> </div>
</div> </div>
<div id="mapmodal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" id="myModalTitle"></h4>
</div>
<div class="modal-body">
<div id="map" class="map"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- /.modals --> <!-- /.modals -->
{% endblock %} {% endblock %}
{% block scripts %} {% block scripts %}
<script src="{% static 'reports/js/Reports_scripts.js' %}"> <script src="{% static 'reports/js/Reports_scripts.js' %}"></script>
<script type="text/javascript">
function showMyModalSetTitle(name,data) {
$('#map').empty();
$('#myModalTitle').empty();
$('#myModalTitle').append(name);
$("#mapmodal").modal();
setTimeout(function () {
createmap(data);
}, 1000);
//console.log(data)
}
function createmap(data) {
/*var map = new ol.Map({
target: 'map',
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
})
],
view: new ol.View({
center: ol.proj.fromLonLat([-89.63873079999999, 21.0404457]),
zoom: 5
})
});*/
var raster = new ol.layer.Tile({
source: new ol.source.OSM()
});
var format = new ol.format.WKT();
var feature = format.readFeature(data);
feature.getGeometry().transform('EPSG:4326', 'EPSG:3857');
var vector = new ol.layer.Vector({
source: new ol.source.Vector({
features: [feature]
})
});
var center = feature.getGeometry();
var map = new ol.Map({
controls: [],
interactions: [],
layers: [raster, vector],
target: 'map',
view: new ol.View({
center: [center.getInteriorPoint().getFirstCoordinate()[0], center.getInteriorPoint().getFirstCoordinate()[1]],
zoom: 9
})
});
}
</script> </script>
{% endblock %} {% endblock %}
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
</span> </span>
</a> </a>
</li> </li>
<li class="treeview"> <li class="treeview">
<a href="#"> <a href="#">
<i class="fa fa-file-archive-o"></i> <i class="fa fa-file-archive-o"></i>
...@@ -136,5 +137,14 @@ ...@@ -136,5 +137,14 @@
</li> </li>
</ul> </ul>
</li> </li>
<li>
<a class="treeview " href="#" onclick="window.history.back();">
<i class="fa fa-backward"></i>
<span>Back</span>
<span class="pull-right-container">
<span class="label label-primary pull-right"></span>
</span>
</a>
</li>
</ul> </ul>
</div> </div>
\ No newline at end of file
...@@ -33,6 +33,7 @@ def report_L2ASCL(request, report, purchase_id): ...@@ -33,6 +33,7 @@ def report_L2ASCL(request, report, purchase_id):
reporteDir = report.replace('_sclData','') reporteDir = report.replace('_sclData','')
image_path = request.user.email + "/" + purchase_id + "/" + "out/"+reporteDir+"/TCI/thumbnails/" image_path = request.user.email + "/" + purchase_id + "/" + "out/"+reporteDir+"/TCI/thumbnails/"
SCL_path = request.user.email + "/" + purchase_id + "/" + "out/"+reporteDir+"/SCL/"
print(image_path) print(image_path)
absolute_path = USERS_PATH + request.user.email + "/" + purchase_id + "/out" absolute_path = USERS_PATH + request.user.email + "/" + purchase_id + "/out"
folders = os.listdir(path=absolute_path) folders = os.listdir(path=absolute_path)
...@@ -75,8 +76,8 @@ def report_L2ASCL(request, report, purchase_id): ...@@ -75,8 +76,8 @@ def report_L2ASCL(request, report, purchase_id):
labelNames = [ labelNames = [
"No Data", "Saturated", "Shadows", "Cloud Shadows", "Vegetation", "No Data", "Saturated", "Shadows", "Cloud Shadows", "Vegetation",
"Not-Vegetated", "Whater", "Unclassified", "Cloud Medium Probablilty", "Not-Vegetated", "Water", "Unclassified", "Cloud Medium Probability",
"Cloud Hight Probablilty", "Thin Cirrus", "Snow" "Cloud High Probability", "Thin Cirrus", "Snow"
] ]
colors = [ colors = [
...@@ -107,7 +108,7 @@ def report_L2ASCL(request, report, purchase_id): ...@@ -107,7 +108,7 @@ def report_L2ASCL(request, report, purchase_id):
# graphData['options']['maintainAspectRatio']=False # graphData['options']['maintainAspectRatio']=False
# print(json.dumps(graphData).encode("utf-8")) # print(json.dumps(graphData).encode("utf-8"))
return render(request, 'L2ASCL_data.html', {"graphData": json.dumps(graphData),"name":"foo", "report_name": "SCL Image Classification Data(Km²)", "startDate": startDate,"endDate": endDate,"clouds": dataProduct['clouds'], "platform": dataProduct['platform'],"productLevel": dataProduct['productLevel'] ,"IMAGE_PATH": image_path, 'dafaultLabel': defaultLabel, 'defaultDataSet': defaultDataset, "folders" : folders,"zone":reporteDir }) return render(request, 'L2ASCL_data.html', {"graphData": json.dumps(graphData),"name":"foo", "report_name": "SCL Image Classification Data(Km²)", "startDate": startDate,"endDate": endDate,"clouds": dataProduct['clouds'], "platform": dataProduct['platform'],"productLevel": dataProduct['productLevel'] ,"IMAGE_PATH": image_path, "SCL_PATH" : SCL_path, 'dafaultLabel': defaultLabel, 'defaultDataSet': defaultDataset, "folders" : folders,"zone":reporteDir })
# -------------------------------------------------------------------------------def Reports(request): # -------------------------------------------------------------------------------def Reports(request):
...@@ -119,7 +120,7 @@ def Reports(request): ...@@ -119,7 +120,7 @@ def Reports(request):
folders=[] folders=[]
zip ="" zip =""
product_list = Purchase.objects.values('id', 'productList', 'aggreg_date', 'search__clouds', 'search__startDate', product_list = Purchase.objects.values('id', 'productList', 'aggreg_date', 'search__clouds', 'search__startDate',
'search__endDate', 'search__process_id__name').filter( 'search__endDate', 'search__process_id__name', 'search__search_name').filter(
user_id=request.user.id, purchased=1) 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"
...@@ -140,10 +141,10 @@ def Reports(request): ...@@ -140,10 +141,10 @@ def Reports(request):
progress = 60 progress = 60
if 'Finalizing...' in open(log_info).read(): if 'Finalizing...' in open(log_info).read():
progress = 100 progress = 100
#item = Purchase.objects.filter(pk=producto['id']) # item = Purchase.objects.filter(pk=producto['id'])
#item = Purchase.objects.get(pk=producto['id']) # item = Purchase.objects.get(pk=producto['id'])
#item.progress = progress # item.progress = progress
#item.save() # item.save()
with open(log_info, 'r') as myfile: with open(log_info, 'r') as myfile:
log = myfile.read().replace('\n', '') log = myfile.read().replace('\n', '')
...@@ -162,6 +163,7 @@ def Reports(request): ...@@ -162,6 +163,7 @@ def Reports(request):
print("folder out noes not exists") print("folder out noes not exists")
else: else:
folders = os.listdir(path=absolute_path) folders = os.listdir(path=absolute_path)
print(folders)
if len(folders)==0: if len(folders)==0:
initial_folder="../#" initial_folder="../#"
else: else:
...@@ -172,12 +174,15 @@ def Reports(request): ...@@ -172,12 +174,15 @@ def Reports(request):
#"../ static / reports / tmpImages / repsat_test_dev / umorales @ centrogeo.edu.mx / "+str(producto['id']) / myzip.zip" #"../ static / reports / tmpImages / repsat_test_dev / umorales @ centrogeo.edu.mx / "+str(producto['id']) / myzip.zip"
wkt = USERS_PATH + request.user.email + "/" + str(producto['id']) + "/findProducts.json"
with open(wkt, 'r') as jsonfile:
polygon = json.load(jsonfile)
for file in os.listdir(path=zip_path): for file in os.listdir(path=zip_path):
if file.endswith(".zip"): if file.endswith(".zip"):
print(file)
zip = zip_path+"/"+file zip = zip_path+"/"+file
print(zip)
productList.append({ productList.append({
"search_name": producto['search__search_name'],
"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'],
...@@ -189,6 +194,7 @@ def Reports(request): ...@@ -189,6 +194,7 @@ def Reports(request):
"log_info": log, "log_info": log,
"initial_folder" :initial_folder, "initial_folder" :initial_folder,
"zip" : zip, "zip" : zip,
"polygon": polygon['wkt'],
}) })
size = 0 size = 0
final_size = 0 final_size = 0
...@@ -196,6 +202,7 @@ def Reports(request): ...@@ -196,6 +202,7 @@ def Reports(request):
progress = 0 progress = 0
initial_folder = "" initial_folder = ""
zip ="" zip =""
wkt =""
return render(request, 'Reports.html', {"productList": productList}) return render(request, 'Reports.html', {"productList": productList})
...@@ -229,9 +236,9 @@ def wsProcessProgress(request): ...@@ -229,9 +236,9 @@ def wsProcessProgress(request):
if 'Finalizing...' in open(log_info).read(): if 'Finalizing...' in open(log_info).read():
progress = 100 progress = 100
item = Purchase.objects.get(pk=producto['id']) #item = Purchase.objects.get(pk=producto['id'])
item.progress = progress #item.progress = progress
item.save() #item.save()
productList2.append({ productList2.append({
"purchase_id": producto['id'], "purchase_id": producto['id'],
......
from django.contrib import admin
# Register your models here.
from django.apps import AppConfig
class UsersConfig(AppConfig):
name = 'users'
from django.db import models
# Create your models here.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
body
{
background-color:White;
}
.next{
padding: 0px;
padding-top: 50%;
cursor: pointer;
font-size: 20px;
}
.prev{
padding-left: 20px;
padding-top: 50%;
cursor: pointer;
font-size: 20px;
}
This source diff could not be displayed because it is too large. You can view the blob instead.
$(document).ready(function () {
$('#example').DataTable
({
language:
{
"sProcessing": "Procesando...",
"sLengthMenu": "Mostrar _MENU_ registros",
"sZeroRecords": "No se encontraron resultados",
"sEmptyTable": "Ningún dato disponible en esta tabla",
"sInfo": "Mostrando registros del _START_ al _END_ de un total de _TOTAL_ registros",
"sInfoEmpty": "Mostrando registros del 0 al 0 de un total de 0 registros",
"sInfoFiltered": "(filtrado de un total de _MAX_ registros)",
"sInfoPostFix": "",
"sSearch": "Buscar:",
"sUrl": "",
"sInfoThousands": ",",
"sLoadingRecords": "Cargando...",
"oPaginate":
{
"sFirst": "Primero",
"sLast": "Último",
"sNext": "Siguiente",
"sPrevious": "Anterior"
},
"oAria":
{
"sSortAscending": ": Activar para ordenar la columna de manera ascendente",
"sSortDescending": ": Activar para ordenar la columna de manera descendente"
}
},
responsive:
{
details:
{
type: 'column',
target: 'tr'
}
},
columnDefs:
[{
className: 'control',
orderable: false,
targets: 0
}],
order: [1, 'asc']
});
});
This diff is collapsed.
{% load staticfiles %}
<div class="col-md-3">
{% for data in user_data %}
<!-- Profile Image -->
<div class="box box-primary">
<div class="box-body box-profile">
<br>
<img class="profile-user-img img-responsive img-circle"
src="{% static 'users/images/user_default.png' %}"
alt="User profile picture">
<h3 class="profile-username text-center">{{ data.user_fullname }}</h3>
<input type="hidden" id="user_id" value="{{ data.user_id }}">
<p class="text-muted text-center">Software Engineer</p>
<ul class="list-group list-group-unbordered">
<li class="list-group-item">
<i class="fa fa-search margin-r-5"></i> <b>Searches</b> <a
class="pull-right">{{ data.searches }}</a>
</li>
<li class="list-group-item">
<i class="fa fa-shopping-cart margin-r-5"></i> <b>Purchases</b> <a
class="pull-right">{{ data.purchases }}</a>
</li>
<li class="list-group-item">
<i class="fa fa-download margin-r-5"></i> <b>In Process</b> <a
class="pull-right">{{ data.in_process }}</a>
</li>
<li class="list-group-item">
<i class="fa fa-pie-chart margin-r-5"></i> <b>Disk usage</b> <a
class="pull-right">{{ data.size }}</a>
</li>
</ul>
<!--a href="#" class="btn btn-primary btn-block"><b>Follow</b></a-->
</div>
<!-- /.box-body -->
</div>
<!-- /.box -->
{% endfor %}
<div>
<br>
</div>
<!-- About Me Box -->
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title">Searches</h3>
</div>
<!-- /.box-header -->
<div class="box-body">
<ul class="list-group list-group-unbordered">
{% for data in user_searches %}
<li class="list-group-item">
<i class="fa fa-map-marker margin-r-5"></i> <b>{{ data.search_name }}</b> <a
class="pull-right">{{ data.count }}</a>
</li>
{% endfor %}
</ul>
</div>
<!-- /.box-body -->
</div>
<!-- /.box -->
<div><br></div>
</div>
<div class="form-group">
<br>
<ul class="sidebar-menu" data-widget="tree">
<li>
<a class="treeview " href="{{ BASE_URL }}/reports">
<i class="fa fa-files-o"></i>
<span>Reports</span>
<span class="pull-right-container">
<span class="label label-primary pull-right"></span>
</span>
</a>
</li>
<!--li>
<a class="treeview " href="{{ BASE_URL }}/administration/request">
<i class="fa fa-user-plus"></i>
<span>Request</span>
<span class="pull-right-container">
<span class="label label-primary pull-right"></span>
</span>
</a>
</li>
<li>
<a class="treeview " href="../../administration/users">
<i class="fa fa-users"></i>
<span>Active users</span>
<span class="pull-right-container">
<span class="label label-primary pull-right"></span>
</span>
</a>
</li-->
<li>
<a class="treeview " href="#" onclick="window.history.back();">
<i class="fa fa-backward"></i>
<span>Back</span>
<span class="pull-right-container">
<span class="label label-primary pull-right"></span>
</span>
</a>
</li>
</ul>
</div>
\ No newline at end of file
from django.test import TestCase
# Create your tests here.
"""GeoInt_SIDT URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.11/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url
from django.contrib import admin
from django.conf.urls import include
from django.views.generic import RedirectView
from django.conf import settings
from django.conf.urls.static import static
from users import views
urlpatterns = [
url(r'^$', views.Users, name='users'),
url(r'^(?P<user_id>(\d+))/$', views.User_id, name='user_id'),
url(r'^ws/report_table$', views.wsPurchasesPM, name='wsPurchasesPM'),
]
# + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
This diff is collapsed.
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