Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui): autofilling the organization in the client examples #15983

Merged
merged 2 commits into from
Nov 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 44 additions & 2 deletions ui/src/clientLibraries/components/ClientCSharpOverlay.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
// Libraries
import React, {FunctionComponent} from 'react'
import {connect} from 'react-redux'

// Components
import ClientLibraryOverlay from 'src/clientLibraries/components/ClientLibraryOverlay'
import TemplatedCodeSnippet from 'src/shared/components/TemplatedCodeSnippet'

// Constants
import {clientCSharpLibrary} from 'src/clientLibraries/constants'

const ClientCSharpOverlay: FunctionComponent<{}> = () => {
// Types
import {AppState} from 'src/types'

interface StateProps {
org: string
}

type Props = StateProps

const ClientCSharpOverlay: FunctionComponent<Props> = props => {
const {
name,
url,
Expand All @@ -20,6 +32,9 @@ const ClientCSharpOverlay: FunctionComponent<{}> = () => {
writingDataPocoCodeSnippet,
pocoClassCodeSnippet,
} = clientCSharpLibrary
const {org} = props
const server = window.location.origin

return (
<ClientLibraryOverlay title={`${name} Client Library`}>
<p>
Expand Down Expand Up @@ -52,6 +67,9 @@ const ClientCSharpOverlay: FunctionComponent<{}> = () => {
server: 'basepath',
token: 'token',
}}
values={{
server,
}}
/>
<h5>Write Data</h5>
<p>Option 1: Use InfluxDB Line Protocol to write data</p>
Expand All @@ -62,6 +80,9 @@ const ClientCSharpOverlay: FunctionComponent<{}> = () => {
org: 'orgID',
bucket: 'bucketID',
}}
values={{
org,
}}
/>
<p>Option 2: Use a Data Point to write data</p>
<TemplatedCodeSnippet
Expand All @@ -71,6 +92,9 @@ const ClientCSharpOverlay: FunctionComponent<{}> = () => {
org: 'orgID',
bucket: 'bucketID',
}}
values={{
org,
}}
/>
<p>Option 3: Use POCO and corresponding Class to write data</p>
<TemplatedCodeSnippet
Expand All @@ -80,6 +104,9 @@ const ClientCSharpOverlay: FunctionComponent<{}> = () => {
org: 'orgID',
bucket: 'bucketID',
}}
values={{
org,
}}
/>
<TemplatedCodeSnippet template={pocoClassCodeSnippet} label="C# Code" />
<h5>Execute a Flux query</h5>
Expand All @@ -90,9 +117,24 @@ const ClientCSharpOverlay: FunctionComponent<{}> = () => {
org: 'orgID',
bucket: 'bucketID',
}}
values={{
org,
}}
/>
</ClientLibraryOverlay>
)
}

export default ClientCSharpOverlay
const mstp = (state: AppState): StateProps => {
const org = state.orgs.org.id

return {
org,
}
}

export {ClientCSharpOverlay}
export default connect<StateProps, {}, Props>(
mstp,
null
)(ClientCSharpOverlay)
35 changes: 33 additions & 2 deletions ui/src/clientLibraries/components/ClientGoOverlay.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Libraries
import React, {FunctionComponent} from 'react'
import {connect} from 'react-redux'

// Components
import ClientLibraryOverlay from 'src/clientLibraries/components/ClientLibraryOverlay'
Expand All @@ -8,13 +9,25 @@ import TemplatedCodeSnippet from 'src/shared/components/TemplatedCodeSnippet'
// Constants
import {clientGoLibrary} from 'src/clientLibraries/constants'

const ClientGoOverlay: FunctionComponent<{}> = () => {
// Types
import {AppState} from 'src/types'

interface StateProps {
org: string
}

type Props = StateProps

const ClientGoOverlay: FunctionComponent<Props> = props => {
const {
name,
url,
initializeClientCodeSnippet,
writeDataCodeSnippet,
} = clientGoLibrary
const {org} = props
const server = window.location.origin

return (
<ClientLibraryOverlay title={`${name} Client Library`}>
<p>
Expand All @@ -31,6 +44,9 @@ const ClientGoOverlay: FunctionComponent<{}> = () => {
token: 'myToken',
server: 'myHTTPInfluxAddress',
}}
values={{
server,
}}
/>
<h5>Write Data</h5>
<TemplatedCodeSnippet
Expand All @@ -40,9 +56,24 @@ const ClientGoOverlay: FunctionComponent<{}> = () => {
bucket: 'my-awesome-bucket',
org: 'my-very-awesome-org',
}}
values={{
org,
}}
/>
</ClientLibraryOverlay>
)
}

export default ClientGoOverlay
const mstp = (state: AppState): StateProps => {
const org = state.orgs.org.id

return {
org,
}
}

export {ClientGoOverlay}
export default connect<StateProps, {}, Props>(
mstp,
null
)(ClientGoOverlay)
37 changes: 35 additions & 2 deletions ui/src/clientLibraries/components/ClientJSOverlay.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Libraries
import React, {FunctionComponent} from 'react'
import {connect} from 'react-redux'

// Components
import ClientLibraryOverlay from 'src/clientLibraries/components/ClientLibraryOverlay'
Expand All @@ -8,14 +9,25 @@ import TemplatedCodeSnippet from 'src/shared/components/TemplatedCodeSnippet'
// Constants
import {clientJSLibrary} from 'src/clientLibraries/constants'

const ClientJSOverlay: FunctionComponent<{}> = () => {
// Types
import {AppState} from 'src/types'

interface StateProps {
org: string
}

type Props = StateProps

const ClientJSOverlay: FunctionComponent<Props> = props => {
const {
name,
url,
initializeClientCodeSnippet,
executeQueryCodeSnippet,
writingDataLineProtocolCodeSnippet,
} = clientJSLibrary
const {org} = props
const server = window.location.origin

return (
<ClientLibraryOverlay title={`${name} Client Library`}>
Expand All @@ -34,6 +46,9 @@ const ClientJSOverlay: FunctionComponent<{}> = () => {
server: 'server',
token: 'token',
}}
values={{
server,
}}
/>
<h5>Write Data</h5>
<TemplatedCodeSnippet
Expand All @@ -43,6 +58,9 @@ const ClientJSOverlay: FunctionComponent<{}> = () => {
org: 'orgID',
bucket: 'bucketID',
}}
values={{
org,
}}
/>
<h5>Execute a Flux query</h5>
<TemplatedCodeSnippet
Expand All @@ -51,9 +69,24 @@ const ClientJSOverlay: FunctionComponent<{}> = () => {
defaults={{
org: 'orgID',
}}
values={{
org,
}}
/>
</ClientLibraryOverlay>
)
}

export default ClientJSOverlay
const mstp = (state: AppState): StateProps => {
const org = state.orgs.org.id

return {
org,
}
}

export {ClientJSOverlay}
export default connect<StateProps, {}, Props>(
mstp,
null
)(ClientJSOverlay)
45 changes: 43 additions & 2 deletions ui/src/clientLibraries/components/ClientJavaOverlay.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
// Libraries
import React, {FunctionComponent} from 'react'
import {connect} from 'react-redux'

// Components
import ClientLibraryOverlay from 'src/clientLibraries/components/ClientLibraryOverlay'
import TemplatedCodeSnippet from 'src/shared/components/TemplatedCodeSnippet'

// Constants
import {clientJavaLibrary} from 'src/clientLibraries/constants'

const ClientJavaOverlay: FunctionComponent<{}> = () => {
// Types
import {AppState} from 'src/types'

interface StateProps {
org: string
}

type Props = StateProps

const ClientJavaOverlay: FunctionComponent<Props> = props => {
const {
name,
url,
Expand All @@ -19,6 +31,8 @@ const ClientJavaOverlay: FunctionComponent<{}> = () => {
writingDataPojoCodeSnippet,
pojoClassCodeSnippet,
} = clientJavaLibrary
const {org} = props
const server = window.location.origin

return (
<ClientLibraryOverlay title={`${name} Client Library`}>
Expand All @@ -44,6 +58,9 @@ const ClientJavaOverlay: FunctionComponent<{}> = () => {
server: 'serverUrl',
token: 'token',
}}
values={{
server,
}}
/>
<h5>Write Data</h5>
<p>Option 1: Use InfluxDB Line Protocol to write data</p>
Expand All @@ -54,6 +71,9 @@ const ClientJavaOverlay: FunctionComponent<{}> = () => {
bucket: 'bucketID',
org: 'orgID',
}}
values={{
org,
}}
/>
<p>Option 2: Use a Data Point to write data</p>
<TemplatedCodeSnippet
Expand All @@ -63,6 +83,9 @@ const ClientJavaOverlay: FunctionComponent<{}> = () => {
bucket: 'bucketID',
org: 'orgID',
}}
values={{
org,
}}
/>
<p>Option 3: Use POJO and corresponding class to write data</p>
<TemplatedCodeSnippet
Expand All @@ -72,6 +95,9 @@ const ClientJavaOverlay: FunctionComponent<{}> = () => {
bucket: 'bucketID',
org: 'orgID',
}}
values={{
org,
}}
/>
<TemplatedCodeSnippet template={pojoClassCodeSnippet} label="Java Code" />
<h5>Execute a Flux query</h5>
Expand All @@ -82,9 +108,24 @@ const ClientJavaOverlay: FunctionComponent<{}> = () => {
bucket: 'my_bucket',
org: 'myorgid',
}}
values={{
org,
}}
/>
</ClientLibraryOverlay>
)
}

export default ClientJavaOverlay
const mstp = (state: AppState): StateProps => {
const org = state.orgs.org.id

return {
org,
}
}

export {ClientJavaOverlay}
export default connect<StateProps, {}, Props>(
mstp,
null
)(ClientJavaOverlay)
Loading