Project

General

Profile

« Previous | Next » 

Revision 50376

continued with compatibility-validate

View differences:

compatibility-validate-type.component.ts
1
import { Component, OnInit } from '@angular/core';
1
import { Component, OnInit, ViewChild } from '@angular/core';
2 2
import { ActivatedRoute } from '@angular/router';
3
import { CompatibilityValidateStep1Component } from './compatibility-validate-forms/compatibility-validate-step1.component';
4
import { RepositoryService } from '../../services/repository.service';
5
import { Repository } from '../../domain/typeScriptClasses';
6
import { AuthenticationService } from '../../services/authentication.service';
7
import {
8
  loadingReposMessage, loadingUserRepoInfo, loadingUserRepoInfoEmpty,
9
  loadingUserRepoInfoError
10
} from '../../domain/shared-messages';
3 11

  
4 12
@Component ({
5 13
  selector: 'compatibility-validate-literature',
......
16 24
  step3: string = '';
17 25
  step4: string = '';
18 26

  
19
  constructor(private route: ActivatedRoute) {}
27
  baseUrlList: string[] = [];
28
  errorMessage: string;
29
  loadingMessage: string;
30
  showSpinner: boolean;
20 31

  
32
  @ViewChild('step1ChooseBaseUrl') step1ChooseBaseUrl : CompatibilityValidateStep1Component;
33

  
34
  constructor(private route: ActivatedRoute,
35
              private authService: AuthenticationService,
36
              private repoService: RepositoryService) {}
37

  
21 38
  ngOnInit() {
22 39
    this.readType();
23
    this.showDatasource = true;
40
    this.getBaseUrlList();
24 41
  }
25 42

  
26 43
  readType() {
......
30 47

  
31 48
  moveAStep(){
32 49
    if (this.showDatasource) {
33
      this.showGuidelines = true;
34
      this.showDatasource = false;
35
      this.step2 = 'active';
50
      if(this.step1ChooseBaseUrl.goToNext()) {
51
        this.showGuidelines = true;
52
        this.showDatasource = false;
53
        this.step2 = 'active';
54
      }
36 55
    } else if (this.showGuidelines) {
37 56
      this.showParameters = true;
38 57
      this.showGuidelines = false;
......
60 79
    }
61 80
  }
62 81

  
82
  /* retrieves the baseUrl list for the registered repositories of the user */
83
  getBaseUrlList(): void {
84
    this.showSpinner = true;
85
    this.loadingMessage = loadingUserRepoInfo;
86
//    this.repoService.getUrlsOfUserRepos(this.authService.getUserEmail()) RESTORE AFTER FINISH!!
87
    this.repoService.getUrlsOfUserRepos('ant.lebesis@gmail.com')
88
      .subscribe(
89
        repos => this.baseUrlList = repos.sort( function(a , b){
90
          if(a < b ){
91
            return -1;
92
          } else if(a > b ){
93
            return 1;
94
          } else {
95
            return 0;
96
          }
97
        }),
98
        error => {
99
          console.log(error);
100
          this.showSpinner = false;
101
          this.loadingMessage = '';
102
          this.errorMessage = loadingUserRepoInfoError;
103
        },
104
        () => {
105
          this.showSpinner = false;
106
          this.loadingMessage = '';
107
          this.showDatasource = true;
108
        }
109
      );
110
  }
111

  
63 112
}

Also available in: Unified diff