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

integrate api workspaces #81

Merged
merged 30 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
3c36a35
integrate API
sanglevinh Jul 25, 2023
baa511c
integrate edit name
sanglevinh Jul 25, 2023
0bc5f8c
join WorkspacesShareUser in search workspaces API
quanpython Jul 25, 2023
f4fa20b
Merge branch 'develop-main' into feature/workspaces
sanglevinh Jul 25, 2023
b819078
Merge branch 'feature/workspace-api' into feature/workspaces
quanpython Jul 25, 2023
7d91778
fix user
sanglevinh Jul 26, 2023
58ee990
Merge remote-tracking branch 'origin/feature/workspaces' into feature…
sanglevinh Jul 26, 2023
ab96476
Merge branch 'develop-main' into feature/workspaces
sanglevinh Jul 26, 2023
227f1af
add pagination
sanglevinh Jul 26, 2023
f36fa61
fix filter database
sanglevinh Jul 26, 2023
40a1089
add api download
sanglevinh Jul 26, 2023
c631f03
fix alert and add moment fix format create at
sanglevinh Jul 27, 2023
50eb92f
fix bug edit name
sanglevinh Jul 27, 2023
a031561
reset value name when name is empty
sanglevinh Jul 27, 2023
69cf53d
fix bug
sanglevinh Jul 27, 2023
3234be3
fix format date
sanglevinh Jul 27, 2023
ef4f09e
Add edit row with single click in workspace Page, add isAnyOf in Work…
sanglevinh Jul 28, 2023
6d73d31
remove any type
sanglevinh Jul 28, 2023
0bec77a
remove user_id in workspace.py
sanglevinh Jul 28, 2023
4dcc382
remove any type
sanglevinh Jul 28, 2023
b17a3ac
add isAnyOfin database
sanglevinh Jul 28, 2023
60b69a8
rename DataRequestEdit to WorkspacePostDataDTO, remove delWorkspace.f…
sanglevinh Jul 28, 2023
5a5e573
add type return getWorkspacesApi
sanglevinh Jul 28, 2023
a09e3c7
rollback user_id to Workspace(BaseModel)
sanglevinh Jul 28, 2023
7f1ed43
validate Workspace Name
sanglevinh Jul 31, 2023
737397b
fix edit name
sanglevinh Jul 31, 2023
84d7fa9
fix button icon
sanglevinh Jul 31, 2023
9a0fddf
fix background color button edit
sanglevinh Jul 31, 2023
96cdf7d
fix onblur row
sanglevinh Jul 31, 2023
819f592
add onCellClick. cancel edit name
sanglevinh Jul 31, 2023
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 frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"axios": "^0.21.1",
"colormap": "^2.3.2",
"flexlayout-react": "^0.5.12",
"moment": "^2.29.4",
"notistack": "^2.0.3",
"plotly.js": "^2.6.0",
"qs": "^6.11.2",
Expand Down
38 changes: 38 additions & 0 deletions frontend/src/api/Workspace/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import axios from "utils/axios"
import qs from 'qs'

export type Data = {
name?: string
id?: number
}
ReiHashimoto marked this conversation as resolved.
Show resolved Hide resolved

export const getWorkspacesApi = async (params: { [key: string]: number}) => {
const paramsNew = qs.stringify(params, { indices: false })
const response = await axios.get(`/workspaces?${paramsNew}`)
return response.data
}

export const delWorkspaceApi = async (id: number) => {
const response = await axios.delete(`/workspace/${id}`)
return response.data
}

export const postWorkspaceApi = async (data: Data) => {
const response = await axios.post(`/workspace`, data)
return response.data
}

export const putWorkspaceApi = async (data: Data) => {
const response = await axios.put(`/workspace/${data.id}`, {name: data.name})
return response.data
}

export const importWorkspaceApi = async (data: Object) => {
const response = await axios.post(`/workspace/import`, {todo_dummy: data})
return response.data
}

export const exportWorkspaceApi = async (id: number) => {
const response = await axios.get(`/workspace/export/${id}`)
return response.data
}
1 change: 1 addition & 0 deletions frontend/src/api/users/UsersApiDTO.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export type UserDTO = {
id: number
uid: string
email: string
}
Expand Down
36 changes: 14 additions & 22 deletions frontend/src/components/Database/DatabaseCells.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,23 +124,23 @@ const DatabaseCells = ({ user }: CellProps) => {

const dataParamsFilter = useMemo(
() => ({
brain_area: searchParams.get('brain_area') || '',
cre_driver: searchParams.get('cre_driver') || '',
reporter_line: searchParams.get('reporter_line') || '',
brain_area: searchParams.get('brain_area') || undefined,
cre_driver: searchParams.get('cre_driver') || undefined,
reporter_line: searchParams.get('reporter_line') || undefined,
imaging_depth: Number(searchParams.get('imaging_depth')) || undefined,
}),
[searchParams],
)

const fetchApi = () => {
const api = !user ? getCellsPublicDatabase : getCellsDatabase
dispatch(api(dataParams))
dispatch(api({...dataParamsFilter, ...dataParams}))
}

useEffect(() => {
fetchApi()
//eslint-disable-next-line
}, [dataParams, user])
}, [dataParams, user, dataParamsFilter])

const handleOpenDialog = (data: string[]) => {
setDataDialog({ type: 'image', data })
Expand Down Expand Up @@ -181,30 +181,22 @@ const DatabaseCells = ({ user }: CellProps) => {
)

const handleFilter = (
model: GridFilterModel | any,
details: GridCallbackDetails,
model: GridFilterModel | any,
details: GridCallbackDetails,
) => {
let filter: string
if (!!model.items[0]?.value) {
//todo multiple filter with version pro. Issue task #55
filter = model.items
.filter((item: { [key: string]: string }) => item.value)
.map((item: any) => {
return `${item.field}=${item?.value}`
})
.join('&')
.filter((item: { [key: string]: string }) => item.value)
.map((item: any) => {
return `${item.field}=${item?.value}`
})
.join('&')
} else {
filter = ''
}
if (!model.items[0]) {
setParams(
`${filter}&sort=${dataParams.sort[0]}&sort=${dataParams.sort[1]}&${pagiFilter}`,
)
return
}
setParams(
`${filter}&sort=${dataParams.sort[0]}&sort=${dataParams.sort[1]}&${pagiFilter}`,
)
const {sort} = dataParams
setParams(`${filter}&sort=${sort[0] || ''}&sort=${sort[1] || ''}&${pagiFilter}`)
}

const getColumns = useMemo(() => {
Expand Down
Loading