Skip to content

Commit

Permalink
fix errors in client handling of frontend:
Browse files Browse the repository at this point in the history
- use correct ping method
- translate trigger names
- remove unused template
  • Loading branch information
seiferta committed Feb 15, 2015
1 parent 8b7b557 commit eb31085
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 96 deletions.
13 changes: 2 additions & 11 deletions emonitor/modules/monitors/content_frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,8 @@ def getFrontendData(self):
return render_template('frontend.monitors.html', monitors=classes.get('monitor').getMonitors())

elif request.args.get('action') == 'ping': # search from monitors
if request.args.get('refresh') == '1': # force refresh
scheduler.add_job(monitorserver.getClients) # use scheduler for search
else:
clients = monitorserver.clients['clients'] # clientids
layouts = {}
for c in clients:
try:
layouts[c] = classes.get('monitor').getMonitors(clientid=int(c)).getLayouts()
except AttributeError: # no layouts for clientid found
pass
return render_template('frontend.monitors_clients.html', clients=clients, layouts=layouts, t=monitorserver.clients['time'])
clients = monitorserver.getClients() # start discovery
return dict(clients=[k for k in clients.keys() if clients[k][0]])

elif request.args.get('action') == 'changelayout': # load monitorlayout
monitorserver.changeLayout(request.args.get('id'), request.args.get('layoutid'))
Expand Down
23 changes: 20 additions & 3 deletions emonitor/modules/monitors/templates/frontend.monitors.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
<ul class="dropdown-menu pull-right">

{% for l in monitor.getLayouts() %}
<li><a href="#" onclick="return changeLayout({{ id }}, {{ l.id }})"><i class="fa fa-desktop fa-fw"></i> {% for tr in l.trigger.split(';') %}{{ tr }}{% if not loop.last %}, {% endif %}{% endfor %}</a></li>
<li><a href="#" onclick="return changeMLayout({{ monitor.clientid }}, {{ l.id }})"><i class="fa fa-desktop fa-fw"></i> {% for tr in l.trigger.split(';') %}{{ _('trigger.'+tr) }}{% if not loop.last %}, {% endif %}{% endfor %}</a></li>
{% endfor %}
<li><a href="#" onclick="return changeLayout({{ id }}, -1)"><i class="fa fa-desktop fa-fw"></i> {{ _('monitor.testpage') }}</a></li>
<li><a href="#" onclick="return changeMLayout({{ monitor.clientid }}, -1)"><i class="fa fa-desktop fa-fw"></i> {{ _('monitor.testpage') }}</a></li>
</ul>
{% endif %}
</div>
Expand All @@ -32,7 +32,7 @@
$('#timestamp').html(new Date().toString().match(/\d{2}:\d{2}:\d{2}/)[0]);
clearTimeout(nextrun);
nextrun = setTimeout(refreshPing, 10000); // 10 seconds
$.ajax({ type : "POST", url : "/admin/data/monitors?action=ping&format=json",
$.ajax({ type : "POST", url : "/data/monitors?action=ping&format=json",
success: function(result){
$.each($('#monitors').children(), function(index, item) {
if (result.clients.indexOf(item.id.split('_')[1])==-1){
Expand All @@ -47,6 +47,12 @@
return false;
}

$('.options').hover(function() {
$(this).find('.dropdown-menu').stop(true, true).delay(200).fadeIn(500);
}, function() {
$(this).find('.dropdown-menu').stop(true, true).delay(200).fadeOut(500);
});

var monitorsocket = new WebSocket("ws://"+location.host+"/ws");
monitorsocket.onopen = function() {
refreshPing()
Expand All @@ -63,4 +69,15 @@
return false;
};

function changeMLayout(id, layoutid){
console.log('schange');
$.ajax({ type : "POST", url : "/data/monitors?action=changelayout&id="+id+"&layoutid="+layoutid,
success: function(){
alert('{{ _('monitor.layout.changed') }}');
return false;
}
});
return false;
}

</script>
82 changes: 0 additions & 82 deletions emonitor/modules/monitors/templates/frontend.monitors_clients.html

This file was deleted.

0 comments on commit eb31085

Please sign in to comment.