Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Rename datasource file #344

Merged
merged 2 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ jobs:

- name: Start Grafana
run: |
docker-compose pull
GRAFANA_VERSION=${{ matrix.GRAFANA_IMAGE.VERSION }} GRAFANA_IMAGE=${{ matrix.GRAFANA_IMAGE.NAME }} docker-compose up -d
docker compose pull
GRAFANA_VERSION=${{ matrix.GRAFANA_IMAGE.VERSION }} GRAFANA_IMAGE=${{ matrix.GRAFANA_IMAGE.NAME }} docker compose up -d
- name: Wait for Grafana to start
uses: nev7n/wait_for_response@v1
Expand Down
3 changes: 2 additions & 1 deletion cspell.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"eslintcache",
"lefthook",
"ssjagad",
"jackspeak"
"jackspeak",
"nvmrc"
]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DataSource } from './DataSource';
import { DataSource } from './SitewiseDataSource';
import { DataSourceInstanceSettings, PluginMeta, ScopedVar, ScopedVars } from '@grafana/data';
import { QueryType, SitewiseOptions, SitewiseQuery } from './types';

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/components/MetaInspector.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { PureComponent } from 'react';
import { MetadataInspectorProps, DataFrame } from '@grafana/data';
import { DataSource } from '../DataSource';
import { DataSource } from '../SitewiseDataSource';
import { SitewiseQuery, SitewiseOptions, SitewiseCustomMeta } from '../types';
import { Tag } from '@grafana/ui';

Expand Down
2 changes: 1 addition & 1 deletion src/components/browser/AssetBrowser.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Component } from 'react';
import { Button, Icon, Modal, Spinner, Tab, TabContent, TabsBar } from '@grafana/ui';
import { AssetInfo } from '../../types';
import { DataSource } from 'DataSource';
import { DataSource } from 'SitewiseDataSource';
import { SitewiseCache } from 'sitewiseCache';
import { BrowseModels } from './BrowseModels';
import { BrowseHierarchy } from './BrowseHierarchy';
Expand Down
2 changes: 1 addition & 1 deletion src/components/query/QueryEditor.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { render, screen, waitFor } from '@testing-library/react';
import { DataQueryRequest, DataSourceInstanceSettings, QueryEditorProps } from '@grafana/data';
import { DataSource } from 'DataSource';
import { DataSource } from 'SitewiseDataSource';
import { QueryType, SitewiseOptions, SitewiseQuery } from 'types';
import { QueryEditor } from './QueryEditor';
import { of } from 'rxjs';
Expand Down
6 changes: 3 additions & 3 deletions src/components/query/QueryEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import defaults from 'lodash/defaults';
import React from 'react';
import { QueryEditorProps, SelectableValue } from '@grafana/data';
import { DataSource } from 'DataSource';
import { DataSource } from 'SitewiseDataSource';
import { SitewiseQuery, SitewiseOptions, QueryType, ListAssetsQuery, ListTimeSeriesQuery } from 'types';
import { Icon, LinkButton, Select } from '@grafana/ui';
import { QueryTypeInfo, siteWiseQueryTypes, changeQueryType } from 'queryInfo';
Expand Down Expand Up @@ -60,8 +60,8 @@ export function QueryEditor(props: Props) {
return null; // nothing required
case QueryType.ListAssets:
return <ListAssetsQueryEditor {...props} query={query as ListAssetsQuery} />;
case QueryType.ListTimeSeries:
return <ListTimeSeriesQueryEditorFunction {...props} query={query as ListTimeSeriesQuery} />
case QueryType.ListTimeSeries:
return <ListTimeSeriesQueryEditorFunction {...props} query={query as ListTimeSeriesQuery} />;
case QueryType.ListAssociatedAssets:
case QueryType.PropertyValue:
case QueryType.PropertyInterpolated:
Expand Down
2 changes: 1 addition & 1 deletion src/components/query/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DataSource } from 'DataSource';
import { DataSource } from 'SitewiseDataSource';
import { SitewiseQuery } from 'types';

export interface SitewiseQueryEditorProps<TQuery extends SitewiseQuery = SitewiseQuery> {
Expand Down
2 changes: 1 addition & 1 deletion src/module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DataSourcePlugin } from '@grafana/data';
import { DataSource } from './DataSource';
import { DataSource } from './SitewiseDataSource';
import { SitewiseQuery, SitewiseOptions } from './types';
import { MetaInspector } from 'components/MetaInspector';
import { ConfigEditor } from 'components/ConfigEditor';
Expand Down
7 changes: 2 additions & 5 deletions src/sitewiseCache.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DataFrameView, SelectableValue } from '@grafana/data';
import { DataSource } from 'DataSource';
import { DataSource } from 'SitewiseDataSource';
import { ListAssetsQuery, ListAssociatedAssetsQuery, QueryType } from 'types';
import { AssetModelSummary, AssetSummary, DescribeAssetResult } from './queryResponseTypes';
import { AssetInfo, AssetPropertyInfo } from './types';
Expand All @@ -15,10 +15,7 @@ export class SitewiseCache {
private topLevelAssets?: DataFrameView<AssetSummary>;
private assetPropertiesByAssetId = new Map<string, DataFrameView<{ id: string; name: string }>>();

constructor(
private ds: DataSource,
private region: string
) {}
constructor(private ds: DataSource, private region: string) {}

async getAssetInfo(id: string): Promise<AssetInfo | undefined> {
const v = this.assetsById.get(id);
Expand Down
26 changes: 13 additions & 13 deletions src/variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { assign } from 'lodash';
import { QueryType, SitewiseQuery } from './types';
import { DataSource } from './DataSource';
import { DataSource } from './SitewiseDataSource';
import { DataQueryRequest, DataQueryResponse, CustomVariableSupport, DataFrameView } from '@grafana/data';
import { QueryEditor } from './components/query/QueryEditor';
import { AssetModelSummary } from 'queryResponseTypes';
Expand All @@ -25,28 +25,28 @@ export class SitewiseVariableSupport extends CustomVariableSupport<DataSource, S
case QueryType.ListAssociatedAssets:
return this.parseOptions(response);
default:
return response
return response;
}
}

parseOptions(response: Observable<DataQueryResponse> ): Observable<DataQueryResponse> {
parseOptions(response: Observable<DataQueryResponse>): Observable<DataQueryResponse> {
return response.pipe(
map((res) => {
let data = []
let data = [];
if (res.data.length) {
data = res.data[0]
data = res.data[0];
}
return {data: new DataFrameView<AssetModelSummary>(data)};
return { data: new DataFrameView<AssetModelSummary>(data) };
}),
map((res) => {
const newData = res.data.map((m)=>{
const newData = res.data.map((m) => {
return {
value: m.id,
text: m.name,
}})
return {data:newData}
value: m.id,
text: m.name,
};
});
return { data: newData };
})
)
);
}

}
Loading