Skip to content

Commit

Permalink
Made placeholder values empty
Browse files Browse the repository at this point in the history
  • Loading branch information
coesent committed Nov 20, 2024
1 parent 647c2c7 commit 82f2566
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 51 deletions.
2 changes: 1 addition & 1 deletion src/components/TagsSection/Tag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export const Tag = ({
/>
<Seg
allowCustomValue
value={tag.value}
value={(tag.value === '' ? 'select tag value' : tag.value)}
loadOptions={getTagValueSegmentOptions}
onChange={(v) => {
const value = v.value ?? ''
Expand Down
2 changes: 1 addition & 1 deletion src/components/TagsSection/TagsSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const TagsSection = ({
tags,
operators,
conditions,
placeholder = 'select tag value',
placeholder = '',
onChange,
getTagKeyOptions = defaultKeys,
getTagValueOptions = defaultValues,
Expand Down
46 changes: 22 additions & 24 deletions src/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,32 +118,30 @@ export class DataSource extends DataSourceWithBackend<Query, HistorianDataSource
(e) => e.Value !== 'enter a value'
)
}
eventQuery.PropertyFilter = eventQuery.PropertyFilter?.filter((e) => e.Value !== 'select tag value').map(
(e) => {
e.Property = this.templateSrv.replace(e.Property, request.scopedVars)
if (e.Operator === 'IN' || e.Operator === 'NOT IN') {
const replacedValue = this.multiSelectReplace(String(e.Value), request.scopedVars)
if (replacedValue.length === 0) {
return e
}
e.Value = replacedValue
} else {
switch (e.Datatype) {
case PropertyDatatype.Number:
e.Value = parseFloat(this.templateSrv.replace(String(e.Value), request.scopedVars))
break
case PropertyDatatype.Bool:
e.Value = this.templateSrv.replace(String(e.Value), request.scopedVars) === 'true'
break
case PropertyDatatype.String:
e.Value = this.templateSrv.replace(String(e.Value), request.scopedVars)
break
}
eventQuery.PropertyFilter = eventQuery.PropertyFilter?.map((e) => {
e.Property = this.templateSrv.replace(e.Property, request.scopedVars)
if (e.Operator === 'IN' || e.Operator === 'NOT IN') {
const replacedValue = this.multiSelectReplace(String(e.Value), request.scopedVars)
if (replacedValue.length === 0) {
return e
}
e.Value = replacedValue
} else {
switch (e.Datatype) {
case PropertyDatatype.Number:
e.Value = parseFloat(this.templateSrv.replace(String(e.Value), request.scopedVars))
break
case PropertyDatatype.Bool:
e.Value = this.templateSrv.replace(String(e.Value), request.scopedVars) === 'true'
break
case PropertyDatatype.String:
e.Value = this.templateSrv.replace(String(e.Value), request.scopedVars)
break
}

return e
}
)

return e
})
target.query = eventQuery
break
}
Expand Down
47 changes: 22 additions & 25 deletions src/variable_support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,32 +196,30 @@ export class VariableSupport extends CustomVariableSupport<DataSource> {
)
}
if ((filter.EventFilter?.PropertyFilter.length ?? 0) > 0) {
filter.EventFilter!.PropertyFilter = filter
.EventFilter!.PropertyFilter?.filter((e) => e.Value !== 'select tag value')
.map((e) => {
e.Property = this.dataAPI.replace(e.Property, request.scopedVars)
if (e.Operator === 'IN' || e.Operator === 'NOT IN') {
const replacedValue = this.dataAPI.multiSelectReplace(String(e.Value), request.scopedVars)
if (replacedValue.length === 0) {
return e
}
e.Value = replacedValue
} else {
switch (e.Datatype) {
case PropertyDatatype.Number:
e.Value = parseFloat(this.dataAPI.replace(String(e.Value), request.scopedVars))
break
case PropertyDatatype.Bool:
e.Value = this.dataAPI.replace(String(e.Value), request.scopedVars) === 'true'
break
case PropertyDatatype.String:
e.Value = this.dataAPI.replace(String(e.Value), request.scopedVars)
break
}
filter.EventFilter!.PropertyFilter = filter.EventFilter!.PropertyFilter?.map((e) => {
e.Property = this.dataAPI.replace(e.Property, request.scopedVars)
if (e.Operator === 'IN' || e.Operator === 'NOT IN') {
const replacedValue = this.dataAPI.multiSelectReplace(String(e.Value), request.scopedVars)
if (replacedValue.length === 0) {
return e
}
e.Value = replacedValue
} else {
switch (e.Datatype) {
case PropertyDatatype.Number:
e.Value = parseFloat(this.dataAPI.replace(String(e.Value), request.scopedVars))
break
case PropertyDatatype.Bool:
e.Value = this.dataAPI.replace(String(e.Value), request.scopedVars) === 'true'
break
case PropertyDatatype.String:
e.Value = this.dataAPI.replace(String(e.Value), request.scopedVars)
break
}
}

return e
})
return e
})
}

if (!filter.EventTypePropertyUUID) {
Expand All @@ -244,6 +242,5 @@ export class VariableSupport extends CustomVariableSupport<DataSource> {
)
}
}
return of({ data: [] })
}
}

0 comments on commit 82f2566

Please sign in to comment.