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 all 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
42 changes: 42 additions & 0 deletions frontend/src/api/Workspace/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import axios from 'utils/axios'
import qs from 'qs'
import { ItemsWorkspace, WorkspaceDataDTO } from 'store/slice/Workspace/WorkspaceType'

export type WorkspacePostDataDTO = { name: string; id?: number }

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

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

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

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

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

export const exportWorkspaceApi = async (id: number): Promise<void> => {
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
60 changes: 25 additions & 35 deletions frontend/src/components/Database/DatabaseCells.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { ChangeEvent, useCallback, useEffect, useMemo, useState } from 'react'
import { useSearchParams } from 'react-router-dom'
import DialogImage from '../common/DialogImage'
import {
GridCallbackDetails,
GridEnrichedColDef,
GridFilterModel,
GridSortDirection,
Expand Down Expand Up @@ -63,24 +62,26 @@ const columns = (handleOpenDialog: (value: string[]) => void) => [
width: 160,
filterable: false,
sortable: false,
renderCell: (params: { row: DatabaseType }) => (
<Box
sx={{
cursor: 'pointer',
display: 'flex',
}}
onClick={() => params.row?.cell_image_url && handleOpenDialog([params.row.cell_image_url])}
>
{params.row?.cell_image_url && (
renderCell: (params: { row: DatabaseType }) => {
const { cell_image_url } = params.row
if (!cell_image_url) return null
return (
<Box
sx={{
cursor: 'pointer',
display: 'flex',
}}
onClick={() => handleOpenDialog([cell_image_url])}
>
<img
src={params.row?.cell_image_url}
alt={''}
width={'100%'}
height={'100%'}
/>
)}
</Box>
),
</Box>
)
},
},
]

Expand Down Expand Up @@ -124,23 +125,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 @@ -180,30 +181,19 @@ const DatabaseCells = ({ user }: CellProps) => {
[pagiFilter, getParamsData],
)

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

Expand All @@ -219,7 +209,7 @@ const DatabaseCells = ({ user }: CellProps) => {
<Box sx={{ display: 'flex' }}>
{params.row.graph_urls?.[index]?.[0] ? (
<img
src={params.row.graph_urls?.[index]?.[0] }
src={params.row.graph_urls?.[index]?.[0]}
alt={''}
width={'100%'}
height={'100%'}
Expand Down
20 changes: 8 additions & 12 deletions frontend/src/components/Database/DatabaseExperiments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import DialogContent from '@mui/material/DialogContent'
import DialogContentText from '@mui/material/DialogContentText'
import SwitchCustom from '../common/SwitchCustom'
import {
GridCallbackDetails,
GridEnrichedColDef,
GridFilterModel,
GridSortDirection,
Expand Down Expand Up @@ -262,7 +261,7 @@ const DatabaseExperiments = ({ user, cellPath }: DatabaseProps) => {
}

const handleChangeAttributes = (event: any) => {
setDataDialog(pre => ({...pre, data: event.target.value}))
setDataDialog((pre) => ({ ...pre, data: event.target.value }))
}

const getParamsData = () => {
Expand Down Expand Up @@ -305,23 +304,20 @@ const DatabaseExperiments = ({ user, cellPath }: DatabaseProps) => {
[pagiFilter, getParamsData],
)

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

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