Co-authored-by: Andrew Watkins <andrew.watkinz@gmail.com>
Co-authored-by: Chris Henn <chris.henn@influxdata.com>
pull/3546/head
Andrew Watkins 2018-05-30 16:30:59 -07:00
parent 53d0de11c0
commit 0327e5d359
3 changed files with 17 additions and 5 deletions

View File

@ -71,7 +71,10 @@ export default class TagListItem extends PureComponent<Props, State> {
</div>
{this.state.isOpen && (
<>
<div className="tag-value-list--header">
<div
className="tag-value-list--header"
onClick={this.handleInputClick}
>
<div className="ifql-schema--filter">
<input
className="form-control input-sm"
@ -80,7 +83,6 @@ export default class TagListItem extends PureComponent<Props, State> {
spellCheck={false}
autoComplete="off"
value={searchTerm}
onClick={this.handleInputClick}
onChange={this.onSearch}
/>
{this.isSearching && (
@ -101,6 +103,7 @@ export default class TagListItem extends PureComponent<Props, State> {
onLoadMoreValues={this.handleLoadMoreValues}
isLoadingMoreValues={loadingMore === RemoteDataState.Loading}
shouldShowMoreValues={limit < count}
loadMoreCount={this.loadMoreCount}
/>
</>
)}
@ -136,7 +139,7 @@ export default class TagListItem extends PureComponent<Props, State> {
private debouncedOnSearch() {} // See constructor
private handleInputClick = (e: MouseEvent<HTMLInputElement>): void => {
private handleInputClick = (e: MouseEvent<HTMLDivElement>): void => {
e.stopPropagation()
}
@ -237,7 +240,12 @@ export default class TagListItem extends PureComponent<Props, State> {
const parsed = parseValuesColumn(response)
if (parsed.length !== 1) {
throw new Error('Unexpected count response')
// We expect to never reach this state; instead, the IFQL server should
// return a non-200 status code is handled earlier (after fetching).
// This return guards against some unexpected behavior---the IFQL server
// returning a 200 status code but ALSO having an error in the CSV
// response body
return
}
const count = Number(parsed[0])

View File

@ -3,7 +3,6 @@ import React, {PureComponent, MouseEvent} from 'react'
import TagValueListItem from 'src/ifql/components/TagValueListItem'
import LoadingSpinner from 'src/ifql/components/LoadingSpinner'
import {Service, SchemaFilter} from 'src/types'
import {explorer} from 'src/ifql/constants'
interface Props {
service: Service

View File

@ -12,6 +12,11 @@ const parseValuesColumn = (resp: string): string[] => {
const tags = results.reduce<string[]>((acc, result: ScriptResult) => {
const colIndex = result.data[0].findIndex(header => header === '_value')
if (colIndex === -1) {
return [...acc]
}
const resultTags = result.data.slice(1).map(row => row[colIndex])
return [...acc, ...resultTags]