2022-05-02 17:28:58 +09:00
|
|
|
import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core';
|
|
|
|
import { Observable } from 'rxjs';
|
|
|
|
import { map } from 'rxjs/operators';
|
|
|
|
import { StateService } from 'src/app/services/state.service';
|
|
|
|
import { WebsocketService } from 'src/app/services/websocket.service';
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-loading-indicator',
|
|
|
|
templateUrl: './loading-indicator.component.html',
|
|
|
|
styleUrls: ['./loading-indicator.component.scss'],
|
|
|
|
changeDetection: ChangeDetectionStrategy.OnPush
|
|
|
|
})
|
|
|
|
export class LoadingIndicatorComponent implements OnInit {
|
|
|
|
@Input() name: string;
|
2022-05-10 14:52:37 +02:00
|
|
|
@Input() label: string;
|
2022-05-02 17:28:58 +09:00
|
|
|
|
|
|
|
public indexingProgress$: Observable<number>;
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
private stateService: StateService,
|
|
|
|
private websocketService: WebsocketService
|
|
|
|
) {}
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
this.indexingProgress$ = this.stateService.loadingIndicators$
|
|
|
|
.pipe(
|
|
|
|
map((indicators) => indicators[this.name] ?? -1)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|