Commit ba06f3bc by Bence Dányi

webui: rewrite hardcoded urls

parent 32174835
......@@ -15,7 +15,7 @@ $(function() {
$('.delete-template').click(function(e) {
e.preventDefault();
e.stopPropagation();
delete_template_confirm($(this).data('id'), $(this).data('name'));
delete_template_confirm($(this).data('url'), $(this).data('id'), $(this).data('name'));
});
$('.delete-key').click(function(e) {
var id = $(this).data('id');
......@@ -97,7 +97,7 @@ $(function() {
$('.try-template').click(function(e) {
e.preventDefault();
e.stopPropagation();
new_vm($(this).data('id'));
new_vm($(this).data('url'));
});
$('.stop-vm').click(function(e) {
e.preventDefault();
......@@ -135,7 +135,7 @@ $(function() {
$('#modal-container .entry .summary').click(toggleDetails);
});
$('#new-template-button').click(function() {
$.get('/ajax/templateWizard', function(data) {
$.get($(this).data('url'), function(data) {
$('#modal-container').html(data);
})
$('#modal').show();
......@@ -146,7 +146,7 @@ $(function() {
var id=$(this).data('id');
$.ajax({
type: 'GET',
url: '/ajax/templateEditWizard/'+id+'/',
url: $(this).data('url'),
success: function(data){
$('#modal').show();
$('#modal-container').html(data);
......@@ -239,7 +239,7 @@ $(function() {
e.stopPropagation();
$.ajax({
type: 'GET',
url: '/ajax/shareEdit/' + $(this).data('id') + '/',
url: $(this).data('url'),
success: function(data) {
$('#modal').show();
$('#modal-container').html(data);
......@@ -353,13 +353,11 @@ $(function() {
* New VM
*/
function new_vm(template_id) {
function new_vm(url) {
$.ajax({
type: 'POST',
url: '/ajax/vm/new/' + template_id + '/',
url: url,
success: function(data, b, xhrRequest) {
window.location.href = '/'; //xhrRequest.getResponseHeader("Location");
//alert(xhrRequest.getResponseHeader("Location"));
window.location.href = xhrRequest.getResponseHeader("Location");
}
})
......@@ -369,7 +367,7 @@ $(function() {
* Template delete
*/
function delete_template_confirm(id, name) {
function delete_template_confirm(url, id, name) {
confirm_message = interpolate(gettext("Are you sure deleting this %s template?"), ["<strong>" + name + "</strong>"])
vm_confirm_popup(confirm_message, gettext("Delete"), function() {
delete_template(id)
......@@ -379,10 +377,10 @@ $(function() {
* Template delete
*/
function delete_template(id) {
function delete_template(url, id) {
$.ajax({
type: 'POST',
url: '/ajax/template/delete/',
url: url,
data: 'id=' + id,
dataType: 'json',
statusCode: {
......@@ -512,7 +510,7 @@ $(function() {
var neptun = $(this).prev().val();
$.ajax({
type: 'POST',
url: '/ajax/group/' + $(this).data('id') + '/add/',
url: $(this).data('url'),
data: 'neptun=' + neptun,
dataType: 'json',
success: function(data) {
......@@ -534,13 +532,14 @@ $(function() {
var timer;
return function(e) {
var val = $(this).val().split(' ')[0];
var that = this;
clearTimeout(timer);
timer = setTimeout(function() {
if (val.length < 1) return;
$.ajax({
type: 'POST',
data: 'q=' + val,
url: '/ajax/group/autocomplete/',
url: $(that).data('url'),
dataType: 'json',
success: function(data) {
console.log(data);
......@@ -597,37 +596,25 @@ $(function() {
var neptun = $(this).data('neptun');
$.ajax({
type: 'POST',
url: '/ajax/group/' + $(this).data('gid') + '/remove/',
url: $(this).data('url'),
data: 'neptun=' + neptun,
success: function(data) {
$('#member-' + neptun).slideUp(700);
}
});
});
/*$('#group-owners .remove').click(function(e) {
e.preventDefault();
e.stopPropagation();
var neptun = $(this).data('neptun');
$.ajax({
type: 'POST',
url: '/ajax/group/' + $(this).data('gid') + '/remove/',
data: 'neptun=' + neptun,
success: function(data) {
$('#member-' + neptun).slideUp(700);
}
});
});*/
$('#groups .delete').click(function(e) {
e.preventDefault();
e.stopPropagation();
var gid = $(this).data('id');
var name = $(this).data('name');
var url = $(this).data('url');
vm_confirm_popup(
interpolate(
gettext('Are you sure deleting <strong>%s</strong>'), [name]), gettext('Delete'), function() {
$.ajax({
type: 'POST',
url: '/ajax/group/delete/',
url: url,
data: 'gid=' + gid,
success: function() {
$('#group-' + gid).slideUp(700);
......
......@@ -46,7 +46,7 @@
</div>
{% endif %}
{% if not group %}
<li id="new-template-button" class="entry new small-row">
<li id="new-template-button" class="entry new small-row" data-url="{% url one.views.ajax_template_wizard %}">
<div class="summary">
<div class="name">Új Sablon</div>
<div class="clear"></div>
......@@ -65,7 +65,7 @@
<div class="status">{{t.state}}</div>
<div class="actions">
{% if t.state == 'READY' %}
<a href="#" class="try-template-button" data-id="{{t.id}}" title="{% trans "Try" %}">
<a href="#" class="try-template-button" data-url="{% url new_vm_from_template template=t.id %}" title="{% trans "Try" %}">
<img src="{% static "icons/control.png" %}" alt="{% trans "Start" %}"/>
</a>
<a href="#" class="template-share" data-id="{{t.id}}" data-gid="{{group.id}}" title="{% trans "Share" %}">
......
......@@ -17,7 +17,7 @@
<form action="{% url one.views.vm_unshare i.id %}" method="post">
<span title="{{i.name}}">{{i.name|truncatechars:20}}</span>
({{i.get_running}}/{{i.instance_limit}}) {{i.type}}
<a href="#" class="edit" data-id="{{i.id}}">
<a href="#" class="edit" data-url="{% url ajax_share_edit_wizard id=i.id %}">
<img src="{% static "icons/pencil.png" %}" alt="{% trans "Edit" %}" title="{% trans "Edit" %}" />
</a>
{% csrf_token %}
......@@ -47,11 +47,11 @@
{% endblock status %}
{% block actions %}
<a href="#" class="edit-template" data-id="{{ t.id }}" title="{% trans "Edit" %}">
<a href="#" class="edit-template" title="{% trans "Edit" %}" data-url="{% url one.views.ajax_template_edit_wizard id=t.id %}">
<img src="{% static "icons/pencil.png" %}" alt="{% trans "Edit" %}" />
</a>
{% if t.state == 'READY' %}
<a href="#" class="try-template" data-id="{{t.id}}" title="{% trans "Try" %}">
<a href="#" class="try-template" data-url="{% url new_vm_from_template template=t.id %}" title="{% trans "Try" %}">
<img src="{% static "icons/control.png" %}" alt="{% trans "Start" %}"/>
</a>
<!--<a href="#" title="{% trans "Edit" %}">
......@@ -61,7 +61,7 @@
<img src="{% static "icons/user-share.png" %}" alt="{% trans "Share" %}" />
</a>
{% endif %}
<a href="#" class="delete-template" data-id="{{ t.id }}" data-name="{{ t.name }}" title="{% trans "Remove" %}">
<a href="#" class="delete-template" data-url="{% url one.views.ajax_template_delete %}" data-id="{{ t.id }}" data-name="{{ t.name }}" title="{% trans "Remove" %}">
<img src="{% static "icons/minus-circle.png" %}" alt="{% trans "Remove" %}" />
</a>
{% endblock actions %}
......@@ -16,7 +16,7 @@
<small class="details">(<a href="{{ group.get_absolute_url }}">{% trans "More details" %}</a>)</small>
</div>
<div class="actions">
<a href="#" class="delete" data-id="{{group.id}}" data-name="{{group.name}}">
<a href="#" class="delete" data-url="{% url school.views.group_ajax_delete %}" data-id="{{group.id}}" data-name="{{group.name}}">
<img src="{% static "icons/minus-circle.png" %}" alt="{% trans "Delete" %}" title="{% trans "Delete" %}" />
</a>
<a href="#" class="hide-group" data-id="{{group.id}}">
......
......@@ -37,7 +37,7 @@
<div class="name">{% trans "Add user" %}</div>
<div id="new-member-form">
<input type="text" placeholder="{% trans "User NEPTUN code" %}" />
<input type="submit" value="{% trans "Add user" %}" data-id="{{group.id}}"/>
<input type="submit" value="{% trans "Add user" %}" data-url="{% url school.views.group_ajax_add_new_member gid=group.id %}"/>
</div>
<div class="clear"></div>
</div>
......
......@@ -19,7 +19,7 @@
{% endif %}
</div>
<div class="actions">
<a href="#" class="remove" data-gid="{{group.id}}" data-neptun="{{member.code}}">
<a href="#" class="remove" data-url="{% url school.views.group_ajax_remove_member gid=group.id %}" data-neptun="{{member.code}}">
<img src="{% static "icons/minus-circle.png" %}" alt="{% trans 'Remove' %}" />
</a>
</div>
......
......@@ -53,7 +53,7 @@
</div>
<div class="details" id="new-owner-form">
<div class="container">
<input type="text" placeholder="{% trans "Owner name/NEPTUN" %}" />
<input type="text" placeholder="{% trans "Owner name/NEPTUN" %}" data-url="{% url school.views.group_ajax_owner_autocomplete %}"/>
<div id="new-owner-autocomplete"></div>
</div>
</div>
......
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