bump client version, and use updated client template types to create template

pull/12315/head
Deniz Kusefoglu 2019-03-05 21:40:03 -08:00
parent faaac68c56
commit d2583c9719
5 changed files with 73 additions and 79 deletions

47
ui/package-lock.json generated
View File

@ -985,9 +985,9 @@
}
},
"@influxdata/influx": {
"version": "0.2.21",
"resolved": "https://registry.npmjs.org/@influxdata/influx/-/influx-0.2.21.tgz",
"integrity": "sha512-ckXKekCMHR3OcdPCGc2w1/y+Z4ARPTmcFmdYNZJ6biIBGKNV+mKyVB3ATLyTfpZrjYV6YtQtWSe8PurUzc/5fA==",
"version": "0.2.26",
"resolved": "https://registry.npmjs.org/@influxdata/influx/-/influx-0.2.26.tgz",
"integrity": "sha512-Zmay0PLHHAATWbRu4uvit6pLDTwy54GlD/V6v1SzbfS1XswhbWZBNXMyALBSN/pWQ/6pafwdotKAK9MqH78Wrg==",
"requires": {
"axios": "^0.18.0"
}
@ -6085,7 +6085,8 @@
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
"integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=",
"dev": true
"dev": true,
"optional": true
},
"aproba": {
"version": "1.2.0",
@ -6109,13 +6110,15 @@
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
"dev": true
"dev": true,
"optional": true
},
"brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"dev": true,
"optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@ -6132,19 +6135,22 @@
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz",
"integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=",
"dev": true
"dev": true,
"optional": true
},
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
"dev": true
"dev": true,
"optional": true
},
"console-control-strings": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz",
"integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=",
"dev": true
"dev": true,
"optional": true
},
"core-util-is": {
"version": "1.0.2",
@ -6275,7 +6281,8 @@
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
"dev": true
"dev": true,
"optional": true
},
"ini": {
"version": "1.3.5",
@ -6289,6 +6296,7 @@
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz",
"integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=",
"dev": true,
"optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
@ -6305,6 +6313,7 @@
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"dev": true,
"optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
@ -6313,13 +6322,15 @@
"version": "0.0.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
"dev": true
"dev": true,
"optional": true
},
"minipass": {
"version": "2.2.4",
"resolved": "https://registry.npmjs.org/minipass/-/minipass-2.2.4.tgz",
"integrity": "sha512-hzXIWWet/BzWhYs2b+u7dRHlruXhwdgvlTMDKC6Cb1U7ps6Ac6yQlR39xsbjWJE377YTCtKwIXIpJ5oP+j5y8g==",
"dev": true,
"optional": true,
"requires": {
"safe-buffer": "^5.1.1",
"yallist": "^3.0.0"
@ -6340,6 +6351,7 @@
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"dev": true,
"optional": true,
"requires": {
"minimist": "0.0.8"
}
@ -6428,7 +6440,8 @@
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz",
"integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=",
"dev": true
"dev": true,
"optional": true
},
"object-assign": {
"version": "4.1.1",
@ -6442,6 +6455,7 @@
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
"dev": true,
"optional": true,
"requires": {
"wrappy": "1"
}
@ -6537,7 +6551,8 @@
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz",
"integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==",
"dev": true
"dev": true,
"optional": true
},
"safer-buffer": {
"version": "2.1.2",
@ -6579,6 +6594,7 @@
"resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz",
"integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=",
"dev": true,
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
@ -6600,6 +6616,7 @@
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
"integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
"dev": true,
"optional": true,
"requires": {
"ansi-regex": "^2.0.0"
}
@ -6648,13 +6665,15 @@
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
"dev": true
"dev": true,
"optional": true
},
"yallist": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.2.tgz",
"integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k=",
"dev": true
"dev": true,
"optional": true
}
}
},

View File

@ -137,7 +137,7 @@
},
"dependencies": {
"@influxdata/clockface": "0.0.5",
"@influxdata/influx": "0.2.21",
"@influxdata/influx": "0.2.26",
"@influxdata/react-custom-scrollbars": "4.3.8",
"axios": "^0.18.0",
"babel-polyfill": "^6.26.0",

View File

@ -1,8 +1,6 @@
import _ from 'lodash'
import {Organization} from 'src/types/v2'
import {ScraperTargetRequest, Task} from '@influxdata/influx'
import {ScraperTargetRequest, Task, ITaskTemplate} from '@influxdata/influx'
import {client} from 'src/utils/api'
import {Template} from 'src/shared/utils/resourceToTemplate'
export enum ActionTypes {
GetTasks = 'GET_TASKS',
@ -21,9 +19,8 @@ export const populateTasks = (tasks: Task[]): PopulateTasks => ({
payload: {tasks},
})
export const getTasks = (org: Organization) => async dispatch => {
const tasks = await client.tasks.getAllByOrg(org.name)
console.log(tasks)
export const getTasks = (orgID: string) => async dispatch => {
const tasks = await client.tasks.getAllByOrgID(orgID)
dispatch(populateTasks(tasks))
}
@ -32,7 +29,7 @@ export const createScraper = (scraper: ScraperTargetRequest) => async () => {
}
export const createTaskFromTemplate = (
template: Template,
template: ITaskTemplate,
orgID: string
) => async dispatch => {
// try catch

View File

@ -52,7 +52,7 @@ class OrgTasksIndex extends Component<Props, State> {
const {getTasks, org} = this.props
await getTasks(org)
await getTasks(org.id)
this.setState({loadingState: RemoteDataState.Done})
}
@ -108,7 +108,7 @@ class OrgTasksIndex extends Component<Props, State> {
private updateTasks = () => {
const {getTasks, org} = this.props
getTasks(org)
getTasks(org.id)
}
}

View File

@ -1,50 +1,27 @@
import _ from 'lodash'
import {getDeep} from 'src/utils/wrappers'
import {Task, Label} from 'src/types/v2'
import {ITemplate, TemplateType} from '@influxdata/influx'
export enum TemplateType {
Label = 'label',
Task = 'task',
const CURRENT_TEMPLATE_VERSION = '1'
const blankTemplate = {
meta: {version: '0.1.0'},
content: {data: {}, included: []},
labels: [],
}
interface KeyValuePairs {
[key: string]: any
}
export interface Template {
meta: TemplateMeta
data: TemplateData[]
included?: TemplateIncluded[]
}
interface TemplateMeta extends KeyValuePairs {
name: string
}
interface TemplateData {
type: TemplateType
attributes: KeyValuePairs
relationships?: {[key in TemplateType]?: {data: RelationshipDataItem[]}}
}
export interface RelationshipDataItem {
type: TemplateType
id: string
}
interface TemplateIncluded {
type: TemplateType
id: string
attributes: KeyValuePairs
}
const blankTemplate = {meta: {version: '0.1.0'}, data: [{}], included: []}
const blankTaskTemplate = {
...blankTemplate,
meta: {
...blankTemplate.meta,
},
content: {
...blankTemplate.content,
data: {...blankTemplate.content.data, type: TemplateType.Task},
},
labels: [
...blankTemplate.labels,
{
id: '1',
name: 'influx.task',
@ -54,11 +31,9 @@ const blankTaskTemplate = {
},
},
],
},
data: [{...blankTemplate.data[0], type: TemplateType.Task}],
}
const labelToRelationship = (l: Label): RelationshipDataItem => {
const labelToRelationship = (l: Label) => {
return {type: TemplateType.Label, id: l.id}
}
@ -66,7 +41,6 @@ const labelToIncluded = (l: Label) => {
return {
type: TemplateType.Label,
id: l.id,
attributes: {
name: l.name,
properties: l.properties,
@ -77,7 +51,7 @@ const labelToIncluded = (l: Label) => {
export const taskToTemplate = (
task: Task,
baseTemplate = blankTaskTemplate
): Template => {
): ITemplate => {
const taskName = _.get(task, 'name', '')
const templateName = `${taskName}-Template`
@ -95,21 +69,25 @@ export const taskToTemplate = (
const relationshipsLabels = labels.map(l => labelToRelationship(l))
const template = {
...baseTemplate,
meta: {
...baseTemplate.meta,
name: templateName,
version: CURRENT_TEMPLATE_VERSION,
description: `template created from task: ${taskName}`,
},
data: [
{
...baseTemplate.data[0],
content: {
...baseTemplate.content,
data: {
...baseTemplate.content.data,
type: TemplateType.Task,
attributes: taskAttributes,
relationships: {
[TemplateType.Label]: {data: relationshipsLabels},
},
},
],
included: [...baseTemplate.included, ...includedLabels],
included: [...baseTemplate.content.included, ...includedLabels],
},
}
return template