Merge branch 'master' of bitbucket.org:SanderVocke/digikam-fatclient

master
Sander Vocke 6 years ago
commit 000443533d
  1. 30
      src/gallery/gallery.js
  2. 11
      src/media.js
  3. 6
      src/queries.js

@ -35,7 +35,7 @@ export function GalleryImageRender(props) {
); );
} }
export function GalleryImage(props) { export function GalleryPhoto(props) {
const { photo } = props; const { photo } = props;
// First show the fast (thumbnail) image. // First show the fast (thumbnail) image.
@ -52,10 +52,34 @@ export function GalleryImage(props) {
}, []); }, []);
return ( return (
<GalleryImageRender src={src}/> <GalleryImageRender src={src} />
); );
} }
export function GalleryVideo(props) {
const { video } = props;
const classes = useStyles();
return (
<>
<video controls className={classes.image}>
<source src={video.state.path} type="video/mp4" />
Your browser does not support HTML5 video.
</video>
</>
);
}
export function GalleryItem(props) {
const { item } = props;
if (item.state.is_video) {
return <GalleryVideo video={item} />;
} else {
return <GalleryPhoto photo={item} />;
}
}
export function Gallery(props) { export function Gallery(props) {
const { onClose, items, current_item } = props; const { onClose, items, current_item } = props;
const classes = useStyles(); const classes = useStyles();
@ -73,7 +97,7 @@ export function Gallery(props) {
<Box className={classes.image_container}> <Box className={classes.image_container}>
{ {
maybe_photo && maybe_photo &&
<GalleryImage photo={maybe_photo} /> <GalleryItem item={maybe_photo} />
} }
</Box> </Box>
</Box> </Box>

@ -3,13 +3,14 @@ import './TableLine.css';
export class Media { } export class Media { }
export class Photo extends Media { export class PhotoOrVideo extends Media {
state = { state = {
id: false, id: false,
name: false, name: false,
path: false, path: false,
thumbnailpath: false, thumbnailpath: false,
fullsize: false, fullsize: false,
is_video: false,
} }
} }
@ -34,13 +35,15 @@ export function create_photo(
maybe_name, maybe_name,
maybe_path, maybe_path,
maybe_thumbnail_path, maybe_thumbnail_path,
maybe_fullsize) { maybe_fullsize,
var p = new Photo(); maybe_is_video) {
var p = new PhotoOrVideo();
if (maybe_id) { p.state.id = maybe_id; } if (maybe_id) { p.state.id = maybe_id; }
if (maybe_name) { p.state.name = maybe_name; } if (maybe_name) { p.state.name = maybe_name; }
if (maybe_path) { p.state.path = maybe_path; } if (maybe_path) { p.state.path = maybe_path; }
if (maybe_thumbnail_path) { p.state.thumbnailpath = maybe_thumbnail_path; } if (maybe_thumbnail_path) { p.state.thumbnailpath = maybe_thumbnail_path; }
if (maybe_fullsize) { p.state.fullsize = maybe_fullsize; } if (maybe_fullsize) { p.state.fullsize = maybe_fullsize; }
p.state.is_video = maybe_is_video;
return p; return p;
} }
@ -97,7 +100,7 @@ export const MediaTableLine = ({ media }) => (
<> <>
{ {
(() => { (() => {
if (media instanceof Photo) { if (media instanceof PhotoOrVideo) {
return <PhotoTableLine photo={media} />; return <PhotoTableLine photo={media} />;
} else if (media instanceof Album) { } else if (media instanceof Album) {
return <AlbumTableLine album={media} />; return <AlbumTableLine album={media} />;

@ -9,6 +9,7 @@ export function escape_regex(s) {
}; };
export function do_image_query(query, database, collection_path, collection_thumbs_path) { export function do_image_query(query, database, collection_path, collection_thumbs_path) {
const category_video = 2;
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
var queries = []; var queries = [];
queries.push(query); queries.push(query);
@ -28,7 +29,8 @@ export function do_image_query(query, database, collection_path, collection_thum
imagepath, imagepath,
thumbpath, thumbpath,
[row[cols.indexOf("width")], [row[cols.indexOf("width")],
row[cols.indexOf("height")]] row[cols.indexOf("height")]],
row[cols.indexOf("category")] == category_video,
)); ));
}); });
} }
@ -347,7 +349,7 @@ export class UserQuery {
// This query will return database entries with the fields "id", "uniqueHash", "relativePath" (of the album) and "name" for each matching image. // This query will return database entries with the fields "id", "uniqueHash", "relativePath" (of the album) and "name" for each matching image.
export function image_query_with_where(maybe_where) { export function image_query_with_where(maybe_where) {
return "SELECT Images.id, Images.name, Images.uniqueHash, Albums.relativePath, " return "SELECT Images.id, Images.name, Images.uniqueHash, Albums.relativePath, "
+ "ImageInformation.width, ImageInformation.height " + "ImageInformation.width, ImageInformation.height, Images.category "
+ "FROM Images INNER JOIN Albums ON Images.album=Albums.id " + "FROM Images INNER JOIN Albums ON Images.album=Albums.id "
+ "LEFT JOIN ImageTags ON Images.id=ImageTags.imageid " + "LEFT JOIN ImageTags ON Images.id=ImageTags.imageid "
+ "LEFT JOIN ImageInformation ON Images.id=ImageInformation.imageid " + "LEFT JOIN ImageInformation ON Images.id=ImageInformation.imageid "

Loading…
Cancel
Save