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