1
|
import {Component} from '@angular/core';
|
2
|
import {ActivatedRoute, Router} from '@angular/router';
|
3
|
import {Session} from '../login/utils/helper.class';
|
4
|
import {HelperFunctions} from "../utils/HelperFunctions.class";
|
5
|
|
6
|
@Component({
|
7
|
selector: 'reload',
|
8
|
template: `
|
9
|
<div id="tm-main" class=" uk-section uk-margin-small-top tm-middle" >
|
10
|
<div uk-grid uk-grid>
|
11
|
<div class="tm-main uk-width-1-1@s uk-width-1-1@m uk-width-1-1@l uk-row-first ">
|
12
|
<div class="uk-container uk-margin-top publication">
|
13
|
Go to initial page....
|
14
|
</div>
|
15
|
</div>
|
16
|
</div>
|
17
|
</div>
|
18
|
`
|
19
|
})
|
20
|
export class ReloadComponent {
|
21
|
|
22
|
constructor (private route: ActivatedRoute, private _router: Router) {}
|
23
|
|
24
|
public ngOnInit() {
|
25
|
HelperFunctions.scroll();
|
26
|
|
27
|
var URL = Session.getReloadUrl();
|
28
|
|
29
|
if(URL && URL["path"] && URL["path"] != null && URL["path"] != ""){
|
30
|
var url = URL["path"];
|
31
|
var host = URL["host"];
|
32
|
var paramsObject = ((URL["params"] && URL["params"] != null)? Session.getParamsObj(URL["params"]):null);
|
33
|
if(host == (location.protocol+"//"+location.host)){
|
34
|
let baseUrl = (document && document.getElementsByTagName('base'))?document.getElementsByTagName('base')[0].href.split(document.location.host)[1]:"/";
|
35
|
url = (baseUrl.length>1 && url.indexOf(baseUrl)!=-1 )?("/"+url.split(baseUrl)[1]):url;
|
36
|
if(paramsObject && paramsObject != null){
|
37
|
Session.setReloadUrl("","","")
|
38
|
this._router.navigate([url],{ queryParams: paramsObject});
|
39
|
}else{
|
40
|
Session.setReloadUrl("","","")
|
41
|
this._router.navigate([url]);
|
42
|
}
|
43
|
}else{
|
44
|
Session.setReloadUrl("","","")
|
45
|
window.location.href = host+url+((URL["params"] && URL["params"] !=null)?((URL["params"].indexOf("?")==-1?"?":"")+URL["params"]):"");
|
46
|
}
|
47
|
|
48
|
}else{
|
49
|
Session.setReloadUrl("","","")
|
50
|
this._router.navigate(['/']);
|
51
|
|
52
|
}
|
53
|
}
|
54
|
|
55
|
}
|