Skip to content

Commit

Permalink
Related to issue #147
Browse files Browse the repository at this point in the history
  • Loading branch information
coderReview committed Apr 5, 2024
1 parent 834ef62 commit 4e5671c
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion dist/module.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/module.js.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion pkg/plugin/timeseries_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ func (d *Datasource) processQuery(query backend.DataQuery, datasourceUID string)
for i, targetBasePath := range PiQuery.Pi.getTargetBasePaths() {
for j, attribute := range PiQuery.Pi.Attributes {
fullTargetPath := targetBasePath + PiQuery.Pi.getTargetPathSeparator() + attribute.Value.Value
backend.Logger.Debug("Process Query", "Summary", PiQuery.Pi.Summary)
// Create a processed query for the target
piQuery := PiProcessedQuery{
Label: attribute.Value.Value,
Expand Down
11 changes: 1 addition & 10 deletions src/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ export class PiWebAPIDatasource extends DataSourceWithBackend<PIWebAPIQuery, PIW
*
* @memberOf PiWebApiDatasource
*/
query(options: DataQueryRequest<PIWebAPIQuery>): Observable<DataQueryResponse> {
console.log('OSISOFT QUERY');

query(options: DataQueryRequest<PIWebAPIQuery>): Observable<DataQueryResponse> {
if (options.targets.length === 1 && !!options.targets[0].isAnnotation) {
return super.query(options);
}
Expand All @@ -109,8 +107,6 @@ export class PiWebAPIDatasource extends DataSourceWithBackend<PIWebAPIQuery, PIW
return of({ data: [] });
}

console.log('OSISOFT QUERY', query);

return super.query(query);
}

Expand Down Expand Up @@ -221,11 +217,6 @@ export class PiWebAPIDatasource extends DataSourceWithBackend<PIWebAPIQuery, PIW
options.maxDataPoints = options.maxDataPoints > 30000 ? 30000 : options.maxDataPoints;
}
options.targets = map(options.targets, (target) => {
if (!!target.rawQuery && !!target.target) {
const { attributes, elementPath } = parseRawQuery(this.templateSrv.replace(target.target, options.scopedVars));
target.attributes = attributes;
target.elementPath = elementPath;
}
const tar = {
enableStreaming: target.enableStreaming,
target: this.templateSrv.replace(target.target, options.scopedVars),
Expand Down
8 changes: 8 additions & 0 deletions src/query/QueryEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { PiWebAPIDatasource } from '../datasource';
import { QueryInlineField, QueryRawInlineField, QueryRowTerminator } from '../components/Forms';
import { PIWebAPISelectableValue, PIWebAPIDataSourceJsonData, PIWebAPIQuery, defaultQuery } from '../types';
import { QueryEditorModeSwitcher } from 'components/QueryEditorModeSwitcher';
import { parseRawQuery } from 'helper';

const LABEL_WIDTH = 24;
const MIN_ELEM_INPUT_WIDTH = 200;
Expand Down Expand Up @@ -887,6 +888,11 @@ export class PIWebAPIQueryEditor extends PureComponent<Props, State> {

if (query.rawQuery) {
query.target = query.query ?? '';
if (!!query.query) {
const { attributes, elementPath } = parseRawQuery(query.target);
query.attributes = attributes;
query.elementPath = elementPath;
}
} else {
query.elementPath = this.getSegmentPathUpTo(this.state.segments, this.state.segments.length);
query.target =
Expand All @@ -904,6 +910,8 @@ export class PIWebAPIQueryEditor extends PureComponent<Props, State> {

onChange({...query, summary});

console.log('QUERY', query.elementPath, query.attributes, query.target);

if (this.isValidQuery(query)) {
onRunQuery();
}
Expand Down
4 changes: 2 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DataQuery } from '@grafana/schema';
import { DataSourceJsonData } from '@grafana/data';
import { DataSourceJsonData, SelectableValue } from '@grafana/data';

export interface PiwebapiElementPath {
path: string;
Expand Down Expand Up @@ -43,7 +43,7 @@ export interface PIWebAPIAnnotationsQuery extends DataQuery {
export interface PIWebAPIQuery extends DataQuery {
target?: string;
elementPath?: string;
attributes?: any[];
attributes?: Array<SelectableValue<PIWebAPISelectableValue>>;
segments?: any[];
isPiPoint?: boolean;
isAnnotation?: boolean;
Expand Down

0 comments on commit 4e5671c

Please sign in to comment.