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(
|
urlpatterns = patterns(
|
||||||
'',
|
'',
|
||||||
url(r'^api/clients$', rest_api.Clients.as_view(), name="api_clients"),
|
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/$', rest_api.ActionList.as_view(), name="api_actions"),
|
||||||
url(r'^api/actions/job/(?P<job_id>[^/]+)?$',
|
url(r'^api/actions/job/(?P<job_id>[^/]+)?$',
|
||||||
rest_api.Actions.as_view(), name="api_actions_in_job"),
|
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>
|
<script type='text/javascript' src='{{ STATIC_URL }}freezer/js/freezer.restore.js'></script>
|
||||||
|
|
||||||
<noscript><h3>{{ step }}</h3></noscript>
|
<noscript><h3>{{ step }}</h3></noscript>
|
||||||
|
|
|
@ -48,4 +48,5 @@
|
||||||
{{ step.get_help_text }}
|
{{ step.get_help_text }}
|
||||||
</div>
|
</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>
|
<script type='text/javascript' src='{{ STATIC_URL }}freezer/js/freezer.jobs.sortable.js'></script>
|
||||||
|
|
|
@ -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();
|
var job_id = $('#id_job_id').val();
|
||||||
|
|
||||||
|
|
||||||
function get_url() {
|
function actions_in_job_url() {
|
||||||
var url = $(location).attr("href");
|
var url = Browser.get_url();
|
||||||
url += 'api/actions/job/';
|
url += 'actions/job/';
|
||||||
url += job_id;
|
url += job_id;
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_actions_url() {
|
|
||||||
var url = $(location).attr("href");
|
function actions_url() {
|
||||||
url += 'api/actions';
|
var url = Browser.get_url();
|
||||||
|
url += 'actions/';
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (job_id !== "") {
|
if (job_id !== "") {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: get_url(),
|
url: actions_in_job_url(),
|
||||||
type: "GET",
|
type: "GET",
|
||||||
cache: false,
|
cache: false,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
|
@ -71,10 +72,8 @@ if (job_id !== "") {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var url = get_actions_url();
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: url,
|
url: actions_url(),
|
||||||
type: "GET",
|
type: "GET",
|
||||||
cache: false,
|
cache: false,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
|
|
|
@ -18,11 +18,15 @@
|
||||||
|
|
||||||
"use strict";
|
"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({
|
$.ajax({
|
||||||
url: url,
|
url: get_url(),
|
||||||
type: "GET",
|
type: "GET",
|
||||||
cache: false,
|
cache: false,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
|
|
Loading…
Reference in New Issue