diff options
-rw-r--r-- | sbhs/templates/dashboard/all_images.html | 15 | ||||
-rw-r--r-- | sbhs/templates/webcam/show_video.html | 10 | ||||
-rw-r--r-- | sbhs/urls.py | 1 | ||||
-rw-r--r-- | sbhs/views.py | 14 | ||||
-rw-r--r-- | sbhs_server/settings.py | 2 |
5 files changed, 22 insertions, 20 deletions
diff --git a/sbhs/templates/dashboard/all_images.html b/sbhs/templates/dashboard/all_images.html index 5a7b74e..8bc6e81 100644 --- a/sbhs/templates/dashboard/all_images.html +++ b/sbhs/templates/dashboard/all_images.html @@ -6,13 +6,14 @@ {% block main %} <div class = "container"> <div class = "row"> - {% for b in boards %} - <div class="span4" style="text-align: center; outline: 1px solid black"> - <img src="{% static b.image_link %}" alt="{{ b.mid }}" style="width:90%;"> - <br> - Board MID: {{ b.mid }} - </div> - {% endfor %} + <table> + {% for board in image_links %} + <tr> + <td>{{board.board.mid}}</td> + <td><img src="{% static board.image_link %}"/></td> + </tr> + {% endfor %} + </table> </div> </div> <script type="text/javascript"> diff --git a/sbhs/templates/webcam/show_video.html b/sbhs/templates/webcam/show_video.html index 1f372d7..ba87635 100644 --- a/sbhs/templates/webcam/show_video.html +++ b/sbhs/templates/webcam/show_video.html @@ -20,7 +20,7 @@ </div> <img src="{% static image_link %}" id="videoImage" alt="SBHS live feed" class = "offeset4"> <div class = "offeset4" style="text-align:center"> - <a href="#" onclick = "image_reloader()" id = "image_reloader" class = "btn btn-primary btn-large">Refresh Image.</a> + <a href="#" onclick = "image_reloader()" id = "image_reloader" class = "btn btn-primary btn-large">Refresh Image</a> </div> </div> </div> @@ -29,8 +29,8 @@ {% if request.user.profile.is_moderator %} setInterval(function(){ var refresh = new Image(); - refresh.src = "{% url 'reload_image' mid %}"; - document.getElementById("videoImage").src = "{% static image_link %}" + new Date().getTime(); + refresh.src = "{% static image_link %}"; + document.getElementById("videoImage").src = "{% static image_link %}"; }, 2000); {% else %} window.image_reloader = function(){ @@ -39,8 +39,8 @@ if (!button.disabled){ button.setAttribute("disabled", true); var refresh = new Image(); - refresh.src = "{% url 'reload_image' mid %}"; - document.getElementById("videoImage").src = "{% static image_link %}" + new Date.getTime(); + refresh.src = "{% static image_link %}"; + document.getElementById("videoImage").src = "{% static image_link %}"; setTimeout(function(){ button.removeAttribute("disabled"); }, 3000); diff --git a/sbhs/urls.py b/sbhs/urls.py index b4df2a6..35ccc22 100644 --- a/sbhs/urls.py +++ b/sbhs/urls.py @@ -96,5 +96,4 @@ urlpatterns = [ name='show_video_to_moderator'), ####################### Webcam Url ######################### url(r'^show_video/$',views.show_video,name='show_video'), - url(r'^reload_image/(.*)/$',views.reload,name='reload_image'), ] diff --git a/sbhs/views.py b/sbhs/views.py index f0da87d..530e692 100644 --- a/sbhs/views.py +++ b/sbhs/views.py @@ -740,13 +740,19 @@ def all_bookings(request): def all_images(request): user = request.user context = {} + image_links = [] if not is_moderator(user): raise Http404("You are not allowed to see this page.") else: boards = Board.objects.filter(online=True) for board in boards: - Webcam.load_image(board.mid) - context["boards"] = boards + board_image_link = {} + capture_status = Webcam.load_image(board.mid) + board_image_link["board"] = board + if capture_status != 0: + board_image_link["image_link"] = board.image_link() + image_links.append(board_image_link.copy()) + context["image_links"] = image_links return render(request,'dashboard/all_images.html') @@ -892,10 +898,6 @@ def download_file(request, experiment_id): ################## Webcam Views ############################# -def reload(request, mid): - Webcam.load_image(mid) - return HttpResponse("") - @login_required def show_video(request): """ diff --git a/sbhs_server/settings.py b/sbhs_server/settings.py index d3d4b8d..119020d 100644 --- a/sbhs_server/settings.py +++ b/sbhs_server/settings.py @@ -198,7 +198,7 @@ SBHS_GLOBAL_LOG_DIR = os.path.join(BASE_DIR, 'log') # Advance slot booking LIMIT for a day. LIMIT = 2 -WEBCAM_DIR = os.path.join(STATIC_ROOT, 'img/webcam/') if IS_DEVELOPMENT \ +WEBCAM_DIR = os.path.join(STATIC_ROOT, 'img/webcam/') if not IS_DEVELOPMENT \ else os.path.join( BASE_DIR, 'static/img/webcam/' |