Beispiel #1
0
    .subscribe(action => {
      const { path, query: queryParams, extras = {} }: RouterMethodCall = action.payload;
      let commands: any[] = Array.isArray(path) ? path : [path];

      switch (action.type) {
        case routerActions.GO:
          router.navigate(commands, Object.assign({}, extras, { queryParams }));
          break;

        case routerActions.REPLACE:
          router.navigate(commands, Object.assign({}, extras, { queryParams, replaceUrl: true }));
          break;

        case routerActions.SEARCH:
          let urlTree: UrlTree = router.parseUrl(router.url);
          urlTree.queryParams = queryParams;
          router.navigateByUrl(urlTree, extras);
          break;

        case routerActions.SHOW:
          router.navigate(commands, Object.assign({}, extras, { queryParams, skipLocationChange: true }));
          break;

        case routerActions.BACK:
          location.back();
          break;

        case routerActions.FORWARD:
          location.forward();
          break;
      }
    });
Beispiel #2
0
    this.authService.login().subscribe(() => {
      this.setMessage();
      if (this.authService.isLoggedIn) {
        // Get the redirect URL from our auth service
        // If no redirect has been set, use the default
        let redirect = this.authService.redirectUrl ? this.router.parseUrl(this.authService.redirectUrl) : '/admin';

        // Redirect the user
        this.router.navigateByUrl(redirect);
      }
    });
Beispiel #3
0
 router.events.subscribe(s => {
   if (s instanceof NavigationEnd) {
     const tree = router.parseUrl(router.url);
     if (tree.fragment) {
       // you can use DomAdapter
       const element:any = document.querySelector("#" + tree.fragment);
       if (element) { 
         element.scrollIntoView(element); 
         document.body.scrollTop -= offset;
       }
     }
   }
 });
    constructor(private http: Http, private cookieService: CookieService, private shareService: ShareService, private router: Router, private location: Location) {

        var queryParams = this.router.parseUrl(router.url).queryParams;

        if (queryParams['share'] == 'true')
        {
            this.comparisonType = queryParams['analysis'] == 'monthly' ? 1 : 2;
        }
        else
        {
            this.comparisonType = 2;
        }

        this.favouriteCountiesCookieKey = 'favouriteCounties';

        this.LoadData();

        this.location.go('/performerii-lunii');
    }
    constructor(private http: Http, private shareService: ShareService, private router: Router, private location: Location) {

        this.GetCounties();

        var queryParams = this.router.parseUrl(this.router.url).queryParams;

        if (queryParams['share'] == 'true') {
            this.indicator = queryParams['chapter'].replace(new RegExp("\\+", "g"), ' ');
            this.comparisonType = queryParams['needToProcessAllYear'] == 'true' ? 2 : 1;
        }
        else {
            this.indicator = 'Forta de munca - salariu mediu net';
            this.comparisonType = 1;
        }

        this.needToProcessAllYear = this.comparisonType == 2;

        this.location.go('/statistici-judetene');
    }
	// ---
	// PRIVATE METHODS.
	// ---

	// I return the requested URL (as defined in the snapshot), less any of the "modal"
	// outlet segments.
	private getUrlWithoutModal( routerStateSnapshot: RouterStateSnapshot ) : UrlTree {

		var urlTree = this.router.parseUrl( routerStateSnapshot.url );
		var segment = urlTree.root;

		// Since the "modal" outlet is known to be directly off the primary view, we're
		// going to walk down the tree of primary outlets and delete any "modal" 
		// children. This should leave us with a UrlTree that contains everything that 
		// the original URL had, less the "modal" outlet.
		while ( segment && segment.children ) {

			delete( segment.children.modal );

			segment = segment.children[ PRIMARY_OUTLET ];

		}

		return( urlTree );

	}
Beispiel #7
0
    this.authService.login().subscribe(() => {
      this.setMessage();
      if (this.authService.isLoggedIn) {
        // Get the redirect URL from our auth service
        // If no redirect has been set, use the default
        let redirect = this.authService.redirectUrl ? this.router.parseUrl(this.authService.redirectUrl) : '/admin';

        // #docregion preserve
        // Set our navigation extras object
        // that passes on our global query params and fragment
        let navigationExtras: NavigationExtras = {
          queryParamsHandling: 'preserve',
          preserveFragment: true
        };

        // Redirect the user
        this.router.navigateByUrl(redirect, navigationExtras);
        // #enddocregion preserve
      }
    });
	// ---
	// PRIVATE METHODS.
	// ---

	// I return the requested URL (as defined in the snapshot), less any the "secondary"
	// named-outlet segments.
	private getUrlWithoutSecondary( routerStateSnapshot: RouterStateSnapshot ) : UrlTree {

		var urlTree = this.router.parseUrl( routerStateSnapshot.url );
		var segment = urlTree.root;

		// Since the "secondary" outlet is known to be directly off the primary view 
		// (ie, not nested within another named-outlet), we're going to walk down the 
		// tree of primary outlets and delete any "secondary" children. This should 
		// leave us with a UrlTree that contains everything that the original URL had,
		// less the "secondary" named-outlet.
		while ( segment && segment.children ) {

			delete( segment.children.secondary );

			segment = segment.children[ PRIMARY_OUTLET ];

		}

		return( urlTree );

	}
            .subscribe(result => {
                this.counties1 = result.json();
                this.county1 = 1;
                this.county1Text = this.counties1.find(x => x.id == 1)!.name;
                this.counties2 = new Array<ICounty>();
                var defaultCounty2 = new County();
                defaultCounty2.id = 0;
                defaultCounty2.name = '-----------------';
                this.counties2.push(defaultCounty2);
                this.counties1.forEach(x => this.counties2.push(x));
                this.county2 = 0;
                this.county2Text = this.counties2.find(x => x.id == 0)!.name;

                var queryParams = this.router.parseUrl(this.router.url).queryParams;
                if (queryParams['share'] == 'true') {
                    this.county1 = +queryParams['countyId1'];
                    this.county1Text = this.counties1.find(x => x.id == this.county1)!.name;
                    this.county2 = +queryParams['countyId2'];
                    this.county2Text = this.counties2.find(x => x.id == this.county2)!.name;
                }

                this.LoadData();
            });
 canActivate(): boolean | UrlTree {
   return this.currentUserService.isLoggedIn() || this.router.parseUrl('/login');
 }