-
Notifications
You must be signed in to change notification settings - Fork 67
feat: set image thumbnail to show as preview in analysis tab #2671
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
base: main
Are you sure you want to change the base?
Changes from all commits
46138d7
f5214f7
05402c6
fe6b5ba
d4c0fb6
738d8fb
92fa20f
f0d43c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,7 @@ def extended_metadata | |
| metadata[:kind] = object.extended_metadata['kind'] | ||
| metadata[:index] = object.extended_metadata['index'] | ||
| metadata[:instrument] = object.extended_metadata['instrument'] | ||
| metadata[:preferred_thumbnail] = object.extended_metadata['preferred_thumbnail'] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/PerceivedComplexity: Perceived complexity for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/BlockLength: Block has too many lines. [26/25] |
||
| if object.extended_metadata['content'].present? | ||
| metadata[:content] = | ||
| JSON.parse(object.extended_metadata['content']) | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -106,15 +106,39 @@ export default class Header extends React.Component { | |||||
|
|
||||||
| // eslint-disable-next-line class-methods-use-this | ||||||
| renderImagePreview = () => { | ||||||
| const { container } = this.props; | ||||||
| const { container, handleChange } = this.props; | ||||||
| const attachment = getAttachmentFromContainer(container); | ||||||
| // Build list of saved, non-deleted attachment IDs (exclude is_new which don't have server IDs yet) | ||||||
| const allAttachments = container?.children?.flatMap((child) => (child.attachments || [])) || []; | ||||||
| const savedAttachments = allAttachments.filter((att) => !att.is_deleted && !att.is_new); | ||||||
| const attachmentsIds = savedAttachments | ||||||
| .map((att) => Number(att.id)) | ||||||
| .filter((id) => !Number.isNaN(id) && id > 0); | ||||||
| // Get current preferred thumbnail (reassignment is handled by ContainerDatasets on deletion) | ||||||
| const preferredThumbnail = container?.extended_metadata?.preferred_thumbnail || null; | ||||||
|
|
||||||
| const onChangePreferredThumbnail = (currentPreferredThumbnail) => { | ||||||
| if (currentPreferredThumbnail !== preferredThumbnail) { | ||||||
| // Handle the change of preferred thumbnail | ||||||
|
||||||
| // Handle the change of preferred thumbnail | |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -15,7 +15,7 @@ import { StoreContext } from 'src/stores/mobx/RootStore'; | |||||
| import UIStore from 'src/stores/alt/stores/UIStore'; | ||||||
| import UserStore from 'src/stores/alt/stores/UserStore'; | ||||||
|
|
||||||
| const AnalysisHeader = ({ container, readonly }) => { | ||||||
| function AnalysisHeader({ container, readonly }) { | ||||||
| const deviceDescriptionsStore = useContext(StoreContext).deviceDescriptions; | ||||||
| const deviceDescription = deviceDescriptionsStore.device_description; | ||||||
|
|
||||||
|
|
@@ -156,6 +156,26 @@ const AnalysisHeader = ({ container, readonly }) => { | |||||
| }), | ||||||
| }; | ||||||
| const attachment = getAttachmentFromContainer(container); | ||||||
| // Build list of non-deleted attachment IDs | ||||||
| const allAttachments = container?.children?.flatMap((child) => (child.attachments || [])) || []; | ||||||
| // Filter: exclude deleted and is_new attachments (is_new don't have server IDs yet) | ||||||
| const savedAttachments = allAttachments.filter((att) => !att.is_deleted && !att.is_new); | ||||||
| const attachmentsIds = savedAttachments | ||||||
| .map((att) => Number(att.id)) | ||||||
| .filter((id) => !Number.isNaN(id) && id > 0); | ||||||
| // Get current preferred thumbnail (reassignment is handled by ContainerDatasets on deletion) | ||||||
| const preferredThumbnail = container?.extended_metadata?.preferred_thumbnail || null; | ||||||
|
|
||||||
| const onChangePreferredThumbnail = (currentPreferredThumbnail) => { | ||||||
| if (currentPreferredThumbnail !== preferredThumbnail) { | ||||||
| // Handle the change of preferred thumbnail | ||||||
|
||||||
| // Handle the change of preferred thumbnail | |
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -203,6 +203,25 @@ export default class ResearchPlanDetailsContainers extends Component { | |||
| }), | ||||
| }; | ||||
| const attachment = getAttachmentFromContainer(container); | ||||
| // Build list of saved, non-deleted attachment IDs (exclude is_new which don't have server IDs yet) | ||||
| const allAttachments = container?.children?.flatMap((child) => (child.attachments || [])) || []; | ||||
| const savedAttachments = allAttachments.filter((att) => !att.is_deleted && !att.is_new); | ||||
| const attachmentsIds = savedAttachments | ||||
| .map((att) => Number(att.id)) | ||||
| .filter((id) => !Number.isNaN(id) && id > 0); | ||||
| // Get current preferred thumbnail (reassignment is handled by ContainerDatasets on deletion) | ||||
| const preferredThumbnail = container?.extended_metadata?.preferred_thumbnail || null; | ||||
|
|
||||
| const onChangePreferredThumbnail = (currentPreferredThumbnail) => { | ||||
| if (currentPreferredThumbnail !== preferredThumbnail) { | ||||
| // Handle the change of preferred thumbnail | ||||
|
||||
| // Handle the change of preferred thumbnail |
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -188,10 +188,18 @@ const headerBtnGroup = ( | |||
| ); | ||||
| }; | ||||
|
|
||||
| const AnalysesHeader = ({ | ||||
| sample, container, mode, readOnly, isDisabled, handleRemove, handleUndo, handleSubmit, toggleAddToReport, | ||||
| }) => { | ||||
|
|
||||
| function AnalysesHeader({ | ||||
| sample, | ||||
| container, | ||||
| mode, | ||||
| readOnly, | ||||
| isDisabled, | ||||
| handleRemove, | ||||
| handleUndo, | ||||
| handleSubmit, | ||||
| toggleAddToReport, | ||||
| updateContainerPreferredThumbnail, | ||||
| }) { | ||||
| let kind = container.extended_metadata.kind || ''; | ||||
| kind = (kind.split('|')[1] || kind).trim(); | ||||
| const deleted = container.is_deleted; | ||||
|
|
@@ -205,20 +213,43 @@ const AnalysesHeader = ({ | |||
| return c; | ||||
| }), | ||||
| }; | ||||
| const attachment = getAttachmentFromContainer(container); | ||||
|
|
||||
| const attachment = getAttachmentFromContainer(container); | ||||
| // Build list of saved, non-deleted attachment IDs (exclude is_new which don't have server IDs yet) | ||||
| const allAttachments = container?.children?.flatMap((child) => (child.attachments || [])) || []; | ||||
| const savedAttachments = allAttachments.filter((att) => !att.is_deleted && !att.is_new); | ||||
| const attachmentsIds = savedAttachments | ||||
| .map((att) => Number(att.id)) | ||||
| .filter((id) => !Number.isNaN(id) && id > 0); | ||||
| // Get current preferred thumbnail (reassignment is handled by ContainerDatasets on deletion) | ||||
| const preferredThumbnail = container?.extended_metadata?.preferred_thumbnail || null; | ||||
|
|
||||
| const onChangePreferredThumbnail = (currentPreferredThumbnail) => { | ||||
| if (currentPreferredThumbnail !== preferredThumbnail) { | ||||
| // Handle the change of preferred thumbnail | ||||
|
||||
| // Handle the change of preferred thumbnail |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/CyclomaticComplexity: Cyclomatic complexity for
extended_metadatais too high. [9/7]