-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Christian Glatthard
committed
Aug 11, 2015
1 parent
e73f101
commit 5674d32
Showing
12 changed files
with
341 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
{% extends 'web/base.html' %} | ||
|
||
{% load staticfiles %} | ||
|
||
{% block external_css %} | ||
<link rel="stylesheet" href="{% static 'bower_components/datatables/media/css/jquery.dataTables.min.css' %}"> | ||
<link rel="stylesheet" href="{% static 'bower_components/datatables-plugins-bootstrap3/dist/css/datatables-plugins-bootstrap3.css' %}"> | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div class="row"> | ||
<div class="col-xs-12"> | ||
{% include 'web/snippets/messages.html' with messages=messages only %} | ||
|
||
<h1>Container Snapshots</h1> | ||
<form role="form"> | ||
<button id="modal-create-snapshot_button" type="button" class="btn btn-primary btn-create pull-right" data-toggle="modal" data-target="#modal-create-snapshot">Create new</button> | ||
</form> | ||
|
||
{% if container_snapshots %} | ||
<div class="row shares-table"> | ||
<div class="col-xs-12"> | ||
<table class="table table-hover table-striped js-table-smart" cellspacing="0" width="100%"> | ||
<thead> | ||
<tr> | ||
<th width="20%">Timestamp</th> | ||
<th width="25%">Name</th> | ||
<th width="45%">Description</th> | ||
<th width="10%" style="text-align: right">Actions</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for snapshot in container_snapshots %} | ||
<tr> | ||
<td> {{ snapshot.created_on }}</td> | ||
<td>{{ snapshot.friendly_name }}</td> | ||
<td>{{ snapshot.description }}</td> | ||
<td> | ||
{% if snapshot.container.owner == request.user.backend_user.id %} | ||
<form action="{% url 'container_restore_snapshot' %}" method="POST" class="form-action" role="form"> | ||
{% csrf_token %} | ||
<input type="hidden" name="id" value="{{ snapshot.id }}"> | ||
<input type="hidden" name="ct_id" value="{{ container.id }}"> | ||
<button type="submit" class="btn btn-sm btn-warning" title="Restore this image?" data-toggle="confirmation" data-placement="left" disabled> | ||
<i class="glyphicon glyphicon-open"></i> | ||
</button> | ||
</form> | ||
<form action="{% url 'container_delete_snapshot' %}" method="POST" class="form-action" role="form"> | ||
{% csrf_token %} | ||
<input type="hidden" name="id" value="{{ snapshot.id }}"> | ||
<input type="hidden" name="ct_id" value="{{ container.id }}"> | ||
<button type="submit" class="btn btn-sm btn-danger" title="Delete this image?" data-toggle="confirmation" data-placement="left"> | ||
<i class="glyphicon glyphicon-remove"></i> | ||
</button> | ||
</form> | ||
{% endif %} | ||
</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
{% else %} | ||
<div class="alert alert-info">No container snapshots you can access available.</div> | ||
{% endif %} | ||
|
||
{% include 'web/container_snapshots/modal_create.html' with container=container csrf_token=csrf_token only %} | ||
</div> | ||
</div> | ||
{% endblock %} | ||
|
||
{% block js %} | ||
<script src="{% static 'bower_components/datatables/media/js/jquery.dataTables.min.js' %}"></script> | ||
<script src="{% static 'bower_components/datatables-plugins-bootstrap3/dist/js/datatables-plugins-bootstrap3.min.js' %}"></script> | ||
<script src="{% static 'bower_components/bootstrap-confirmation2/bootstrap-confirmation.min.js' %}"></script> | ||
<script> | ||
$(function () { | ||
{% if selected %} | ||
$('#modal-create-snapshot_button').click(); | ||
{% endif %} | ||
|
||
$('[data-toggle="confirmation"]').confirmation({ | ||
popout: true | ||
}); | ||
|
||
$('.js-table-smart').dataTable({ | ||
columnDefs: [{ | ||
aTargets: [ 3 ], | ||
bSearchable: false, | ||
bSortable: false | ||
}] | ||
}); | ||
}); | ||
</script> | ||
{% endblock %} |
30 changes: 30 additions & 0 deletions
30
ipynbsrv/web/templates/web/container_snapshots/modal_create.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<div class="modal fade" id="modal-create-snapshot" tabindex="-1" role="dialog" aria-labelledby="modal-create-snapshot" aria-hidden="true"> | ||
<div class="modal-dialog"> | ||
<div class="modal-content"> | ||
<div class="modal-header"> | ||
<button type="button" class="close" data-dismiss="modal"> | ||
<span aria-hidden="true">×</span><span class="sr-only">Close</span> | ||
</button> | ||
<h4 class="modal-title">New Container Snapshot</h4> | ||
</div> | ||
<form role="form" action="{% url 'container_create_snapshot' %}" method="POST"> | ||
{% csrf_token %} | ||
<div class="modal-body"> | ||
<input name="ct_id" type="hidden" class="form-control" value="{{ container.id }}"> | ||
<div class="form-group"> | ||
<label for="name">Name</label> | ||
<input name="name" type="text" pattern="[A-Za-z1-9_-]+" class="form-control" required> | ||
</div> | ||
<div class="form-group"> | ||
<label for="description">Description</label> | ||
<textarea name="description" class="form-control" rows="3" placeholder="..."></textarea> | ||
</div> | ||
</div> | ||
<div class="modal-footer"> | ||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button> | ||
<button type="submit" class="btn btn-primary">Create</button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
from ipynbsrv import settings | ||
import json | ||
|
||
|
||
def api_error_message(exception, params): | ||
if settings.DEBUG: | ||
return "{}. Data: {}".format(exception, params) | ||
return "{}. Data: {}".format(exception, json.dumps(params)) | ||
else: | ||
return "Whooops, something went wrong when calling the API :(" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from django.contrib import messages | ||
from django.contrib.auth.decorators import user_passes_test | ||
from django.shortcuts import render | ||
from ipynbsrv.core.auth.checks import login_allowed | ||
from ipynbsrv.web.api_client_proxy import get_httpclient_instance | ||
from ipynbsrv.web.views._messages import api_error_message | ||
|
||
|
||
@user_passes_test(login_allowed) | ||
def index(request, ct_id): | ||
""" | ||
Get a list of all snapshots for this container. | ||
""" | ||
client = get_httpclient_instance(request) | ||
container = client.containers(ct_id).get() | ||
container_snapshots = client.containers(ct_id).snapshots.get() | ||
new_notifications_count = len(client.notificationlogs.unread.get()) | ||
|
||
return render(request, 'web/container_snapshots/index.html', { | ||
'title': "Container Snapshots", | ||
'container_snapshots': container_snapshots, | ||
'container': container, | ||
'new_notifications_count': new_notifications_count | ||
}) |
Oops, something went wrong.