How to use the @grafana/data.LoadingState.Error 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 / dashboard / state / analyticsProcessor.ts View on Github external
return (data: PanelData) => {
    if (!data.request || done) {
      return;
    }

    if (data.state !== LoadingState.Done && data.state !== LoadingState.Error) {
      return;
    }

    const eventData: MetaAnalyticsEventPayload = {
      datasourceName: datasource.name,
      datasourceId: datasource.id,
      panelId: data.request.panelId,
      dashboardId: data.request.dashboardId,
      // app: 'dashboard',
      dataSize: 0,
      duration: data.request.endTime - data.request.startTime,
      eventName: 'data-request',
      // sessionId: '',
    };

    // enrich with dashboard info
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;
        }
github GridProtectionAlliance / openHistorian / Source / Applications / openHistorian / openHistorian / Grafana / public / app / features / explore / QueryStatus.tsx View on Github external
render() {
    const { queryResponse, latency } = this.props;
    const className =
      queryResponse.state === LoadingState.Done || LoadingState.Error
        ? 'query-transaction'
        : 'query-transaction query-transaction--loading';
    return (
      <div>
        {/* <div>{transaction.resultType}:</div> */}
        <div>
          {queryResponse.state === LoadingState.Done || LoadingState.Error ? formatLatency(latency) : }
        </div>
      </div>
    );
  }
}
github grafana / grafana / public / app / features / dashboard / state / PanelQueryState.ts View on Github external
setError(err: any): PanelData {
    if (!this.request.endTime) {
      this.request.endTime = Date.now();
    }
    this.closeStreams(true);
    this.response = {
      ...this.response, // Keep any existing data
      state: LoadingState.Error,
      error: toDataQueryError(err),
    };
    return this.validateStreamsAndGetPanelData();
  }
}
github grafana / grafana / public / app / features / dashboard / panel_editor / QueryEditorRow.tsx View on Github external
const series = data.series.filter(series => series.refId === refId);

  // No matching series
  if (!series.length) {
    return undefined;
  }

  // Don't pass the request if all requests are the same
  const request: DataQueryRequest = undefined;
  // TODO: look in sub-requets to match the info

  // Only say this is an error if the error links to the query
  let state = LoadingState.Done;
  const error = data.error && data.error.refId === refId ? data.error : undefined;
  if (error) {
    state = LoadingState.Error;
  }

  const timeRange = data.timeRange;

  return {
    state,
    series,
    request,
    error,
    timeRange,
  };
}
github grafana / grafana / public / app / features / dashboard / state / runRequest.ts View on Github external
lodashMap(packets, (packet: DataQueryResponse) => {
      if (packet.error) {
        loadingState = LoadingState.Error;
        error = packet.error;
      }
      return packet.data;
    })
  );
github GridProtectionAlliance / openHistorian / Source / Applications / openHistorian / openHistorian / Grafana / public / app / features / dashboard / state / runRequest.ts View on Github external
lodashMap(packets, (packet: DataQueryResponse) => {
      if (packet.error) {
        loadingState = LoadingState.Error;
        error = packet.error;
      }
      return packet.data;
    })
  );
github grafana / grafana / public / app / plugins / datasource / dashboard / runSharedRequest.ts View on Github external
function getQueryError(msg: string): PanelData {
  return {
    state: LoadingState.Error,
    series: [],
    error: { message: msg },
    timeRange: DefaultTimeRange,
  };
}