Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
BeHub-web
Project
Project
Details
Activity
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dominik Rosiek
BeHub-web
Commits
446b8885
Commit
446b8885
authored
Nov 22, 2015
by
Dominik Rosiek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
:)
parent
c33bfdf2
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
3 deletions
+68
-3
map.js
BeHub/Hub/static/js/map.js
+60
-0
maps.html
BeHub/Hub/templates/user_panel/content/maps.html
+7
-2
views.py
BeHub/Hub/views.py
+1
-1
No files found.
BeHub/Hub/static/js/map.js
View file @
446b8885
...
...
@@ -34,7 +34,19 @@ Map.prototype.addMarker = function(data){
title
:
data
.
title
,
beacon
:
data
.
beacon
}).
addListener
(
'click'
,
function
()
{
if
(
!
project_data
){
$
.
getJSON
(
"/api/user_project/"
+
project_id
+
"/beacons"
,
function
(
beacon
){
return
function
(
data
){
project_data
=
data
project_summary
[
'uuids'
]
=
[];
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
){
project_summary
[
'uuids'
].
push
(
project_data
[
i
].
uuid
)
}
self
.
showInfo
(
beacon
)
}}(
this
.
beacon
))
}
else
{
self
.
showInfo
(
this
.
beacon
)
}
})
self
.
markers
.
push
(
marker
)
...
...
@@ -89,6 +101,54 @@ Map.prototype.showInfo = function(beacon){
beacon
.
latitude
,
'</div>'
,
'<div class="clearfix"></div>'
].
join
(
""
))
if
(
project_summary
[
'uuids'
].
indexOf
(
beacon
.
uuid
)
===
-
1
){
$
(
"#modal-footer"
).
html
(
'<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
\
<button type="button" class="btn btn-danger" id="addToProjectBtn" >Add to project</button>'
)
}
else
{
$
(
"#modal-footer"
).
html
(
'<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
\
<button type="button" class="btn btn-danger" id="removeFromProjectBtn">Remove from project</button>'
)
}
$
(
"#removeFromProjectBtn"
).
click
(
function
(
beacon
){
return
function
(){
$
.
getJSON
(
"/api/user_project/"
+
project_id
,
function
(
beacon
){
return
function
(
data
){
var
index
=
data
[
'beacon_managers'
].
indexOf
(
beacon
.
beacon_manager_url
)
data
[
'beacon_managers'
].
slice
(
index
,
1
);
$
.
ajax
({
url
:
"/api/user_project/"
+
project_id
,
type
:
'PUT'
,
data
:
data
,
dataType
:
"json"
,
success
:
function
(
result
)
{
alert
(
result
)
}
});
}}(
beacon
));
}}(
beacon
));
$
(
"#addToProjectBtn"
).
click
(
function
(
beacon
){
return
function
(){
$
.
getJSON
(
"/api/user_project/"
+
project_id
,
function
(
beacon
){
return
function
(
data
){
data
[
'beacon_managers'
].
push
(
beacon
.
beacon_manager_url
)
$
.
ajax
({
url
:
"/api/user_project/"
+
project_id
,
type
:
'PUT'
,
data
:
data
,
dataType
:
"json"
,
success
:
function
(
result
)
{
alert
(
result
)
}
});
}}(
beacon
));
}}(
beacon
));
$
(
"#myModal"
).
modal
(
"show"
);
// alert('marker klikniety' + marker.beacon.uuid)
}
\ No newline at end of file
BeHub/Hub/templates/user_panel/content/maps.html
View file @
446b8885
...
...
@@ -4,6 +4,11 @@
<script>
var
map
;
var
project_id
=
parseInt
(
'{{ project_id }}'
);
var
project_data
;
var
beaconManager
;
var
project_summary
=
{};
$
(
document
).
ready
(
function
(){
$
(
'a[data-toggle="tab"]'
).
on
(
'shown.bs.tab'
,
function
(
e
)
{
var
target
=
$
(
e
.
target
).
attr
(
"href"
)
// activated tab
...
...
@@ -27,9 +32,9 @@
<div
class=
"modal-body"
id=
"modal-content"
>
</div>
<div
class=
"modal-footer"
>
<div
class=
"modal-footer"
id=
"modal-footer"
>
<button
type=
"button"
class=
"btn btn-default"
data-dismiss=
"modal"
>
Close
</button>
<button
type=
"button"
class=
"btn btn-primary"
>
Save changes
</button>
<button
type=
"button"
class=
"btn btn-primary"
>
Add to category
</button>
</div>
</div>
</div>
...
...
BeHub/Hub/views.py
View file @
446b8885
...
...
@@ -155,7 +155,7 @@ def project(request, project_id):
data
[
'user_project'
]
=
user_project
#user_project_serializer = UserProjectSerializer(user_project, context={'request': request})
#data['project_data'] = user_project_serializer.data
#
data['project_id'] = project_id
data
[
'project_id'
]
=
project_id
#data['beacon_display'] = []
# beacon_managers = user_project.beacon_managers.all()
# for beacon_manager in beacon_managers:
...
...
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