Skip to content
This repository has been archived by the owner on May 4, 2024. It is now read-only.

Commit

Permalink
Finish road image display
Browse files Browse the repository at this point in the history
- Remove frontend rotation (done during importation)
- Display all images
- Fix image rotation direction during importation
  • Loading branch information
Seb-sti1 committed Dec 16, 2023
1 parent d811bfd commit 353d23d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 73 deletions.
7 changes: 3 additions & 4 deletions backend/src/images/image.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ export class ImageService {
* @author Kerbourc'h
*/
formatImagePath(image: IImage) {
image.image_path = image.image_path.replace(
process.env.IMAGE_STORE_PATH,
'/cdn/',
);
image.image_path = image.image_path
.replace(process.env.IMAGE_STORE_PATH, '/cdn/')
.replace('/home/fish/images/', '/cdn/');
return image;
}

Expand Down
2 changes: 1 addition & 1 deletion backend/src/upload/upload.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class UploadService {

const sourcePath = image.image_path;
if (image.type !== 'DashCamera') {
await sharp(sourcePath).rotate(-90).toFile(destinationPath);
await sharp(sourcePath).rotate(90).toFile(destinationPath);
} else {
copyFileSync(sourcePath, destinationPath);
}
Expand Down
37 changes: 17 additions & 20 deletions frontend/src/Components/RoadDetails/RoadImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { IImage, IImageValuesForPixels } from '../../models/models';
import { getImagesForASurvey, getImagesForWays } from '../../queries/images';

import '../../css/road_image.css';
import RotatedImage from './RotatedImage';
import { useParams } from 'react-router-dom';

interface Props {
Expand Down Expand Up @@ -186,7 +185,7 @@ const RoadImage: React.FC<Props> = ({
}

onRoadDistanceChange(getRoadDistances(currentlyVisibleImagesForPixels));
}, [containerRef, onRoadDistanceChange, displayedImages]);
}, [onRoadDistanceChange, displayedImages, type]);

useEffect(() => {
if (!hasFiltered) return;
Expand Down Expand Up @@ -231,26 +230,24 @@ const RoadImage: React.FC<Props> = ({
<div className="border-road-image-surface-container">
<div ref={containerRef} className="road-image-surface-container">
{displayedImages.length > 0
? displayedImages.slice(0, 25).map((image, index) => (
<div
key={'div' + image.id}
? displayedImages.map((image, index) => (
<img
draggable={false}
key={image.id}
src={image.image_path}
className="road-image-surface-image"
data-image-id={image.id}
>
<RotatedImage
key={image.id}
src={image.image_path}
onLoad={() => {
if (index === indexLastViewed) {
setTimeout(() => {
if (containerRef.current === null) return;
const container = containerRef.current as HTMLElement;
container.children[index].scrollIntoView();
}, 20);
}
}}
/>
</div>
onLoad={() => {
if (index === indexLastViewed) {
setTimeout(() => {
if (containerRef.current === null) return;
const container = containerRef.current as HTMLElement;
container.children[index].scrollIntoView();
}, 20);
}
}}
alt={`Image n°${index}`}
/>
))
: null}
</div>
Expand Down
47 changes: 0 additions & 47 deletions frontend/src/Components/RoadDetails/RotatedImage.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion frontend/src/css/road_image.css
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@
overflow-y: hidden;
}

.road-image-surface-image canvas {
.road-image-surface-image {
height: 100%;
}

0 comments on commit 353d23d

Please sign in to comment.