|
|
|
@ -15,18 +15,22 @@ import { AppsStoreService } from './../services/apps-store.service'; |
|
|
|
}) |
|
|
|
export class DashboardLinkDirective implements Ng2.OnInit, Ng2.OnDestroy { |
|
|
|
private appSubscription: any; |
|
|
|
private appName: string; |
|
|
|
private url: string; |
|
|
|
|
|
|
|
constructor( |
|
|
|
private readonly appsStore: AppsStoreService, |
|
|
|
private readonly router: Ng2Router.Router |
|
|
|
private readonly router: Ng2Router.Router, |
|
|
|
private readonly element: Ng2.ElementRef, |
|
|
|
private readonly renderer: Ng2.Renderer |
|
|
|
) { |
|
|
|
} |
|
|
|
|
|
|
|
public ngOnInit() { |
|
|
|
this.appSubscription = |
|
|
|
this.appsStore.selectedApp.subscribe(app => { |
|
|
|
this.appName = app.name; |
|
|
|
this.url = this.router.createUrlTree(['app', app.name]).toString(); |
|
|
|
|
|
|
|
this.renderer.setElementAttribute(this.element.nativeElement, 'href', this.url); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
@ -36,8 +40,8 @@ export class DashboardLinkDirective implements Ng2.OnInit, Ng2.OnDestroy { |
|
|
|
|
|
|
|
@Ng2.HostListener('click') |
|
|
|
public onClick() { |
|
|
|
if (this.appName) { |
|
|
|
this.router.navigate(['app', this.appName]); |
|
|
|
} |
|
|
|
this.router.navigateByUrl(this.url); |
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
} |