Commit 5c5cdfc5 authored by Michail Tzanatos's avatar Michail Tzanatos
Browse files

display NaN in landing page metrics when api is not responding

parent 5d48540a
Loading
Loading
Loading
Loading
+33 −3
Original line number Diff line number Diff line
@@ -60,19 +60,19 @@ export class LandingComponent implements OnInit {
      registeredUsers: this.generalMetricsService.getRegisteredIndividuals().pipe(
        catchError(error => {
          console.error('Failed to load registered users', error);
          return scheduled([{ registeredIndividuals: this.registeredUsers }], asyncScheduler);
          return scheduled([{ registeredIndividuals: NaN }], asyncScheduler);
        })
      ),
      publishedServiceSpecs: this.generalMetricsService.getPublishedServiceSpecifications().pipe(
        catchError(error => {
          console.error('Failed to load published specs', error);
          return scheduled([{ publishedServiceSpecifications: this.publishedServiceSpecs }], asyncScheduler);
          return scheduled([{ publishedServiceSpecifications: NaN }], asyncScheduler);
        })
      ),
      registeredResourceSpecs: this.generalMetricsService.getRegisteredResourceSpecifications().pipe(
        catchError(error => {
          console.error('Failed to load resource specs', error);
          return scheduled([{ registeredResourceSpecifications: this.registeredResourceSpecs }], asyncScheduler);
          return scheduled([{ registeredResourceSpecifications: NaN }], asyncScheduler);
        })
      )
    }).subscribe(
@@ -157,6 +157,7 @@ export class LandingComponent implements OnInit {
  // }

  startAnimation() {

    const stepTime = 50;

    this.intervalId = setInterval(() => {
@@ -172,6 +173,35 @@ export class LandingComponent implements OnInit {
        }
      }
    }, stepTime);

  }

  infiniteLoopAnimation() {
    
    const stepTime = 50;
    let time = 0;
    
    const maxValues: { [key: string]: number } = {};
    
    for (const key in this.animatedCounts) {
      maxValues[key] = Math.floor(Math.random() * 500) + 10;
    }

    this.intervalId = setInterval(() => {
      time += 0.1;
      
      for (const key in this.animatedCounts) {
        const k = key as keyof typeof this.animatedCounts;
        const maxValue = maxValues[key];
        
        const triangleWave = 2 * Math.abs((time % 2) - 1) - 1;
        const normalizedTriangleWave = (triangleWave + 1) / 2;
        const apiNotRespondingValue = normalizedTriangleWave * maxValue;
        
        this.animatedCounts[k] = Math.round(apiNotRespondingValue);
      }
    }, stepTime);

  }

  ngOnDestroy() {