Commit 8d0b54fb authored by HERBERT Ryan's avatar HERBERT Ryan

added notification integration into user interface

parent 88d74609
......@@ -1549,6 +1549,33 @@ table.log textarea {
background-image: linear-gradient(45deg, transparent -25%, #ffffff 100%, #ffffff 100%, transparent 0%);
}
.message_container {
float: left;
display: none;
}
.urgent_message {
background-color: #D4A190;
}
.info_message {
background-color: #A1D490;
}
.notification {
margin: 5px;
padding: 3px;
display: inline-flex;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
border: 2px dashed #cccccc;
}
#login_messages.notification {
display: inline-block;
}
#listLocus, #listVsegment, #listDsegment, #listJsegment {
display: none;
}
\ No newline at end of file
......@@ -214,6 +214,7 @@
</div></div>
</div>
<div id="debug_menu" class="menu" onmouseover="showSelector('adminSelector');" style="display : none"> development
<div id="adminSelector" class="selector"><div>
<input type="checkbox" onclick=" this.checked ? $('#fps').css('display', '') : $('#fps').css('display', 'none');">display fps</input></br>
......@@ -221,6 +222,8 @@
<div class="buttonSelector" onclick="m.changeTimeFormat('delta_date_no_zero', true)"><input type="radio" name="time" value="delta_date_no_zero">day after first sample (no zero)</input></div>
</div></div>
</div>
<div id="header_messages" class="message_container"></div>
<div id="logo" style="float: right;" onclick="console.log({'type': 'popup', 'default':'welcome'})">Vidjil <span class='logo'>(beta)</span></div>
......@@ -283,6 +286,4 @@
</body>
</html>
</html>
\ No newline at end of file
......@@ -2,6 +2,7 @@ DB_ADDRESS = ""
DB_TIMEOUT_CALL = 5000 // Regular call
DB_TIMEOUT_GET_DATA = 15000 // Get patient/sample .data
DB_TIMEOUT_GET_CUSTOM_DATA = 1200000 // Launch custum fused sample .data
NOTIFICATION_PERIOD = 5000 // Time interval to check for notifications periodically
/**
......@@ -1011,3 +1012,81 @@ function suggest_box(id, list) {
}, 200)
};
}
// periodically query the server for notifications
// TODO : Tidy up
(function worker(address, url, period, undefined) {
if (address !== undefined && address != "") {
$.ajax({
type: "GET",
crossDomain: true,
url: DB_ADDRESS + url,
contentType: 'text/plain',
timeout: DB_TIMEOUT_CALL,
success: function (result) {
var messages;
try {
messages = JSON.parse(result);
var header_messages = [];
var login_messages = [];
for (var i = 0; i < messages.length; ++i) {
console.log(messages[i]['message_type']);
if (messages[i]['message_type'] == 'header') {
header_messages.push(messages[i]);
} else if (messages[i]['message_type'] == 'login') {
login_messages.push(messages[i]);
}
}
// clear out the element and load new messaged
var hm = $('#header_messages');
hm.empty();
if (header_messages.length > 0) {
integrateMessages(hm, header_messages);
hm.fadeIn();
} else {
hm.fadeOut();
}
var lm = $('#login_messages');
lm.empty();
if (login_messages.length > 0) {
integrateMessages(lm, login_messages);
lm.fadeIn();
} else {
lm.fadeOut();
}
} catch (err) {
console.log("ERROR: " + err);
}
},
error: function (request, status, error) {
if (status === "timeout") {
console.log({"type": "flash", "default" : "database_timeout", "priority": 2});
} else {
console.log("unable to get notifications");
console.log(address + url + ": " + error);
}
}
});
} else {
console.log("DB_ADDRESS : " + DB_ADDRESS);
}
setTimeout(worker, period, DB_ADDRESS, url, period);
})(DB_ADDRESS, 'notification/get_active_notifications', NOTIFICATION_PERIOD);
function integrateMessages(elem, messages, classNames) {
var message;
classNames = classNames === undefined ? {'urgent': 'urgent_message', 'info': 'info_message'} : classNames;
for (var i=0; i < messages.length; ++i) {
message = document.createElement('span');
message.className = classNames[messages[i]['priority']] + " notification";
$(message).append(
document.createTextNode(messages[i]['message_content'])
);
elem.append(message);
}
}
\ No newline at end of file
{{extend 'db_layout.html'}}
{{extend 'db_layout.html'}}
<h2>{{=T( request.args(0).replace('_',' ').capitalize() )}}</h2>
......@@ -35,7 +35,8 @@ demo login: <i>demo@vidjil.org</i>
You can <a href="mailto:contact@vidjil.org?Subject=%5BVidjil%5D%20Account%20on%20rbx.vidjil.org&Body=%0ADear%20Vidjil%20Team%2C%0A%0AI%20would%20like%20to%20have%20an%20account%20on%20the%20Vidjil%20server.%0A%0A">request an account</a> on this server to test your data.
</p>
<div id="login_messages" class="message_container"></div>
<br/>
<hr />
<h3>About</h3>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment