1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-19 13:54:25 +01:00

(bug) broken display of machines pages

This commit is contained in:
Sylvain 2022-11-21 15:22:23 +01:00
parent 451cd0e915
commit b2540a1cd4
5 changed files with 15 additions and 9 deletions

View File

@ -1,5 +1,6 @@
# Changelog Fab-manager
- Fix a bug: broken display of machines pages
- Fix a bug: some automated tests were randomly failing because ElasticSearch was not synced
## v5.5.4 2022 November 17

View File

@ -44,12 +44,12 @@ const MachineCard: React.FC<MachineCardProps> = ({ user, machine, onShowMachine,
* Return the machine's picture or a placeholder
*/
const machinePicture = (): ReactNode => {
if (!machine.machine_image_attributes) {
if (!machine.machine_image) {
return <div className="machine-picture no-picture" />;
}
return (
<div className="machine-picture" style={{ backgroundImage: `url(${machine.machine_image_attributes.attachment_url}), url('/default-image.png')` }} onClick={handleShowMachine} />
<div className="machine-picture" style={{ backgroundImage: `url(${machine.machine_image}), url('/default-image.png')` }} onClick={handleShowMachine} />
);
};

View File

@ -1,6 +1,5 @@
import { Reservation } from './reservation';
import { ApiFilter } from './api';
import { FileType } from './file';
export interface MachineIndexFilter extends ApiFilter {
disabled: boolean,
@ -13,8 +12,12 @@ export interface Machine {
spec?: string,
disabled: boolean,
slug: string,
machine_image_attributes: FileType,
machine_files_attributes?: Array<FileType>,
machine_image: string,
machine_files_attributes?: Array<{
id: number,
attachment: string,
attachment_url: string
}>,
trainings?: Array<{
id: number,
name: string,

View File

@ -1,5 +1,7 @@
# frozen_string_literal: true
json.array!(@machines) do |machine|
json.partial! 'api/machines/machine', machine: machine
json.extract! machine, :id, :name, :slug, :disabled
json.machine_image machine.machine_image.attachment.medium.url if machine.machine_image
end

View File

@ -1,11 +1,11 @@
# frozen_string_literal: true
json.partial! 'api/machines/machine', machine: @machine
json.extract! @machine, :description, :spec
json.extract! @machine, :id, :name, :description, :spec, :disabled, :slug
json.machine_image @machine.machine_image.attachment.large.url if @machine.machine_image
json.machine_files_attributes @machine.machine_files do |f|
json.id f.id
json.attachment_name f.attachment_identifier
json.attachment f.attachment_identifier
json.attachment_url f.attachment_url
end
json.trainings @machine.trainings.each, :id, :name, :disabled