Allow container-based url in history api
When a url is now loaded for an non-main container, the url for the container is appended to the GET part of the URL refs #4303
This commit is contained in:
parent
a8019222f5
commit
04f7149cfe
|
@ -71,7 +71,6 @@ define([
|
||||||
loadUrl: function(url, target, params) {
|
loadUrl: function(url, target, params) {
|
||||||
target = target || "icinga-main";
|
target = target || "icinga-main";
|
||||||
async.loadToTarget(target, url, params);
|
async.loadToTarget(target, url, params);
|
||||||
History.pushState(params, document.title, url);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getFailedModules: function() {
|
getFailedModules: function() {
|
||||||
|
|
|
@ -10,6 +10,32 @@
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var getCurrentGETParameters = function() {
|
||||||
|
var currentGET = window.location.search.substring(1).split("&");
|
||||||
|
var params = {};
|
||||||
|
if(currentGET.length > 0) {
|
||||||
|
$.each(currentGET, function(idx, elem) {
|
||||||
|
var keyVal = elem.split("=");
|
||||||
|
params[encodeURIComponent(keyVal[0])] = encodeURIComponent(keyVal[1]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
;
|
||||||
|
var pushGet = function(param, value, url) {
|
||||||
|
url = url || (window.location.origin+window.location.pathname);
|
||||||
|
var params = getCurrentGETParameters();
|
||||||
|
params[encodeURIComponent(param)] = encodeURIComponent(value);
|
||||||
|
var search = "?";
|
||||||
|
for (var name in params) {
|
||||||
|
if(search != "?")
|
||||||
|
search += "&";
|
||||||
|
search += name+"="+params[name];
|
||||||
|
}
|
||||||
|
|
||||||
|
return url+search+"#"+window.location.hash;
|
||||||
|
};
|
||||||
|
|
||||||
var getDOMForDestination = function(destination) {
|
var getDOMForDestination = function(destination) {
|
||||||
var target = destination;
|
var target = destination;
|
||||||
if(typeof destination === "string") {
|
if(typeof destination === "string") {
|
||||||
|
@ -96,12 +122,11 @@
|
||||||
if (destination == "icinga-main") {
|
if (destination == "icinga-main") {
|
||||||
History.pushState(data, document.title, url);
|
History.pushState(data, document.title, url);
|
||||||
} else {
|
} else {
|
||||||
data = data || {};
|
url = pushGet("c["+destination+"]", url);
|
||||||
data[destination] = url;
|
History.pushState(data, document.title, url);
|
||||||
History.pushState(data, document.title, document.location.href);
|
|
||||||
}
|
}
|
||||||
|
console.log("New url: ", url);
|
||||||
return req;
|
return req;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.loadCSS = function(name) {
|
this.loadCSS = function(name) {
|
||||||
|
|
|
@ -44,12 +44,16 @@ var onSecondLink = function() {
|
||||||
casper.page.evaluate(function() {
|
casper.page.evaluate(function() {
|
||||||
requirejs(["icinga/icinga"], function(icinga) {
|
requirejs(["icinga/icinga"], function(icinga) {
|
||||||
icinga.loadUrl("/fragments/testFragment3.html?this=is_a_param", "icinga-detail");
|
icinga.loadUrl("/fragments/testFragment3.html?this=is_a_param", "icinga-detail");
|
||||||
console.log(document.location.href);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
this.wait(400, function() {
|
||||||
console.log(casper.page.evaluate(function() {
|
console.log(casper.page.evaluate(function() {
|
||||||
return document.location.href;
|
return window.location.href;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
this.test.assertUrlMatch(/testFragment2.html.*testFragment3.html/);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
casper.run(function() {
|
casper.run(function() {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<div>
|
<div>
|
||||||
<h1>Test fragment</h1>
|
<h1>Test fragment</h1>
|
||||||
<a href="/fragments/testFragment2.html">Fragment 2</a>
|
<a href="/fragments/testFragment2.html?this=istesting">Fragment 2</a>
|
||||||
<a href="/fragments/testFragment3.html">Fragment 3</a>
|
<a href="/fragments/testFragment3.html">Fragment 3</a>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
/Users/moja/git/icinga2-web/test/frontend/../../public
|
Loading…
Reference in New Issue