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
f0537364
Commit
f0537364
authored
Feb 06, 2019
by
José Luis Uc
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of gitlab.geoint.mx:mario.chirinos/GeoInt_SIDT into dev
parents
b0ea183d
f5991429
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
90 additions
and
61 deletions
+90
-61
body.css
catalog/static/catalog/css/body.css
+6
-1
map.css
catalog/static/catalog/css/map.css
+2
-1
dataRetrieval.js
catalog/static/catalog/js/dataRetrieval.js
+50
-50
base_top.html
catalog/templates/base_top.html
+1
-1
map.html
catalog/templates/map.html
+1
-0
templates.html
catalog/templates/templates.html
+2
-2
views.py
catalog/views.py
+28
-6
No files found.
catalog/static/catalog/css/body.css
View file @
f0537364
...
...
@@ -331,7 +331,7 @@ div .menu-info h4 {
/*}*/
div
#product-list-globe
{
max-height
:
773
px
;
max-height
:
820
px
;
overflow
:
auto
;
}
...
...
@@ -363,6 +363,11 @@ ul.product_list_category li:hover div.bg-geo {
display
:
block
;
}
div
#product-list-cart
{
max-height
:
820px
;
overflow
:
auto
;
}
/*div #product-list-cart-items {
max-height: 167px;
overflow: auto;
...
...
catalog/static/catalog/css/map.css
View file @
f0537364
...
...
@@ -17,7 +17,8 @@ html, body
position
:
absolute
;
bottom
:
0
;
border
:
0px
solid
blue
;
z-index
:
99999
;
/* z-index: 99999; */
z-index
:
6
!important
;
width
:
100%
;
height
:
32px
;
vertical-align
:
middle
;
...
...
catalog/static/catalog/js/dataRetrieval.js
View file @
f0537364
...
...
@@ -66,6 +66,42 @@ var makeRequest = function (value) {
});
};
function
updateCart
(){
$
(
"#product-list-cart"
).
empty
();
$
.
ajax
({
type
:
'POST'
,
url
:
prod_from_cartDB_url
,
data
:
{
'csrfmiddlewaretoken'
:
document
.
getElementsByName
(
'csrfmiddlewaretoken'
)[
0
].
value
},
dataType
:
'json'
,
success
:
function
(
data
)
{
productsToObtain
=
[];
createProductContainer
(
data
.
product_list
);
data
.
product_list
.
forEach
(
function
(
products
)
{
let
id
=
"L-"
+
products
.
aggreg_date
.
replace
(
/
([
.*+?^=!:${}()|
\[\]\/\\])
/g
,
"-"
);
products
.
catalog
.
forEach
(
function
(
product
)
{
var
temp_2
=
document
.
querySelector
(
'#product_cart_2'
);
// filling template
temp_2
.
content
.
querySelector
(
'li'
).
id
=
product
.
uuid
;
temp_2
.
content
.
querySelector
(
'h4'
).
id
=
product
.
uuid
+
"-h4"
;
temp_2
.
content
.
querySelector
(
'h4'
).
textContent
=
product
.
info
.
producttype
+
"_"
+
product
.
info
.
tileid
;
temp_2
.
content
.
querySelector
(
'p'
).
textContent
=
product
.
info
.
beginposition
;
temp_2
.
content
.
querySelector
(
'img'
).
src
=
"data:image/jpeg;base64, "
+
product
.
info
.
img
;
temp_2
.
content
.
querySelectorAll
(
'span'
)[
1
].
textContent
=
product
.
info
.
identifier
;
temp_2
.
content
.
querySelectorAll
(
'span'
)[
2
].
textContent
=
product
.
info
.
size
;
temp_2
.
content
.
querySelectorAll
(
'span'
)[
3
].
textContent
=
product
.
info
.
instrumentname
;
var
clone_2
=
document
.
importNode
(
temp_2
.
content
,
true
);
//document.querySelector('#product-list-cart-items').appendChild(clone_2);
document
.
querySelector
(
'#'
+
id
).
appendChild
(
clone_2
);
});
});
}
});
};
function
drawPolygon
(
element
)
{
polygonList
.
forEach
(
function
(
polygon
)
{
...
...
@@ -171,14 +207,15 @@ function drawApiResponse(element) {
}
function
createProductContainer
()
{
function
createProductContainer
(
products
)
{
products
.
forEach
(
function
(
list
){
var
temp_1
=
document
.
querySelector
(
'#product_cart_1'
);
// filling template
temp_1
.
content
.
querySelector
(
'span'
).
textContent
=
"Product"
;
let
name
=
list
.
aggreg_date
.
replace
(
/
([
.*+?^=!:${}()|
\[\]\/\\])
/g
,
"-"
);
temp_1
.
content
.
querySelector
(
'span'
).
textContent
=
name
;
temp_1
.
content
.
querySelector
(
'ul .control-sidebar-menu'
).
id
=
"L-"
+
name
;
var
clone_1
=
document
.
importNode
(
temp_1
.
content
,
true
);
document
.
querySelector
(
'#product-list-cart'
).
appendChild
(
clone_1
);
})
}
let
productCategory
=
new
Map
();
...
...
@@ -416,45 +453,7 @@ $(document).ready(function () {
success
:
function
()
{
cartProductList
=
[];
productUUIDListCart
.
push
.
apply
(
productUUIDListCart
,
productsToObtain
);
if
(
!
IS_PRODUCT_CONTAINER
)
{
// building product container
createProductContainer
();
IS_PRODUCT_CONTAINER
=
true
;
// this flag is set to false when products are purchased
}
// request to DB for showing the products in cart
// variable prod_from_cartDB_url in map.html
$
.
ajax
({
type
:
'POST'
,
url
:
prod_from_cartDB_url
,
data
:
{
'csrfmiddlewaretoken'
:
document
.
getElementsByName
(
'csrfmiddlewaretoken'
)[
0
].
value
,
'product_uuid_list'
:
productsToObtain
.
toString
()
},
dataType
:
'json'
,
success
:
function
(
data
)
{
productsToObtain
=
[];
data
.
product_list
.
forEach
(
function
(
products
)
{
products
.
catalog
.
forEach
(
function
(
product
){
var
temp_2
=
document
.
querySelector
(
'#product_cart_2'
);
// filling template
temp_2
.
content
.
querySelector
(
'li'
).
id
=
product
.
uuid
;
temp_2
.
content
.
querySelector
(
'h4'
).
id
=
product
.
uuid
+
"-h4"
;
temp_2
.
content
.
querySelector
(
'h4'
).
textContent
=
product
.
info
.
producttype
+
"_"
+
product
.
info
.
tileid
;
temp_2
.
content
.
querySelector
(
'p'
).
textContent
=
product
.
info
.
beginposition
;
temp_2
.
content
.
querySelector
(
'img'
).
src
=
"data:image/jpeg;base64, "
+
product
.
info
.
img
;
temp_2
.
content
.
querySelectorAll
(
'span'
)[
1
].
textContent
=
product
.
info
.
identifier
;
temp_2
.
content
.
querySelectorAll
(
'span'
)[
2
].
textContent
=
product
.
info
.
size
;
temp_2
.
content
.
querySelectorAll
(
'span'
)[
3
].
textContent
=
product
.
info
.
instrumentname
;
var
clone_2
=
document
.
importNode
(
temp_2
.
content
,
true
);
document
.
querySelector
(
'#product-list-cart-items'
).
appendChild
(
clone_2
);
});
});
}
});
updateCart
();
}
});
}
else
{
...
...
@@ -494,6 +493,7 @@ $(document).ready(function () {
'startDate'
:
$
(
"#product-form input[name=start]"
).
val
(),
'endDate'
:
$
(
"#product-form input[name=end]"
).
val
(),
'clouds'
:
$
(
"#product-form input[name=cloudPercentage]"
).
val
(),
'usuario'
:
$
(
"#product-form input[name=user_name]"
).
val
()
},
dataType
:
'json'
});
...
...
catalog/templates/base_top.html
View file @
f0537364
...
...
@@ -104,7 +104,7 @@
<!-- Create the tabs -->
<ul
class=
"nav nav-tabs nav-justified control-sidebar-tabs"
>
<li
id=
"globe"
><a
href=
"#control-sidebar-home-tab"
data-toggle=
"tab"
><i
class=
"fa fa-globe"
></i></a></li>
<li
id=
"cart"
><a
href=
"#control-sidebar-settings-tab"
data-toggle=
"tab"
><i
class=
"fa fa-shopping-cart"
></i></a>
<li
id=
"cart"
><a
href=
"#control-sidebar-settings-tab"
onclick=
"updateCart()"
data-toggle=
"tab"
><i
class=
"fa fa-shopping-cart"
></i></a>
</li>
</ul>
<!-- Tab panes -->
...
...
catalog/templates/map.html
View file @
f0537364
...
...
@@ -137,6 +137,7 @@
<!-- <form role="form" target="catalogFrame" action="{% url 'productList' %}" method="post"> -->
<form
id=
'product-form'
role=
"form"
method=
"post"
>
{% csrf_token %}
<input
type=
"hidden"
id=
"user_name"
name=
"user_name"
value=
{{user.get_username}}
>
<ul
class=
"sidebar-menu"
data-widget=
"tree"
>
<li
class=
"treeview"
>
<a
href=
"#"
>
...
...
catalog/templates/templates.html
View file @
f0537364
...
...
@@ -80,7 +80,7 @@
</a>
<ul
class=
"treeview-menu sidebar-form"
>
<li>
<ul
id=
"
product-list-cart-items"
class=
"control-sidebar-menu
"
></ul>
<ul
id=
"
"
class=
"control-sidebar-menu product_list_category
"
></ul>
</li>
</ul>
</li>
...
...
@@ -95,7 +95,7 @@
<p></p>
</div>
</a>
<div
class=
"info-product-
cart-
box bg-geo"
>
<div
class=
"info-product-box bg-geo"
>
<span
class=
"info-product-box-img"
>
<img
src=
""
>
</span>
...
...
catalog/views.py
View file @
f0537364
...
...
@@ -12,12 +12,14 @@ from django.core import management
#from urllib import urlencode
#from collections import OrderedDict
import
requests
,
json
,
unicodedata
,
sys
,
base64
import
os
import
sys
sys
.
path
.
append
(
'../GeoSentinel/'
)
from
geosentinel
import
APISentinel
,
polygonToBox
sentinel
=
APISentinel
.
APISentinel
(
'emmhp'
,
'geoemm29'
)
NAS_PATH
=
'/home/david/NAS/'
# Create your views here.
...
...
@@ -206,13 +208,14 @@ def getFromCart(request):
user
=
User
.
objects
.
get
(
id
=
request
.
user
.
id
)
prod_list
=
[]
product_list
=
Purchase
.
objects
.
values
(
'user'
,
'productList'
,
'purchased'
,
'pric
e'
)
.
filter
(
user
=
user
,
purchased
=
0
)
product_list
=
Purchase
.
objects
.
values
(
'user'
,
'productList'
,
'purchased'
,
'price'
,
'aggreg_dat
e'
)
.
filter
(
user
=
user
,
purchased
=
0
)
for
products
in
product_list
:
product
=
json
.
loads
(
products
[
'productList'
])
prod_list
.
append
({
'purchased'
:
products
[
'purchased'
],
'price'
:
products
[
'price'
],
'aggreg_date'
:
products
[
'aggreg_date'
],
'catalog'
:
product
})
return
JsonResponse
({
'product_list'
:
prod_list
})
...
...
@@ -267,17 +270,36 @@ def purchaseProduct(request):
print
(
request
.
POST
[
'startDate'
])
print
(
request
.
POST
[
'endDate'
])
print
(
request
.
POST
[
'clouds'
])
print
(
request
.
POST
[
'usuario'
])
username
=
request
.
POST
[
'usuario'
]
fecha_inicio
=
request
.
POST
[
'startDate'
]
fecha_fin
=
request
.
POST
[
'endDate'
]
print
(
fecha_inicio
.
replace
(
"-"
,
""
))
print
(
fecha_fin
.
replace
(
"-"
,
""
))
userdir
=
NAS_PATH
+
"repsat_test_dev/"
+
username
##crea el directorio del usuario
if
not
os
.
path
.
exists
(
userdir
):
os
.
makedirs
(
userdir
)
products_dir
=
NAS_PATH
+
"sentinelImages/L2A/"
linksDir
=
userdir
+
"/L2A/"
#obtiene los datos para el json
data
=
{}
data
[
'wkt'
]
=
request
.
POST
[
'wkt'
]
data
[
'platform'
]
=
'Sentinel-2'
data
[
'productLevel'
]
=
'L2A'
data
[
'startDate'
]
=
request
.
POST
[
'startDate'
]
data
[
'endDate'
]
=
request
.
POST
[
'endDate'
]
data
[
'startDate'
]
=
fecha_inicio
.
replace
(
"-"
,
""
)
#quita los guiones de la fecha
data
[
'endDate'
]
=
fecha_fin
.
replace
(
"-"
,
""
)
#quita los guiones de la fecha
#~ data['startDate'] = request.POST['startDate']
#~ data['endDate'] = request.POST['endDate']
data
[
'clouds'
]
=
request
.
POST
[
'clouds'
]
data
[
'productsDir'
]
=
'/home/david/NAS/sentinelImages/L2A/'
data
[
'linksDir'
]
=
'/home/david/centroGEO/repsat/tests/L2A/'
#~ data['productsDir'] = '/home/david/NAS/sentinelImages/L2A/'
#~ data['linksDir'] = '/home/david/centroGEO/repsat/tests/L2A/'
data
[
'productsDir'
]
=
products_dir
data
[
'linksDir'
]
=
linksDir
data
[
'username'
]
=
'mario-chirinos'
data
[
'password'
]
=
'r4nc0r4u'
...
...
@@ -286,7 +308,7 @@ def purchaseProduct(request):
json_data
=
json
.
dumps
(
data
,
indent
=
4
)
print
(
json_data
)
#escribe el json en el archivo
fidProductsFile
=
open
(
"/home/david/centroGEO/repsat/GeoInt_SIDT
/findProducts.json"
,
"w"
)
fidProductsFile
=
open
(
userdir
+
"
/findProducts.json"
,
"w"
)
fidProductsFile
.
write
(
json_data
)
fidProductsFile
.
close
()
...
...
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