Project

General

Profile

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
  
25
  public ngOnInit() {
26
    HelperFunctions.scroll();
27
    var URL = Session.getReloadUrl();
28
    if (URL && URL["path"] && URL["path"] != null && URL["path"] != "") {
29
      var url = URL["path"];
30
      var host = URL["host"];
31
      var paramsObject = ((URL["params"] && URL["params"] != null) ? Session.getParamsObj(URL["params"]) : null);
32
      if (host == (location.protocol + "//" + location.host)) {
33
        let baseUrl = (document && document.getElementsByTagName('base')) ? document.getElementsByTagName('base')[0].href.split(document.location.host)[1] : "/";
34
        url = (baseUrl.length > 1 && url.indexOf(baseUrl) != -1) ? ("/" + url.split(baseUrl)[1]) : url;
35
        if (paramsObject) {
36
          Session.setReloadUrl("", "", "")
37
          this._router.navigate([url], {queryParams: paramsObject});
38
        } else {
39
          Session.setReloadUrl("", "", "")
40
          this._router.navigate([url]);
41
        }
42
      } else {
43
        Session.setReloadUrl("", "", "")
44
        window.location.href = host + url + ((URL["params"] && URL["params"] != null) ? ((URL["params"].indexOf("?") == -1 ? "?" : "") + URL["params"]) : "");
45
      }
46
      
47
    } else {
48
      Session.setReloadUrl("", "", "")
49
      this._router.navigate(['/']);
50
      
51
    }
52
  }
53
  
54
}
(2-2/3)