Project

General

Profile

1
import { Component, OnInit } from '@angular/core';
2
import { RepositoryService } from '../../services/repository.service';
3
import { Topic } from '../../domain/typeScriptClasses';
4
import { ActivatedRoute } from '@angular/router';
5
import { loadingTopicsError } from '../../domain/shared-messages';
6

    
7
@Component ({
8
  selector: 'content-events-of-repository',
9
  templateUrl: 'content-events-of-repository.component.html'
10
})
11

    
12
export class ContentEventsOfRepositoryComponent implements OnInit {
13

    
14
  repoTopics: Topic[] = [];
15
  noDatasources: boolean;
16
  showSpinner: boolean;
17
  errorMessage: string;
18

    
19
  constructor(
20
    private route: ActivatedRoute,
21
    private repoService: RepositoryService
22
  ) {}
23

    
24
  ngOnInit() {
25
    this.getTopics();
26
  }
27

    
28
  getTopics(): void {
29
    let name = this.route.snapshot.paramMap.get('name');
30
    this.showSpinner = true;
31
    this.repoService.getTopicsForDataSource(name)
32
      .subscribe(topics => this.repoTopics = topics,
33
        error => {
34
          console.log(error);
35
          this.errorMessage = loadingTopicsError;
36
          this.showSpinner = false;
37
        },
38
        () => {
39
          if(!this.repoTopics.length) this.noDatasources=true;
40
          this.showSpinner = false;
41
        }
42
      );
43
  }
44

    
45
}
(2-2/9)