Commit af70c61f authored by Emmanuel René Huchim Puc's avatar Emmanuel René Huchim Puc

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

parents 031f5f74 d4a99ea7
...@@ -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)
...@@ -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 %}
...@@ -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,9 +518,10 @@ ...@@ -535,9 +518,10 @@
}); });
$(document).ready(function () { /*$(document).ready(function () {
$('#example').DataTable var table = $('#example').DataTable
({ ({
"ajax": data,
language: language:
{ {
"sProcessing": "Procesando...", "sProcessing": "Procesando...",
...@@ -581,7 +565,7 @@ ...@@ -581,7 +565,7 @@
}], }],
order: [1, 'asc'] order: [1, 'asc']
}); });
}); });*/
// mostrar imagen al dar click en los puntos // mostrar imagen al dar click en los puntos
...@@ -591,31 +575,51 @@ ...@@ -591,31 +575,51 @@
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>
......
...@@ -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,10 +152,14 @@ ...@@ -152,10 +152,14 @@
</td> </td>
<td> <td>
<input type="checkbox" name="is_staff" value="1" <input type="checkbox" name="is_staff" value="1"
{% if user.staff == True %}checked{% endif %}> {% if not request.user.is_superuser %}disabled{% 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>
......
...@@ -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,10 +99,10 @@ def Dashboard(request): ...@@ -96,10 +99,10 @@ 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:
return redirect('../')
user_list = [] user_list = []
for user in User.objects.filter(is_active=False): for user in User.objects.filter(is_active=False):
user_list.append({ user_list.append({
...@@ -114,12 +117,12 @@ def Request_users(request): ...@@ -114,12 +117,12 @@ def Request_users(request):
}) })
# messages.success(request, 'your registration is being processed') # messages.success(request, 'your registration is being processed')
return render(request, 'users_table.html', {'users': user_list, "Viewname": "Request"}) return render(request, 'users_table.html', {'users': user_list, "Viewname": "Request"})
else:
return redirect('../')
# ------------------------------------------------------------------------ # ------------------------------------------------------------------------
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,9 +144,10 @@ def update_user(request): ...@@ -141,9 +144,10 @@ 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:
return redirect('../')
user_list = [] user_list = []
for user in User.objects.filter(is_active=True): for user in User.objects.filter(is_active=True):
user_list.append({ user_list.append({
...@@ -161,52 +165,41 @@ def active_users(request): ...@@ -161,52 +165,41 @@ 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 @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">
......
...@@ -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 + '%');
......
// Creamos una gráfica con los datos al macenados en config
var ctx = document.getElementById('myChart').getContext('2d');
//ctx.canvas.width = 256;
//ctx.canvas.height = 512;
var myChart = new Chart(ctx, config);
//var activePoints = [];
var activePoints = config.data.labels;
var imageNumber = 0;
var playImages;
var reportImg = activePoints[0];
//var myChart;
// mostrar imagen al dar click en los puntos
document.getElementById("myChart").onclick = function (evt) {
stop();
console.log("on click")
console.log("evento: ")
console.log(evt)
// activePoints = myChart.getElementsAtEvent(evt);
var activePoint = myChart.getElementAtEvent(evt);
console.log("activePoint: ")
console.log(activePoint)
console.log(activePoint.length)
if(activePoint.length>0){
console.log("asd")
var firstPoint = activePoint[0];
//console.log(firstPoint)
//console.log(firstPoint._datasetIndex) //la clase a la que pertenece (vegetación, agua, etc.)
var label = myChart.data.labels[firstPoint._index];
//console.log(label)
//if (!firstPoint) return;
activePoints.forEach(function (value, index) {
//if(value==firstPoint){
if (value == label) {
imageNumber = index;
}
});
var imagePoint = activePoints[imageNumber];
updateImage(imagePoint);
//updateImage(firstPoint);
//alert("{{ IMAGE_PATH }}"+label+"_TCI_60m.jpg");
//document.getElementById("satImage").src = "{{ IMAGE_PATH }}"+label+"_TCI_60m.jpg";
}
};
function play() {
$("#play").hide();
$("#stop").show();
// $(".next").hide();
// $(".prev").hide();
// $("#showImage").addClass('col-lg-offset-1');
playImages = setInterval(function () { next(); }, 4000);
}
//****************************
function scl_on(imagePoint) {
console.log("scl on!!")
label = imagePoint;
//console.log({{SCL_PATH}})
document.getElementById("satImage").src = "../../static/reports/tmpImages/repsat_test_dev/{{SCL_PATH}}" + label + "_SCL_60m_clasificationMap.png"
// $(".next").show();
// $(".prev").show();
}
function scl_stop() {
console.log("scl off!!")
// $(".next").show();
// $(".prev").show();
}
//********************************
function stop() {
clearInterval(playImages)
// $("#showImage").removeClass('col-lg-offset-1');
$("#play").show();
$("#stop").hide();
// $(".next").show();
// $(".prev").show();
}
// cambiar el tipo de gráfica
function next() {
if (imageNumber == (activePoints.length - 1)) {
imageNumber = 0;
} else {
imageNumber++;
}
var imagePoint = activePoints[imageNumber];
if (!imagePoint) return;
updateImage(imagePoint);
}
function prev() {
if (imageNumber == 0) {
imageNumber = activePoints.length - 1;
} else {
imageNumber--;
}
var imagePoint = activePoints[imageNumber];
if (!imagePoint) return;
updateImage(imagePoint);
}
function updateImage(imagePoint) {
//label = myChart.data.labels[imagePoint._index];
//datasets = myChart.data.datasets[imagePoint._datasetIndex].label;
//document.getElementById("titleMap").innerHTML = label + " - " + datasets;
label = imagePoint;
reportImg = imagePoint;
titleLabel = label.slice(0, 4) + "/" + label.slice(4, 6) + "/" + label.slice(6);
document.getElementById("titleMap").innerHTML = titleLabel;
document.getElementById("satImage").src = "../../static/reports/tmpImages/repsat_test_dev/" + image_path + label + "_TCI_60m.jpg"
document.getElementById("scl_Vegetation").src = "../../static/reports/tmpImages/repsat_test_dev/" + scl_path + label + "_SCL_60m_vegetation.png"
}
function change(newType) {
var ctx = document.getElementById("myChart").getContext("2d");
// Remove the old chart and all its event handles
if (myChart) {
myChart.destroy();
}
// Chart.js modifies the object you pass in. Pass a copy of the object so we can use the original object later
var temp = jQuery.extend(true, {}, config);
temp.type = newType;
if (newType == 'radar' || newType == 'pie' || newType == 'polarArea' || newType == 'doughnut') {
temp.options.scales.xAxes = { "display": false };
temp.options.scales.yAxes = { "display": false };
}
myChart = new Chart(ctx, temp);
};
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
...@@ -4,6 +4,16 @@ ...@@ -4,6 +4,16 @@
<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>
{% endblock %} {% endblock %}
{% block messages %} {% block messages %}
<a href="#" class="dropdown-toggle" data-toggle="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">
...@@ -123,7 +133,7 @@ ...@@ -123,7 +133,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 +143,7 @@ ...@@ -133,6 +143,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 +155,9 @@ ...@@ -144,6 +155,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 }}', 'Some body txt')"> {{ 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 +242,54 @@ ...@@ -228,9 +242,54 @@
</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').val(name);
$("#mapmodal").modal();
setTimeout(function(){ createmap(); }, 1000);
}
function createmap() {
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
})
});
}
</script> </script>
{% endblock %} {% endblock %}
...@@ -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,7 +76,7 @@ def report_L2ASCL(request, report, purchase_id): ...@@ -75,7 +76,7 @@ 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 Probablilty",
"Cloud Hight Probablilty", "Thin Cirrus", "Snow" "Cloud Hight Probablilty", "Thin Cirrus", "Snow"
] ]
...@@ -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:
...@@ -178,6 +180,7 @@ def Reports(request): ...@@ -178,6 +180,7 @@ def Reports(request):
zip = zip_path+"/"+file zip = zip_path+"/"+file
print(zip) 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'],
......
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">
<!-- Profile Image -->
<div class="box box-primary">
<div class="box-body box-profile">
<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">{{ user.get_full_name }}</h3>
<p class="text-muted text-center">Software Engineer</p>
<ul class="list-group list-group-unbordered">
<li class="list-group-item">
<b>Searches</b> <a class="pull-right">1,322</a>
</li>
<li class="list-group-item">
<b>Purchases</b> <a class="pull-right">543</a>
</li>
<li class="list-group-item">
<b>In Process</b> <a class="pull-right">13,287</a>
</li>
</ul>
<!--a href="#" class="btn btn-primary btn-block"><b>Follow</b></a-->
</div>
<!-- /.box-body -->
</div>
<!-- /.box -->
<div>
<br>
</div>
<!-- About Me Box -->
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title">About Me</h3>
</div>
<!-- /.box-header -->
<div class="box-body">
<strong><i class="fa fa-book margin-r-5"></i> Education</strong>
<p class="text-muted">
B.S. in Computer Science from the University of Tennessee at Knoxville
</p>
<hr>
<strong><i class="fa fa-map-marker margin-r-5"></i> Location</strong>
<p class="text-muted">Malibu, California</p>
<hr>
<strong><i class="fa fa-pencil margin-r-5"></i> Skills</strong>
<p>
<span class="label label-danger">UI Design</span>
<span class="label label-success">Coding</span>
<span class="label label-info">Javascript</span>
<span class="label label-warning">PHP</span>
<span class="label label-primary">Node.js</span>
</p>
<hr>
<strong><i class="fa fa-file-text-o margin-r-5"></i> Notes</strong>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam fermentum enim neque.</p>
</div>
<!-- /.box-body -->
</div>
<!-- /.box -->
</div>
\ No newline at end of file
<div class="form-group">
<br>
<!--ul class="sidebar-menu" data-widget="tree">
<li>
<a class="treeview " href="{{ BASE_URL }}/administration">
<i class="fa fa-home"></i>
<span>Dashboard</span>
<span class="pull-right-container">
<span class="label label-primary pull-right"></span>
</span>
</a>
</li>
<li>
<a class="treeview " href="../../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>
</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'),
]
# + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
from django.shortcuts import render
# Create your views here.
def Users(request):
return render(request,'User_profile.html')
\ No newline at end of file
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