This is an automated email from the ASF dual-hosted git repository.
qiaojialin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new ad60df6178 grafana plugin add password input type and optimization
(#6052)
ad60df6178 is described below
commit ad60df6178187efbc4e3cb45188fb137e51b5814
Author: CloudWise-Lukemiao
<[email protected]>
AuthorDate: Tue Jun 28 22:58:34 2022 +0800
grafana plugin add password input type and optimization (#6052)
---
grafana-plugin/pkg/plugin/plugin.go | 4 +--
grafana-plugin/src/ConfigEditor.tsx | 1 +
grafana-plugin/src/QueryEditor.tsx | 52 ++++++++++++++++++-------------------
grafana-plugin/src/datasource.ts | 2 +-
grafana-plugin/src/types.ts | 4 +--
5 files changed, 32 insertions(+), 31 deletions(-)
diff --git a/grafana-plugin/pkg/plugin/plugin.go
b/grafana-plugin/pkg/plugin/plugin.go
index 37c8cb6ca6..e7de5f30ed 100644
--- a/grafana-plugin/pkg/plugin/plugin.go
+++ b/grafana-plugin/pkg/plugin/plugin.go
@@ -114,7 +114,7 @@ type queryParam struct {
EndTime int64 `json:"endTime"`
Condition string `json:"condition"`
Control string `json:"control"`
- Aggregated string `json:"aggregated"`
+ SqlType string `json:"sqlType"`
Paths []string `json:"paths"`
AggregateFun string `json:"aggregateFun"`
FillClauses string `json:"fillClauses"`
@@ -163,7 +163,7 @@ func (d *IoTDBDataSource) query(cxt context.Context, pCtx
backend.PluginContext,
qp.EndTime = query.TimeRange.To.UnixNano() / 1000000
client := &http.Client{}
- if qp.Aggregated == "Aggregation" {
+ if qp.SqlType == "SQL: Drop-down List" {
qp.Control = ""
var expressions []string = qp.Paths[len(qp.Paths)-1:]
var paths []string = qp.Paths[0 : len(qp.Paths)-1]
diff --git a/grafana-plugin/src/ConfigEditor.tsx
b/grafana-plugin/src/ConfigEditor.tsx
index ef5a4fc2ec..fb225c44f0 100644
--- a/grafana-plugin/src/ConfigEditor.tsx
+++ b/grafana-plugin/src/ConfigEditor.tsx
@@ -88,6 +88,7 @@ export class ConfigEditor extends PureComponent<Props, State>
{
<FormField
value={jsonData.password || ''}
label="password"
+ type="password"
placeholder="please input password"
labelWidth={6}
inputWidth={20}
diff --git a/grafana-plugin/src/QueryEditor.tsx
b/grafana-plugin/src/QueryEditor.tsx
index 0af54a87cf..2190bc8b91 100644
--- a/grafana-plugin/src/QueryEditor.tsx
+++ b/grafana-plugin/src/QueryEditor.tsx
@@ -43,8 +43,8 @@ interface State {
aggregateFun: string;
groupBy: GroupBy;
fillClauses: string;
- isAggregated: boolean;
- aggregated: string;
+ isDropDownList: boolean;
+ sqlType: string;
shouldAdd: boolean;
}
@@ -64,7 +64,7 @@ const selectElement = [
const paths = [''];
const expressions = [''];
-const selectRaw = ['Raw', 'Aggregation'];
+const selectType = ['SQL: Full Customized', 'SQL: Drop-down List'];
const commonOption: SelectableValue<string> = { label: '*', value: '*' };
const commonOptionDou: SelectableValue<string> = { label: '**', value: '**' };
type Props = QueryEditorProps<DataSource, IoTDBQuery, IoTDBOptions>;
@@ -84,8 +84,8 @@ export class QueryEditor extends PureComponent<Props, State> {
groupByLevel: '',
},
fillClauses: '',
- isAggregated: false,
- aggregated: selectRaw[0],
+ isDropDownList: false,
+ sqlType: selectType[0],
shouldAdd: true,
};
@@ -138,7 +138,7 @@ export class QueryEditor extends PureComponent<Props,
State> {
onChange({ ...query });
};
- onSelectRawChange = (event: ChangeEvent<HTMLInputElement>) => {
+ onSelectTypeChange = (event: ChangeEvent<HTMLInputElement>) => {
const { onChange, query } = this.props;
onChange({ ...query });
};
@@ -176,10 +176,10 @@ export class QueryEditor extends PureComponent<Props,
State> {
};
componentDidMount() {
- if (this.props.query.aggregated) {
- this.setState({ isAggregated: this.props.query.isAggregated, aggregated:
this.props.query.aggregated });
+ if (this.props.query.sqlType) {
+ this.setState({ isDropDownList: this.props.query.isDropDownList,
sqlType: this.props.query.sqlType });
} else {
- this.props.query.aggregated = selectRaw[0];
+ this.props.query.sqlType = selectType[0];
}
if (this.state.options.length === 1 && this.state.options[0][0].value ===
'') {
this.props.datasource.nodeQuery(['root']).then((a) => {
@@ -194,7 +194,7 @@ export class QueryEditor extends PureComponent<Props,
State> {
render() {
const query = defaults(this.props.query);
- var { expression, prefixPath, condition, control, fillClauses,
aggregateFun, paths, options, aggregated, groupBy } =
+ var { expression, prefixPath, condition, control, fillClauses,
aggregateFun, paths, options, sqlType, groupBy } =
query;
return (
<>
@@ -204,8 +204,8 @@ export class QueryEditor extends PureComponent<Props,
State> {
<Segment
onChange={({ value: value = '' }) => {
const { onChange, query } = this.props;
- if (value === selectRaw[0]) {
- this.props.query.aggregated = selectRaw[0];
+ if (value === selectType[0]) {
+ this.props.query.sqlType = selectType[0];
this.props.query.aggregateFun = '';
if (this.props.query.paths) {
const nextTimeSeries = this.props.query.paths.filter((_,
i) => i < 0);
@@ -223,40 +223,40 @@ export class QueryEditor extends PureComponent<Props,
State> {
}
this.props.query.condition = '';
this.props.query.fillClauses = '';
- this.props.query.isAggregated = false;
+ this.props.query.isDropDownList = false;
this.setState({
- isAggregated: false,
- aggregated: selectRaw[0],
+ isDropDownList: false,
+ sqlType: selectType[0],
shouldAdd: true,
aggregateFun: '',
fillClauses: '',
condition: '',
});
- onChange({ ...query, aggregated: value, isAggregated:
false });
+ onChange({ ...query, sqlType: value, isDropDownList: false
});
} else {
- this.props.query.aggregated = selectRaw[1];
+ this.props.query.sqlType = selectType[1];
this.props.query.expression = [''];
this.props.query.prefixPath = [''];
this.props.query.condition = '';
this.props.query.control = '';
- this.props.query.isAggregated = true;
+ this.props.query.isDropDownList = true;
this.setState({
- isAggregated: true,
- aggregated: selectRaw[1],
+ isDropDownList: true,
+ sqlType: selectType[1],
expression: [''],
prefixPath: [''],
condition: '',
control: '',
});
- onChange({ ...query, aggregated: value, isAggregated: true
});
+ onChange({ ...query, sqlType: value, isDropDownList: true
});
}
}}
- options={selectRaw.map(toOption)}
- value={aggregated ? aggregated : this.state.aggregated}
- className="query-keyword width-6"
+ options={selectType.map(toOption)}
+ value={sqlType ? sqlType : this.state.sqlType}
+ className="query-keyword width-10"
/>
</div>
- {!this.state.isAggregated && (
+ {!this.state.isDropDownList && (
<>
<div className="gf-form">
<QueryInlineField label={'SELECT'}>
@@ -292,7 +292,7 @@ export class QueryEditor extends PureComponent<Props,
State> {
</div>
</>
)}
- {this.state.isAggregated && (
+ {this.state.isDropDownList && (
<>
<div className="gf-form">
<QueryInlineField label={'TIME-SERIES'}>
diff --git a/grafana-plugin/src/datasource.ts b/grafana-plugin/src/datasource.ts
index b8b66d5de0..c5ebe453df 100644
--- a/grafana-plugin/src/datasource.ts
+++ b/grafana-plugin/src/datasource.ts
@@ -32,7 +32,7 @@ export class DataSource extends
DataSourceWithBackend<IoTDBQuery, IoTDBOptions>
this.username = instanceSettings.jsonData.username;
}
applyTemplateVariables(query: IoTDBQuery, scopedVars: ScopedVars) {
- if (query.aggregated === 'Raw') {
+ if (query.sqlType === 'SQL: Full Customized') {
query.expression.map(
(_, index) => (query.expression[index] =
getTemplateSrv().replace(query.expression[index], scopedVars))
);
diff --git a/grafana-plugin/src/types.ts b/grafana-plugin/src/types.ts
index 10c2705aba..0d62f2f56b 100644
--- a/grafana-plugin/src/types.ts
+++ b/grafana-plugin/src/types.ts
@@ -26,8 +26,8 @@ export interface IoTDBQuery extends DataQuery {
paths: string[];
aggregateFun?: string;
- aggregated: string;
- isAggregated: boolean;
+ sqlType: string;
+ isDropDownList: boolean;
fillClauses: string;
groupBy?: GroupBy;
limitAll?: LimitAll;