Add append handlers for join function
parent
149cd4a27f
commit
8abf433a6e
|
@ -12,6 +12,7 @@ interface Props {
|
||||||
body: Body[]
|
body: Body[]
|
||||||
suggestions: Suggestion[]
|
suggestions: Suggestion[]
|
||||||
onAppendFrom: () => void
|
onAppendFrom: () => void
|
||||||
|
onAppendJoin: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Body extends FlatBody {
|
interface Body extends FlatBody {
|
||||||
|
|
|
@ -23,6 +23,7 @@ interface Props {
|
||||||
onChangeScript: OnChangeScript
|
onChangeScript: OnChangeScript
|
||||||
onSubmitScript: OnSubmitScript
|
onSubmitScript: OnSubmitScript
|
||||||
onAppendFrom: () => void
|
onAppendFrom: () => void
|
||||||
|
onAppendJoin: () => void
|
||||||
onAnalyze: () => void
|
onAnalyze: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,6 +74,7 @@ class TimeMachine extends PureComponent<Props> {
|
||||||
onAnalyze,
|
onAnalyze,
|
||||||
suggestions,
|
suggestions,
|
||||||
onAppendFrom,
|
onAppendFrom,
|
||||||
|
onAppendJoin,
|
||||||
onChangeScript,
|
onChangeScript,
|
||||||
onSubmitScript,
|
onSubmitScript,
|
||||||
} = this.props
|
} = this.props
|
||||||
|
@ -119,6 +121,7 @@ class TimeMachine extends PureComponent<Props> {
|
||||||
body={body}
|
body={body}
|
||||||
suggestions={suggestions}
|
suggestions={suggestions}
|
||||||
onAppendFrom={onAppendFrom}
|
onAppendFrom={onAppendFrom}
|
||||||
|
onAppendJoin={onAppendJoin}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
export const NEW_FROM = `from(db: "pick a db")\n\t|> filter(fn: (r) => r.tag == "value")\n\t|> range(start: -1m)`
|
export const NEW_FROM = `from(db: "pick a db")\n\t|> filter(fn: (r) => r.tag == "value")\n\t|> range(start: -1m)`
|
||||||
|
export const NEW_JOIN = `join(tables: {table1:table1, table2:table2}, on:["host"], fn: (tables) => tables.table1["_value"] + tables.table2["_value"])`
|
||||||
|
|
|
@ -102,6 +102,7 @@ export class IFQLPage extends PureComponent<Props, State> {
|
||||||
suggestions={suggestions}
|
suggestions={suggestions}
|
||||||
onAnalyze={this.handleAnalyze}
|
onAnalyze={this.handleAnalyze}
|
||||||
onAppendFrom={this.handleAppendFrom}
|
onAppendFrom={this.handleAppendFrom}
|
||||||
|
onAppendJoin={this.handleAppendJoin}
|
||||||
onChangeScript={this.handleChangeScript}
|
onChangeScript={this.handleChangeScript}
|
||||||
onSubmitScript={this.handleSubmitScript}
|
onSubmitScript={this.handleSubmitScript}
|
||||||
/>
|
/>
|
||||||
|
@ -249,6 +250,13 @@ export class IFQLPage extends PureComponent<Props, State> {
|
||||||
this.getASTResponse(newScript)
|
this.getASTResponse(newScript)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private handleAppendJoin = (): void => {
|
||||||
|
const {script} = this.state
|
||||||
|
const newScript = `${script.trim()}\n\n${builder.NEW_JOIN}\n\n`
|
||||||
|
|
||||||
|
this.getASTResponse(newScript)
|
||||||
|
}
|
||||||
|
|
||||||
private handleChangeScript = (script: string): void => {
|
private handleChangeScript = (script: string): void => {
|
||||||
this.setState({script})
|
this.setState({script})
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ const setup = () => {
|
||||||
onChangeScript: () => {},
|
onChangeScript: () => {},
|
||||||
onAnalyze: () => {},
|
onAnalyze: () => {},
|
||||||
onAppendFrom: () => {},
|
onAppendFrom: () => {},
|
||||||
|
onAppendJoin: () => {},
|
||||||
}
|
}
|
||||||
|
|
||||||
const wrapper = shallow(<TimeMachine {...props} />)
|
const wrapper = shallow(<TimeMachine {...props} />)
|
||||||
|
|
Loading…
Reference in New Issue