11import Button from '@mui/joy/Button'
2+ import IconButton from '@mui/joy/IconButton'
23import Stack from '@mui/joy/Stack'
34import useSWRMutation from 'swr/mutation'
45
56import type { Prediction } from '../../../app/api/admin/classify/route'
6- import { photoPath } from '../../lib/paths'
7+ import { originalPath , photoPath } from '../../lib/paths'
78import config from '../../models/config'
89import type { Gallery , RawXmlItem } from '../../types/common'
910import Img from '../Img'
1011import Link from '../Link'
1112
13+ function OpenInNewIcon ( ) {
14+ return (
15+ < svg xmlns = "http://www.w3.org/2000/svg" width = "20" height = "20" viewBox = "0 0 24 24" fill = "currentColor" aria-hidden >
16+ < path d = "M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z" />
17+ </ svg >
18+ )
19+ }
20+
1221const fetcher = async ( url : string , { arg } : { arg : string } ) =>
1322 fetch ( url , {
1423 method : 'POST' ,
@@ -25,22 +34,39 @@ export default function AdminAlbumPhoto(
2534 fetcher ,
2635 )
2736
28- const path = photoPath ( item . filename , gallery )
37+ const photoSrc = photoPath ( item . filename , gallery )
38+ const originalSrc = originalPath ( item . filename , gallery )
2939 const dimensions = size === 'small' ? config . resizeDimensions . preview : config . resizeDimensions . photo
3040
3141 return (
3242 < >
3343 < Stack direction = "column" >
34- < Img
35- src = { path }
36- alt = { item . thumb_caption || 'Photo' }
37- width = { dimensions . width - 20 }
38- height = { dimensions . height - 20 }
39- />
44+ < Stack direction = "row" alignItems = "flex-start" spacing = { 1 } sx = { { position : 'relative' } } >
45+ < Img
46+ src = { photoSrc }
47+ alt = { item . thumb_caption || 'Photo' }
48+ width = { dimensions . width - 20 }
49+ height = { dimensions . height - 20 }
50+ />
51+ < IconButton
52+ component = { Link }
53+ href = { originalSrc }
54+ target = "_blank"
55+ rel = "noopener noreferrer"
56+ variant = "soft"
57+ color = "primary"
58+ size = "sm"
59+ title = "Open original image in new tab"
60+ aria-label = "Open original image in new tab"
61+ sx = { { flexShrink : 0 , mt : 0.5 } }
62+ >
63+ < OpenInNewIcon />
64+ </ IconButton >
65+ </ Stack >
4066 < Button
4167 onClick = { ( e ) => {
4268 e . preventDefault ( )
43- trigger ( path )
69+ trigger ( photoSrc )
4470 } }
4571 >
4672 Classify Image
0 commit comments