From b1feeb7b3d54137357d9d655cb3ec00f8de294d1 Mon Sep 17 00:00:00 2001 From: Alex P Date: Fri, 1 Mar 2019 15:51:18 -0800 Subject: [PATCH 01/17] Condense layout of scraper form --- .../components/configureStep/ScraperTarget.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ui/src/dataLoaders/components/configureStep/ScraperTarget.tsx b/ui/src/dataLoaders/components/configureStep/ScraperTarget.tsx index 271aea8a7a1..af19316e9ed 100644 --- a/ui/src/dataLoaders/components/configureStep/ScraperTarget.tsx +++ b/ui/src/dataLoaders/components/configureStep/ScraperTarget.tsx @@ -7,7 +7,6 @@ import { Input, Columns, Grid, - ComponentSize, InputType, ComponentStatus, } from 'src/clockface' @@ -34,7 +33,7 @@ export class ScraperTarget extends PureComponent { return ( - + { name="name" onChange={this.handleChangeName} titleText="Name" - size={ComponentSize.Medium} autoFocus={true} status={this.nameStatus} /> + + { /> - + { name="url" onChange={this.handleChangeURL} titleText="Target URL" - size={ComponentSize.Medium} status={this.urlStatus} /> From 833d6a232118138cd70b7237748e43b66c493c84 Mon Sep 17 00:00:00 2001 From: Alex P Date: Fri, 1 Mar 2019 16:16:27 -0800 Subject: [PATCH 02/17] Introduce overlay component for creating scrapers --- .../components/CreateScraperOverlay.tsx | 176 ++++++++++++++++++ ui/src/organizations/actions/orgView.ts | 5 + ui/src/organizations/components/Scrapers.tsx | 69 ++++--- 3 files changed, 228 insertions(+), 22 deletions(-) create mode 100644 ui/src/dataLoaders/components/CreateScraperOverlay.tsx diff --git a/ui/src/dataLoaders/components/CreateScraperOverlay.tsx b/ui/src/dataLoaders/components/CreateScraperOverlay.tsx new file mode 100644 index 00000000000..f0f7f150df8 --- /dev/null +++ b/ui/src/dataLoaders/components/CreateScraperOverlay.tsx @@ -0,0 +1,176 @@ +// Libraries +import React, {PureComponent} from 'react' +import {connect} from 'react-redux' +import _ from 'lodash' + +// Components +import {Button, ComponentColor, ComponentStatus} from '@influxdata/clockface' +import { + Form, + OverlayContainer, + OverlayHeading, + OverlayBody, + OverlayFooter, +} from 'src/clockface' +import ScraperTarget from 'src/dataLoaders/components/configureStep/ScraperTarget' + +// Actions +import { + setScraperTargetBucket, + setScraperTargetURL, + setScraperTargetName, + saveScraperTarget, +} from 'src/dataLoaders/actions/dataLoaders' +import {setBucketInfo} from 'src/dataLoaders/actions/steps' +import {notify as notifyAction, notify} from 'src/shared/actions/notifications' + +// Types +import {Bucket, ScraperTargetResponse} from '@influxdata/influx' +import {AppState} from 'src/types/v2/index' +import { + scraperCreateSuccess, + scraperCreateFailed, +} from 'src/shared/copy/v2/notifications' + +interface OwnProps { + onDismiss: () => void + buckets: Bucket[] + onCreate: (scraper: ScraperTargetResponse) => void +} + +interface DispatchProps { + onSetScraperTargetBucket: typeof setScraperTargetBucket + onSetScraperTargetURL: typeof setScraperTargetURL + onSetScraperTargetName: typeof setScraperTargetName + onSaveScraperTarget: typeof saveScraperTarget + onSetBucketInfo: typeof setBucketInfo + notify: typeof notifyAction +} + +interface StateProps { + scraperBucket: string + url: string + currentBucket: string + name: string +} + +type Props = OwnProps & DispatchProps & StateProps + +export class Scraping extends PureComponent { + public componentDidMount() { + const { + buckets, + scraperBucket, + currentBucket, + onSetScraperTargetBucket, + } = this.props + + if (!scraperBucket) { + onSetScraperTargetBucket(currentBucket || _.get(buckets, '0.name', '')) + } + } + + public render() { + const { + onDismiss, + scraperBucket, + onSetScraperTargetURL, + onSetScraperTargetName, + url, + buckets, + name, + } = this.props + + return ( + + +
+ +
+ Scrapers collect data from multiple targets at regular intervals + and to write to a bucket +
+ +
+ +