Project

General

Profile

« Previous | Next » 

Revision 50290

forms array view works!

View differences:

repository-tiles.component.ts
1 1
import { Component, Input, OnInit } from '@angular/core';
2
import { PiwikInfo, Repository } from '../../domain/typeScriptClasses';
2
import { Repository } from '../../domain/typeScriptClasses';
3 3
import { RepositoryService } from '../../services/repository.service';
4 4
import { AuthenticationService } from '../../services/authentication.service';
5 5
import { loadingReposMessage, reposRetrievalError } from '../../domain/shared-messages';
......
12 12
export class RepositoryTilesComponent implements OnInit {
13 13
  reposOfUser: Repository[] = [];
14 14
  showSpinner: boolean;
15
  layoutChoice: string;
16
  badgeCSS: string;
17
  badgeText: string;
18
  linkToNext: string;
15
  tilesView: boolean;
19 16
  errorMessage: string;
20 17
  loadingMessage: string;
21 18

  
......
26 23

  
27 24
  ngOnInit() {
28 25
    this.getReposOfUser();
29
    this.layoutChoice = 'tiles';
26
    this.tilesView = true;
30 27
  }
31 28

  
32 29
  getReposOfUser(): void {
......
56 53
      );
57 54
  }
58 55

  
59
  setPropertiesForRepo(repo: Repository): void {
60
    if(this.parent=='metrics'){
61
      this.goToValidationLink(repo.piwikInfo, repo.id);
56
  getLinkToNext(repo): string {
57
    if (this.parent == 'metrics') {
58
      if (repo.piwikInfo) {
59
        if (repo.piwikInfo.validated === true) {
60
          return `show_metrics/${repo.id}`;
61
        } else if (repo.piwikInfo.validated === false) {
62
          return `instructions/${repo.id}`;
63
        }
64
      } else {
65
        return `enable/${repo.id}`;
66
      }
67
    } else if(this.parent == 'sourcesUpdate'){
68
      return repo.id;
69
    } else if(this.parent=='contentEvents'){
70
      return repo.officialName;
71
    }
72
  }
62 73

  
74
  getBadgeCSS(repo): string {
75
    if (this.parent == 'metrics') {
76
      if (repo.piwikInfo) {
77
        if (repo.piwikInfo.validated === true) {
78
          return 'uk-badge uk-badge-success';
79
        } else if (repo.piwikInfo.validated === false) {
80
          return 'uk-badge uk-badge-warning';
81
        }
82
      } else {
83
        return 'uk-badge uk-badge-danger';
84
      }
85
    } else if (this.parent == 'sourcesUpdate') {
86
      return repo.id;
63 87
    } else if(this.parent=='contentEvents'){
64
      this.badgeCSS = 'el-meta uk-margin uk-text-meta';
65
      this.badgeText = '0';
66
      this.linkToNext = `/contact/events/${repo.officialName}`;
67

  
68
    } else if(this.parent=='sourcesUpd') {
69
      console.log("got repo id!!");
70
      this.linkToNext = `/sources/update/${repo.id}`;
88
      return 'el-meta uk-margin uk-text-meta';
71 89
    }
72 90
  }
73 91

  
74
  goToValidationLink(piwik: PiwikInfo, id: string) {
75
    if(piwik){
76
      if(piwik.validated === true){
77
        this.badgeCSS = 'uk-badge uk-badge-success';
78
        this.badgeText = 'enabled';
79
        this.linkToNext = `/getImpact/show_metrics/${id}`;
92
  getBadgeText(repo): string {
93
    if(this.parent=='metrics'){
94
      if(repo.piwikInfo){
95
        if(repo.piwikInfo.validated === true){
96
          return 'enabled';
97
        } else if ( repo.piwikInfo.validated === false ) {
98
          return 'enabling in progress';
99
        }
100
      } else {
101
        return 'not enabled';
102
      }
80 103

  
81
      } else if ( piwik.validated === false ) {
82
        this.badgeCSS = 'uk-badge uk-badge-warning';
83
        this.badgeText = 'enabling in progress';
84
        this.linkToNext = `/getImpact/instructions/${id}`;
85
      }
86
    } else {
87
      this.badgeCSS = 'uk-badge uk-badge-danger';
88
      this.badgeText = 'not enabled';
89
      this.linkToNext = `/getImpact/enable/${id}`;
104
    } else if(this.parent=='contentEvents') {
105
      return '0';
90 106
    }
91 107
  }
92 108

  
93 109
  showTiles(){
94
    this.layoutChoice = 'tiles';
110
    this.tilesView = true;
95 111
  }
96 112

  
97 113
  showList(){
98
    this.layoutChoice = 'list';
114
    this.tilesView = false;
99 115
  }
100 116
}

Also available in: Unified diff