Project

General

Profile

« Previous | Next » 

Revision 56635

View differences:

dashboard.component.ts
1 1
import { Component, OnInit } from '@angular/core';
2 2
import { AuthenticationService } from '../../services/authentication.service';
3
import { RepositoryService } from '../../services/repository.service';
4
import {Repository, RepositorySnippet, RepositorySummaryInfo} from '../../domain/typeScriptClasses';
3 5

  
4 6
@Component ({
5 7
  selector: 'app-dashboard',
......
8 10

  
9 11
export class DashboardComponent implements OnInit {
10 12

  
11
  constructor(private authService: AuthenticationService) { }
13
  constructor(private authService: AuthenticationService,
14
              private repositoryService: RepositoryService) { }
12 15

  
13
  ngOnInit() {}
16
  repositories: RepositorySummaryInfo[] = [];
17
  userEmail: string;
14 18

  
19
  loading: boolean = true;
20

  
21
  ngOnInit() {
22
    // this.getUserEmail();
23
    this.userEmail = sessionStorage.getItem('email');
24
    if (this.userEmail) {
25
      this.getRepositoriesSummaryInfo(this.userEmail);
26
    }
27
  }
28

  
15 29
  getIsUserLoggedIn() {
16 30
    return this.authService.getIsUserLoggedIn();
17 31
  }
32

  
33
  getUserEmail() {
34
    this.userEmail = this.authService.getUserEmail();
35
  }
36

  
37
  getRepos() {
38
    console.log('in getRepos');
39
    this.getRepositoriesSummaryInfo(this.userEmail);
40
  }
41

  
42
  getRepositoriesSummaryInfo(userEmail: string) {
43
    this.repositoryService.getRepositoriesSummaryInfo(userEmail).subscribe(
44
      repositories => { this.repositories = repositories; this.loading=false },
45
      error => { console.log('Errrrror'); this.loading=false },
46
      () => { console.log(this.repositories); this.loading=false }
47
    );
48
  }
18 49
}

Also available in: Unified diff