Skip to content

Commit

Permalink
move and rename typings
Browse files Browse the repository at this point in the history
  • Loading branch information
MGJamJam committed May 14, 2024
1 parent 8585af6 commit 000ad9a
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 38 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { ChangeEvent, useEffect } from 'react';
import { DataSourceHttpSettings, FieldSet, InlineField, InlineSwitch, Input } from '@grafana/ui';
import { DataSourcePluginOptionsEditorProps } from '@grafana/data';
import { BitmovinDataSourceOptions } from '../types';
import { BitmovinDataSourceOptions } from '../types/grafanaTypes';

interface Props extends DataSourcePluginOptionsEditorProps<BitmovinDataSourceOptions> {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { QueryEditorProps, SelectableValue } from '@grafana/data';
import { defaults } from 'lodash';

import { DataSource } from '../datasource';
import { BitmovinDataSourceOptions, BitmovinAnalyticsDataQuery, DEFAULT_QUERY } from '../types';
import { BitmovinDataSourceOptions, BitmovinAnalyticsDataQuery, DEFAULT_QUERY } from '../types/grafanaTypes';
import { fetchLicenses } from '../utils/licenses';
import { DEFAULT_SELECTABLE_QUERY_INTERVAL, SELECTABLE_QUERY_INTERVALS } from '../utils/intervalUtils';
import { SELECTABLE_AGGREGATIONS } from '../types/aggregations';
Expand Down
32 changes: 24 additions & 8 deletions bitmovin-analytics-datasource/src/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,37 @@ import {
Field,
} from '@grafana/data';
import { getBackendSrv } from '@grafana/runtime';
import { filter } from 'lodash';
import { catchError, lastValueFrom, map, Observable, of } from 'rxjs';

import { BitmovinDataSourceOptions, BitmovinAnalyticsDataQuery, DEFAULT_QUERY } from './types/grafanaTypes';
import {
MixedDataRowList,
BitmovinDataSourceOptions,
BitmovinAnalyticsDataQuery,
NumberDataRowList,
BitmovinAnalyticsRequestQuery,
DEFAULT_QUERY,
} from './types';
import { transformGroupedTimeSeriesData, transformSimpleTimeSeries, transformTableData } from './utils/dataUtils';
import { calculateQueryInterval } from './utils/intervalUtils';
transformGroupedTimeSeriesData,
transformSimpleTimeSeries,
transformTableData,
} from './utils/dataUtils';
import { calculateQueryInterval, QueryInterval } from './utils/intervalUtils';
import { Metric } from './types/metric';
import { Aggregation } from './types/aggregations';
import { filter } from 'lodash';
import { QueryFilter } from './types/queryFilter';
import { QueryAttribute } from './types/queryAttributes';
import { QueryAdAttribute } from './types/queryAdAttributes';
import { QueryOrderBy } from './types/queryOrderBy';

type BitmovinAnalyticsRequestQuery = {
licenseKey: string;
start: Date;
end: Date;
filters: QueryFilter[];
groupBy: QueryAttribute[] | QueryAdAttribute[];
orderBy: QueryOrderBy[];
dimension?: QueryAttribute | QueryAdAttribute;
metric?: Metric;
interval?: QueryInterval;
limit?: number;
};

export class DataSource extends DataSourceApi<BitmovinAnalyticsDataQuery, BitmovinDataSourceOptions> {
baseUrl: string;
Expand Down
2 changes: 1 addition & 1 deletion bitmovin-analytics-datasource/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { DataSourcePlugin } from '@grafana/data';
import { DataSource } from './datasource';
import { ConfigEditor } from './components/ConfigEditor';
import { QueryEditor } from './components/QueryEditor';
import { BitmovinAnalyticsDataQuery, BitmovinDataSourceOptions } from './types';
import { BitmovinAnalyticsDataQuery, BitmovinDataSourceOptions } from './types/grafanaTypes';

export const plugin = new DataSourcePlugin<DataSource, BitmovinAnalyticsDataQuery, BitmovinDataSourceOptions>(
DataSource
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { DataSourceJsonData } from '@grafana/data';
import { DataQuery } from '@grafana/schema';
import { QueryInterval } from './utils/intervalUtils';
import { Aggregation } from './types/aggregations';
import { QueryAttribute } from './types/queryAttributes';
import { QueryAdAttribute } from './types/queryAdAttributes';
import { Metric } from './types/metric';
import { QueryOrderBy } from './types/queryOrderBy';
import { QueryFilter } from './types/queryFilter';
import { QueryInterval } from '../utils/intervalUtils';
import { Aggregation } from './aggregations';
import { QueryAttribute } from './queryAttributes';
import { QueryAdAttribute } from './queryAdAttributes';
import { Metric } from './metric';
import { QueryOrderBy } from './queryOrderBy';
import { QueryFilter } from './queryFilter';

/**
* These are the options configurable via the QueryEditor
Expand Down Expand Up @@ -40,22 +40,3 @@ export interface BitmovinDataSourceOptions extends DataSourceJsonData {
tenantOrgId?: string;
adAnalytics?: boolean;
}

export type BitmovinAnalyticsRequestQuery = {
licenseKey: string;
start: Date;
end: Date;
filters: QueryFilter[];
groupBy: QueryAttribute[] | QueryAdAttribute[];
orderBy: QueryOrderBy[];
dimension?: QueryAttribute | QueryAdAttribute;
metric?: Metric;
interval?: QueryInterval;
limit?: number;
};

export type MixedDataRow = Array<string | number>;
export type MixedDataRowList = MixedDataRow[];

export type NumberDataRow = number[];
export type NumberDataRowList = NumberDataRow[];
7 changes: 6 additions & 1 deletion bitmovin-analytics-datasource/src/utils/dataUtils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { differenceWith, sortBy, zip } from 'lodash';
import { ceilTimestampAccordingToQueryInterval, intervalToMilliseconds, QueryInterval } from './intervalUtils';
import { Field, FieldType } from '@grafana/data';
import { MixedDataRow, MixedDataRowList, NumberDataRow, NumberDataRowList } from '../types';

export type MixedDataRow = Array<string | number>;
export type MixedDataRowList = MixedDataRow[];

export type NumberDataRow = number[];
export type NumberDataRowList = NumberDataRow[];

/**
* Adds padding to a given time series to fill in any missing timestamps for a given interval.
Expand Down

0 comments on commit 000ad9a

Please sign in to comment.