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
cc6fa8ef
Commit
cc6fa8ef
authored
Nov 22, 2015
by
Rafal
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
334fd8b5
2e32bf95
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
44 deletions
+73
-44
beacon.js
BeHub/Hub/static/js/beacon.js
+57
-41
map.js
BeHub/Hub/static/js/map.js
+16
-3
No files found.
BeHub/Hub/static/js/beacon.js
View file @
cc6fa8ef
...
@@ -96,51 +96,67 @@ function removeLink(beacon_manager, link){
...
@@ -96,51 +96,67 @@ function removeLink(beacon_manager, link){
function
dodajLink
(
beacon_manager
,
beacon
){
function
dodajLink
(
beacon_manager
,
beacon
){
$
(
"#myModal"
).
modal
(
"show"
);
$
.
getJSON
(
"/api/category/"
,
function
(
data
){
$
(
"#modal-content"
).
html
(
'<form action="/login/" method="post" class="form-signin">
\
$
(
"#myModal"
).
modal
(
"show"
);
var
html
=
'<form action="/login/" method="post" class="form-signin">
\
<p><input id="url" type="text" class="form-control" placeholder="Link url" required autofocus name="name"></p>
\
<p><input id="url" type="text" class="form-control" placeholder="Link url" required autofocus name="name"></p>
\
<p><input id="desc" type="text" class="form-control" placeholder="Description" required autofocus name="desc"></p>
\
<p><input id="desc" type="text" class="form-control" placeholder="Description" required autofocus name="desc"></p>'
;
</form>'
);
$
(
"#modal-footer"
).
html
(
'<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
\
html
+=
"<select id=
\"
kat
\"
class=
\"
form-control
\"
>"
<button type="button" class="btn btn-primary" id="addProjectBtn">Add beacon</button>'
);
html
+=
"<option value=
\"
-
\"
>No category</option>"
;
for
(
var
i
=
0
;
i
<
data
.
results
.
length
;
i
++
){
html
+=
"<option value=
\"
"
+
data
.
results
[
i
].
url
+
"
\"
>"
+
data
.
results
[
i
].
name
+
"</option>"
;
}
html
+=
"</select>"
html
+=
'</form>'
;
$
(
"#addProjectBtn"
).
off
(
"click"
);
$
(
"#modal-content"
).
html
(
html
)
$
(
"#addProjectBtn"
).
on
(
"click"
,
function
(){
var
link_url
=
$
(
"#url"
).
val
();
var
desc
=
$
(
"#desc"
).
val
();
var
data
=
{
"link_url"
:
link_url
,
"description"
:
desc
,
"categories"
:
[],
"author"
:
user_id
,
};
$
.
ajax
({
$
(
"#modal-footer"
).
html
(
'<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
\
url
:
"/api/sites/"
,
<button type="button" class="btn btn-primary" id="addProjectBtn">Add beacon</button>'
);
type
:
'POST'
,
data
:
JSON
.
stringify
(
data
),
$
(
"#addProjectBtn"
).
off
(
"click"
);
contentType
:
"application/json"
,
$
(
"#addProjectBtn"
).
on
(
"click"
,
function
(){
success
:
function
(
beacon_manager
){
return
function
(
result
)
{
var
link_url
=
$
(
"#url"
).
val
();
$
.
ajax
({
var
desc
=
$
(
"#desc"
).
val
();
url
:
beacon_manager
,
var
kat
=
$
(
"#kat"
).
val
();
type
:
'GET'
,
if
(
kat
==
"-"
){
data
:
JSON
.
stringify
(
data
),
delete
kat
;
contentType
:
"application/json"
,
}
success
:
function
(
site_data
){
return
function
(
result
)
{
var
data
=
{
result
[
'sites'
].
push
(
site_data
.
url
);
"link_url"
:
link_url
,
$
.
ajax
({
"description"
:
desc
,
url
:
result
.
url
,
"categories"
:
[],
type
:
"PUT"
,
"author"
:
user_id
,
data
:
JSON
.
stringify
(
result
),
};
contentType
:
"application/json"
,
success
:
function
(){
$
.
ajax
({
document
.
location
.
reload
()
url
:
"/api/sites/"
,
}
type
:
'POST'
,
})
data
:
JSON
.
stringify
(
data
),
}}(
result
)
contentType
:
"application/json"
,
});
success
:
function
(
beacon_manager
){
return
function
(
result
)
{
}}(
beacon_manager
)
$
.
ajax
({
url
:
beacon_manager
,
type
:
'GET'
,
data
:
JSON
.
stringify
(
data
),
contentType
:
"application/json"
,
success
:
function
(
site_data
){
return
function
(
result
)
{
result
[
'sites'
].
push
(
site_data
.
url
);
$
.
ajax
({
url
:
result
.
url
,
type
:
"PUT"
,
data
:
JSON
.
stringify
(
result
),
contentType
:
"application/json"
,
success
:
function
(){
document
.
location
.
reload
()
}
})
}}(
result
)
});
}}(
beacon_manager
)
});
});
});
});
});
}
}
\ No newline at end of file
BeHub/Hub/static/js/map.js
View file @
cc6fa8ef
...
@@ -38,13 +38,21 @@ Map.prototype.addMarker = function(data){
...
@@ -38,13 +38,21 @@ Map.prototype.addMarker = function(data){
icon
:
image
,
icon
:
image
,
title
:
data
.
title
,
title
:
data
.
title
,
beacon
:
data
.
beacon
beacon
:
data
.
beacon
}).
addListener
(
'click'
,
function
()
{
})
marker
.
addListener
(
'click'
,
function
()
{
self
.
showInfo
(
this
.
beacon
)
self
.
showInfo
(
this
.
beacon
)
})
})
self
.
markers
.
push
(
marker
)
self
.
markers
.
push
(
marker
)
}
}
Map
.
prototype
.
clearMarkers
=
function
(){
for
(
var
i
=
0
;
i
<
this
.
markers
.
length
;
i
++
){
this
.
markers
[
i
].
setMap
(
null
);
}
}
Map
.
prototype
.
getAllBeacons
=
function
(){
Map
.
prototype
.
getAllBeacons
=
function
(){
var
self
=
this
;
var
self
=
this
;
$
.
getJSON
(
"/api/user_project/"
+
project_id
+
"/beacons"
,
function
(
data
){
$
.
getJSON
(
"/api/user_project/"
+
project_id
+
"/beacons"
,
function
(
data
){
...
@@ -68,6 +76,7 @@ Map.prototype.getAllBeacons = function(){
...
@@ -68,6 +76,7 @@ Map.prototype.getAllBeacons = function(){
}
}
Map
.
prototype
.
showInfo
=
function
(
beacon
){
Map
.
prototype
.
showInfo
=
function
(
beacon
){
var
self
=
true
;
$
(
"#myModalLabel"
).
text
([
beacon
.
name
,
" ("
,
beacon
.
uuid
,
")"
].
join
(
""
))
$
(
"#myModalLabel"
).
text
([
beacon
.
name
,
" ("
,
beacon
.
uuid
,
")"
].
join
(
""
))
$
(
"#modal-content"
).
html
([
$
(
"#modal-content"
).
html
([
'<div class="col-md-6">'
,
'<div class="col-md-6">'
,
...
@@ -126,7 +135,9 @@ Map.prototype.showInfo = function(beacon){
...
@@ -126,7 +135,9 @@ Map.prototype.showInfo = function(beacon){
data
:
JSON
.
stringify
(
data
),
data
:
JSON
.
stringify
(
data
),
contentType
:
"application/json"
,
contentType
:
"application/json"
,
success
:
function
(
result
)
{
success
:
function
(
result
)
{
alert
(
JSON
.
stringify
(
result
))
map
.
clearMarkers
();
map
.
getAllBeacons
();
$
(
"#myModal"
).
modal
(
"hide"
);
}
}
});
});
...
@@ -143,7 +154,9 @@ Map.prototype.showInfo = function(beacon){
...
@@ -143,7 +154,9 @@ Map.prototype.showInfo = function(beacon){
data
:
JSON
.
stringify
(
data
),
data
:
JSON
.
stringify
(
data
),
contentType
:
"application/json"
,
contentType
:
"application/json"
,
success
:
function
(
result
)
{
success
:
function
(
result
)
{
alert
(
JSON
.
stringify
(
result
))
map
.
clearMarkers
();
map
.
getAllBeacons
();
$
(
"#myModal"
).
modal
(
"hide"
);
}
}
});
});
...
...
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