pokus o opravu loadingu
This commit is contained in:
@@ -64,13 +64,23 @@ export class ServiceStatusState {
|
||||
|
||||
@Action(CheckAllServicesStatus)
|
||||
checkServicesStatus(ctx: StateContext<ServiceStatusModel>) {
|
||||
ctx.patchState({ loading: true });
|
||||
const config = ctx.getState().config;
|
||||
|
||||
if (!config || !Array.isArray(config)) {
|
||||
ctx.patchState({ services: [], loading: false });
|
||||
return;
|
||||
}
|
||||
|
||||
const currentServices = ctx.getState().services;
|
||||
const initialServices = config.map((service: Service) => {
|
||||
const existing = currentServices.find(s => s.name === service.name);
|
||||
return existing
|
||||
? { ...existing, status: 'loading' }
|
||||
: { ...service, status: 'loading' };
|
||||
});
|
||||
|
||||
ctx.patchState({ services: initialServices, loading: true });
|
||||
|
||||
const statusObservables = config.map((service: Service) =>
|
||||
this.checkServiceStatus.checkStatus(service.name, service.url, service.headers).pipe(
|
||||
map((status: Status) => ({ ...service, status, lastChecked: Date.now() }))
|
||||
|
||||
Reference in New Issue
Block a user