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

adding local metrics dashboard for quickstart #13715

Merged
merged 4 commits into from
Apr 30, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
1. [13520](https://github.com/influxdata/influxdb/pull/13520): Add cautioning to bucket renaming
1. [13560](https://github.com/influxdata/influxdb/pull/13560): Add option to generate all access token in tokens tab
1. [13601](https://github.com/influxdata/influxdb/pull/13601): Add option to generate read/write token in tokens tab
1. [13715](https://github.com/influxdata/influxdb/pull/13715): Added a new Local Metrics Dashboard template that is created during Quick Start

### Bug Fixes
1. [13584](https://github.com/influxdata/influxdb/pull/13584): Fixed scroll clipping found in label editing flow
Expand Down
4 changes: 4 additions & 0 deletions ui/src/onboarding/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ export const setupAdmin = (params: ISetupParams) => async (
...defaultTemplates.gettingStartedWithFluxTemplate(),
orgID,
})
await client.templates.create({
...defaultTemplates.localMetricsTemplate(),
orgID,
})

dispatch(notify(SetupSuccess))
dispatch(setStepStatus(1, StepStatus.Complete))
Expand Down
28 changes: 27 additions & 1 deletion ui/src/onboarding/components/CompletionStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ import FancyScrollbar from 'src/shared/components/fancy_scrollbar/FancyScrollbar
import {
QuickstartScraperCreationSuccess,
QuickstartScraperCreationError,
QuickstartDashboardCreationSuccess,
QuickstartDashboardCreationError,
} from 'src/shared/copy/notifications'
import {QUICKSTART_DASHBOARD_NAME} from 'src/onboarding/constants'

// APIs
import {getDashboards} from 'src/organizations/apis'
import {client} from 'src/utils/api'
import {createDashboardFromTemplate as createDashboardFromTemplateAJAX} from 'src/templates/api'

// Types
import {
Expand All @@ -26,6 +30,7 @@ import {
Columns,
Grid,
} from '@influxdata/clockface'
import {DashboardTemplate} from 'src/types'
import {Organization, Dashboard, ScraperTargetRequest} from '@influxdata/influx'
import {OnboardingStepProps} from 'src/onboarding/containers/OnboardingWizard'
import {QUICKSTART_SCRAPER_TARGET_URL} from 'src/dataLoaders/constants/pluginConfigs'
Expand Down Expand Up @@ -151,7 +156,28 @@ class CompletionStep extends PureComponent<Props> {
} catch (err) {
this.props.notify(QuickstartScraperCreationError)
}

try {
const templatesEntries = await client.templates.getAll(this.props.orgID)
const templatesToGet = templatesEntries.filter(t => {
return (
t.meta.name.toLowerCase() == QUICKSTART_DASHBOARD_NAME.toLowerCase()
)
})
const pendingTemplates = templatesToGet.map(t =>
client.templates.get(t.id)
)
const templates = await Promise.all(pendingTemplates)
const pendingDashboards = templates.map(t =>
createDashboardFromTemplateAJAX(
t as DashboardTemplate,
this.props.orgID
)
)
await Promise.all(pendingDashboards)
this.props.notify(QuickstartDashboardCreationSuccess)
} catch (err) {
this.props.notify(QuickstartDashboardCreationError)
}
this.props.onExit()
}

Expand Down
1 change: 1 addition & 0 deletions ui/src/onboarding/constants/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const QUICKSTART_DASHBOARD_NAME = 'Local Metrics-Template'
4 changes: 4 additions & 0 deletions ui/src/organizations/actions/orgs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ export const createOrgWithBucket = (
...defaultTemplates.gettingStartedWithFluxTemplate(),
orgID: createdOrg.id,
})
await client.templates.create({
...defaultTemplates.localMetricsTemplate(),
orgID: createdOrg.id,
})
dispatch(notify(orgCreateSuccess()))

dispatch(addOrg(createdOrg))
Expand Down
10 changes: 10 additions & 0 deletions ui/src/shared/copy/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ export const QuickstartScraperCreationError: Notification = {
message: `Failed to configure InfluxDB Scraper`,
}

export const QuickstartDashboardCreationSuccess: Notification = {
...defaultSuccessNotification,
message: `The Local Metrics Dashboard has been created`,
}

export const QuickstartDashboardCreationError: Notification = {
...defaultErrorNotification,
message: `Failed to create the Local Metrics Dashboard`,
}

export const TelegrafConfigCreationSuccess: Notification = {
...defaultSuccessNotification,
message: `Your configurations have been saved`,
Expand Down
Loading