55 lines
1.9 KiB
TypeScript
55 lines
1.9 KiB
TypeScript
import {Component} from '@angular/core';
|
|
import {ActivatedRoute, Router} from '@angular/router';
|
|
import {Session} from '../login/utils/helper.class';
|
|
import {HelperFunctions} from "../utils/HelperFunctions.class";
|
|
|
|
@Component({
|
|
selector: 'reload',
|
|
template: `
|
|
<div id="tm-main" class=" uk-section uk-margin-small-top tm-middle">
|
|
<div uk-grid uk-grid>
|
|
<div class="tm-main uk-width-1-1@s uk-width-1-1@m uk-width-1-1@l uk-row-first ">
|
|
<div class="uk-container uk-margin-top publication">
|
|
Go to initial page....
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
`
|
|
})
|
|
export class ReloadComponent {
|
|
|
|
constructor(private route: ActivatedRoute, private _router: Router) {
|
|
}
|
|
|
|
public ngOnInit() {
|
|
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]);
|
|
}
|
|
} 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(['/']);
|
|
|
|
}
|
|
}
|
|
|
|
}
|