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): Adding templating to code snippets #15671

Merged
merged 7 commits into from
Oct 31, 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
61 changes: 48 additions & 13 deletions ui/src/clientLibraries/components/ClientCSharpOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import React, {FunctionComponent} from 'react'
// Components
import ClientLibraryOverlay from 'src/clientLibraries/components/ClientLibraryOverlay'
import CodeSnippet from 'src/shared/components/CodeSnippet'
import TemplatedCodeSnippet from 'src/shared/components/TemplatedCodeSnippet'
// Constants
import {clientCSharpLibrary} from 'src/clientLibraries/constants'

Expand Down Expand Up @@ -30,32 +30,67 @@ const ClientCSharpOverlay: FunctionComponent<{}> = () => {
</p>
<h5>Install Package</h5>
<p>Package Manager</p>
<CodeSnippet
copyText={installingPackageManagerCodeSnippet}
<TemplatedCodeSnippet
template={installingPackageManagerCodeSnippet}
label="Code"
/>
<p>.NET CLI</p>
<CodeSnippet
copyText={installingPackageDotNetCLICodeSnippet}
<TemplatedCodeSnippet
template={installingPackageDotNetCLICodeSnippet}
label="Code"
/>
<p>Package Reference</p>
<CodeSnippet copyText={packageReferenceCodeSnippet} label="Code" />
<TemplatedCodeSnippet
template={packageReferenceCodeSnippet}
label="Code"
/>
<h5>Initialize the Client</h5>
<CodeSnippet copyText={initializeClientCodeSnippet} label="C# Code" />
<TemplatedCodeSnippet
template={initializeClientCodeSnippet}
label="C# Code"
defaults={{
server: 'basepath',
token: 'token',
}}
/>
<h5>Write Data</h5>
<p>Option 1: Use InfluxDB Line Protocol to write data</p>
<CodeSnippet
copyText={writingDataLineProtocolCodeSnippet}
<TemplatedCodeSnippet
template={writingDataLineProtocolCodeSnippet}
label="C# Code"
defaults={{
org: 'orgID',
bucket: 'bucketID',
}}
/>
<p>Option 2: Use a Data Point to write data</p>
<CodeSnippet copyText={writingDataDataPointCodeSnippet} label="C# Code" />
<TemplatedCodeSnippet
template={writingDataDataPointCodeSnippet}
label="C# Code"
defaults={{
org: 'orgID',
bucket: 'bucketID',
}}
/>
<p>Option 3: Use POCO and corresponding Class to write data</p>
<CodeSnippet copyText={writingDataPocoCodeSnippet} label="C# Code" />
<CodeSnippet copyText={pocoClassCodeSnippet} label="C# Code" />
<TemplatedCodeSnippet
template={writingDataPocoCodeSnippet}
label="C# Code"
defaults={{
org: 'orgID',
bucket: 'bucketID',
}}
/>
<TemplatedCodeSnippet template={pocoClassCodeSnippet} label="C# Code" />
<h5>Execute a Flux query</h5>
<CodeSnippet copyText={executeQueryCodeSnippet} label="C# Code" />
<TemplatedCodeSnippet
template={executeQueryCodeSnippet}
label="C# Code"
defaults={{
org: 'orgID',
bucket: 'bucketID',
}}
/>
</ClientLibraryOverlay>
)
}
Expand Down
20 changes: 17 additions & 3 deletions ui/src/clientLibraries/components/ClientGoOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, {FunctionComponent} from 'react'

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

// Constants
import {clientGoLibrary} from 'src/clientLibraries/constants'
Expand All @@ -24,9 +24,23 @@ const ClientGoOverlay: FunctionComponent<{}> = () => {
</a>
</p>
<h5>Initialize the Client</h5>
<CodeSnippet copyText={initializeClientCodeSnippet} label="Go Code" />
<TemplatedCodeSnippet
template={initializeClientCodeSnippet}
label="Go Code"
defaults={{
token: 'myToken',
server: 'myHTTPInfluxAddress',
}}
/>
<h5>Write Data</h5>
<CodeSnippet copyText={writeDataCodeSnippet} label="Go Code" />
<TemplatedCodeSnippet
template={writeDataCodeSnippet}
label="Go Code"
defaults={{
bucket: 'my-awesome-bucket',
org: 'my-very-awesome-org',
}}
/>
</ClientLibraryOverlay>
)
}
Expand Down
26 changes: 20 additions & 6 deletions ui/src/clientLibraries/components/ClientJSOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, {FunctionComponent} from 'react'

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

// Constants
import {clientJSLibrary} from 'src/clientLibraries/constants'
Expand All @@ -27,17 +27,31 @@ const ClientJSOverlay: FunctionComponent<{}> = () => {
</p>
<br />
<h5>Initialize the Client</h5>
<CodeSnippet
copyText={initializeClientCodeSnippet}
<TemplatedCodeSnippet
template={initializeClientCodeSnippet}
label="JavaScript Code"
defaults={{
server: 'server',
token: 'token',
}}
/>
<h5>Write Data</h5>
<CodeSnippet
copyText={writingDataLineProtocolCodeSnippet}
<TemplatedCodeSnippet
template={writingDataLineProtocolCodeSnippet}
label="JavaScript Code"
defaults={{
org: 'orgID',
bucket: 'bucketID',
}}
/>
<h5>Execute a Flux query</h5>
<CodeSnippet copyText={executeQueryCodeSnippet} label="JavaScript Code" />
<TemplatedCodeSnippet
template={executeQueryCodeSnippet}
label="JavaScript Code"
defaults={{
org: 'orgID',
}}
/>
</ClientLibraryOverlay>
)
}
Expand Down
55 changes: 45 additions & 10 deletions ui/src/clientLibraries/components/ClientJavaOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import React, {FunctionComponent} from 'react'
// Components
import ClientLibraryOverlay from 'src/clientLibraries/components/ClientLibraryOverlay'
import CodeSnippet from 'src/shared/components/CodeSnippet'
import TemplatedCodeSnippet from 'src/shared/components/TemplatedCodeSnippet'
// Constants
import {clientJavaLibrary} from 'src/clientLibraries/constants'

Expand Down Expand Up @@ -30,24 +30,59 @@ const ClientJavaOverlay: FunctionComponent<{}> = () => {
</p>
<h5>Add Dependency</h5>
<p>Build with Maven</p>
<CodeSnippet copyText={buildWithMavenCodeSnippet} label="Code" />
<TemplatedCodeSnippet template={buildWithMavenCodeSnippet} label="Code" />
<p>Build with Gradle</p>
<CodeSnippet copyText={buildWithGradleCodeSnippet} label="Code" />
<TemplatedCodeSnippet
template={buildWithGradleCodeSnippet}
label="Code"
/>
<h5>Initialize the Client</h5>
<CodeSnippet copyText={initializeClientCodeSnippet} label="Java Code" />
<TemplatedCodeSnippet
template={initializeClientCodeSnippet}
label="Java Code"
defaults={{
server: 'serverUrl',
token: 'token',
}}
/>
<h5>Write Data</h5>
<p>Option 1: Use InfluxDB Line Protocol to write data</p>
<CodeSnippet
copyText={writingDataLineProtocolCodeSnippet}
<TemplatedCodeSnippet
template={writingDataLineProtocolCodeSnippet}
label="Java Code"
defaults={{
bucket: 'bucketID',
org: 'orgID',
}}
/>
<p>Option 2: Use a Data Point to write data</p>
<CodeSnippet copyText={writingDataPointCodeSnippet} label="Java Code" />
<TemplatedCodeSnippet
template={writingDataPointCodeSnippet}
label="Java Code"
defaults={{
bucket: 'bucketID',
org: 'orgID',
}}
/>
<p>Option 3: Use POJO and corresponding class to write data</p>
<CodeSnippet copyText={writingDataPojoCodeSnippet} label="Java Code" />
<CodeSnippet copyText={pojoClassCodeSnippet} label="Java Code" />
<TemplatedCodeSnippet
template={writingDataPojoCodeSnippet}
label="Java Code"
defaults={{
bucket: 'bucketID',
org: 'orgID',
}}
/>
<TemplatedCodeSnippet template={pojoClassCodeSnippet} label="Java Code" />
<h5>Execute a Flux query</h5>
<CodeSnippet copyText={executeQueryCodeSnippet} label="Java Code" />
<TemplatedCodeSnippet
template={executeQueryCodeSnippet}
label="Java Code"
defaults={{
bucket: 'my_bucket',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be bucketID and orgID for consistency?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to start standardizing those, but at the same time have a plan to connect them all to redux state in a little bit to give them MORE consistency. like site wide, frontend <=> backend consistency. so.... yes, but meh?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so.... yes, but meh

pretty much perfectly sums up software engineering, circa 2019.

👍

org: 'myorgid',
}}
/>
</ClientLibraryOverlay>
)
}
Expand Down
51 changes: 43 additions & 8 deletions ui/src/clientLibraries/components/ClientPythonOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, {FunctionComponent} from 'react'

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

// Constants
import {clientPythonLibrary} from 'src/clientLibraries/constants'
Expand All @@ -29,21 +29,56 @@ const ClientPythonOverlay: FunctionComponent<{}> = () => {
</a>
</p>
<h5>Install Package</h5>
<CodeSnippet copyText={initializePackageCodeSnippet} label="Code" />
<TemplatedCodeSnippet
template={initializePackageCodeSnippet}
label="Code"
/>
<h5>Initialize the Client</h5>
<CodeSnippet copyText={initializeClientCodeSnippet} label="Python Code" />
<TemplatedCodeSnippet
template={initializeClientCodeSnippet}
label="Python Code"
defaults={{
server: 'serverUrl',
token: 'token',
}}
/>
<h5>Write Data</h5>
<p>Option 1: Use InfluxDB Line Protocol to write data</p>
<CodeSnippet
copyText={writingDataLineProtocolCodeSnippet}
<TemplatedCodeSnippet
template={writingDataLineProtocolCodeSnippet}
label="Python Code"
defaults={{
bucket: 'bucketID',
org: 'orgID',
}}
/>
<p>Option 2: Use a Data Point to write data</p>
<CodeSnippet copyText={writingDataPointCodeSnippet} label="Python Code" />
<TemplatedCodeSnippet
template={writingDataPointCodeSnippet}
label="Python Code"
defaults={{
bucket: 'bucketID',
org: 'orgID',
}}
/>
<p>Option 3: Use a Batch Sequence to write data</p>
<CodeSnippet copyText={writingDataBatchCodeSnippet} label="Python Code" />
<TemplatedCodeSnippet
template={writingDataBatchCodeSnippet}
label="Python Code"
defaults={{
bucket: 'bucketID',
org: 'orgID',
}}
/>
<h5>Execute a Flux query</h5>
<CodeSnippet copyText={executeQueryCodeSnippet} label="Python Code" />
<TemplatedCodeSnippet
template={executeQueryCodeSnippet}
label="Python Code"
defaults={{
bucket: 'my_bucket',
org: 'orgID',
}}
/>
</ClientLibraryOverlay>
)
}
Expand Down
Loading