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 . +*/ + +(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 %} + {% endblock %} {% block content-1-right %} @@ -20,19 +21,24 @@
{{ letter.grouper }}
{% for item in letter.list %} -
- {% trans "Reader" %} {{ item.id }} -
{{ item.ip_address }}:{{ item.management_port }}
+
+

{% trans "Reader" %} {{ item.id }}

+

{{ item.ip_address }}:{{ item.management_port }}

{% if item.room %} -
{% trans "Room" %} : {{ item.room }}
+

{% trans "Room" %} : {{ item.room }}

{% if item.room.patient %} -
{% trans "Patient" %} : {{ item.room.patient }}
+

{% trans "Patient" %} : {{ item.room.patient }}

{% else %} -
{% trans "No patient associated" %}
+

{% trans "No patient associated" %}

{% endif %} {% else %} -
{% trans "No room associated" %}
+

{% trans "No room associated" %}

{% endif %} +
+

+

+

+
{% endfor %}