Fix api endpoint for action retrieval
js code cannot reach the api endpoints for action retrieval in specific cases because it depends on the actual url in the browser Closes-bug: 1525169 Depends-On: I837e3fe973d72c792cb34711cef9f6507a004d49 Change-Id: Ibffad1a6a24559535c71ea94ba98deeb78ebeccb
This commit is contained in:
parent
fc5d38a483
commit
94956bade3
@ -23,8 +23,8 @@ import rest_api
|
||||
|
||||
urlpatterns = patterns(
|
||||
'',
|
||||
url(r'^api/clients$', rest_api.Clients.as_view(), name="api_clients"),
|
||||
url(r'^api/actions$', rest_api.ActionList.as_view(), name="api_actions"),
|
||||
url(r'^api/clients/$', rest_api.Clients.as_view(), name="api_clients"),
|
||||
url(r'^api/actions/$', rest_api.ActionList.as_view(), name="api_actions"),
|
||||
url(r'^api/actions/job/(?P<job_id>[^/]+)?$',
|
||||
rest_api.Actions.as_view(), name="api_actions_in_job"),
|
||||
)
|
||||
|
@ -1,3 +1,4 @@
|
||||
<script type='text/javascript' src='{{ STATIC_URL }}freezer/js/freezer.common.js'></script>
|
||||
<script type='text/javascript' src='{{ STATIC_URL }}freezer/js/freezer.restore.js'></script>
|
||||
|
||||
<noscript><h3>{{ step }}</h3></noscript>
|
||||
|
@ -48,4 +48,5 @@
|
||||
{{ step.get_help_text }}
|
||||
</div>
|
||||
|
||||
<script type='text/javascript' src='{{ STATIC_URL }}freezer/js/freezer.common.js'></script>
|
||||
<script type='text/javascript' src='{{ STATIC_URL }}freezer/js/freezer.jobs.sortable.js'></script>
|
||||
|
22
disaster_recovery/static/freezer/js/freezer.common.js
Normal file
22
disaster_recovery/static/freezer/js/freezer.common.js
Normal file
@ -0,0 +1,22 @@
|
||||
var Browser = (function () {
|
||||
|
||||
var url_path = $(location).attr("pathname");
|
||||
|
||||
var url = null;
|
||||
url = $(location).attr("protocol");
|
||||
url += "//";
|
||||
url += $(location).attr("host");
|
||||
|
||||
if (url_path.indexOf("horizon") > -1) {
|
||||
url += '/horizon/disaster_recovery/api/';
|
||||
} else {
|
||||
url += '/disaster_recovery/api/';
|
||||
}
|
||||
|
||||
return {
|
||||
get_url : function () {
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
@ -30,22 +30,23 @@ $("form").submit(function (event) {
|
||||
var job_id = $('#id_job_id').val();
|
||||
|
||||
|
||||
function get_url() {
|
||||
var url = $(location).attr("href");
|
||||
url += 'api/actions/job/';
|
||||
url += job_id;
|
||||
return url;
|
||||
function actions_in_job_url() {
|
||||
var url = Browser.get_url();
|
||||
url += 'actions/job/';
|
||||
url += job_id;
|
||||
return url;
|
||||
}
|
||||
|
||||
function get_actions_url() {
|
||||
var url = $(location).attr("href");
|
||||
url += 'api/actions';
|
||||
return url;
|
||||
|
||||
function actions_url() {
|
||||
var url = Browser.get_url();
|
||||
url += 'actions/';
|
||||
return url;
|
||||
}
|
||||
|
||||
if (job_id !== "") {
|
||||
$.ajax({
|
||||
url: get_url(),
|
||||
url: actions_in_job_url(),
|
||||
type: "GET",
|
||||
cache: false,
|
||||
dataType: 'json',
|
||||
@ -71,10 +72,8 @@ if (job_id !== "") {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
var url = get_actions_url();
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
url: actions_url(),
|
||||
type: "GET",
|
||||
cache: false,
|
||||
dataType: 'json',
|
||||
|
@ -18,11 +18,15 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
var url = $(location).attr("origin");
|
||||
url += '/disaster_recovery/api/clients';
|
||||
|
||||
function get_url() {
|
||||
var url = Browser.get_url();
|
||||
url += 'clients/';
|
||||
return url;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
url: get_url(),
|
||||
type: "GET",
|
||||
cache: false,
|
||||
dataType: 'json',
|
||||
|
Loading…
x
Reference in New Issue
Block a user