29 lines
903 B
TypeScript
29 lines
903 B
TypeScript
|
|
import { Injectable, inject, signal } from '@angular/core';
|
||
|
|
import { take } from 'rxjs/operators';
|
||
|
|
import { Connector } from '../../../../core/integrations/models/connector.model';
|
||
|
|
import { CONNECTOR_GATEWAY } from '../../../../core/integrations/services/connector-gateway.token';
|
||
|
|
|
||
|
|
@Injectable({ providedIn: 'root' })
|
||
|
|
export class AdminIntegrationsFacade {
|
||
|
|
private readonly gateway = inject(CONNECTOR_GATEWAY);
|
||
|
|
|
||
|
|
readonly connectors = signal<Connector[]>([]);
|
||
|
|
readonly loading = signal(false);
|
||
|
|
|
||
|
|
load(): void {
|
||
|
|
this.loading.set(true);
|
||
|
|
this.gateway.loadConnectors().pipe(take(1)).subscribe(items => {
|
||
|
|
this.connectors.set(items);
|
||
|
|
this.loading.set(false);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
pause(id: string): void {
|
||
|
|
this.gateway.pause(id).pipe(take(1)).subscribe(() => this.load());
|
||
|
|
}
|
||
|
|
|
||
|
|
resume(id: string): void {
|
||
|
|
this.gateway.resume(id).pipe(take(1)).subscribe(() => this.load());
|
||
|
|
}
|
||
|
|
}
|