Skip to content
This repository was archived by the owner on May 8, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
27a7852
auto completion work
alexisvisco Apr 10, 2019
dc8fbbb
add esc sequence to hide auto completions.
alexisvisco Apr 10, 2019
5b87188
add arrow navigation.
alexisvisco Apr 10, 2019
98654c7
change let to const.
alexisvisco Apr 10, 2019
14d85c7
refactor event.
alexisvisco Apr 10, 2019
e158272
tab hide.
alexisvisco Apr 10, 2019
2c9258e
auto completion work in any cases.
alexisvisco Apr 10, 2019
8bbdc21
tags working
alexisvisco Apr 11, 2019
9764f17
tags work, missing focus
alexisvisco Apr 11, 2019
eb9bcac
fix input width
alexisvisco Apr 11, 2019
4c04cb8
fix esc with tags, need to add tabs
alexisvisco Apr 11, 2019
f7d1aae
add focus to tags component
alexisvisco Apr 11, 2019
6761e74
fix focus, add tabulation on next tags
alexisvisco Apr 11, 2019
8cdb19d
add render function and optional parameters
alexisvisco Apr 11, 2019
b22eaa1
tag input is okay
alexisvisco Apr 12, 2019
9d3c2eb
add auto completion input
alexisvisco Apr 12, 2019
08d992c
add to NewContainer debug
alexisvisco Apr 12, 2019
6d868d9
add header to ListImage
alexisvisco Apr 12, 2019
4534031
start to fix
remicaumette Apr 13, 2019
253d5c1
rewrite with reducer
remicaumette Apr 13, 2019
0ba0b5b
add error on formgroup
remicaumette Apr 14, 2019
9ba9c09
refactor account route
remicaumette Apr 15, 2019
f478f84
add redux and account reducer
remicaumette Apr 16, 2019
5e5fd68
add navbar dropdown
remicaumette Apr 16, 2019
79f98b3
update new container
remicaumette Apr 17, 2019
29fad62
update client
remicaumette Apr 17, 2019
0db4eb5
convert to api response
remicaumette Apr 18, 2019
17d56f0
update
remicaumette Apr 18, 2019
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,031 changes: 821 additions & 210 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
"react": "^16.8.1",
"react-dom": "^16.8.1",
"react-router-dom": "^4.3.1",
"react-timeago": "^4.3.0"
"react-timeago": "^4.3.0",
"redux": "^4.0.1",
"redux-react-hook": "^3.3.1"
},
"eslintConfig": {
"extends": "react-app"
Expand Down
104 changes: 0 additions & 104 deletions src/client.ts

This file was deleted.

48 changes: 48 additions & 0 deletions src/client/account.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { ApiResponse, client, remapFields } from "./index"

export interface Account {
id: string
name: string
email: string
avatarUrl: string
apiKey: string
admin: boolean
createdAt: Date
}

const toAccount = (data: object): Account => {
const account = remapFields(data, {
avatar_url: "avatarUrl",
api_key: "apiKey",
created_at: "createdAt",
})
account.createdAt = new Date(account.createdAt)
return account
}

export const getAccount = (): Promise<ApiResponse<Account>> =>
client.get("/v1/account")
.then((res) => {
if (res.status !== 200) {
return { status: res.status, error: res.data }
}
return { status: res.status, data: toAccount(res.data.account) }
})

export const syncAccount = (): Promise<ApiResponse<Account>> =>
client.post("/v1/account/sync")
.then((res) => {
if (res.status !== 200) {
return { status: res.status, error: res.data }
}
return { status: res.status, data: toAccount(res.data.account) }
})

export const regenerateApiKey = (): Promise<ApiResponse<Account>> =>
client.post("/v1/account/regenerate_apikey")
.then((res) => {
if (res.status !== 200) {
return { status: res.status, error: res.data }
}
return { status: res.status, data: toAccount(res.data.account) }
})
45 changes: 45 additions & 0 deletions src/client/container.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { ApiResponse, client, remapFields } from "./index"

export interface Container {
id: string
name: string
status: string
image: string
endpoint: string
memory: number
tags: string[]
createdAt: Date
}

const toContainer = (data: object): Container => {
const container = remapFields(data, {
created_at: "createdAt",
})
container.createdAt = new Date(container.createdAt)
return container
}

export const getContainers = (): Promise<ApiResponse<Container[]>> =>
client.get("/v1/containers")
.then((res) => {
if (res.status !== 200) {
return { status: res.status, error: res.data }
}
return { status: res.status, data: res.data.containers.map((data: object) => toContainer(data)) }
})

export interface CreateContainerRequest {
name: string
image: string
size: string
tags: string[]
}

export const createContainer = (req: CreateContainerRequest): Promise<ApiResponse<Container>> =>
client.post("/v1/containers", req)
.then((res) => {
if (res.status !== 200) {
return { status: res.status, error: res.data }
}
return { status: res.status, data: toContainer(res.data.container) }
})
22 changes: 22 additions & 0 deletions src/client/image.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { ApiResponse, client, remapFields } from "./index"

export interface ImageSummary {
name: string
tag: string
namespaceId: string
lastPush: Date
}

const toImageSummary = (data: object): ImageSummary =>
remapFields(data, {
namespace_id: "namespaceId",
last_push: "lastPush",
})

export const getImages = (): Promise<ApiResponse<ImageSummary[]>> =>
client.get("/v1/images").then((res) => {
if (res.status !== 200) {
return { status: res.status, error: res.data }
}
return { status: res.status, data: res.data.images.map((data: object) => toImageSummary(data)) }
})
32 changes: 32 additions & 0 deletions src/client/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import axios from "axios"
import * as container from "./container"
import * as account from "./account"
import * as image from "./image"

export const client = axios.create({
baseURL: process.env.API_URL || "http://localhost:3000",
transformRequest(data, headers) {
headers.Authorization = document.cookie.split("=")[1]
return data
},
validateStatus() {
return true
},
})

export const remapFields = (obj: any, fields: any): any =>
Object.entries(obj)
.map(([key, value]) => [fields[key] || key, value])
.reduce((prev, [key, value]) => ({ ...prev, [key]: value }), {})

export interface ApiResponse<T> {
status: number
data?: T
error?: {
message: string
fields?: object
}
}
const a = { ...container, ...account, ...image }
console.log(a)
export default a
1 change: 1 addition & 0 deletions src/client/plan.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default () => {}
Loading