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
ef6c8b1a
Commit
ef6c8b1a
authored
Jan 17, 2019
by
Mario Chirinos Colunga
Browse files
Options
Browse Files
Download
Plain Diff
updata
parents
0bfae9f3
ad233d58
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
119 additions
and
35 deletions
+119
-35
.gitignore
.gitignore
+1
-0
models.py
catalog/models.py
+1
-1
dataRetrieval.js
catalog/static/catalog/js/dataRetrieval.js
+70
-28
map.html
catalog/templates/map.html
+6
-5
urls.py
catalog/urls.py
+5
-0
views.py
catalog/views.py
+35
-0
geosentinel
geosentinel
+1
-1
No files found.
.gitignore
View file @
ef6c8b1a
...
@@ -3,3 +3,4 @@
...
@@ -3,3 +3,4 @@
*.pyc
*.pyc
.idea/
.idea/
__pycache__/
__pycache__/
geosentinel/
catalog/models.py
View file @
ef6c8b1a
...
@@ -42,8 +42,8 @@ class Product_l2a(models.Model):
...
@@ -42,8 +42,8 @@ class Product_l2a(models.Model):
class
CartProduct
(
models
.
Model
):
class
CartProduct
(
models
.
Model
):
user
=
models
.
ForeignKey
(
User
,
on_delete
=
models
.
CASCADE
)
user
=
models
.
ForeignKey
(
User
,
on_delete
=
models
.
CASCADE
)
aggreg_date
=
models
.
DateTimeField
(
auto_now
=
True
)
## date of product aggregation
uuid
=
models
.
CharField
(
max_length
=
50
)
uuid
=
models
.
CharField
(
max_length
=
50
)
aggreg_date
=
models
.
DateTimeField
(
auto_now
=
True
)
## date of product aggregation
info
=
models
.
TextField
(
null
=
True
)
info
=
models
.
TextField
(
null
=
True
)
purchased
=
models
.
NullBooleanField
()
purchased
=
models
.
NullBooleanField
()
...
...
catalog/static/catalog/js/dataRetrieval.js
View file @
ef6c8b1a
...
@@ -14,8 +14,8 @@ var polygonList;
...
@@ -14,8 +14,8 @@ var polygonList;
var
makeRequest
=
function
(
value
)
{
var
makeRequest
=
function
(
value
)
{
var
pol_element
=
document
.
getElementById
(
'polygon-list'
);
var
pol_element
=
document
.
getElementById
(
'polygon-list'
);
//
petición de municipios a base de datos
//
city request to DB
// variable req_url
e
n map.html
// variable req_url
i
n map.html
$
.
ajax
({
$
.
ajax
({
type
:
"POST"
,
type
:
"POST"
,
url
:
req_url
,
url
:
req_url
,
...
@@ -112,6 +112,7 @@ $("#id_polygon").on('keyup', function (e) {
...
@@ -112,6 +112,7 @@ $("#id_polygon").on('keyup', function (e) {
});
});
// this function cleans list of available products
function
erase_product_list_globe
()
{
function
erase_product_list_globe
()
{
prevfeature
=
null
;
prevfeature
=
null
;
var
pol_element
=
document
.
getElementById
(
'product-list-globe'
);
var
pol_element
=
document
.
getElementById
(
'product-list-globe'
);
...
@@ -121,6 +122,7 @@ function erase_product_list_globe() {
...
@@ -121,6 +122,7 @@ function erase_product_list_globe() {
}
}
// this function cleans list of available products by ID
function
erase_product_list_globe_by_id
(
element_id
)
{
function
erase_product_list_globe_by_id
(
element_id
)
{
var
$div_element
=
$
(
'div#'
+
element_id
+
"-div"
);
var
$div_element
=
$
(
'div#'
+
element_id
+
"-div"
);
var
$li_element
=
$
(
'li#'
+
element_id
+
"-li"
);
var
$li_element
=
$
(
'li#'
+
element_id
+
"-li"
);
...
@@ -129,6 +131,15 @@ function erase_product_list_globe_by_id(element_id) {
...
@@ -129,6 +131,15 @@ function erase_product_list_globe_by_id(element_id) {
}
}
// this function cleans list of products in cart
function
erase_product_list_cart
()
{
var
item_element
=
document
.
getElementById
(
'product-list-cart'
);
while
(
item_element
.
firstChild
)
{
item_element
.
removeChild
(
item_element
.
firstChild
);
}
}
var
prevfeature
=
null
;
var
prevfeature
=
null
;
function
drawApiResponse
(
element
)
{
function
drawApiResponse
(
element
)
{
var
list_globe
=
document
.
getElementById
(
'product-list-globe'
).
children
;
var
list_globe
=
document
.
getElementById
(
'product-list-globe'
).
children
;
...
@@ -220,6 +231,7 @@ $(document).ready(function () {
...
@@ -220,6 +231,7 @@ $(document).ready(function () {
var
typingInterval
=
800
;
//milliseconds
var
typingInterval
=
800
;
//milliseconds
var
productListGlobe
=
[];
var
productListGlobe
=
[];
var
cartProductList
=
[];
// this array represent DB where products will be stored
var
cartProductList
=
[];
// this array represent DB where products will be stored
var
productsToObtain
=
[];
var
productUUIDListCart
=
[];
var
productUUIDListCart
=
[];
// On keyup, start the contdown
// On keyup, start the contdown
...
@@ -250,8 +262,8 @@ $(document).ready(function () {
...
@@ -250,8 +262,8 @@ $(document).ready(function () {
erase_product_list_globe
();
erase_product_list_globe
();
var
submit_data
=
$
(
'#product-form'
).
serialize
();
var
submit_data
=
$
(
'#product-form'
).
serialize
();
// p
etición de producto a base de datos
// p
roduct request to DB
// variable prod_req_url
e
n map.html
// variable prod_req_url
i
n map.html
$
.
ajax
({
$
.
ajax
({
type
:
"POST"
,
type
:
"POST"
,
url
:
prod_req_url
,
url
:
prod_req_url
,
...
@@ -268,7 +280,8 @@ $(document).ready(function () {
...
@@ -268,7 +280,8 @@ $(document).ready(function () {
console
.
log
(
"DEFS: ahora crea producto"
);
console
.
log
(
"DEFS: ahora crea producto"
);
data
.
catalog
.
forEach
(
function
(
data
)
{
data
.
catalog
.
forEach
(
function
(
data
)
{
// petición de imagen a webservice
// image request to webservice
// variable img_req_url in map.html
$
.
ajax
({
$
.
ajax
({
type
:
"GET"
,
type
:
"GET"
,
url
:
img_req_url
,
url
:
img_req_url
,
...
@@ -315,7 +328,7 @@ $(document).ready(function () {
...
@@ -315,7 +328,7 @@ $(document).ready(function () {
});
});
// a
grega producto al carrito
// a
dds product to cart
$
(
'#product-to-cart-form'
).
submit
(
function
(
event
)
{
$
(
'#product-to-cart-form'
).
submit
(
function
(
event
)
{
event
.
preventDefault
();
event
.
preventDefault
();
var
ul_element
=
document
.
getElementById
(
'product-list-globe'
);
var
ul_element
=
document
.
getElementById
(
'product-list-globe'
);
...
@@ -332,7 +345,7 @@ $(document).ready(function () {
...
@@ -332,7 +345,7 @@ $(document).ready(function () {
if
(
submit_data_array
.
indexOf
(
data
.
uuid
)
>
-
1
)
{
if
(
submit_data_array
.
indexOf
(
data
.
uuid
)
>
-
1
)
{
console
.
log
(
"DATA sí esta: "
,
data
.
uuid
);
console
.
log
(
"DATA sí esta: "
,
data
.
uuid
);
console
.
log
(
"SS: "
,
data
.
product
.
size
);
console
.
log
(
"SS: "
,
data
.
product
.
size
);
product
UUIDListCart
.
push
(
data
.
uuid
);
product
sToObtain
.
push
(
data
.
uuid
);
erase_product_list_globe_by_id
(
data
.
uuid
);
erase_product_list_globe_by_id
(
data
.
uuid
);
cartProductList
.
push
({
cartProductList
.
push
({
...
@@ -351,8 +364,8 @@ $(document).ready(function () {
...
@@ -351,8 +364,8 @@ $(document).ready(function () {
});
});
if
(
cartProductList
.
length
>
0
)
{
if
(
cartProductList
.
length
>
0
)
{
// request
para guardado de producto en carrito
// request
for saving product in cart DB
// variable prod_cart_url
e
n map.html
// variable prod_cart_url
i
n map.html
$
.
ajax
({
$
.
ajax
({
type
:
'POST'
,
type
:
'POST'
,
url
:
prod_cart_url
,
url
:
prod_cart_url
,
...
@@ -362,35 +375,26 @@ $(document).ready(function () {
...
@@ -362,35 +375,26 @@ $(document).ready(function () {
},
},
success
:
function
()
{
success
:
function
()
{
cartProductList
=
[];
cartProductList
=
[];
// PRODUCT_COUNTER += 1; // this variable counts the number of products in shopping cart
productUUIDListCart
.
push
.
apply
(
productUUIDListCart
,
productsToObtain
);
// PRODUCT_COUNTER_STR = PRODUCT_COUNTER.toString();
// var temp_1 = document.querySelector('#product_cart_1');
// var prod_id = temp_1.content.querySelectorAll('ul')[1].id + "-" + PRODUCT_COUNTER_STR;
// // filling template
// temp_1.content.querySelector('span').textContent = "Product " + PRODUCT_COUNTER_STR;
// temp_1.content.querySelectorAll('ul')[1].id = prod_id;
// var clone_1 = document.importNode(temp_1.content, true);
// document.querySelector('#product-list-cart').appendChild(clone_1);
if
(
!
IS_PRODUCT_CONTAINER
)
{
if
(
!
IS_PRODUCT_CONTAINER
)
{
// building product container
createProductContainer
();
createProductContainer
();
IS_PRODUCT_CONTAINER
=
true
;
IS_PRODUCT_CONTAINER
=
true
;
// this flag is set to false when products are purchased
}
}
// request
a DB para mostrar los productos en el carrito
// request
to DB for showing the products in cart
// variable prod_from_cartDB_url
e
n map.html
// variable prod_from_cartDB_url
i
n map.html
$
.
ajax
({
$
.
ajax
({
type
:
'POST'
,
type
:
'POST'
,
url
:
prod_from_cartDB_url
,
url
:
prod_from_cartDB_url
,
data
:
{
data
:
{
'csrfmiddlewaretoken'
:
document
.
getElementsByName
(
'csrfmiddlewaretoken'
)[
0
].
value
,
'csrfmiddlewaretoken'
:
document
.
getElementsByName
(
'csrfmiddlewaretoken'
)[
0
].
value
,
'product_uuid_list'
:
product
UUIDListCart
.
toString
()
'product_uuid_list'
:
product
sToObtain
.
toString
()
},
},
dataType
:
'json'
,
dataType
:
'json'
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
product
UUIDListCart
=
[];
product
sToObtain
=
[];
data
.
product_list
.
forEach
(
function
(
product
)
{
data
.
product_list
.
forEach
(
function
(
product
)
{
var
temp_2
=
document
.
querySelector
(
'#product_cart_2'
);
var
temp_2
=
document
.
querySelector
(
'#product_cart_2'
);
...
@@ -406,7 +410,6 @@ $(document).ready(function () {
...
@@ -406,7 +410,6 @@ $(document).ready(function () {
var
clone_2
=
document
.
importNode
(
temp_2
.
content
,
true
);
var
clone_2
=
document
.
importNode
(
temp_2
.
content
,
true
);
document
.
querySelector
(
'#product-list-cart-items'
).
appendChild
(
clone_2
);
document
.
querySelector
(
'#product-list-cart-items'
).
appendChild
(
clone_2
);
// document.querySelector('#' + prod_id).appendChild(clone_2);
});
});
}
}
});
});
...
@@ -420,4 +423,43 @@ $(document).ready(function () {
...
@@ -420,4 +423,43 @@ $(document).ready(function () {
}
}
}
}
});
});
// purchasing products in cart
$
(
'#purchased-product-form'
).
submit
(
function
(
event
)
{
event
.
preventDefault
();
var
ul_element
=
document
.
getElementById
(
'product-list-cart'
);
if
(
ul_element
.
firstChild
)
{
console
.
log
(
"productUUIDListCart: "
,
productUUIDListCart
);
var
productObject
=
{};
productListGlobe
.
forEach
(
function
(
data
)
{
if
(
productUUIDListCart
.
indexOf
(
data
.
uuid
)
>
-
1
)
{
productObject
[
data
.
uuid
]
=
data
.
product
;
}
});
// L1C product download request
// variable purch_prod_url in map.html
$
.
ajax
({
type
:
"POST"
,
url
:
purch_prod_url
,
data
:
{
'csrfmiddlewaretoken'
:
document
.
getElementsByName
(
'csrfmiddlewaretoken'
)[
0
].
value
,
'product_objects'
:
JSON
.
stringify
(
productObject
)
},
dataType
:
'json'
});
erase_product_list_cart
();
IS_PRODUCT_CONTAINER
=
false
;
productUUIDListCart
=
[];
}
else
{
mssgModal
({
title
:
"No products available!"
,
body
:
"There are no products charged in cart yet."
});
}
});
});
});
catalog/templates/map.html
View file @
ef6c8b1a
...
@@ -256,9 +256,10 @@
...
@@ -256,9 +256,10 @@
osmap
.
addInteraction
();
osmap
.
addInteraction
();
var
req_url
=
"{% url 'search-submit' %}"
;
// url for requesting polygon data
var
req_url
=
"{% url 'search-submit' %}"
;
// url for requesting polygon data
var
prod_req_url
=
"{% url 'productList' %}"
// url for requesting product data
var
prod_req_url
=
"{% url 'productList' %}"
;
// url for requesting product data
var
img_req_url
=
"{% url 'img-rqst' %}"
// url for requesting preview image
var
img_req_url
=
"{% url 'img-rqst' %}"
;
// url for requesting preview image
var
prod_cart_url
=
"{% url 'cart-rqst' %}"
// url for requesting product saving in cart
var
prod_cart_url
=
"{% url 'cart-rqst' %}"
;
// url for requesting product saving in cart
var
prod_from_cartDB_url
=
"{% url 'from-cart-rqst' %}"
// url for requesting product from cart table in DB
var
prod_from_cartDB_url
=
"{% url 'from-cart-rqst' %}"
;
// url for requesting product from cart table in DB
var
purch_prod_url
=
"{% url 'purch-prod-rqst' %}"
;
</script>
</script>
{% endblock %}
{% endblock %}
catalog/urls.py
View file @
ef6c8b1a
...
@@ -11,7 +11,12 @@ urlpatterns = [
...
@@ -11,7 +11,12 @@ urlpatterns = [
url
(
r'^imgrequest/$'
,
views
.
requestToImage
,
name
=
'img-rqst'
),
url
(
r'^imgrequest/$'
,
views
.
requestToImage
,
name
=
'img-rqst'
),
url
(
r'^cartrequest/$'
,
views
.
saveInCart
,
name
=
'cart-rqst'
),
url
(
r'^cartrequest/$'
,
views
.
saveInCart
,
name
=
'cart-rqst'
),
url
(
r'^fromcartrqst/$'
,
views
.
getFromCart
,
name
=
'from-cart-rqst'
),
url
(
r'^fromcartrqst/$'
,
views
.
getFromCart
,
name
=
'from-cart-rqst'
),
<<<<<<<
HEAD
# url(r'^scl/$', views.L2ASCL_data, name='L2ASCL-data'),
# url(r'^scl/$', views.L2ASCL_data, name='L2ASCL-data'),
=======
url
(
r'^purchcartrqst/$'
,
views
.
purchaseProduct
,
name
=
'purch-prod-rqst'
),
url
(
r'^scl/$'
,
views
.
L2ASCL_data
,
name
=
'L2ASCL-data'
)
>>>>>>>
ad233d589b10f9ad3e86a5f5e5201c7abf763f77
]
]
catalog/views.py
View file @
ef6c8b1a
...
@@ -202,6 +202,7 @@ def getFromCart(request):
...
@@ -202,6 +202,7 @@ def getFromCart(request):
})
})
return
JsonResponse
({
'product_list'
:
prod_list
})
return
JsonResponse
({
'product_list'
:
prod_list
})
<<<<<<<
HEAD
##-------------------------------------------------------------------------------
##-------------------------------------------------------------------------------
#def L2ASCL_data(request):
#def L2ASCL_data(request):
# with open("/home/mario/NAS_MarioCh/mario_repsat_test/T15QZD_sclData.json") as f:
# with open("/home/mario/NAS_MarioCh/mario_repsat_test/T15QZD_sclData.json") as f:
...
@@ -237,6 +238,40 @@ def getFromCart(request):
...
@@ -237,6 +238,40 @@ def getFromCart(request):
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
def
wsReportImages
(
request
):
def
wsReportImages
(
request
):
print
(
request
.
GET
)
print
(
request
.
GET
)
=======
#-------------------------------------------------------------------------------
def
purchaseProduct
(
request
):
"""
For now to purchase a product consists in verifying whether L1C products in cart already exist in DB.
"""
products
=
json
.
loads
(
request
.
POST
[
'product_objects'
])
orderedProducts
=
OrderedDict
()
for
p_uuid
in
products
.
keys
():
PRODUCT_EXISTS
=
Product_l1c
.
objects
.
filter
(
uuid
=
p_uuid
)
.
exists
()
if
not
PRODUCT_EXISTS
:
orderedProducts
[
p_uuid
]
=
products
[
p_uuid
]
print
orderedProducts
return
HttpResponse
(
status
=
204
)
## TODO: Implement a webservice in server for downloading those non-existing L1C products. ##
## TODO: Add product L1C to Cart DB after product download. ##
#-------------------------------------------------------------------------------
def
L2ASCL_data
(
request
):
with
open
(
"/home/mchc/data.json"
)
as
f
:
json_data
=
json
.
load
(
f
)
print
(
json_data
)
return
render
(
request
,
'L2ASCL_data.html'
,
{
"labels"
:
","
.
join
([
k
for
k
in
json_data
]),
"vegetation"
:[
v
[
"4"
]
for
k
,
v
in
json_data
.
items
()]
})
>>>>>>>
ad233d589b10f9ad3e86a5f5e5201c7abf763f77
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# def purchaseProduct(request):
# def purchaseProduct(request):
# """
# """
...
...
geosentinel
View file @
ef6c8b1a
/home/mchc/git/GeoSentinel/geosentinel/
/home/geointdev/sidt-env/GeoSentinel/geosentinel/
\ No newline at end of file
\ No newline at end of file
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