| ... | ... | @@ -50,7 +50,7 @@ Some of the important functions in the `views.py` module are: |
|
|
|
|
|
|
|
**`reports()`**: Returns the main Reports page which is used to configure and view all of the charts and reports provided by the BMON application. The Django template used to create the page is the [[`reports.html` template|https://github.com/alanmitchell/bmon/blob/master/bmsapp/templates/bmsapp/reports.html]].
|
|
|
|
|
|
|
|
**`get_report_results()`**: The Reports page in the browser is a [[Single Page Application|https://en.wikipedia.org/wiki/Single-page_application]]. When the User makes a change to the input controls on that page that affects the report or chart, this function is called by the browser to request the new report or chart content. More explanation of the data format returned in provided in the Client Application section of this document.
|
|
|
|
**`get_report_results()`**: The Reports page in the browser is a [[Single Page Application|https://en.wikipedia.org/wiki/Single-page_application]]. When the User makes a change to the input controls on that page that affects the report or chart, this function is called by the browser to request the new report or chart content. More explanation of the data format returned is provided later in this document.
|
|
|
|
|
|
|
|
**`bldg_list()`**: Returns a list of buildings to display to the user for selection.
|
|
|
|
|
| ... | ... | @@ -64,7 +64,7 @@ To use a different database technology, the only part of the BMON application th |
|
|
|
|
|
|
|
### Report/Chart Classes
|
|
|
|
|
|
|
|
Each report or chart type generated by BMON is mapped to a Python class located in the `bmon/bmsapp/reports` directory. In the [[basechart.py file|https://github.com/alanmitchell/bmon/blob/master/bmsapp/reports/basechart.py]], you can see how each single building chart is mapped to a particular class that is used to render the chart:
|
|
|
|
Each report or chart type provided by BMON is mapped to a Python class located in the `bmon/bmsapp/reports` directory that generates the report or chart. In the [[basechart.py file|https://github.com/alanmitchell/bmon/blob/master/bmsapp/reports/basechart.py]], you can see how each single building chart is mapped to a particular class that is used to render the chart:
|
|
|
|
|
|
|
|
```python
|
|
|
|
# These are the possible chart types currently implemented, in the order they will be
|
| ... | ... | @@ -101,4 +101,6 @@ class MultiBuildingChart(models.Model): |
|
|
|
... more code
|
|
|
|
```
|
|
|
|
|
|
|
|
You can see that the Multi-building Current Sensor Values report is produced by the [[`currentvalues_multi.CurrentValuesMulti`|https://github.com/alanmitchell/bmon/blob/master/bmsapp/reports/currentvalues_multi.py]] class. |
|
|
\ No newline at end of file |
|
|
|
You can see that the Multi-building Current Sensor Values report is produced by the [[`currentvalues_multi.CurrentValuesMulti`|https://github.com/alanmitchell/bmon/blob/master/bmsapp/reports/currentvalues_multi.py]] class. If you wish to create an additional type of multi-building report, you need to add a new choice in `MULTI_CHART_CHOICES` and then create the class that the new report is mapped to in the `bmon/bmsapp/reports` directory.
|
|
|
|
|
|
|
|
These chart classes all must have a `result()` method that returns the report/chart content. This report/chart content is used to fill out the HTML div element with `id="results"` on the Reports page in the browser. The return value from the `result()` function is generally a Python dictionary with two keys: an `html` key and an `objects` key. The value of the `html` key is the HTML that is inserted into the `results` div on the browser page. The value of the `objects` key is a list of two-tuples, one two-tuple for each object that the browser needs to create. Objects that the BMON client app knows how to create are Highcharts charts, Highstock charts, and Dashboards. The fist element of the two-tuple is the object type that the browser should create (`highcharts`, `highstock`, or `dashboard`), and the second element is a configuration dictionary for that particular object. For the Highchart and Highstock charts, this configuation dictionary is exactly the standard [[Highcharts options object|http://www.highcharts.com/docs/getting-started/how-to-set-options]]. |
|
|
\ No newline at end of file |