Skip to content

Commit

Permalink
Merge pull request #86 from arayabrain/feature/check_role
Browse files Browse the repository at this point in the history
Add Permission Role
  • Loading branch information
itutu-tienday authored Aug 4, 2023
2 parents 5e972c1 + 916a91e commit 4279938
Show file tree
Hide file tree
Showing 32 changed files with 823 additions and 418 deletions.
12 changes: 12 additions & 0 deletions frontend/src/@types/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export const enum ROLE {
ADMIN = 1,
MANAGER = 10,
OPERATOR = 20,
GUEST_OPERATOR = 30
}

export const enum SHARE {
NOSHARE = 0,
ORGANIZATION = 2,
USERS = 1,
}
11 changes: 11 additions & 0 deletions frontend/src/api/Workspace/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import axios from 'utils/axios'
import qs from 'qs'
import { ItemsWorkspace, WorkspaceDataDTO } from 'store/slice/Workspace/WorkspaceType'
import { ListShareDTO } from 'store/slice/Database/DatabaseType';

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

Expand Down Expand Up @@ -40,3 +41,13 @@ export const exportWorkspaceApi = async (id: number): Promise<void> => {
const response = await axios.get(`/workspace/export/${id}`)
return response.data
}

export const getListUserShareWorkspaceApi = async (id: number): Promise<ListShareDTO> => {
const response = await axios.get(`/workspace/share/${id}/status`)
return response.data
}

export const postListUserShareWorkspaceApi = async (id: number, data: {user_ids: number[]}): Promise<boolean> => {
const response = await axios.post(`/workspace/share/${id}/status`, data)
return response.data
}
22 changes: 16 additions & 6 deletions frontend/src/api/database/index.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,42 @@
import { DatabaseParams } from 'store/slice/Database/DatabaseType'
import { DatabaseDTO, DatabaseParams, ListShareDTO } from 'store/slice/Database/DatabaseType'
import axios from 'utils/axios'
import qs from 'qs'

export const getExperimentsPublicApi = async (params: DatabaseParams) => {
export const getExperimentsPublicApi = async (params: DatabaseParams): Promise<DatabaseDTO> => {
const paramsNew = qs.stringify(params, { indices: false })
const response = await axios.get(`/public/experiments?${paramsNew}`)
return response.data
}

export const getCellsPublicApi = async (params: DatabaseParams) => {
export const getCellsPublicApi = async (params: DatabaseParams): Promise<DatabaseDTO> => {
const paramsNew = qs.stringify(params, { indices: false })
const response = await axios.get(`/public/cells?${paramsNew}`)
return response.data
}

export const getExperimentsApi = async (params: DatabaseParams) => {
export const getExperimentsApi = async (params: DatabaseParams): Promise<DatabaseDTO> => {
const paramsNew = qs.stringify(params, { indices: false })
const response = await axios.get(`/expdb/experiments?${paramsNew}`)
return response.data
}

export const getCellsApi = async (params: DatabaseParams) => {
export const getCellsApi = async (params: DatabaseParams): Promise<DatabaseDTO> => {
const paramsNew = qs.stringify(params, { indices: false })
const response = await axios.get(`/expdb/cells?${paramsNew}`)
return response.data
}

export const postPublistApi = async (id: number, status: 'on' | 'off') => {
export const postPublistApi = async (id: number, status: 'on' | 'off'): Promise<boolean> => {
const response = await axios.post(`/expdb/experiment/publish/${id}/${status}`)
return response.data
}

export const getListUserShareApi = async (id: number): Promise<ListShareDTO> => {
const response = await axios.get(`/expdb/share/${id}/status`)
return response.data
}

export const postListUserShareApi = async (id: number, data: {share_type: number; user_ids: number[]}): Promise<boolean> => {
const response = await axios.post(`/expdb/share/${id}/status`, data)
return response.data
}
5 changes: 5 additions & 0 deletions frontend/src/api/users/UsersAdmin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,8 @@ export const deleteUserApi = async (uid: string): Promise<string> => {
const response = await axios.delete(`/admin/users/${uid}`)
return response.data
}

export const getListSearchApi = async (data: {keyword: string | null}): Promise<UserDTO[]> => {
const response = await axios.get(`/users/search/share_users${data.keyword ? `?keyword=${data.keyword}` : ''}`)
return response.data
}
9 changes: 7 additions & 2 deletions frontend/src/api/users/UsersApiDTO.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
export type UserDTO = {
id: number
uid: string
uid?: string
email: string
id?: number
name?: string
organization_id?: number
role_id?: number
create_at?: string
update_at?: string
}

export type AddUserDTO = {
Expand Down
5 changes: 2 additions & 3 deletions frontend/src/components/Database/DatabaseCells.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,8 @@ const columns = (handleOpenDialog: (value: ImageUrls[], expId?: string) => void)
width={'100%'}
height={'100%'}
/>
</Box>
)
},
</Box>
)}
},
]

Expand Down
Loading

0 comments on commit 4279938

Please sign in to comment.