2019-04-24 14:31:01 +02:00
|
|
|
import {Component} from '@angular/core';
|
2017-12-19 13:53:46 +01:00
|
|
|
import {ActivatedRoute, Router} from '@angular/router';
|
|
|
|
import {Session} from '../login/utils/helper.class';
|
2019-04-24 14:31:01 +02:00
|
|
|
import {HelperFunctions} from "../utils/HelperFunctions.class";
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
@Component({
|
2020-09-23 12:15:39 +02:00
|
|
|
selector: 'reload',
|
|
|
|
template: `
|
2020-11-26 12:14:14 +01:00
|
|
|
<loading [full]="true"></loading>
|
2020-09-23 12:15:39 +02:00
|
|
|
`
|
2017-12-19 13:53:46 +01:00
|
|
|
})
|
|
|
|
export class ReloadComponent {
|
2020-09-23 12:15:39 +02:00
|
|
|
|
|
|
|
constructor(private route: ActivatedRoute, private _router: Router) {
|
|
|
|
}
|
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
public ngOnInit() {
|
2020-09-23 12:15:39 +02:00
|
|
|
HelperFunctions.scroll();
|
|
|
|
var URL = Session.getReloadUrl();
|
|
|
|
if (URL && URL["path"] && URL["path"] != null && URL["path"] != "") {
|
|
|
|
var url = URL["path"];
|
|
|
|
var host = URL["host"];
|
|
|
|
var paramsObject = ((URL["params"] && URL["params"] != null) ? Session.getParamsObj(URL["params"]) : null);
|
|
|
|
if (host == (location.protocol + "//" + location.host)) {
|
|
|
|
let baseUrl = (document && document.getElementsByTagName('base')) ? document.getElementsByTagName('base')[0].href.split(document.location.host)[1] : "/";
|
|
|
|
url = (baseUrl.length > 1 && url.indexOf(baseUrl) != -1) ? ("/" + url.split(baseUrl)[1]) : url;
|
|
|
|
if (paramsObject) {
|
|
|
|
Session.setReloadUrl("", "", "")
|
|
|
|
this._router.navigate([url], {queryParams: paramsObject});
|
|
|
|
} else {
|
|
|
|
Session.setReloadUrl("", "", "")
|
|
|
|
this._router.navigate([url]);
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2020-09-23 12:15:39 +02:00
|
|
|
} else {
|
|
|
|
Session.setReloadUrl("", "", "")
|
|
|
|
window.location.href = host + url + ((URL["params"] && URL["params"] != null) ? ((URL["params"].indexOf("?") == -1 ? "?" : "") + URL["params"]) : "");
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
Session.setReloadUrl("", "", "")
|
|
|
|
this._router.navigate(['/']);
|
|
|
|
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2020-09-23 12:15:39 +02:00
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|