Skip to content

Commit

Permalink
Docs: Replace all absolute production links (#1065)
Browse files Browse the repository at this point in the history
Co-authored-by: David Harris <[email protected]>
  • Loading branch information
jackw and sympatheticmoose authored Aug 20, 2024
1 parent 611ecd1 commit c5daba6
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 118 deletions.
2 changes: 1 addition & 1 deletion docusaurus/docs/e2e-test-a-plugin/get-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ If you scaffolded a plugin with a version of create-plugin prior to 4.6.0, follo

You need to have the following:

- Grafana [plugin development environment](https://grafana.com/developers/plugin-tools/get-started/set-up-development-environment).
- Grafana [plugin development environment](/get-started/set-up-development-environment).
- Node.js version 18 or later.
- Basic knowledge of Playwright. If you have not worked with Playwright before, we recommend following the [Getting started](https://playwright.dev/docs/intro) section in their documentation.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ keywords:

This guide shows you how to convert an existing frontend-only data source plugin into a [backend plugin](../../key-concepts/backend-plugins).

To convert the frontend data source, we recommend scaffolding a new backend data source plugin using [`npx @grafana/create-plugin@latest`](https://grafana.com/developers/plugin-tools/). Use the following instructions to extend this foundation to copy functionality from your original plugin.
To convert the frontend data source, we recommend scaffolding a new backend data source plugin using `npx @grafana/create-plugin@latest`. Use the following instructions to extend this foundation to copy functionality from your original plugin.

## Why

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ const response = getBackendSrv().fetch<TODO[]>({

## Add authentication to your requests using the data proxy

To learn about adding authentication to the data proxy, refer to our [documentation](https://grafana.com/developers/plugin-tools/how-to-guides/data-source-plugins/add-annotations-for-data-source-plugins) (./add-annotations-for-data-source-plugins).
To learn about adding authentication to the data proxy, refer to our [documentation](./add-authentication-for-data-source-plugins).

## Debug requests from the data proxy

Expand Down
Original file line number Diff line number Diff line change
@@ -1,109 +1,109 @@
---
id: angular-react-convert-from-time_series2
title: Migrate from time_series2 package
sidebar_position: 6
description: How to migrate a plugin that uses the app/core/time_series2 package to current methods.
keywords:
- grafana
- plugins
- plugin
- React
- ReactJS
- Angular
- migration
- time_series2
---

# Angular to React: Convert from app/core/time_series2

The `app/core/time_series2` package is commonly used by AngularJS plugins to retrieve data to be rendered by a panel. This package is no longer available, and all plugins need to use dataframes instead.

This guide provides one method of converting from the old library to the new dataframe format.

## Convert data using the AngularJS method

Before the removal of the `app/core/time_series2` package in AngularJS, data was rendered by a panel using a method similar to this:

```ts
seriesHandler(seriesData: any) {
const series = new TimeSeries({
datapoints: seriesData.datapoints,
alias: seriesData.target,
});
series.flotpairs = series.getFlotPairs(this.panel.nullPointMode);
return series;
}
```

## Convert data using dataframes

The following code example shows one way of converting data from panels using dataframes:

```ts
import {
GrafanaTheme2,
FieldDisplay,
getDisplayProcessor,
getFieldDisplayValues,
FieldConfig,
DisplayValue,
formattedValueToString,
} from '@grafana/data';

const theme2 = useTheme2();

const getValues = (): FieldDisplay[] => {
for (const frame of data.series) {
for (const field of frame.fields) {
// Set the Min/Max value automatically for percent and percentunit
if (field.config.unit === 'percent' || field.config.unit === 'percentunit') {
const min = field.config.min ?? 0;
const max = field.config.max ?? (field.config.unit === 'percent' ? 100 : 1);
field.state = field.state ?? {};
field.state.range = { min, max, delta: max - min };
field.display = getDisplayProcessor({ field, theme: theme2 });
}
}
}
return getFieldDisplayValues({
fieldConfig,
reduceOptions: {
calcs: [options.operatorName],
values: false,
},
replaceVariables,
theme: theme2,
data: data.series,
timeZone,
});
};

const getThresholdForValue = (field: FieldConfig, value: number, theme: GrafanaTheme2) => {
if (fieldConfig.defaults.thresholds) {
const result = getActiveThreshold(value, field.thresholds?.steps);
return result;
}
return null;
};

const getFormattedValue = (index: number) => {
const singleMetric = metrics[index];
return formattedValueToString(singleMetric.display);
};

const getDisplayValue = (index: number) => {
const singleMetric = metrics[index];
if (!isNaN(singleMetric.display.numeric)) {
return singleMetric.display.numeric;
}
return NaN;
};

// get the formatted metrics
const metrics = getValues();
```

## Additional resources

- Read more [Angular to React conversion guides](https://grafana.com/developers/plugin-tools/migration-guides/angular-react/).
- Learn more about [data frames](../../key-concepts/data-frames).
---
id: angular-react-convert-from-time_series2
title: Migrate from time_series2 package
sidebar_position: 6
description: How to migrate a plugin that uses the app/core/time_series2 package to current methods.
keywords:
- grafana
- plugins
- plugin
- React
- ReactJS
- Angular
- migration
- time_series2
---

# Angular to React: Convert from app/core/time_series2

The `app/core/time_series2` package is commonly used by AngularJS plugins to retrieve data to be rendered by a panel. This package is no longer available, and all plugins need to use dataframes instead.

This guide provides one method of converting from the old library to the new dataframe format.

## Convert data using the AngularJS method

Before the removal of the `app/core/time_series2` package in AngularJS, data was rendered by a panel using a method similar to this:

```ts
seriesHandler(seriesData: any) {
const series = new TimeSeries({
datapoints: seriesData.datapoints,
alias: seriesData.target,
});
series.flotpairs = series.getFlotPairs(this.panel.nullPointMode);
return series;
}
```

## Convert data using dataframes

The following code example shows one way of converting data from panels using dataframes:

```ts
import {
GrafanaTheme2,
FieldDisplay,
getDisplayProcessor,
getFieldDisplayValues,
FieldConfig,
DisplayValue,
formattedValueToString,
} from '@grafana/data';

const theme2 = useTheme2();

const getValues = (): FieldDisplay[] => {
for (const frame of data.series) {
for (const field of frame.fields) {
// Set the Min/Max value automatically for percent and percentunit
if (field.config.unit === 'percent' || field.config.unit === 'percentunit') {
const min = field.config.min ?? 0;
const max = field.config.max ?? (field.config.unit === 'percent' ? 100 : 1);
field.state = field.state ?? {};
field.state.range = { min, max, delta: max - min };
field.display = getDisplayProcessor({ field, theme: theme2 });
}
}
}
return getFieldDisplayValues({
fieldConfig,
reduceOptions: {
calcs: [options.operatorName],
values: false,
},
replaceVariables,
theme: theme2,
data: data.series,
timeZone,
});
};

const getThresholdForValue = (field: FieldConfig, value: number, theme: GrafanaTheme2) => {
if (fieldConfig.defaults.thresholds) {
const result = getActiveThreshold(value, field.thresholds?.steps);
return result;
}
return null;
};

const getFormattedValue = (index: number) => {
const singleMetric = metrics[index];
return formattedValueToString(singleMetric.display);
};

const getDisplayValue = (index: number) => {
const singleMetric = metrics[index];
if (!isNaN(singleMetric.display.numeric)) {
return singleMetric.display.numeric;
}
return NaN;
};

// get the formatted metrics
const metrics = getValues();
```

## Additional resources

- Read more [Angular to React conversion guides](/migration-guides/angular-react/).
- Learn more about [data frames](../../key-concepts/data-frames).
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ import { cx, css } from '@emotion/css';

## Update needed for app plugins using dashboards

To make side navigation work properly - app plugins targeting Grafana `8.+` and integrating into the side menu via [addToNav](https://grafana.com/developers/plugin-tools/reference/metadata.md#properties-4#properties-4) property need to adjust their `plugin.json` and all dashboard json files to have a matching `uid`.
To make side navigation work properly - app plugins targeting Grafana `8.+` and integrating into the side menu via [addToNav](/reference/metadata.md#properties-6) property need to adjust their `plugin.json` and all dashboard json files to have a matching `uid`.

**`plugin.json`**

Expand Down
4 changes: 2 additions & 2 deletions docusaurus/docs/publish-a-plugin/provide-test-environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ sidebar_position: 5

# Provide a test environment

Developers often ask us how long it takes for a plugin to be reviewed for publishing to the Grafana [plugin catalog](https://grafana.com/plugins). Although we [can't provide estimates](https://grafana.com/developers/plugin-tools/publish-a-plugin/publish-a-plugin#how-long-does-it-take-to-review-a-submission), we are always looking for ways to reduce cycle times.
Developers often ask us how long it takes for a plugin to be reviewed for publishing to the Grafana [plugin catalog](https://grafana.com/plugins). Although we [can't provide estimates](/publish-a-plugin/publish-a-plugin#how-long-does-it-take-to-review-a-submission), we are always looking for ways to reduce cycle times.

By far the most time consuming aspect of a plugin's review is the creation of a suitable test environment so we can verify its behavior. This step often involves a number of back-and-forth conversations between the plugin developer and the review team.

To drastically improve the review time, developers can provide this themselves by [_provisioning_](https://grafana.com/docs/grafana/latest/administration/provisioning/#provision-grafana) their plugin. Provisioning refers to the process of preparing and configuring a test environment within the plugin's [Docker development environment](https://grafana.com/developers/plugin-tools/get-started/set-up-development-environment).
To drastically improve the review time, developers can provide this themselves by [_provisioning_](https://grafana.com/docs/grafana/latest/administration/provisioning/#provision-grafana) their plugin. Provisioning refers to the process of preparing and configuring a test environment within the plugin's [Docker development environment](/get-started/set-up-development-environment).

## Why should plugin developers care about this?

Expand Down
2 changes: 1 addition & 1 deletion docusaurus/docs/reference/cli-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Performs a type-checking process on the frontend code using TypeScript.

### `npm run server`

Launches the [Grafana development server](https://grafana.com/developers/plugin-tools/get-started/set-up-development-environment) using Docker.
Launches the [Grafana development server](/get-started/set-up-development-environment) using Docker.

### `npm run sign`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ npx @grafana/create-plugin@latest

:::note

For a complete list of prerequisites and suggestions for setting up your development environment, refer to [Get started](https://grafana.com/developers/plugin-tools/).
For a complete list of prerequisites and suggestions for setting up your development environment, refer to [Get started](/).

:::

Create Plugin will prompt you with some questions about your plugin name and type, your organization, and many other options.

2. For this tutorial, enter `data source` for the type of the plugin, and specify that it has a backend part.
1. For this tutorial, enter `data source` for the type of the plugin, and specify that it has a backend part.

The tool will create a skeleton with all the necessary code and dependencies to run a data source backend plugin. And, if you compile the code, you will have a very simple backend plugin. However, this generated code isn't a streaming plugin yet, and we need to make some modifications.

Expand Down

0 comments on commit c5daba6

Please sign in to comment.