Skip to content

Commit

Permalink
Retrieve system status via JSON, parse it with Jquery and display on …
Browse files Browse the repository at this point in the history
…camera viewer.
  • Loading branch information
misaelnieto committed Apr 4, 2011
1 parent a923cd5 commit ea8cbbb
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
15 changes: 13 additions & 2 deletions spionistoserver/static/js/viewer.js
@@ -1,6 +1,18 @@
// execute your scripts when the DOM is ready. this is mostly a good habit
$(function() {
//Load system_information
$.ajax({
url: '/@@system_status',
dataType: 'json',
success: function(data){
$('p#time_update span').html(data.last_update);
$('li#registered_cameras a').html(data.registered_cameras);
$('li#online_cameras a').html(data.online_cameras);
$('li#cameras_recording a').html(data.cameras_recording);
}
});


// initialize scrollable
$(".scrollable").scrollable();

Expand Down Expand Up @@ -39,5 +51,4 @@ $(function() {

// when page loads simulate a "click" on the first image
}).filter(":first").click();

});
});
7 changes: 4 additions & 3 deletions spionistoserver/templates/master.pt
Expand Up @@ -53,10 +53,11 @@
<metal:aside define-slot="aside_slot">
<aside>
<h3>System status</h3>
<p id="time_update">Last update: <span> Loading ...</span></p>
<ul id="status-panel">
<li>Registered Cameras: <a href="/list/registered">10</a></li>
<li>Online Cameras:<a href="/list/online">9</a></li>
<li>Cameras Recording:<a href="/list/recording">3</a></li>
<li id="registered_cameras">Registered Cameras: <a href="/list/registered">--</a></li>
<li id="online_cameras">Online Cameras:<a href="/list/online">--</a></li>
<li id="cameras_recording">Cameras Recording:<a href="/list/recording">--</a></li>
</ul>
</aside>
</metal:aside>
Expand Down
13 changes: 13 additions & 0 deletions spionistoserver/views.py
@@ -1,3 +1,7 @@
#Python imports
import datetime

#Pyramid imports
from pyramid.view import view_config
from pyramid.response import Response
from pyramid.renderers import get_renderer
Expand All @@ -10,6 +14,15 @@ def site_root_view(context,request):
master_template = get_renderer('templates/master.pt').implementation()
return dict (master_template = master_template,)

@view_config(context = 'spionistoserver.models.SpionistoSite',
renderer = 'json', name = 'system_status',
permission = 'View')
def system_status(context,request):
return dict (registered_cameras = 10,
online_cameras = 10,
cameras_recording = 3,
last_update = datetime.datetime.now().strftime('%H:%M:%S'))

@view_config(context = 'spionistoserver.models.Camera',
permission = 'View')
def default_camera_view(context,request):
Expand Down

0 comments on commit ea8cbbb

Please sign in to comment.