-
Notifications
You must be signed in to change notification settings - Fork 398
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE-BRANCH] ImageField: add support to new fields of type image (#…
…5279) # Description This PR is the first one related with the addition of a new field of type `image` including the following changes: * Changes in the backend to support a new `image` field type supporting URLs and Data URLs. * Changes in the frontend rendering this new `image` field for records. * Changes in the SDK to define datasets with `image` fields and create records specifying images. * Changes in the documentation with examples on how to use the SDK with this new type of field. This new type will have the following characteristics: * A new filed type `image` is supported (without additional settings). * Records created with fields of type `image` are validated to have correct Web URLs or data URLs like: * `https://argilla.io/image.jpeg`: * `HTTPS` schema is present * A host and a path is present. * The URL is not longer than `2038` characters. * `http://argilla.io/image.jpeg`: * `HTTP` schema is present * A host and a path is present. * The URL is not longer than `2038` characters. * `data:image/webp;base64,UklGRhgCAABXRUJQVlA4WA`: * `data` schema is present * A path is present. * The Data URL is not longer than `5` million characters. * A valid MIME type is present. Closes #5276 **Type of change** - New feature (non-breaking change which adds functionality) **How Has This Been Tested** - [x] Adding new tests to our suite checking this new field. **Checklist** - I added relevant documentation - I followed the style guidelines of this project - I did a self-review of my code - I made corresponding changes to the documentation - I confirm My changes generate no new warnings - I have added tests that prove my fix is effective or that my feature works - I have added relevant notes to the CHANGELOG.md file (See https://keepachangelog.com/) --------- Co-authored-by: Paco Aranda <[email protected]> Co-authored-by: burtenshaw <[email protected]> Co-authored-by: David Berenstein <[email protected]> Co-authored-by: Ben Burtenshaw <[email protected]> Co-authored-by: Damián Pumar <[email protected]> Co-authored-by: Leire Aguirre <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Francisco Aranda <[email protected]>
- Loading branch information
1 parent
745e57b
commit 0f05270
Showing
46 changed files
with
2,903 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
argilla-frontend/components/features/annotation/container/fields/image-field/ImageField.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<template> | ||
<div class="image_field" :key="content"> | ||
<span class="image_field_title" v-text="title" /> | ||
<template v-if="!hasError"> | ||
<BaseSpinner v-if="!isLoaded" /> | ||
<img | ||
v-show="isLoaded" | ||
:src="content" | ||
@error="handleError()" | ||
@load="onLoad()" | ||
/> | ||
</template> | ||
<div v-else class="image_field_placeholder"> | ||
<img src="images/img-placeholder.svg" /> | ||
<p v-text="$t('couldNotLoadImage')" /> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
props: { | ||
name: { | ||
type: String, | ||
required: true, | ||
}, | ||
title: { | ||
type: String, | ||
required: true, | ||
}, | ||
content: { | ||
type: String, | ||
required: true, | ||
}, | ||
}, | ||
data() { | ||
return { | ||
hasError: false, | ||
isLoaded: false, | ||
}; | ||
}, | ||
methods: { | ||
handleError() { | ||
this.hasError = true; | ||
}, | ||
onLoad() { | ||
this.isLoaded = true; | ||
}, | ||
}, | ||
}; | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
.image_field { | ||
$this: &; | ||
display: flex; | ||
flex-direction: column; | ||
min-height: 100%; | ||
min-width: 100%; | ||
height: fit-content; | ||
width: fit-content; | ||
gap: $base-space * 2; | ||
padding: 2 * $base-space; | ||
background: palette(grey, 800); | ||
border-radius: $border-radius-m; | ||
&_placeholder { | ||
display: flex; | ||
flex-direction: column; | ||
width: 300px; | ||
max-width: 100%; | ||
margin: auto; | ||
align-items: center; | ||
color: $black-37; | ||
} | ||
img { | ||
max-width: fit-content; | ||
max-height: fit-content; | ||
height: fit-content; | ||
width: fit-content; | ||
} | ||
&_title { | ||
word-break: break-word; | ||
width: calc(100% - 30px); | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
|
||
class FieldType(str, Enum): | ||
text = "text" | ||
image = "image" | ||
|
||
|
||
class ResponseStatus(str, Enum): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.