Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
B
bmon
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
energy
bmon
Commits
2bf51c07
Commit
2bf51c07
authored
Mar 10, 2020
by
Alan Mitchell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Progress on BMON Essential Coffeescript.
parent
76e60449
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
131 additions
and
2 deletions
+131
-2
bmon/settings_example.py
bmon/settings_example.py
+5
-0
bmsapp/static/bmsapp/scripts/energy-reports.coffee
bmsapp/static/bmsapp/scripts/energy-reports.coffee
+48
-0
bmsapp/static/bmsapp/scripts/energy-reports.js
bmsapp/static/bmsapp/scripts/energy-reports.js
+43
-0
bmsapp/templates/bmsapp/energy-reports.html
bmsapp/templates/bmsapp/energy-reports.html
+10
-2
bmsapp/urls.py
bmsapp/urls.py
+1
-0
bmsapp/views.py
bmsapp/views.py
+24
-0
No files found.
bmon/settings_example.py
View file @
2bf51c07
...
...
@@ -47,6 +47,11 @@ BMSAPP_NAV_LINKS = (('Map', 'map'),
# The number of hours before a sensor is considered to be inactive (not posting data).
BMSAPP_SENSOR_INACTIVITY
=
2.0
# Hours
# This is the base URL where BMON Essential Energy Reports are located.
# If Energy Reports are not being geneerated for this system, assign None
# to this variable.
ENERGY_REPORTS_URL
=
'https://bmonreporter-data.energytools.com/reports/bms.ahfc.us/'
# If you are using the Pushover notification service for alerts generated by the BMON
# application, you need to register an Application with Pushover and enter the API
# Token/Key below. It is a 30 character string. See 'https://pushover.net'.
...
...
bmsapp/static/bmsapp/scripts/energy-reports.coffee
0 → 100644
View file @
2bf51c07
# Coffee Script file that provides the functionality for the Energy Reports
# page. The Javascript version of this is included in the 'energy-reports.html'
# template.
# Variables needed for identifying availabe reports
# An object mapping organization ID to a list of buildings associated with
# that organization.
_org_to_bldgs
=
{}
# An object mapping building ID to a list of building reports
_bldg_reports
=
{}
# An object mapping organization ID to a list of organization reports
_org_reports
=
{}
# ---------------------------------------------------------------
# function that runs when the document is ready.
$
->
# Get the data files from the Report server, first getting the base URL from
# the hidden span element on this page.
base_url
=
$
(
"#energy-reports-url"
).
text
()
# only acquire data if there is a Base URL.
if
base_url
.
length
>
0
$
.
getJSON
(
base_url
+
"org_to_bldgs.json"
).
done
((
results
)
->
_org_to_bldgs
=
results
).
fail
(
jqxhr
,
textStatus
,
error
)
->
$
(
"body"
).
css
"cursor"
,
"default"
# remove hourglass cursor
err
=
textStatus
+
", "
+
error
alert
"Error Occurred: "
+
err
$
.
getJSON
(
base_url
+
"building.json"
).
done
((
results
)
->
_bldg_reports
=
results
).
fail
(
jqxhr
,
textStatus
,
error
)
->
$
(
"body"
).
css
"cursor"
,
"default"
# remove hourglass cursor
err
=
textStatus
+
", "
+
error
alert
"Error Occurred: "
+
err
$
.
getJSON
(
base_url
+
"organization.json"
).
done
((
results
)
->
_org_reports
=
results
$
(
"#debug-out"
).
text
JSON
.
stringify
(
_org_reports
)
).
fail
(
jqxhr
,
textStatus
,
error
)
->
$
(
"body"
).
css
"cursor"
,
"default"
# remove hourglass cursor
err
=
textStatus
+
", "
+
error
alert
"Error Occurred: "
+
err
bmsapp/static/bmsapp/scripts/energy-reports.js
0 → 100644
View file @
2bf51c07
// Generated by CoffeeScript 1.12.7
(
function
()
{
var
_bldg_reports
,
_org_reports
,
_org_to_bldgs
;
_org_to_bldgs
=
{};
_bldg_reports
=
{};
_org_reports
=
{};
$
(
function
()
{
var
base_url
;
base_url
=
$
(
"
#energy-reports-url
"
).
text
();
if
(
base_url
.
length
>
0
)
{
$
.
getJSON
(
base_url
+
"
org_to_bldgs.json
"
).
done
(
function
(
results
)
{
return
_org_to_bldgs
=
results
;
}).
fail
(
function
(
jqxhr
,
textStatus
,
error
)
{
var
err
;
$
(
"
body
"
).
css
(
"
cursor
"
,
"
default
"
);
err
=
textStatus
+
"
,
"
+
error
;
return
alert
(
"
Error Occurred:
"
+
err
);
});
$
.
getJSON
(
base_url
+
"
building.json
"
).
done
(
function
(
results
)
{
return
_bldg_reports
=
results
;
}).
fail
(
function
(
jqxhr
,
textStatus
,
error
)
{
var
err
;
$
(
"
body
"
).
css
(
"
cursor
"
,
"
default
"
);
err
=
textStatus
+
"
,
"
+
error
;
return
alert
(
"
Error Occurred:
"
+
err
);
});
return
$
.
getJSON
(
base_url
+
"
organization.json
"
).
done
(
function
(
results
)
{
_org_reports
=
results
;
return
$
(
"
#debug-out
"
).
text
(
JSON
.
stringify
(
_org_reports
));
}).
fail
(
function
(
jqxhr
,
textStatus
,
error
)
{
var
err
;
$
(
"
body
"
).
css
(
"
cursor
"
,
"
default
"
);
err
=
textStatus
+
"
,
"
+
error
;
return
alert
(
"
Error Occurred:
"
+
err
);
});
}
});
}).
call
(
this
);
bmsapp/templates/bmsapp/energy-reports.html
View file @
2bf51c07
{% extends "bmsapp/base.html" %}
{% load staticfiles %}
{% block pagetitle %}Energy Reports{% endblock %}
{% block head %}
<style>
</style>
<style>
</style>
<script
src=
"{% static 'bmsapp/scripts/energy-reports.js' %}"
></script>
{% endblock %}
{% block this_nav_link %}link_energy-reports{% endblock %}
{% block content %}
<span
id=
"energy-reports-url"
style=
"display:none"
>
{{ energy_reports_url }}
</span>
<h2>
Energy Reports
</h2>
<h5><i>
{{ error_message }}
</i></h5>
<div
id=
"debug-out"
></div>
{% endblock %}
{% block scripts %}
...
...
bmsapp/urls.py
View file @
2bf51c07
...
...
@@ -20,6 +20,7 @@ urlpatterns = [
re_path
(
r'^reports/$'
,
views
.
reports
,
name
=
'reports'
),
re_path
(
r'^reports/results/$'
,
views
.
get_report_results
),
re_path
(
r'^reports/embed/$'
,
views
.
get_embedded_results
),
# javascript embedded version of report results
re_path
(
r'^energy-reports/$'
,
views
.
energy_reports
),
re_path
(
r'^custom-reports/$'
,
views
.
custom_report_list
),
re_path
(
r'^custom-reports/(.+)$'
,
views
.
custom_report
),
re_path
(
r'^show-log/$'
,
views
.
show_log
),
...
...
bmsapp/views.py
View file @
2bf51c07
...
...
@@ -139,6 +139,30 @@ def get_embedded_results(request):
script_content
=
view_util
.
get_embedded_results_script
(
request
,
result
)
return
HttpResponse
(
script_content
,
content_type
=
"application/javascript"
)
def
energy_reports
(
request
):
"""Presents the BMON Essential Energy Reports page.
"""
# determine the base Energy Reports URL to pass to the template
if
hasattr
(
settings
,
'ENERGY_REPORTS_URL'
)
and
settings
.
ENERGY_REPORTS_URL
is
not
None
:
energy_reports_url
=
settings
.
ENERGY_REPORTS_URL
if
energy_reports_url
[
-
1
]
!=
'/'
:
# add a slash at end, as it did not contain one.
energy_reports_url
+=
'/'
error_message
=
''
else
:
energy_reports_url
=
''
error_message
=
'Energy Reports are not Available. Contact your System Administrator for more information.'
ctx
=
base_context
()
ctx
.
update
(
{
'energy_reports_url'
:
energy_reports_url
,
'error_message'
:
error_message
,
}
)
return
render_to_response
(
'bmsapp/energy-reports.html'
,
ctx
)
def
custom_report_list
(
request
):
"""The main Custom Reports page - lists available custom reports for the
organization identified by the query parameter 'select_org'.
...
...
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