Commit 31ff2ebf by Őry Máté

one: better share

parent 9ffe65d1
...@@ -37,7 +37,7 @@ urlpatterns = patterns('', ...@@ -37,7 +37,7 @@ urlpatterns = patterns('',
url(r'^store/gui/$', 'store.views.gui', name='store_gui'), url(r'^store/gui/$', 'store.views.gui', name='store_gui'),
url(r'^store/top/$', 'store.views.toplist', name='store_top'), url(r'^store/top/$', 'store.views.toplist', name='store_top'),
url(r'^ajax/templateWizard$', 'one.views.ajax_template_wizard', name='ajax_template_wizard'), url(r'^ajax/templateWizard$', 'one.views.ajax_template_wizard', name='ajax_template_wizard'),
url(r'^ajax/share/(?P<id>\d+)$', 'one.views.ajax_share_wizard', name='ajax_share_wizard'), url(r'^ajax/share/(?P<id>\d+)/$', 'one.views.ajax_share_wizard', name='ajax_share_wizard'),
url(r'^ajax/share/(?P<id>\d+)/(?P<gid>\d+)$', 'one.views.ajax_share_wizard', name='ajax_share_wizard'), url(r'^ajax/share/(?P<id>\d+)/(?P<gid>\d+)$', 'one.views.ajax_share_wizard', name='ajax_share_wizard'),
url(r'^ajax/template/delete/$', 'one.views.ajax_template_delete', name='ajax_template_delete'), url(r'^ajax/template/delete/$', 'one.views.ajax_template_delete', name='ajax_template_delete'),
url(r'^ajax/template_name_unique/(?P<name>.*)$', 'one.views.ajax_template_name_unique', name='ajax_template_name_unique'), url(r'^ajax/template_name_unique/(?P<name>.*)$', 'one.views.ajax_template_name_unique', name='ajax_template_name_unique'),
......
...@@ -95,7 +95,7 @@ $(function() { ...@@ -95,7 +95,7 @@ $(function() {
}) })
$('.template-share').click(function(e) { $('.template-share').click(function(e) {
e.preventDefault(); e.stopPropagation(); e.preventDefault(); e.stopPropagation();
$.get('/ajax/share/'+$(this).data('id'), function(data) { $.get('/ajax/share/'+$(this).data('id')+'/'+$(this).data('gid'), function(data) {
$('#modal-container').html(data); $('#modal-container').html(data);
}) })
$('#modal').show(); $('#modal').show();
......
...@@ -10,17 +10,19 @@ ...@@ -10,17 +10,19 @@
{% if t.myshares %} {% if t.myshares %}
<ul> <ul>
{% for i in t.myshares %} {% for i in t.myshares %}
<li>share {{i.name}} -&gt; {{i.group}}</li> <li>{{i.name}} -&gt; {{i.group}} ({{i.get_running}}/{{i.instance_limit}} = {{i.get_instance_pc}}%)
<form style="display:inline" action="/vm/unshare/{{i.id}}/" method="post"><input type="submit" value="unshare"/></form>
</li>
{% endfor %} {% endfor %}
{% endif %} {% endif %}
</div> </div>
<div class="status">{{t.state}}</div> <div class="status">{{t.state}}</div>
<div class="actions"> <div class="actions">
<a href="#" class="try-template-button" data-id="{{t.id}}" title="{% trans "Try" %}"> <a href="#" class="try-template-button" data-id="{{t.id}}" title="{% trans "Try" %}">
<img src="static/icons/control.png" alt="{% trans "Start" %}"/></a> <img src="/static/icons/control.png" alt="{% trans "Start" %}"/></a>
<a href="#" title="{% trans "Edit" %}"><img src="/static/icons/pencil.png" alt="{% trans "Edit" %}" /></a> <a href="#" title="{% trans "Edit" %}"><img src="/static/icons/pencil.png" alt="{% trans "Edit" %}" /></a>
<a href="#" class="delete-template-button" data-id="{{ t.id }}" data-name="{{ t.name }}" title="{% trans "Remove" %}"><img src="/static/icons/minus-circle.png" alt="{% trans "Remove" %}" /></a> <a href="#" class="delete-template-button" data-id="{{ t.id }}" data-name="{{ t.name }}" title="{% trans "Remove" %}"><img src="/static/icons/minus-circle.png" alt="{% trans "Remove" %}" /></a>
<a href="#" class="template-share" data-id="{{t.id}}" title="{% trans "Share" %}"><img src="/static/icons/user-share.png" alt="{% trans "Share" %}" /></a> <a href="#" class="template-share" data-id="{{t.id}}" data-gid="{{group.id}}" title="{% trans "Share" %}"><img src="/static/icons/user-share.png" alt="{% trans "Share" %}" /></a>
</div> </div>
<div class="clear"></div> <div class="clear"></div>
</div> </div>
...@@ -69,8 +71,8 @@ ...@@ -69,8 +71,8 @@
{% if t.myshares %} {% if t.myshares %}
<ul> <ul>
{% for i in t.myshares %} {% for i in t.myshares %}
<li>share {{i.name}} -&gt; {{i.group}} <li>{{i.name}} -&gt; {{i.group}} ({{i.get_running}}/{{i.instance_limit}} = {{i.get_instance_pc}}%)
<a href="/vm/unshare/{{i.id}}/">unshare</a> <form style="display:inline" action="/vm/unshare/{{i.id}}/" method="post"><input type="submit" value="unshare"/></form>
</li> </li>
{% endfor %} {% endfor %}
{% endif %} {% endif %}
...@@ -79,7 +81,7 @@ ...@@ -79,7 +81,7 @@
<div class="actions"> <div class="actions">
<a href="#" class="try-template-button" data-id="{{t.id}}" title="{% trans "Try" %}"> <a href="#" class="try-template-button" data-id="{{t.id}}" title="{% trans "Try" %}">
<img src="/static/icons/control.png" alt="{% trans "Start" %}"/></a> <img src="/static/icons/control.png" alt="{% trans "Start" %}"/></a>
<a href="#" class="template-share" data-id="{{t.id}}" {%if group%}data-gid="{{group.id}}"{%endif%} title="{% trans "Share" %}"><img src="/static/icons/user-share.png" alt="{% trans "Share" %}" /></a> <a href="#" class="template-share" data-id="{{t.id}}" data-gid="{{group.id}}" title="{% trans "Share" %}"><img src="/static/icons/user-share.png" alt="{% trans "Share" %}" /></a>
</div> </div>
<div class="clear"></div> <div class="clear"></div>
</div> </div>
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
<form action="/ajax/share/{{base.id}}" method="post" id="template-wizard">{% csrf_token %} <form action="/ajax/share/{{base.id}}" method="post" id="template-wizard">{% csrf_token %}
<div id="new-share" class="wizard"> <div id="new-share" class="wizard">
<h2>{% blocktrans with t=base.name%}Sharing template: {{t}}{% endblocktrans %}</h2> <h2>{% blocktrans with t=base.name%}Sharing template: {{t}}{% endblocktrans %}</h2>
{% if not group %}
<div class="hilight">
<p>{% trans "Choose a group" %}</p> <p>{% trans "Choose a group" %}</p>
{% if not groups %} {% if not groups %}
<p class="hilight">{% trans "You have no groups." %}</p> <p class="hilight">{% trans "You have no groups." %}</p>
...@@ -10,14 +12,18 @@ ...@@ -10,14 +12,18 @@
<ul> <ul>
<li> <li>
<label for="share-group">{% trans "Group" %}</label> <label for="share-group">{% trans "Group" %}</label>
<select name="group"{% if not groups %} disabled=""{%endif%}> <select id="share-group-select" name="group"{% if not groups %} disabled=""{%endif%}>
<option value="" selected="" class="dummy">--</option> <option value="" selected="" class="dummy">--</option>
{%for i in groups%}<option value="{{i.id}}">{{i.name}} ({{i.members.count}})</option>{%endfor%} {%for i in groups%}<option value="{{i.id}}">{{i.name}} ({{i.members.count}})</option>{%endfor%}
</select> </select>
<div class="clear"></div> <div class="clear"></div>
</li> </li>
</ul> </ul>
</div>
<div class="clear"></div> <div class="clear"></div>
{% else %}
<input type="hidden" name="group" value="{{group.id}}" />
{% endif %}
<p>{% trans "Change the parameters as needed." %}</p> <p>{% trans "Change the parameters as needed." %}</p>
<ul> <ul>
<li> <li>
...@@ -76,12 +82,12 @@ ...@@ -76,12 +82,12 @@
</nav> </nav>
<script type="text/javascript"> <script type="text/javascript">
$(function(){ $(function(){
if ("" == $(":selected this").val()) if (!$("select#share-group-select :selected").val())
$('#new-share input[type=submit]').attr("disabled", "") $('#new-share input[type=submit]').attr("disabled", "")
else else
$('#new-share input[type=submit]').removeAttr("disabled") $('#new-share input[type=submit]').removeAttr("disabled")
$('#new-share select').change(function(e) { $('#new-share select#share-group-select').change(function(e) {
if ("" == $(":selected this").val()) if (!$(":selected", this).val())
$('#new-share input[type=submit]').attr("disabled", "") $('#new-share input[type=submit]').attr("disabled", "")
else else
$('#new-share input[type=submit]').removeAttr("disabled") $('#new-share input[type=submit]').removeAttr("disabled")
......
...@@ -173,7 +173,7 @@ class AjaxShareWizard(View): ...@@ -173,7 +173,7 @@ class AjaxShareWizard(View):
type=stype, instance_limit=il, per_user_limit=request.POST['per_user_limit'], type=stype, instance_limit=il, per_user_limit=request.POST['per_user_limit'],
group=group, template=base) group=group, template=base)
messages.success(request, _('Successfully shared %s.') % base) messages.success(request, _('Successfully shared %s.') % base)
return redirect('/') return redirect(group)
ajax_share_wizard = login_required(AjaxShareWizard.as_view()) ajax_share_wizard = login_required(AjaxShareWizard.as_view())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment