From 078153e69fcf887b7e91acf3fabdeb78a898c01e Mon Sep 17 00:00:00 2001 From: Myriam Gantner <48029745+MGJamJam@users.noreply.github.com> Date: Thu, 25 Jul 2024 12:53:38 +0200 Subject: [PATCH] Format code (#94) * add format script and prettierignore * format --- .github/workflows/ci.yml | 2 ++ .prettierignore | 5 ++++ README.md | 30 +++++++++++----------- example_dashboard.json | 40 ++++++++--------------------- package.json | 2 ++ src/README.md | 28 ++++++++++---------- src/components/FilterRow.tsx | 2 +- src/components/GroupByRow.tsx | 2 +- src/components/OrderByRow.tsx | 2 +- src/components/QueryFilterInput.tsx | 3 +++ src/plugin.json | 10 ++++++-- 11 files changed, 62 insertions(+), 64 deletions(-) create mode 100644 .prettierignore diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1ec3bf3..7e9cf53 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,6 +25,8 @@ jobs: - name: Check types run: yarn run typecheck + - name: Check formatting + run: yarn run format:check - name: Lint run: yarn run lint - name: Unit tests diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..dc24fe6 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,5 @@ +# Ignore artifacts +dist + +# Ignore files created by `@grafana/create-plugin` +.config diff --git a/README.md b/README.md index 618aaaf..66af0a6 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Add the plugin and acquire your Bitmovin Analytics API key from the [bitmovin da Configure the datasource: | Setting | Value | -|--------------|----------------------------------------------------------| +| ------------ | -------------------------------------------------------- | | URL | `https://api.bitmovin.com/v1` | | API Key | Your API key | | Ad Analytics | If checked, the datasource is switched to query ads data | @@ -27,18 +27,18 @@ See the [example_dashboard.json](example_dashboard.json) for a demo. Configure t Add a new panel and select the bitmovin analytics datasource. Configure the metric with following settings: -| Setting | Description | -|------------------------|------------------------------------------------------------------------------------------| -| License* | Your analytics license | -| Metric* | Aggregation method to use, e.g. `count`, `sum` | -| Dimension* | Dimension to aggregate over | -| Filter | Apply filters to the query | -| Format as time series* | Check the switch to see time series data | -| Group By | Group query by dimension and plot as individual time series | -| Order By | Order query ascending or descending by dimension | -| Limit | Limit the result to given number | -| Interval* | Time granularity of queries, select `AUTO` to automatically adapt to selected time range | -| Alias By | Set the name of series (only visible with multiple queries in one Graph) | +| Setting | Description | +| ----------------------- | ---------------------------------------------------------------------------------------- | +| License\* | Your analytics license | +| Metric\* | Aggregation method to use, e.g. `count`, `sum` | +| Dimension\* | Dimension to aggregate over | +| Filter | Apply filters to the query | +| Format as time series\* | Check the switch to see time series data | +| Group By | Group query by dimension and plot as individual time series | +| Order By | Order query ascending or descending by dimension | +| Limit | Limit the result to given number | +| Interval\* | Time granularity of queries, select `AUTO` to automatically adapt to selected time range | +| Alias By | Set the name of series (only visible with multiple queries in one Graph) | Settings marked with `*` are required for the time series graph. @@ -52,7 +52,7 @@ Configure the metric as described in [Time Series Graph](#time-series-graph) but ## Gauges -Configure the Gauge's `Value Options`, depending on your query. +Configure the Gauge's `Value Options`, depending on your query. - For table data (`Format as time series` option **unchecked**) for the `Show` option select `All Values`. - For time series data (`Format as time series` option **checked**) for the `Show` option select `Calculate` and choose a reducer function. @@ -61,7 +61,7 @@ Configure the Gauge's `Value Options`, depending on your query. Please refer to our [Documentation](https://developer.bitmovin.com/playback/docs/integrating-bitmovin-analytics-with-grafana) and [Analytics Api Reference](https://developer.bitmovin.com/playback/reference/overview) for more information or reach out to us at [bitmovin.com](https://bitmovin.com/contact-bitmovin/). ------ +--- ## Development diff --git a/example_dashboard.json b/example_dashboard.json index e06ddec..fc14ed2 100644 --- a/example_dashboard.json +++ b/example_dashboard.json @@ -621,9 +621,7 @@ "value": "0" } ], - "groupBy": [ - "BROWSER" - ], + "groupBy": ["BROWSER"], "interval": "AUTO", "license": "", "metric": "count", @@ -723,9 +721,7 @@ "value": "0" } ], - "groupBy": [ - "COUNTRY" - ], + "groupBy": ["COUNTRY"], "interval": "AUTO", "license": "", "metric": "count", @@ -781,9 +777,7 @@ "footer": { "countRows": false, "fields": "", - "reducer": [ - "sum" - ], + "reducer": ["sum"], "show": false }, "showHeader": true @@ -800,9 +794,7 @@ "value": "0" } ], - "groupBy": [ - "PLAYER_TECH" - ], + "groupBy": ["PLAYER_TECH"], "interval": "AUTO", "license": "", "metric": "count", @@ -863,9 +855,7 @@ "footer": { "countRows": false, "fields": "", - "reducer": [ - "sum" - ], + "reducer": ["sum"], "show": false }, "showHeader": true @@ -882,9 +872,7 @@ "value": "0" } ], - "groupBy": [ - "OPERATINGSYSTEM" - ], + "groupBy": ["OPERATINGSYSTEM"], "interval": "AUTO", "license": "", "limit": 10, @@ -946,9 +934,7 @@ "footer": { "countRows": false, "fields": "", - "reducer": [ - "sum" - ], + "reducer": ["sum"], "show": false }, "showHeader": true @@ -959,9 +945,7 @@ "datasource": {}, "dimension": "IMPRESSION_ID", "filter": [], - "groupBy": [ - "BROWSER" - ], + "groupBy": ["BROWSER"], "interval": "AUTO", "license": "", "limit": 10, @@ -1023,9 +1007,7 @@ "footer": { "countRows": false, "fields": "", - "reducer": [ - "sum" - ], + "reducer": ["sum"], "show": false }, "showHeader": true @@ -1036,9 +1018,7 @@ "datasource": {}, "dimension": "IMPRESSION_ID", "filter": [], - "groupBy": [ - "COUNTRY" - ], + "groupBy": ["COUNTRY"], "interval": "AUTO", "license": "", "limit": 10, diff --git a/package.json b/package.json index b7b66f8..0046b51 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,8 @@ "typecheck": "tsc --noEmit", "lint": "eslint --cache --ignore-pattern 'dist/**' --ignore-path ./.gitignore --ext .js,.jsx,.ts,.tsx .", "lint:fix": "yarn run lint --fix", + "format": "yarn prettier . --write", + "format:check": "yarn prettier --check .", "e2e": "yarn exec cypress install && yarn exec grafana-e2e run", "e2e:update": "yarn exec cypress install && yarn exec grafana-e2e run --update-screenshots", "server": "docker-compose up --build", diff --git a/src/README.md b/src/README.md index 7cbe264..55009f2 100644 --- a/src/README.md +++ b/src/README.md @@ -11,7 +11,7 @@ Add the plugin and acquire your Bitmovin Analytics API key from the [bitmovin da Configure the datasource: | Setting | Value | -|--------------|----------------------------------------------------------| +| ------------ | -------------------------------------------------------- | | URL | `https://api.bitmovin.com/v1` | | API Key | Your API key | | Ad Analytics | If checked, the datasource is switched to query ads data | @@ -27,18 +27,18 @@ See the [example_dashboard.json](example_dashboard.json) for a demo. Configure t Add a new panel and select the bitmovin analytics datasource. Configure the metric with following settings: -| Setting | Description | -|------------------------|------------------------------------------------------------------------------------------| -| License* | Your analytics license | -| Metric* | Aggregation method to use, e.g. `count`, `sum` | -| Dimension* | Dimension to aggregate over | -| Filter | Apply filters to the query | -| Format as time series* | Check the switch to see time series data | -| Group By | Group query by dimension and plot as individual time series | -| Order By | Order query ascending or descending by dimension | -| Limit | Limit the result to given number | -| Interval* | Time granularity of queries, select `AUTO` to automatically adapt to selected time range | -| Alias By | Set the name of series (only visible with multiple queries in one Graph) | +| Setting | Description | +| ----------------------- | ---------------------------------------------------------------------------------------- | +| License\* | Your analytics license | +| Metric\* | Aggregation method to use, e.g. `count`, `sum` | +| Dimension\* | Dimension to aggregate over | +| Filter | Apply filters to the query | +| Format as time series\* | Check the switch to see time series data | +| Group By | Group query by dimension and plot as individual time series | +| Order By | Order query ascending or descending by dimension | +| Limit | Limit the result to given number | +| Interval\* | Time granularity of queries, select `AUTO` to automatically adapt to selected time range | +| Alias By | Set the name of series (only visible with multiple queries in one Graph) | Settings marked with `*` are required for the time series graph. @@ -52,7 +52,7 @@ Configure the metric as described in [Time Series Graph](#time-series-graph) but ## Gauges -Configure the Gauge's `Value Options`, depending on your query. +Configure the Gauge's `Value Options`, depending on your query. - For table data (`Format as time series` option **unchecked**) for the `Show` option select `All Values`. - For time series data (`Format as time series` option **checked**) for the `Show` option select `Calculate` and choose a reducer function. diff --git a/src/components/FilterRow.tsx b/src/components/FilterRow.tsx index 1a085e6..f7ec5b2 100644 --- a/src/components/FilterRow.tsx +++ b/src/components/FilterRow.tsx @@ -17,7 +17,7 @@ type Props = { export function FilterRow(props: Props) { const [hasNewQueryFilter, setHasNewQueryFilter] = useState(false); - const paddingTop= props.filters.length === 0 ? 4 : 0 + const paddingTop = props.filters.length === 0 ? 4 : 0; function handleQueryFilterDelete(queryFilterIndex: number) { const newQueryFilters = [...props.filters]; diff --git a/src/components/GroupByRow.tsx b/src/components/GroupByRow.tsx index f0516c8..f6f5da9 100644 --- a/src/components/GroupByRow.tsx +++ b/src/components/GroupByRow.tsx @@ -44,7 +44,7 @@ type Props = { }; export function GroupByRow(props: Props) { - const paddingTop= props.groupBys.length === 0 ? 4 : 0 + const paddingTop = props.groupBys.length === 0 ? 4 : 0; const deleteGroupByInput = (index: number) => { const newSelectedGroupBys = [...props.groupBys]; newSelectedGroupBys.splice(index, 1); diff --git a/src/components/OrderByRow.tsx b/src/components/OrderByRow.tsx index cad605e..6e67169 100644 --- a/src/components/OrderByRow.tsx +++ b/src/components/OrderByRow.tsx @@ -46,7 +46,7 @@ type Props = { }; export function OrderByRow(props: Props) { - const paddingTop= props.orderBys.length === 0 ? 4 : 0 + const paddingTop = props.orderBys.length === 0 ? 4 : 0; const deleteOrderByInput = (index: number) => { const newOrderBys = [...props.orderBys]; newOrderBys.splice(index, 1); diff --git a/src/components/QueryFilterInput.tsx b/src/components/QueryFilterInput.tsx index 187dccc..d48f60c 100644 --- a/src/components/QueryFilterInput.tsx +++ b/src/components/QueryFilterInput.tsx @@ -10,8 +10,11 @@ import { convertFilterValueToProperType } from 'utils/filterUtils'; interface QueryFilterInputProps { /** `undefined` when component is used to create new filter (no values yet) */ value: undefined | QueryFilter; + onChange(queryFilter: QueryFilter): void; + onDelete(): void; + isAdAnalytics: boolean; /** Selected query filters are used to filter out used values from attribute select options */ selectedQueryFilters: QueryFilter[]; diff --git a/src/plugin.json b/src/plugin.json index a7be010..cba2910 100644 --- a/src/plugin.json +++ b/src/plugin.json @@ -16,8 +16,14 @@ "large": "img/logo.svg" }, "links": [ - {"name": "Project site", "url": "https://github.com/bitmovin/analytics-grafana-datasource"}, - {"name": "Apache License", "url": "https://github.com/bitmovin/analytics-grafana-datasource/blob/main/LICENSE"} + { + "name": "Project site", + "url": "https://github.com/bitmovin/analytics-grafana-datasource" + }, + { + "name": "Apache License", + "url": "https://github.com/bitmovin/analytics-grafana-datasource/blob/main/LICENSE" + } ], "screenshots": [], "version": "%VERSION%",