Project

General

Profile

1
import {Component, Input, Output, EventEmitter, ViewChild, ElementRef} from '@angular/core';
2
import {Observable}       from 'rxjs/Observable';
3
import {ActivatedRoute, Router} from '@angular/router';
4
import {Location} from '@angular/common';
5

    
6
import {ErrorCodes} from '../utils/properties/errorCodes';
7
import {RouterHelper} from '../utils/routerHelper.class';
8
import {Session} from '../login/utils/helper.class';
9

    
10
@Component({
11
    selector: 'reload',
12
    template: `
13
    <div id="tm-main" class=" uk-section  uk-margin-small-top tm-middle"   >
14
      <div uk-grid uk-grid>
15
       <div class="tm-main uk-width-1-1@s uk-width-1-1@m  uk-width-1-1@l uk-row-first ">
16
          <div class="uk-container uk-margin-top publication">
17
            Go to initial page....
18
          </div>
19
        </div>
20
      </div>
21
    </div>
22
     `
23
})
24
export class ReloadComponent {
25

    
26
  constructor (private element: ElementRef,
27
    private route: ActivatedRoute,
28
      private _router: Router,
29
       private location: Location
30
    ) {
31

    
32
   }
33

    
34
  public ngOnInit() {
35
    if (typeof document !== 'undefined') {
36
      this.element.nativeElement.scrollIntoView();
37
    }
38
      var URL = Session.getReloadUrl();
39

    
40
        if(URL && URL["path"] && URL["path"] != null && URL["path"] != ""){
41
          var url = URL["path"];
42
          var host = URL["host"];
43
          var paramsObject =  Session.getParamsObj(URL["params"]);
44
          if(host == (location.protocol+"//"+location.host)){
45
            if(paramsObject &&  paramsObject != null){
46
              Session.setReloadUrl("","","")
47
              this._router.navigate([url],{ queryParams: paramsObject});
48
            }else{
49
              Session.setReloadUrl("","","")
50
              this._router.navigate([url]);
51
            }
52
          }else{
53
            Session.setReloadUrl("","","")
54
            window.location.href = host+url+URL["params"];
55
          }
56

    
57
        }else{
58
          Session.setReloadUrl("","","")
59
          this._router.navigate(['/']);
60

    
61
        }
62
  }
63

    
64
}
(2-2/3)