Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions backend/app/models/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class FileVersion(MongoModel):
version_num: int = 1
file_id: PyObjectId
creator: UserOut
bytes: int = 0
content_type: str = "N/A"
created: datetime = Field(default_factory=datetime.utcnow)


Expand All @@ -33,6 +35,8 @@ class FileDB(FileBase):
folder_id: Optional[PyObjectId]
views: int = 0
downloads: int = 0
bytes: int = 0
content_type: str = "N/A"


class FileOut(FileDB):
Expand Down
6 changes: 6 additions & 0 deletions backend/app/routers/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,11 +316,15 @@ async def save_file(
part_size=settings.MINIO_UPLOAD_CHUNK_SIZE,
) # async write chunk to minio
version_id = response.version_id
bytes = len(fs.get_object(settings.MINIO_BUCKET_NAME, str(new_file_id)).data)
content_type = file.content_type
if version_id is None:
# TODO: This occurs in testing when minio is not running
version_id = 999999999
fileDB.version_id = version_id
fileDB.version_num = 1
fileDB.bytes = bytes
fileDB.content_type = content_type
print(fileDB)
await db["files"].replace_one({"_id": ObjectId(new_file_id)}, fileDB.to_mongo())

Expand All @@ -329,6 +333,8 @@ async def save_file(
version_id=version_id,
file_id=new_file_id,
creator=user,
bytes=bytes,
content_type=content_type
)
await db["file_versions"].insert_one(new_version.to_mongo())
return fileDB
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/components/files/FileAbout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type FileAboutProps = {
}

export function FileAbout(props: FileAboutProps) {
const {id, created, name, creator, version_id} = props.fileSummary;
const {id, created, name, creator, version_id, bytes, content_type} = props.fileSummary;

return (
<Box className="infoCard">
Expand All @@ -19,6 +19,8 @@ export function FileAbout(props: FileAboutProps) {
<Typography className="content">Uploaded as: {name}</Typography>
<Typography className="content">Uploaded by: {creator.first_name} {creator.last_name}</Typography>
<Typography className="content">Latest Version: {version_id}</Typography>
<Typography className="content">Size: {bytes} bytes</Typography>
<Typography className="content">Content Type: {content_type}</Typography>
</Box>
);
}
Expand Down
9 changes: 4 additions & 5 deletions frontend/src/components/files/FilesTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ export default function FilesTable(props: FilesTableProps) {
<TableRow>
<TableCell>Name</TableCell>
<TableCell align="right">Updated</TableCell>
{/*<TableCell align="right">Size</TableCell>*/}
{/*<TableCell align="right">Type</TableCell>*/}
<TableCell align="right">Size</TableCell>
<TableCell align="right">Type</TableCell>
<TableCell align="right"></TableCell>
</TableRow>
</TableHead>
Expand Down Expand Up @@ -83,9 +83,8 @@ export default function FilesTable(props: FilesTableProps) {
<VersionChip versionNumber={file.version_num}/>
</TableCell>
<TableCell align="right">{parseDate(file.created)} by {file.creator.first_name} {file.creator.last_name}</TableCell>
{/*TODO we don't have those in backend yet*/}
{/*<TableCell align="right">{file.size}</TableCell>*/}
{/*<TableCell align="right">{file.contentType}</TableCell>*/}
<TableCell align="right">{file.bytes} bytes</TableCell>
<TableCell align="right">{file.content_type}</TableCell>
<TableCell align="right"><FileMenu file={file}/></TableCell>
</TableRow>))
}
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/openapi/v2/models/FileOut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ export type FileOut = {
folder_id?: string;
views?: number;
downloads?: number;
bytes?: number;
content_type?: string;
}
2 changes: 2 additions & 0 deletions frontend/src/openapi/v2/models/FileVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ export type FileVersion = {
version_num?: number;
file_id: string;
creator: UserOut;
bytes?: number;
content_type?: string;
created?: string;
}
18 changes: 18 additions & 0 deletions frontend/src/openapi/v2/services/FilesService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,22 @@ export class FilesService {
});
}

/**
* Get File Extract
* @param fileId
* @returns any Successful Response
* @throws ApiError
*/
public static getFileExtractApiV2FilesFileIdExtractPost(
fileId: string,
): CancelablePromise<any> {
return __request({
method: 'POST',
path: `/api/v2/files/${fileId}/extract`,
errors: {
422: `Validation Error`,
},
});
}

}
19 changes: 19 additions & 0 deletions frontend/src/openapi/v2/services/MetadataService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,25 @@ export class MetadataService {
});
}

/**
* Delete Metadata
* Delete metadata by specific ID.
* @param metadataId
* @returns any Successful Response
* @throws ApiError
*/
public static deleteMetadataApiV2MetadataMetadataIdDelete(
metadataId: string,
): CancelablePromise<any> {
return __request({
method: 'DELETE',
path: `/api/v2/metadata/${metadataId}`,
errors: {
422: `Validation Error`,
},
});
}

/**
* Update Metadata
* Update metadata. Any fields provided in the contents JSON will be added or updated in the metadata. If context or
Expand Down