Skip to content
Snippets Groups Projects
workspace.component.ts 1.07 KiB
Newer Older
  • Learn to ignore specific revisions
  • rhenck's avatar
    rhenck committed
    import { Component, OnInit, OnDestroy } from '@angular/core';
    
    Martin Mechtel's avatar
    Martin Mechtel committed
    import { ActivatedRoute } from '@angular/router';
    
    import { Subscription } from 'rxjs';
    
    rhenck's avatar
    rhenck committed
    import { WorkspaceDataService } from './workspacedata.service';
    import { BackendService } from './backend.service';
    
    Martin Mechtel's avatar
    Martin Mechtel committed
    
    @Component({
      templateUrl: './workspace.component.html',
      styleUrls: ['./workspace.component.css']
    })
    export class WorkspaceComponent implements OnInit, OnDestroy {
      private routingSubscription: Subscription = null;
    
      constructor(
        private route: ActivatedRoute,
    
        private bs: BackendService,
    
    mechtelm's avatar
    mechtelm committed
        public wds: WorkspaceDataService
    
    Martin Mechtel's avatar
    Martin Mechtel committed
      ) { }
    
    
    rhenck's avatar
    rhenck committed
      ngOnInit(): void {
        this.routingSubscription = this.route.params.subscribe((params) => {
    
          this.wds.wsId = params['ws'];
    
    rhenck's avatar
    rhenck committed
          this.bs.getWorkspaceData(this.wds.wsId).subscribe((wsData) => {
            if (typeof wsData !== 'number') {
              this.wds.wsName = wsData.name;
              this.wds.wsRole = wsData.role;
    
    rhenck's avatar
    rhenck committed
          });
    
    Martin Mechtel's avatar
    Martin Mechtel committed
        });
      }
    
    
    rhenck's avatar
    rhenck committed
      ngOnDestroy(): void {
    
    Martin Mechtel's avatar
    Martin Mechtel committed
        if (this.routingSubscription !== null) {
          this.routingSubscription.unsubscribe();
        }
      }
    }