Skip to content

Commit

Permalink
fix typos; no tables if no record exists; group fixes; button fixes; …
Browse files Browse the repository at this point in the history
…user-guide link; fix dashboard containers
  • Loading branch information
Michel Käser committed Aug 11, 2015
1 parent eb57367 commit db6cf91
Show file tree
Hide file tree
Showing 12 changed files with 106 additions and 95 deletions.
1 change: 1 addition & 0 deletions ipynbsrv/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
LOGIN_URL = '/accounts/login'
LOGIN_REDIRECT_URL = '/accounts/flag'
PUBLIC_URL = '/public/'
USER_GUIDE_URL = '/docs/user-guide/'

VARS_MODULE_PATH = 'ipynbsrv.core.conf'

Expand Down
99 changes: 49 additions & 50 deletions ipynbsrv/web/templates/web/collaborationgroups/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
<div class="col-xs-12">
{% include 'web/snippets/messages.html' with messages=messages only %}

<h1>My Groups</h1>
<h1>Groups</h1>
<form role="form">
<button type="button" class="btn btn-primary btn-create pull-right" data-toggle="modal" data-target="#modal-group-create">Create new</button>
</form>

{% if groups %}
{% if groups and not groups|length_is:"1" %}
<table id="groups-table" class="table table-hover table-striped js-table-smart" cellspacing="0" width="100%">
<thead>
<tr>
Expand All @@ -29,56 +29,55 @@ <h1>My Groups</h1>
</tr>
</thead>
<tbody>
{% for group in groups %}
{% if not group.is_single_user_group %}
<tr>
<td><a href="/groups/manage/{{group.id}}">{{group.name}}</a></td>
<td>{{ group.member_count }}</td>
<td>{% if request.user.backend_user.id in group.admins %}<span class="label label-info">Admin</span>{% endif %}
{% if request.user.backend_user.id == group.creator.id %}<span class="label label-info">Creator</span>
{% else %} {% if request.user.backend_user.id in group.member_ids %}<span class="label label-info">Member</span>{% endif %}{% endif %}
</td>
<td>
{% if request.user.backend_user.id != group.creator.id and group.creator %}
{% if request.user.backend_user.id in group.member_ids %}
<form action="{% url 'group_leave' %}" method="POST" role="form" class="form-action">
{% csrf_token %}
<input type="hidden" name="group_id" value="{{ group.id }}">
<input type="hidden" name="user_id" value="{{ request.user.id }}">
<button class="btn btn-sm btn-warning" title="Leave group?" data-toggle="confirmation" data-placement="left">
<i class="glyphicon glyphicon-minus-sign" aria-hidden="true"></i>
</button>
</form>
{% else %}
<form action="{% url 'group_join' %}" method="POST" role="form" class="form-action">
{% csrf_token %}
<input type="hidden" name="group_id" value="{{ group.id }}">
<input type="hidden" name="user_id" value="{{ request.user.id }}">
<button class="btn btn-sm btn-success" title="Join group?" data-toggle="confirmation" data-placement="left">
<i class="glyphicon glyphicon-plus-sign" aria-hidden="true"></i>
</button>
</form>
{% endif %}
{% endif %}
{% for group in groups %}
{% if not group.is_single_user_group %}
<tr>
<td><a href="/groups/manage/{{group.id}}">{{group.name}}</a></td>
<td>{{ group.member_count }}</td>
<td>{% if request.user.backend_user.id in group.admins %}<span class="label label-info">Admin</span>{% endif %}
{% if request.user.backend_user.id == group.creator.id %}<span class="label label-info">Creator</span>
{% else %} {% if request.user.backend_user.id in group.member_ids %}<span class="label label-info">Member</span>{% endif %}{% endif %}
</td>
<td>
{% if request.user.backend_user.id != group.creator.id and group.creator %}
{% if request.user.backend_user.id in group.member_ids %}
<form action="{% url 'group_leave' %}" method="POST" role="form" class="form-action">
{% csrf_token %}
<input type="hidden" name="group_id" value="{{ group.id }}">
<input type="hidden" name="user_id" value="{{ request.user.id }}">
<button class="btn btn-sm btn-warning" title="Leave group?" data-toggle="confirmation" data-placement="left">
<i class="glyphicon glyphicon-minus-sign" aria-hidden="true"></i>
</button>
</form>
{% else %}
<form action="{% url 'group_join' %}" method="POST" role="form" class="form-action">
{% csrf_token %}
<input type="hidden" name="group_id" value="{{ group.id }}">
<input type="hidden" name="user_id" value="{{ request.user.id }}">
<button class="btn btn-sm btn-success" title="Join group?" data-toggle="confirmation" data-placement="left">
<i class="glyphicon glyphicon-plus-sign" aria-hidden="true"></i>
</button>
</form>
{% endif %}
{% endif %}

{% if request.user.backend_user.id == group.creator.id or request.user.id in group.admins %}
<form action="{% url 'group_delete' %}" method="POST" role="form" class="form-action">
{% csrf_token %}
<input type="hidden" name="group_id" value="{{ group.id }}">
<button class="btn btn-sm btn-danger" title="Delete group?" data-toggle="confirmation" data-placement="left">
<i class="glyphicon glyphicon-remove" aria-hidden="true"></i>
</button>
</form>
{% endif %}
</td>
</tr>
{% endif %}
{% endfor %}
</tbody>
{% if request.user.backend_user.id == group.creator.id or request.user.id in group.admins %}
<form action="{% url 'group_delete' %}" method="POST" role="form" class="form-action">
{% csrf_token %}
<input type="hidden" name="group_id" value="{{ group.id }}">
<button class="btn btn-sm btn-danger" title="Delete group?" data-toggle="confirmation" data-placement="left">
<i class="glyphicon glyphicon-remove" aria-hidden="true"></i>
</button>
</form>
{% endif %}
</td>
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>

{% else %}
<div class="alert alert-info">You have no groups yet.</div>
<div class="alert alert-info">You have no groups.</div>
{% endif %}

{% include 'web/collaborationgroups/modal_addusers.html' with csrf_token=csrf_token only %}
Expand Down Expand Up @@ -111,7 +110,7 @@ <h1>My Groups</h1>
table.find('.label').click(function (e) {
var label = $(e.target);
search_input.val(label.text());
search_input.submit();
search_input.submit();
});

$('[data-toggle="modal"]').click(function (e) {
Expand Down
22 changes: 14 additions & 8 deletions ipynbsrv/web/templates/web/collaborationgroups/manage.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ <h1>Group</h1>
{% endif %}

<table class="table">
<thead>
<tr>
<th style="width: 25%">Property</th>
<th style="width: 75%">Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>Name:</td><td>{{ group.name }}</td>
Expand All @@ -54,13 +60,13 @@ <h1>Group</h1>
</table>

<h2>Members</h2>
<form role="form">
{% if request.user.backend_user.id in group.admins or request.user.backend_user.id == group.creator.id %}
<form role="form">
<button type="button" class="btn btn-primary btn-add pull-right" data-toggle="modal" data-target="#modal-group-addusers">Add Users</button>
</form>
{% endif %}
</form>
<div class="row" style="margin-bottom: 20px">
{% if request.user.backend_user.id in group.admins or request.user.backend_user.id == group.creator.id %}
<form role="form" class="col-xs-12">
<button type="button" class="btn btn-primary btn-add pull-right" data-toggle="modal" data-target="#modal-group-addusers">Add Users</button>
</form>
{% endif %}
</div>
<table class="table table-hover table-striped js-table-smart" cellspacing="0" width="100%">
<thead>
<tr>
Expand All @@ -87,7 +93,7 @@ <h2>Members</h2>
</form>
{% endif %}
{% if request.user.backend_user.id in group.admins or request.user.backend_user.id == group.creator.id %}
{% if member.id != group.creator.id %}
{% if member.id != group.creator.id %}
<form action="{% url 'group_remove_member' %}" method="POST" role="form" class="form-action">
{% csrf_token %}
<input type="hidden" name="group_id" value="{{ group.id }}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h4 class="modal-title">New group</h4>
</div>
</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>
Expand Down
3 changes: 0 additions & 3 deletions ipynbsrv/web/templates/web/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ <h1>Dashboard</h1>
<h2>Running containers</h2>
{% include 'web/snippets/container_grid.html' with containers=containers csrf_token=csrf_token only %}

<h2>Groups</h2>
blabla

<h2>Recent activities</h2>
notifications
</div>
Expand Down
6 changes: 3 additions & 3 deletions ipynbsrv/web/templates/web/notifications/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ <h1>Notifications</h1>
</tr>
</thead>
<tbody>
{% for n in notifications %}
{% for n in notifications %}
<tr data-id="{{ n.id }}" {% if not n.read %} class="unread" {% endif %}>
<td>{{ n.date | date:"d.m.Y, H:i" }}</td>
<td>{{ n.notification.sender.username }}</td>
Expand All @@ -48,11 +48,11 @@ <h1>Notifications</h1>
</form>
</td>
</tr>
{% endfor %}
{% endfor %}
</tbody>
</table>
{% else %}
<div class="alert alert-info">You have no notifications yet.</div>
<div class="alert alert-info">You have no notifications.</div>
{% endif %}

{% include 'web/notifications/modal_create.html' with groups=groups notification_types=notification_types containers=containers container_images=container_images shares=shares csrf_token=csrf_token only %}
Expand Down
15 changes: 8 additions & 7 deletions ipynbsrv/web/templates/web/notifications/modal_create.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ <h4 class="modal-title">New notification</h4>
{% csrf_token %}
<div class="modal-body">
<div class="form-group">
<label for="receiver_groups">Receiver Groups</label>
<label for="receiver_groups">Receiving Group</label>
<select class="form-control" name="receiver_groups">
<option></option>
{% for group in groups %}

<option value="{{ group.id }}">{{ group.name }}</option>

{% if not group.is_single_user_group %}
<option value="{{ group.id }}">{{ group.name }}</option>
{% endif %}
{% endfor %}
</select>
</div>
<div class="form-group">
<label for="type">Notification type</label>
<label for="type">Notification Type</label>
<select class="form-control" name="notification_type">
<option></option>
{% for n1, n2 in notification_types %}
Expand Down Expand Up @@ -62,8 +62,9 @@ <h4 class="modal-title">New notification</h4>
<select class="form-control" name="group">
<option></option>
{% for g in groups %}
<option value="{{ g.id }}">{{ g.name }}</option>

{% if not group.is_single_user_group %}
<option value="{{ g.id }}">{{ g.name }}</option>
{% endif %}
{% endfor %}
</select>

Expand Down
28 changes: 18 additions & 10 deletions ipynbsrv/web/templates/web/shares/manage.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,24 @@ <h1>Share</h1>
</table>

<h2>Shared with...</h2>
<form role="form">
<button type="button" class="btn btn-primary btn-adduser pull-right" data-toggle="modal" data-target="#modal-share-adduser">
Add user
</button>
</form>
<form role="form">
<button type="button" class="btn btn-primary btn-addgroup pull-right" data-toggle="modal" data-target="#modal-share-addgroup">
Add group
</button>
</form>
<div class="row" style="margin-bottom: 20px">
<form role="form" class="col-xs-12">
<fieldset class="pull-right">
<button type="button" class="btn btn-primary btn-adduser" data-toggle="modal" data-target="#modal-share-adduser">
Add user
</button>
{% if groups|length_is:"1" %}
<button type="button" class="btn btn-primary btn-addgroup" data-toggle="modal" data-target="#modal-share-addgroup" disabled>
Add group
</button>
{% else %}
<button type="button" class="btn btn-primary btn-addgroup" data-toggle="modal" data-target="#modal-share-addgroup">
Add group
</button>
{% endif %}
</fieldset>
</form>
</div>
<table class="table table-hover table-striped js-table-smart" cellspacing="0" width="100%">
<thead>
<tr>
Expand Down
17 changes: 8 additions & 9 deletions ipynbsrv/web/templates/web/snippets/container_grid.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,6 @@
<button type="submit"></button>
</form>
</li>
<li role="presentation">
<a role="menuitem" tabindex="-1" href="javascript:document.getElementById('restart-{{ ct.id }}').getElementsByTagName('button')[0].click();">Restart</a>
<form id="restart-{{ ct.id }}" action="{% url 'container_restart' %}" method="POST" role="form">
{% csrf_token %}
<input name="id" type="hidden" value="{{ ct.id }}">
<button type="submit"><button>
</form>
</li>
{% if ct.is_suspended %}
<li role="presentation">
<a role="menuitem" tabindex="-1" href="javascript:document.getElementById('resume-{{ ct.id }}').getElementsByTagName('button')[0].click();">Resume</a>
Expand All @@ -78,6 +70,14 @@
</form>
</li>
{% else %}
<li role="presentation">
<a role="menuitem" tabindex="-1" href="javascript:document.getElementById('restart-{{ ct.id }}').getElementsByTagName('button')[0].click();">Restart</a>
<form id="restart-{{ ct.id }}" action="{% url 'container_restart' %}" method="POST" role="form">
{% csrf_token %}
<input name="id" type="hidden" value="{{ ct.id }}">
<button type="submit"><button>
</form>
</li>
<li role="presentation">
<a role="menuitem" tabindex="-1" href="javascript:document.getElementById('suspend-{{ ct.id }}').getElementsByTagName('button')[0].click();">Suspend</a>
<form id="suspend-{{ ct.id }}" action="{% url 'container_suspend' %}" method="POST" role="form">
Expand All @@ -86,7 +86,6 @@
<button type="submit"><button>
</form>
</li>

{% endif %}
{% else %}
<li role="presentation">
Expand Down
4 changes: 2 additions & 2 deletions ipynbsrv/web/templates/web/snippets/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<li><a href="/notifications">Notifications {% if new_notifications_count >= 0 %}<span id="notification_bubble">{{ new_notifications_count }}</span>{% endif %}</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="hidden-xs"><a href="" data-tooltip data-placement="bottom" title="User Guide" target="_blank">
<li class="hidden-xs"><a href="{% settings 'USER_GUIDE_URL' %}" data-tooltip data-placement="bottom" title="User Guide" target="_blank">
<i class="glyphicon glyphicon-question-sign" aria-hidden="true"></i>
</a></li>
<li class="hidden-xs"><a href="{% settings 'PUBLIC_URL' %}{{ request.user.get_username }}" data-tooltip data-placement="bottom" title="My publications" target="_blank">
Expand All @@ -32,7 +32,7 @@
<i class="glyphicon glyphicon-log-out" aria-hidden="true"></i>
</a></li>
<li class="hidden-sm hidden-md hidden-lg">
<a href="" title="User Guide" target="_blank">Use Guide</a>
<a href="{% settings 'USER_GUIDE_URL' %}" title="User Guide" target="_blank">Use Guide</a>
</li>
<li class="hidden-sm hidden-md hidden-lg">
<a href="{% settings 'PUBLIC_URL' %}{{ request.user.get_username }}" title="My publications" target="_blank">My publications</a>
Expand Down
2 changes: 1 addition & 1 deletion ipynbsrv/web/views/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ def dashboard(request):

return render(request, 'web/dashboard.html', {
'title': "Dashboard",
'containers': containers,
'containers': filter(lambda ct: ct.is_running is True, containers),
'new_notifications_count': new_notifications_count
})
2 changes: 1 addition & 1 deletion ipynbsrv/web/views/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def create(request):
try:
# server and owner get set by the core automatically
client.containers.post(params)
messages.success(request, "Image created successfully.")
messages.success(request, "Container created successfully.")
except Exception as ex:
messages.error(request, api_error_message(ex, params))

Expand Down

0 comments on commit db6cf91

Please sign in to comment.