Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
intranet
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Bertrand Delhomme
intranet
Commits
cfe66135
Commit
cfe66135
authored
Oct 09, 2012
by
Daniel STAN
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[wifimap] édition borne (server side)
parent
7d8c1062
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
100 additions
and
23 deletions
+100
-23
apps/wifimap/admin.py
apps/wifimap/admin.py
+5
-0
apps/wifimap/models.py
apps/wifimap/models.py
+24
-1
apps/wifimap/views.py
apps/wifimap/views.py
+4
-0
settings.py
settings.py
+1
-1
static/css/wifimap.css
static/css/wifimap.css
+4
-0
static/js/wifimap.js
static/js/wifimap.js
+58
-21
templates/wifimap/index.html
templates/wifimap/index.html
+4
-0
No files found.
apps/wifimap/admin.py
0 → 100644
View file @
cfe66135
import
models
from
django.contrib
import
admin
admin
.
site
.
register
(
models
.
VirtAP
)
apps/wifimap/models.py
View file @
cfe66135
from
django.db
import
models
# Create your models here.
class
VirtAP
(
models
.
Model
):
u
"""Une borne virtuelle"""
class
Meta
:
verbose_name
=
"Borne WiFi virtuelle"
verbose_name_plural
=
"Bornes WiFi virtuelles"
#ordering = ['batiment', 'etage']
host
=
models
.
CharField
(
max_length
=
255
)
location
=
models
.
CharField
(
max_length
=
255
)
lat
=
models
.
FloatField
()
lon
=
models
.
FloatField
()
def
xmlRepr
(
self
,
doc
):
borne
=
doc
.
createElement
(
'borne'
)
borne
.
setAttribute
(
'virtual'
,
'virtual'
)
def
addTextNode
(
label
,
value
):
node
=
doc
.
createElement
(
label
)
node
.
appendChild
(
doc
.
createTextNode
(
unicode
(
value
)))
borne
.
appendChild
(
node
)
addTextNode
(
'hostname'
,
self
.
host
)
addTextNode
(
'lon'
,
self
.
lon
)
addTextNode
(
'lat'
,
self
.
lat
)
addTextNode
(
'location'
,
self
.
location
)
addTextNode
(
'client_count'
,
'0'
)
return
borne
apps/wifimap/views.py
View file @
cfe66135
...
...
@@ -24,6 +24,8 @@ import django.shortcuts
from
django.template
import
RequestContext
from
django.http
import
HttpResponse
from
models
import
VirtAP
#from django.contrib.auth.decorators import login_required, permission_required
...
...
@@ -31,6 +33,8 @@ def get_xml(request):
import
parse_xml
public
=
not
request
.
user
.
groups
.
filter
(
name
=
'crans_nounou'
)
doc
=
parse_xml
.
global_status
(
public
)
for
ap
in
VirtAP
.
objects
.
all
():
doc
.
documentElement
.
appendChild
(
ap
.
xmlRepr
(
doc
))
return
HttpResponse
(
doc
.
toxml
(
'utf-8'
),
content_type
=
'text/xml; coding=utf-8'
)
def
index
(
request
):
...
...
settings.py
View file @
cfe66135
...
...
@@ -102,7 +102,7 @@ LOGIN_URL = "/login"
LOGIN_REDIRECT_URL
=
"/"
AUTHENTICATION_BACKENDS
=
(
#
'intranet.login.LDAPUserBackend',
'intranet.login.LDAPUserBackend'
,
'django.contrib.auth.backends.ModelBackend'
,
)
...
...
static/css/wifimap.css
View file @
cfe66135
...
...
@@ -106,6 +106,10 @@
font-weight
:
normal
;
}
.borne
.coords.modified
{
color
:
red
;
}
/* sorting */
.order
{
...
...
static/js/wifimap.js
View file @
cfe66135
...
...
@@ -15,7 +15,8 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
var
debug
=
document
.
location
.
hostname
!=
'
intranet2.crans.org
'
;
//var debug = document.location.hostname != 'intranet2.crans.org';
var
debug
=
false
;
var
WifiMap
;
...
...
@@ -27,6 +28,7 @@ WifiMap = {
'
init
'
:
function
()
{
var
that
=
this
;
this
.
map
=
new
OpenLayers
.
Map
({
'
div
'
:
'
map
'
,
'
controls
'
:[]});
this
.
moved
=
null
;
// Note: Min lon: 2.325175
// : Min lat: 48.786424
// : Min lon: 2.33118
...
...
@@ -91,10 +93,17 @@ WifiMap = {
}
});
WifiMap
.
map
.
events
.
register
(
"
click
"
,
map
,
function
(
e
)
{
var
pos
=
WifiMap
.
map
.
getLonLatFromViewPortPx
(
WifiMap
.
map
.
events
.
getMousePosition
(
e
));
console
.
debug
(
pos
.
lon
,
pos
.
lat
);
});
this
.
map
.
events
.
register
(
"
click
"
,
this
,
function
(
e
)
{
var
pos
=
this
.
map
.
getLonLatFromViewPortPx
(
this
.
map
.
events
.
getMousePosition
(
e
));
var
gps
=
pos
.
clone
().
transform
(
this
.
projections
.
map
,
this
.
projections
.
gps
);
$
(
'
x
'
).
value
=
gps
.
lon
;
$
(
'
y
'
).
value
=
gps
.
lat
;
if
(
this
.
moved
)
{
this
.
moved
.
moveTo
(
gps
);
this
.
moved
=
false
;
}
});
//Event select: tout déselectionner
this
.
map
.
events
.
register
(
'
click
'
,
undefined
,
this
.
highlight
.
bind
(
this
,
undefined
));
...
...
@@ -136,15 +145,19 @@ WifiMap = {
borne
.
wifiMap
=
this
;
//Noms des fichiers images suivant le mode de la borne
var
files
=
{
'
on
'
:
'
marker-green
'
,
'
ens
'
:
'
marker-blue
'
,
'
off
'
:
'
marker
'
};
var
files
=
{
'
on
'
:
'
marker-green
'
,
'
ens
'
:
'
marker-blue
'
,
'
off
'
:
'
marker
'
,
'
autres
'
:
'
marker-gold
'
};
borne
.
update_info
=
function
(
xml
)
{
//Clean up last marker
var
old
=
this
.
marker
;
this
.
xml
=
xml
;
var
highlighted
=
this
.
highlighted
;
var
type
=
"
on
"
;
if
(
xml
.
hasAttribute
(
'
offline
'
))
type
=
"
off
"
;
if
(
xml
.
hasAttribute
(
'
virtual
'
))
type
=
"
autres
"
;
this
.
layer
=
that
.
bornesLayers
[
type
];
//On définit layer même
//S'il n'est pas sûr qu'on placera la borne sur la carte
if
(
old
)
{
...
...
@@ -153,20 +166,22 @@ WifiMap = {
old
.
destroy
();
this
.
marker
=
null
;
}
//New coords !
try
{
var
x
=
parseFloat
(
xml
.
getElementsByTagName
(
'
lon
'
)[
0
].
firstChild
.
nodeValue
);
var
y
=
parseFloat
(
xml
.
getElementsByTagName
(
'
lat
'
)[
0
].
firstChild
.
nodeValue
);
}
catch
(
e
)
{
this
.
mapPosition
=
undefined
;
//Mettre à jour les infos tabulaires de la borne avant de quitter
this
.
update_borne_infos
(
xml
);
return
;
}
//New coords ?
if
(
!
this
.
mapPosition
||
!
this
.
mapPosition
.
modified
)
{
try
{
var
x
=
parseFloat
(
xml
.
getElementsByTagName
(
'
lon
'
)[
0
].
firstChild
.
nodeValue
);
var
y
=
parseFloat
(
xml
.
getElementsByTagName
(
'
lat
'
)[
0
].
firstChild
.
nodeValue
);
}
catch
(
e
)
{
this
.
mapPosition
=
undefined
;
//Mettre à jour les infos tabulaires de la borne avant de quitter
this
.
update_borne_infos
(
xml
);
return
;
}
//mapPosition sera stockée dans les coordonnées de la map
this
.
mapPosition
=
new
OpenLayers
.
LonLat
(
x
,
y
);
//mapPosition sera stockée dans les coordonnées de la map
this
.
mapPosition
=
new
OpenLayers
.
LonLat
(
x
,
y
);
}
this
.
mapPosition
.
transform
(
that
.
projections
.
gps
,
that
.
projections
.
map
);
...
...
@@ -184,7 +199,7 @@ WifiMap = {
var
url
=
'
/static/OpenLayers/img/
'
+
(
files
[
type
])
+
'
.png
'
;
var
icon
=
new
OpenLayers
.
Icon
(
url
,
size
,
offset
);
this
.
marker
=
new
OpenLayers
.
Marker
(
this
.
mapPosition
,
icon
);
this
.
marker
=
new
OpenLayers
.
Marker
(
this
.
mapPosition
,
icon
);
this
.
layer
.
addMarker
(
this
.
marker
);
this
.
update_marker_size
();
...
...
@@ -222,6 +237,12 @@ WifiMap = {
this
.
update_marker_size
();
};
borne
.
moveTo
=
function
(
gps
)
{
this
.
mapPosition
=
gps
;
this
.
mapPosition
.
modified
=
true
;
this
.
update_info
(
this
.
xml
);
};
//Met à jour la taille du markeur (notamment après un zoom)
borne
.
update_marker_size
=
function
()
{
if
(
!
this
.
marker
)
return
;
//Nothing to do
...
...
@@ -310,7 +331,7 @@ WifiMap = {
//Si position sur la carte, on active le bouton pour zoomer dessus
if
(
this
.
mapPosition
)
{
panTo
=
getElementsByClassName
(
html
,
'
pan_to
'
)[
0
]
panTo
=
getElementsByClassName
(
html
,
'
pan_to
'
)[
0
]
;
panTo
.
addEventListener
(
'
click
'
,
(
function
(
event
)
{
if
(
this
.
mapPosition
)
{
...
...
@@ -322,6 +343,22 @@ WifiMap = {
panTo
.
className
=
panTo
.
className
.
replace
(
/ *template
?
/
,
''
);
}
setCoord
=
getElementsByClassName
(
html
,
'
setCoord
'
)[
0
];
setCoord
.
addEventListener
(
'
click
'
,
(
function
(
event
)
{
this
.
wifiMap
.
moved
=
this
;
event
.
preventDefault
();
}).
bind
(
this
));
coords
=
getElementsByClassName
(
html
,
'
coords
'
)[
0
];
if
(
this
.
mapPosition
)
{
var
gps
=
this
.
mapPosition
.
clone
();
gps
.
transform
(
that
.
projections
.
map
,
that
.
projections
.
gps
);
setInnerText
(
coords
,
gps
.
lon
+
'
'
+
gps
.
lat
)
this
.
mapPosition
.
modified
&&
coords
.
setAttribute
(
'
class
'
,
'
coords modified
'
);
}
else
setInnerText
(
coords
,
'
N/A
'
);
//On fixe la nouvelle bar d'info
if
(
this
.
html_list
)
this
.
html_list
.
parentNode
.
replaceChild
(
html
,
this
.
html_list
);
...
...
templates/wifimap/index.html
View file @
cfe66135
...
...
@@ -26,6 +26,8 @@ Dernière mise à jour il y a <label id="last_update"> </label>
<span
class=
"uptime template"
>
Uptime:
<span
class=
"content"
></span></span>
<ul>
<li
class=
"comment template"
>
Liste commentaire
</li>
<li
class=
"coord"
>
Lon/Lat
<span
class=
"coords"
>
N/A
</span>
<a
href=
"#"
class=
"setCoord"
>
Placer
</a></li>
<li
class=
"prise template"
>
Prise:
<span
class=
"content"
></span></li>
</ul>
<div
class=
"network template"
>
...
...
@@ -42,4 +44,6 @@ Dernière mise à jour il y a <label id="last_update"> </label>
</div>
<div
id=
"map"
>
</div>
<input
type=
"text"
id=
"x"
>
<input
type=
"text"
id=
"y"
>
{% endblock %}
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