mirror of https://github.com/ghostfolio/ghostfolio
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.4 KiB
50 lines
1.4 KiB
import { DataService } from '@ghostfolio/client/services/data.service';
|
|
|
|
import { CommonModule } from '@angular/common';
|
|
import {
|
|
ChangeDetectionStrategy,
|
|
Component,
|
|
Input,
|
|
OnDestroy,
|
|
OnInit
|
|
} from '@angular/core';
|
|
import type { DataSource } from '@prisma/client';
|
|
import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader';
|
|
import { catchError, map, type Observable, of, Subject, takeUntil } from 'rxjs';
|
|
|
|
import { DataProviderStatus } from './interfaces/interfaces';
|
|
|
|
@Component({
|
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
imports: [CommonModule, NgxSkeletonLoaderModule],
|
|
selector: 'gf-data-provider-status',
|
|
templateUrl: './data-provider-status.component.html'
|
|
})
|
|
export class GfDataProviderStatusComponent implements OnDestroy, OnInit {
|
|
@Input() dataSource: DataSource;
|
|
|
|
public status$: Observable<DataProviderStatus>;
|
|
|
|
private unsubscribeSubject = new Subject<void>();
|
|
|
|
public constructor(private dataService: DataService) {}
|
|
|
|
public ngOnInit() {
|
|
this.status$ = this.dataService
|
|
.fetchDataProviderHealth(this.dataSource)
|
|
.pipe(
|
|
map(() => {
|
|
return { isHealthy: true };
|
|
}),
|
|
catchError(() => {
|
|
return of({ isHealthy: false });
|
|
}),
|
|
takeUntil(this.unsubscribeSubject)
|
|
);
|
|
}
|
|
|
|
public ngOnDestroy() {
|
|
this.unsubscribeSubject.next();
|
|
this.unsubscribeSubject.complete();
|
|
}
|
|
}
|
|
|