mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
Adds the ability for users to control whether a layer should refresh on auto-update or when the refresh-button is clicked. This is required to display static layers from geo-data indexed in Elasticsearch. Co-authored-by: Thomas Neirynck <thomas@elastic.co>
60 lines
1.4 KiB
TypeScript
60 lines
1.4 KiB
TypeScript
/*
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
* 2.0.
|
|
*/
|
|
|
|
/* eslint-disable max-classes-per-file */
|
|
|
|
import { DataRequestDescriptor, DataRequestMeta } from '../../../common/descriptor_types';
|
|
|
|
export class DataRequest {
|
|
private readonly _descriptor: DataRequestDescriptor;
|
|
|
|
constructor(descriptor: DataRequestDescriptor) {
|
|
this._descriptor = {
|
|
...descriptor,
|
|
};
|
|
}
|
|
|
|
getData(): object | undefined {
|
|
return this._descriptor.data;
|
|
}
|
|
|
|
isLoading(): boolean {
|
|
return !!this._descriptor.dataRequestToken;
|
|
}
|
|
|
|
getMeta(): DataRequestMeta {
|
|
if (this._descriptor.dataRequestMetaAtStart) {
|
|
return this._descriptor.dataRequestMetaAtStart;
|
|
} else if (this._descriptor.dataRequestMeta) {
|
|
return this._descriptor.dataRequestMeta;
|
|
} else {
|
|
return {};
|
|
}
|
|
}
|
|
|
|
hasData(): boolean {
|
|
return !!this._descriptor.data;
|
|
}
|
|
|
|
hasDataOrRequestInProgress(): boolean {
|
|
return this.hasData() || this.isLoading();
|
|
}
|
|
|
|
getDataId(): string {
|
|
return this._descriptor.dataId;
|
|
}
|
|
|
|
getRequestToken(): symbol | undefined {
|
|
return this._descriptor.dataRequestToken;
|
|
}
|
|
}
|
|
|
|
export class DataRequestAbortError extends Error {
|
|
constructor() {
|
|
super();
|
|
}
|
|
}
|