Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
energy
bmon
Commits
28a8779a
Commit
28a8779a
authored
Apr 09, 2019
by
Alan Mitchell
Browse files
Got links to incorporate Organization.
parent
c77cdf9d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
57 additions
and
44 deletions
+57
-44
bmsapp/reports/currentvalues.py
bmsapp/reports/currentvalues.py
+2
-1
bmsapp/reports/currentvalues_multi.py
bmsapp/reports/currentvalues_multi.py
+2
-1
bmsapp/templates/bmsapp/customReports.html
bmsapp/templates/bmsapp/customReports.html
+1
-1
bmsapp/templates/bmsapp/map.html
bmsapp/templates/bmsapp/map.html
+43
-39
bmsapp/views.py
bmsapp/views.py
+9
-2
No files found.
bmsapp/reports/currentvalues.py
View file @
28a8779a
...
...
@@ -19,6 +19,7 @@ class CurrentValues(basechart.BaseChart):
# make a list with the major items being a sensor group and the
# minor items being a list of sensor info:
# (sensor name, most recent value, units, how many minutes ago value occurred)
org_id
=
int
(
self
.
request_params
.
get
(
'select_org'
,
0
))
cur_group
=
''
cur_group_sensor_list
=
[]
sensor_list
=
[]
...
...
@@ -38,7 +39,7 @@ class CurrentValues(basechart.BaseChart):
'unit'
:
b_to_sen
.
sensor
.
unit
.
label
,
'minutes_ago'
:
minutes_ago
,
'sensor_id'
:
b_to_sen
.
sensor
.
id
,
'href'
:
'?select_group={}&select_bldg={}&select_chart={}&select_sensor={}'
.
format
(
self
.
request_params
[
'select_group'
],
self
.
bldg_id
,
basechart
.
TIME_SERIES_CHART_ID
,
b_to_sen
.
sensor
.
id
)
,
'href'
:
'?select_
org={}&select_
group={}&select_bldg={}&select_chart={}&select_sensor={}'
.
format
(
org_id
,
self
.
request_params
[
'select_group'
],
self
.
bldg_id
,
basechart
.
TIME_SERIES_CHART_ID
,
b_to_sen
.
sensor
.
id
)
,
'notes'
:
'%s
\n
id: %s'
%
(
b_to_sen
.
sensor
.
notes
,
b_to_sen
.
sensor
.
sensor_id
),
'alerts'
:
'; '
.
join
([
message
for
subject
,
message
in
b_to_sen
.
sensor
.
alerts
(
self
.
reading_db
)])})
# add the last group
...
...
bmsapp/reports/currentvalues_multi.py
View file @
28a8779a
...
...
@@ -18,6 +18,7 @@ class CurrentValuesMulti(basechart.BaseChart):
# get the current time for calculating how long ago reading occurred
cur_time
=
time
.
time
()
org_id
=
int
(
self
.
request_params
.
get
(
'select_org'
,
0
))
# get the buildings in the current building group
building_group_id
=
int
(
self
.
request_params
[
'select_group'
])
buildings
=
bmsapp
.
view_util
.
buildings_for_group
(
building_group_id
)
...
...
@@ -61,7 +62,7 @@ class CurrentValuesMulti(basechart.BaseChart):
'unit'
:
b_to_sen
.
sensor
.
unit
.
label
,
'minutes_ago'
:
minutes_ago
,
'sensor_id'
:
b_to_sen
.
sensor
.
id
,
'href'
:
'?select_group={}&select_bldg={}&select_chart={}&select_sensor={}'
.
format
(
self
.
request_params
[
'select_group'
],
bldg_info
.
building
.
pk
,
basechart
.
TIME_SERIES_CHART_ID
,
b_to_sen
.
sensor
.
id
)
,
'href'
:
'?select_
org={}&select_
group={}&select_bldg={}&select_chart={}&select_sensor={}'
.
format
(
org_id
,
self
.
request_params
[
'select_group'
],
bldg_info
.
building
.
pk
,
basechart
.
TIME_SERIES_CHART_ID
,
b_to_sen
.
sensor
.
id
)
,
'building_href'
:
'?select_group={}&select_bldg={}'
.
format
(
self
.
request_params
[
'select_group'
],
bldg_info
.
building
.
pk
)
,
'alerts'
:
'; '
.
join
([
message
for
subject
,
message
in
b_to_sen
.
sensor
.
alerts
(
self
.
reading_db
)])})
...
...
bmsapp/templates/bmsapp/customReports.html
View file @
28a8779a
...
...
@@ -61,7 +61,7 @@
<span
class=
"report_groups"
>
{{ group }}
</span>
<ul
class=
"reports"
>
{% for report in reports %}
<li
class=
"reports"
><a
class=
"reports"
href=
"{{ report.id }}"
>
{{ report.title }}
</a></li>
<li
class=
"reports"
><a
class=
"reports"
href=
"{{ report.id
}}?select_org={{ org_id
}}"
>
{{ report.title }}
</a></li>
{% endfor %}
</ul>
</li>
...
...
bmsapp/templates/bmsapp/map.html
View file @
28a8779a
...
...
@@ -15,48 +15,52 @@
background-color
:
#fff
;
}
</style>
<script
src=
"https://maps.googleapis.com/maps/api/js?sensor=false"
></script>
<script
src=
"https://maps.googleapis.com/maps/api/js?
key=AIzaSyAwDNzAbqTajhjNQIv5T76uCmWvVB2XzXk&
sensor=false"
></script>
<script>
$
(
function
()
{
var
map_canvas
=
document
.
getElementById
(
'
map_canvas
'
);
var
map_options
=
{
center
:
new
google
.
maps
.
LatLng
(
65
,
-
155
),
zoom
:
4
,
mapTypeId
:
google
.
maps
.
MapTypeId
.
TERRAIN
}
var
map
=
new
google
.
maps
.
Map
(
map_canvas
,
map_options
)
drawMap
=
function
()
{
var
map_canvas
=
document
.
getElementById
(
'
map_canvas
'
);
var
map_options
=
{
center
:
new
google
.
maps
.
LatLng
(
65
,
-
155
),
zoom
:
4
,
mapTypeId
:
google
.
maps
.
MapTypeId
.
TERRAIN
}
var
map
=
new
google
.
maps
.
Map
(
map_canvas
,
map_options
)
$
.
getJSON
(
'
{% url "map-json" %}
'
,
function
(
sitesJSON
)
{
for
(
var
i
=
0
;
i
<
sitesJSON
.
features
.
length
;
i
++
)
{
var
site
=
sitesJSON
.
features
[
i
];
var
coords
=
site
.
geometry
.
coordinates
;
var
latLng
=
new
google
.
maps
.
LatLng
(
coords
[
1
],
coords
[
0
]);
var
markerText
=
site
.
properties
.
facilityName
;
var
markerColor
=
'
green
'
;
if
(
site
.
properties
.
message
.
length
>
0
)
{
markerText
=
markerText
+
'
\n
'
+
site
.
properties
.
message
;
markerColor
=
'
red
'
;
};
var
marker
=
new
google
.
maps
.
Marker
({
position
:
latLng
,
title
:
markerText
,
facilityID
:
site
.
properties
.
facilityID
.
toString
(),
href
:
site
.
properties
.
href
,
icon
:
{
path
:
google
.
maps
.
SymbolPath
.
CIRCLE
,
fillColor
:
markerColor
,
fillOpacity
:
.
6
,
scale
:
5
,
strokeColor
:
'
black
'
,
strokeWeight
:
.
5
},
scale
:
.
5
,
map
:
map
});
google
.
maps
.
event
.
addListener
(
marker
,
'
click
'
,
function
()
{
window
.
location
.
href
=
this
.
href
})
}
$
.
getJSON
(
'
{% url "map-json" %}
'
+
'
?select_org=
'
+
$
(
'
#select_org
'
).
val
(),
function
(
sitesJSON
)
{
for
(
var
i
=
0
;
i
<
sitesJSON
.
features
.
length
;
i
++
)
{
var
site
=
sitesJSON
.
features
[
i
];
var
coords
=
site
.
geometry
.
coordinates
;
var
latLng
=
new
google
.
maps
.
LatLng
(
coords
[
1
],
coords
[
0
]);
var
markerText
=
site
.
properties
.
facilityName
;
var
markerColor
=
'
green
'
;
if
(
site
.
properties
.
message
.
length
>
0
)
{
markerText
=
markerText
+
'
\n
'
+
site
.
properties
.
message
;
markerColor
=
'
red
'
;
};
var
marker
=
new
google
.
maps
.
Marker
({
position
:
latLng
,
title
:
markerText
,
facilityID
:
site
.
properties
.
facilityID
.
toString
(),
href
:
site
.
properties
.
href
,
icon
:
{
path
:
google
.
maps
.
SymbolPath
.
CIRCLE
,
fillColor
:
markerColor
,
fillOpacity
:
.
6
,
scale
:
5
,
strokeColor
:
'
black
'
,
strokeWeight
:
.
5
},
scale
:
.
5
,
map
:
map
});
});
google
.
maps
.
event
.
addListener
(
marker
,
'
click
'
,
function
()
{
window
.
location
.
href
=
this
.
href
})
}
});
};
$
(
function
()
{
$
(
"
#select_org
"
).
change
(
drawMap
);
drawMap
();
});
</script>
{% endblock %}
...
...
bmsapp/views.py
View file @
28a8779a
...
...
@@ -139,6 +139,7 @@ def custom_report_list(request):
org_id
=
int
(
request
.
GET
.
get
(
'select_org'
,
'0'
))
ctx
=
base_context
()
ctx
.
update
({
'org_id'
:
org_id
,
'customReports'
:
view_util
.
custom_reports
(
org_id
)
})
...
...
@@ -357,7 +358,13 @@ def map_json(request):
"crs"
:
{
"type"
:
"name"
,
"properties"
:
{
"name"
:
"urn:ogc:def:crs:OGC:1.3:CRS83"
}},
"features"
:
[]}
for
bldg
in
models
.
Building
.
objects
.
all
():
org_id
=
int
(
request
.
GET
.
get
(
'select_org'
,
'0'
))
if
org_id
!=
0
:
bldgs
=
models
.
Organization
.
objects
.
get
(
id
=
org_id
).
buildings
.
all
()
else
:
bldgs
=
models
.
Building
.
objects
.
all
()
for
bldg
in
bldgs
:
ret
[
'features'
].
append
(
{
"type"
:
"Feature"
,
"geometry"
:
{
"type"
:
"Point"
,
"coordinates"
:
[
bldg
.
longitude
,
bldg
.
latitude
]
...
...
@@ -365,7 +372,7 @@ def map_json(request):
"properties"
:
{
"facilityName"
:
bldg
.
title
,
"facilityID"
:
bldg
.
id
,
"message"
:
""
,
"href"
:
'{}?select_
group=0
&select_bldg={}'
.
format
(
request
.
build_absolute_uri
(
'../reports/'
),
bldg
.
id
)
"href"
:
'{}?select_
org={}
&select_bldg={}'
.
format
(
request
.
build_absolute_uri
(
'../reports/'
),
org_id
,
bldg
.
id
)
}
}
)
...
...
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