diff --git a/ui/src/index.tsx b/ui/src/index.tsx index f5e9d220ff7..928027a089e 100644 --- a/ui/src/index.tsx +++ b/ui/src/index.tsx @@ -45,6 +45,7 @@ import {disablePresentationMode} from 'src/shared/actions/app' // Styles import 'src/style/chronograf.scss' +import TaskRunsPage from 'src/tasks/components/TaskRunsPage' const rootNode = getRootNode() const basepath = getBasepath() @@ -120,6 +121,7 @@ class Root extends PureComponent { + diff --git a/ui/src/tasks/actions/v2/index.ts b/ui/src/tasks/actions/v2/index.ts index 889c3855fdc..9d498b02bce 100644 --- a/ui/src/tasks/actions/v2/index.ts +++ b/ui/src/tasks/actions/v2/index.ts @@ -3,7 +3,7 @@ import {push, goBack} from 'react-router-redux' import _ from 'lodash' // APIs -import {Task as TaskAPI, Organization} from '@influxdata/influx' +import {Task as TaskAPI, Organization, Run} from '@influxdata/influx' import {client} from 'src/utils/api' import {notify} from 'src/shared/actions/notifications' import { @@ -477,3 +477,8 @@ export const getErrorMessage = (e: any) => { } return message } + +export const getRuns = async (taskID: string): Promise => { + const runs = await client.tasks.getRunsByTaskID(taskID) + return runs +} diff --git a/ui/src/tasks/components/TaskRow.tsx b/ui/src/tasks/components/TaskRow.tsx index 1ab63e4c4c8..430446bc03c 100644 --- a/ui/src/tasks/components/TaskRow.tsx +++ b/ui/src/tasks/components/TaskRow.tsx @@ -71,6 +71,12 @@ export class TaskRow extends PureComponent { {this.schedule} + { ) } + private handleViewRuns = () => { + const {router, task} = this.props + router.push(`tasks/${task.id}/runs`) + } + private handleUpdateTask = (name: string) => { const {onUpdate, task} = this.props onUpdate({...task, name}) diff --git a/ui/src/tasks/components/TaskRunsPage.tsx b/ui/src/tasks/components/TaskRunsPage.tsx new file mode 100644 index 00000000000..4f7bbd26dea --- /dev/null +++ b/ui/src/tasks/components/TaskRunsPage.tsx @@ -0,0 +1,73 @@ +// Libraries +import React, {PureComponent} from 'react' + +// Types +import {Run} from '@influxdata/influx' +import {IndexList} from 'src/clockface' +import {taskRuns} from '../dummyData' +import {Page} from 'src/pageLayout' + +interface Props { + taskID: string + runs: Run[] +} + +const dummyData = taskRuns + +class TaskRunsPage extends PureComponent { + public render() { + return ( + <> + + + + + + + + + + + + + + + + + + + >} columnCount={6}> + {this.listRuns} + + + + + + > + ) + } + + public get listRuns(): JSX.Element[] { + const taskRuns = dummyData.map(t => ( + + {this.dateTimeString(t.requestedAt)} + {this.dateTimeString(t.startedAt)} + {this.dateTimeString(t.finishedAt)} + {t.status} + {this.dateTimeString(t.scheduledFor)} + + + )) + + return taskRuns + } + + private dateTimeString(dt: Date): string { + const date = dt.toDateString() + const time = dt.toLocaleTimeString() + const formatted = `${date} ${time}` + + return formatted + } +} +export default TaskRunsPage diff --git a/ui/src/tasks/components/__snapshots__/TaskRow.test.tsx.snap b/ui/src/tasks/components/__snapshots__/TaskRow.test.tsx.snap index 4f01d951d4d..f1b171fb293 100644 --- a/ui/src/tasks/components/__snapshots__/TaskRow.test.tsx.snap +++ b/ui/src/tasks/components/__snapshots__/TaskRow.test.tsx.snap @@ -64,6 +64,16 @@ exports[`Tasks.Components.TaskRow renders 1`] = ` + range(start: -1h)', - cron: '2 0 * * *', - }, - { - id: '02f12c50dba72000', - orgID: '02ee9e2a29d73000', - name: 'somename', - status: Task.StatusEnum.Active, - owner: null, - flux: - 'option task = {\n name: "somename",\n every: 1m,\n}\nfrom(bucket: "inbucket") \n|> range(start: -task.every)', - every: '1m0s', + id: '40002242', + taskID: 'string', + status: Run.StatusEnum.Scheduled, + scheduledFor: new Date('2019-02-11T22:37:25.985Z'), + startedAt: new Date('2019-02-11T22:37:25.985Z'), + finishedAt: new Date('2019-02-11T22:37:25.985Z'), + requestedAt: new Date('2019-02-11T22:37:25.985Z'), + links: { + self: '/api/v2/tasks/1/runs/1', + task: '/arequei/v2/tasks/1', + retry: '/api/v2/tasks/1/runs/1/retry', + logs: '/api/v2/tasks/1/runs/1/logs', + }, }, ]