summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikaël Ates <mates@entrouvert.com>2016-01-22 16:31:53 (GMT)
committerMikaël Ates <mates@entrouvert.com>2016-01-22 16:31:53 (GMT)
commitd90b5f7db108a8bff6c9e4fb9451243080f767d6 (patch)
treefc59d666640e0e2ce98428330a7fb9243a977a9a
parent7e4d6dbeb7003dabc75d66a60635c6fb2ce2fe62 (diff)
downloadbiomon-d90b5f7db108a8bff6c9e4fb9451243080f767d6.zip
biomon-d90b5f7db108a8bff6c9e4fb9451243080f767d6.tar.gz
biomon-d90b5f7db108a8bff6c9e4fb9451243080f767d6.tar.bz2
Add reader config from rfiddrivers on reader list view.
-rw-r--r--src/biomon/static/biomon/css/biomonitor.css27
-rw-r--r--src/biomon/static/biomon/js/biomon.manager.js83
-rw-r--r--src/biomon/templates/biomon/reader_list.html20
3 files changed, 123 insertions, 7 deletions
diff --git a/src/biomon/static/biomon/css/biomonitor.css b/src/biomon/static/biomon/css/biomonitor.css
index f87e0c4..1a0dfef 100644
--- a/src/biomon/static/biomon/css/biomonitor.css
+++ b/src/biomon/static/biomon/css/biomonitor.css
@@ -162,6 +162,33 @@ padding: 0;
margin-top: 20px;
}
+/*
+ * Manager
+ */
+div.reader-block {
+width: 90%;
+background: none repeat scroll 0% 0% rgba(255, 255, 255, 1);
+display: inline-block;
+padding: 10px;
+border: 1px solid #0972a5;
+border-radius: 5px;
+box-shadow: 0px 1px rgba(255, 255, 255, 0.1) inset, -1px 0px rgba(0, 0, 0, 0.1) inset, 1px 0px rgba(0, 0, 0, 0.1) inset, 0px -1px rgba(0, 0, 0, 0.6) inset;
+margin: 20px;
+text-align: left;
+text-decoration: none;
+color: #0972a5;
+vertical-align: bottom;
+cursor: pointer;
+}
+
+div.reader-block p#title{
+font-weight: bold;
+}
+
+div.reader-block > * {
+color: black;
+}
+
/*
* Main template
diff --git a/src/biomon/static/biomon/js/biomon.manager.js b/src/biomon/static/biomon/js/biomon.manager.js
new file mode 100644
index 0000000..038a6db
--- /dev/null
+++ b/src/biomon/static/biomon/js/biomon.manager.js
@@ -0,0 +1,83 @@
+/*
+ biomon - Signs monitoring and patient management application
+
+ Copyright (C) 2015 Entr'ouvert
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+(function($) {
+ $(function() {
+ function set_element(element, value, new_class){
+ element.text(value);
+ element.removeClass();
+ element.addClass(new_class);
+ }
+
+ function _reload_readers(){
+ $('div.reader-block').each(function(){
+ var target = $(this).attr('id')
+ target += "?"
+ target = UTILS.fresh_query(target);
+ var element = this;
+ $.ajax({
+ type: 'get',
+ url: target,
+ success: function(data) {
+ if (data.status == 'connected' && data.config) {
+ $('p#title', element).switchClass('disabled', 'enabled')
+ set_element($('p#address span#status', element), gettext("Connected"), 'enabled')
+ if(data.config.reader_status){
+ set_element($('div.reader-connected p#reader_driver span#status', element), gettext("On"), 'enabled')
+ if(data.config.tags_in_field){
+ set_element($('div.reader-connected p#tags_in_field span#status', element), gettext(data.config.tags_in_field), 'enabled')
+ } else {
+ set_element($('div.reader-connected p#tags_in_field span#status', element), gettext("No tag detected"), 'disabled')
+ }
+ $('div.reader-connected p#tags_in_field', element).fadeIn();
+ } else {
+ set_element($('div.reader-connected p#reader_driver span#status', element), gettext("Off"), 'disabled')
+ $('div.reader-connected p#tags_in_field', element).fadeOut();
+ }
+ if(data.config.transmitter_status){
+ set_element($('div.reader-connected p#transmitter span#status', element), gettext("On"), 'enabled')
+ } else {
+ set_element($('div.reader-connected p#transmitter span#status', element), gettext("Off"), 'disabled')
+ }
+ $('div.reader-connected', element).fadeIn();
+ } else {
+ $('p#title', element).switchClass('enabled', 'disabled')
+ set_element($('p#address span#status', element), gettext("Disconnected"), 'disabled')
+ $('div.reader-connected', element).fadeOut();
+ }
+ },
+ error: function(xhr, ajaxOptions, thrownError) {
+ UTILS.show_message(gettext("Connection error."));
+ }
+ });
+ });
+ }
+
+ function refresh_readers(){
+ _reload_readers();
+ setTimeout(function(){
+ refresh_readers();
+ }, 2000);
+ };
+ refresh_readers();
+ $('div.reader-block').click(function() {
+ window.location.href = $(this).attr('action');
+ });
+ })
+})(jQuery);
diff --git a/src/biomon/templates/biomon/reader_list.html b/src/biomon/templates/biomon/reader_list.html
index 2caafd0..2096ca3 100644
--- a/src/biomon/templates/biomon/reader_list.html
+++ b/src/biomon/templates/biomon/reader_list.html
@@ -3,6 +3,7 @@
{% block extra_scripts %}
<script type="text/javascript" src="{{ STATIC_URL }}biomon/js/biomon.patientlist.js"></script>
+<script type="text/javascript" src="{{ STATIC_URL }}biomon/js/biomon.manager.js"></script>
{% endblock %}
{% block content-1-right %}
@@ -20,19 +21,24 @@
<div class="value">{{ letter.grouper }}</div>
<div class="list">
{% for item in letter.list %}
- <div class="patient-block enabled hvr-float-shadow" display-name="{{ item.room }}" action="{% url 'reader_update' pk=item.pk %}">
- <span class="display_name">{% trans "Reader" %} {{ item.id }}</span>
- <pre><span>{{ item.ip_address }}:{{ item.management_port }}</span></pre>
+ <div class="reader-block enabled hvr-float-shadow" id="{{ item.id }}" display-name="{{ item.room }}" action="{% url 'reader_update' pk=item.pk %}">
+ <p id="title" class="display_name disabled">{% trans "Reader" %} {{ item.id }}</p>
+ <p id="address">{{ item.ip_address }}:{{ item.management_port }} <span id="status"></span></p>
{% if item.room %}
- <pre><span>{% trans "Room" %} : {{ item.room }}</span></pre>
+ <p>{% trans "Room" %} : <span class="enabled">{{ item.room }}</span></p>
{% if item.room.patient %}
- <pre><span>{% trans "Patient" %} : {{ item.room.patient }}</span></pre>
+ <p>{% trans "Patient" %} : <span class="enabled">{{ item.room.patient }}</span></p>
{% else %}
- <pre><span>{% trans "No patient associated" %}</span></pre>
+ <p><span class="disabled">{% trans "No patient associated" %}</span></p>
{% endif %}
{% else %}
- <pre><span>{% trans "No room associated" %}</span></pre>
+ <p><span class="disabled">{% trans "No room associated" %}</span></p>
{% endif %}
+ <div class="reader-connected">
+ <p id="reader_driver"><label>{% trans 'Reader driver' %} :</label> <span id="status"></span></p>
+ <p id="tags_in_field"><label>{% trans 'Tags detected' %} :</label> <span id="status"></span></p>
+ <p id="transmitter"><label>{% trans 'Transmitter' %} :</label> <span id="status"></span></p>
+ </div>
</div>
{% endfor %}
</div>