How to use the @grafana/data.LoadingState.Loading function in @grafana/data

To help you get started, we’ve selected a few @grafana/data examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github grafana / grafana / public / app / features / explore / state / reducers.ts View on Github external
// Send legacy data to Angular editors
  if (state.datasourceInstance.components.QueryCtrl) {
    const legacy = series.map(v => toLegacyResponseData(v));

    state.eventBridge.emit(PanelEvents.dataReceived, legacy);
  }

  return {
    ...state,
    latency,
    queryResponse: response,
    graphResult,
    tableResult,
    logsResult,
    loading: loadingState === LoadingState.Loading || loadingState === LoadingState.Streaming,
    update: makeInitialUpdateState(),
  };
};
github GridProtectionAlliance / openHistorian / Source / Applications / openHistorian / openHistorian / Grafana / public / app / features / explore / state / reducers.ts View on Github external
// Send legacy data to Angular editors
  if (state.datasourceInstance.components.QueryCtrl) {
    const legacy = series.map(v => toLegacyResponseData(v));

    state.eventBridge.emit(PanelEvents.dataReceived, legacy);
  }

  return {
    ...state,
    latency,
    queryResponse: response,
    graphResult,
    tableResult,
    logsResult,
    loading: loadingState === LoadingState.Loading || loadingState === LoadingState.Streaming,
    update: makeInitialUpdateState(),
  };
};
github GridProtectionAlliance / openHistorian / Source / Applications / openHistorian / openHistorian / Grafana / public / app / features / dashboard / state / runRequest.ts View on Github external
export function runRequest(datasource: DataSourceApi, request: DataQueryRequest): Observable {
  let state: RunningQueryState = {
    panelData: {
      state: LoadingState.Loading,
      series: [],
      request: request,
      timeRange: request.range,
    },
    packets: {},
  };

  // Return early if there are no queries to run
  if (!request.targets.length) {
    request.endTime = Date.now();
    state.panelData.state = LoadingState.Done;
    return of(state.panelData);
  }

  const dataObservable = callQueryMethod(datasource, request).pipe(
    // Transform response packets into PanelData with merged results
github GridProtectionAlliance / openHistorian / Source / Applications / openHistorian / openHistorian / Grafana / public / app / features / panel / metrics_panel_ctrl.ts View on Github external
next: (data: PanelData) => {
      if (data.state === LoadingState.Error) {
        this.loading = false;
        this.processDataError(data.error);
      }

      // Ignore data in loading state
      if (data.state === LoadingState.Loading) {
        this.loading = true;
        this.angularDirtyCheck();
        return;
      }

      if (data.request) {
        const { timeInfo } = data.request;
        if (timeInfo) {
          this.timeInfo = timeInfo;
        }
      }

      if (data.timeRange) {
        this.range = data.timeRange;
      }
github grafana / grafana / public / app / features / dashboard / state / runRequest.ts View on Github external
export function runRequest(datasource: DataSourceApi, request: DataQueryRequest): Observable {
  let state: RunningQueryState = {
    panelData: {
      state: LoadingState.Loading,
      series: [],
      request: request,
      timeRange: request.range,
    },
    packets: {},
  };

  // Return early if there are no queries to run
  if (!request.targets.length) {
    request.endTime = Date.now();
    state.panelData.state = LoadingState.Done;
    return of(state.panelData);
  }

  const dataObservable = callQueryMethod(datasource, request).pipe(
    // Transform response packets into PanelData with merged results
github grafana / grafana / public / app / features / explore / GraphContainer.tsx View on Github external
function mapStateToProps(state: StoreState, { exploreId }: { exploreId: string }) {
  const explore = state.explore;
  const { split } = explore;
  // @ts-ignore
  const item: ExploreItemState = explore[exploreId];
  const { graphResult, loadingState, showingGraph, showingTable, absoluteRange } = item;
  const loading = loadingState === LoadingState.Loading || loadingState === LoadingState.Streaming;
  return {
    graphResult,
    loading,
    showingGraph,
    showingTable,
    split,
    timeZone: getTimeZone(state.user),
    absoluteRange,
  };
}
github GridProtectionAlliance / openHistorian / Source / Applications / openHistorian / openHistorian / Grafana / public / app / features / dashboard / state / runRequest.ts View on Github external
export function preProcessPanelData(data: PanelData, lastResult: PanelData): PanelData {
  const { series } = data;

  //  for loading states with no data, use last result
  if (data.state === LoadingState.Loading && series.length === 0) {
    if (!lastResult) {
      lastResult = data;
    }

    return { ...lastResult, state: LoadingState.Loading };
  }

  // Make sure the data frames are properly formatted
  return {
    ...data,
    series: getProcessedDataFrames(series),
  };
}
github GridProtectionAlliance / openHistorian / Source / Applications / openHistorian / openHistorian / Grafana / public / app / plugins / datasource / prometheus / datasource.ts View on Github external
map((response: any) => {
          const data = this.processResult(response, query, target, queries.length);
          return {
            data,
            key: query.requestId,
            state: runningQueriesCount === 0 ? LoadingState.Done : LoadingState.Loading,
          } as DataQueryResponse;
        })
      );
github grafana / grafana / public / app / plugins / datasource / mixed / MixedDataSource.ts View on Github external
(response: DataQueryResponse) => {
                if (
                  hasCountedAsDone ||
                  response.state === LoadingState.Streaming ||
                  response.state === LoadingState.Loading
                ) {
                  return;
                }
                runningSubRequests--;
                hasCountedAsDone = true;
              },
              () => {