adding caption support

This commit is contained in:
Patrik J. Braun 2018-12-05 19:15:24 +01:00
parent 7692c455bc
commit 8e18abd2bd
12 changed files with 73 additions and 11 deletions

View File

@ -1,7 +1,6 @@
dist: trusty dist: trusty
language: node_js language: node_js
node_js: node_js:
- '8'
- '10' - '10'
- '11' - '11'

View File

@ -77,8 +77,6 @@ export class GalleryMWs {
delete (<PhotoDTO>m).metadata.positionData; delete (<PhotoDTO>m).metadata.positionData;
} }
Utils.removeNullOrEmptyObj(m); Utils.removeNullOrEmptyObj(m);
console.log(m);
console.log(Utils.removeNullOrEmptyObj(m));
}); });
}; };

View File

@ -70,6 +70,16 @@ export class SearchManager implements ISearchManager {
.getRawMany()) .getRawMany())
.map(r => r.name), SearchTypes.photo)); .map(r => r.name), SearchTypes.photo));
result = result.concat(this.encapsulateAutoComplete((await photoRepository
.createQueryBuilder('media')
.select('DISTINCT(media.metadata.caption) as caption')
.where('media.metadata.caption LIKE :text COLLATE utf8_general_ci', {text: '%' + text + '%'})
.limit(5)
.getRawMany())
.map(r => r.caption), SearchTypes.photo));
result = result.concat(this.encapsulateAutoComplete((await videoRepository result = result.concat(this.encapsulateAutoComplete((await videoRepository
.createQueryBuilder('media') .createQueryBuilder('media')
.select('DISTINCT(media.name)') .select('DISTINCT(media.name)')
@ -123,6 +133,10 @@ export class SearchManager implements ISearchManager {
query.orWhere('media.name LIKE :text COLLATE utf8_general_ci', {text: '%' + text + '%'}); query.orWhere('media.name LIKE :text COLLATE utf8_general_ci', {text: '%' + text + '%'});
} }
if (!searchType || searchType === SearchTypes.photo) {
query.orWhere('media.metadata.caption LIKE :text COLLATE utf8_general_ci', {text: '%' + text + '%'});
}
if (!searchType || searchType === SearchTypes.position) { if (!searchType || searchType === SearchTypes.position) {
query.orWhere('media.metadata.positionData.country LIKE :text COLLATE utf8_general_ci', {text: '%' + text + '%'}) query.orWhere('media.metadata.positionData.country LIKE :text COLLATE utf8_general_ci', {text: '%' + text + '%'})
.orWhere('media.metadata.positionData.state LIKE :text COLLATE utf8_general_ci', {text: '%' + text + '%'}) .orWhere('media.metadata.positionData.state LIKE :text COLLATE utf8_general_ci', {text: '%' + text + '%'})
@ -176,6 +190,7 @@ export class SearchManager implements ISearchManager {
.orWhere('media.metadata.positionData.state LIKE :text COLLATE utf8_general_ci', {text: '%' + text + '%'}) .orWhere('media.metadata.positionData.state LIKE :text COLLATE utf8_general_ci', {text: '%' + text + '%'})
.orWhere('media.metadata.positionData.city LIKE :text COLLATE utf8_general_ci', {text: '%' + text + '%'}) .orWhere('media.metadata.positionData.city LIKE :text COLLATE utf8_general_ci', {text: '%' + text + '%'})
.orWhere('media.name LIKE :text COLLATE utf8_general_ci', {text: '%' + text + '%'}) .orWhere('media.name LIKE :text COLLATE utf8_general_ci', {text: '%' + text + '%'})
.orWhere('media.metadata.caption LIKE :text COLLATE utf8_general_ci', {text: '%' + text + '%'})
.innerJoinAndSelect('media.directory', 'directory') .innerJoinAndSelect('media.directory', 'directory')
.limit(10) .limit(10)
.getMany(); .getMany();

View File

@ -255,7 +255,9 @@ export class DiskMangerWorker {
metadata.positionData.state = iptcData.province_or_state; metadata.positionData.state = iptcData.province_or_state;
metadata.positionData.city = iptcData.city; metadata.positionData.city = iptcData.city;
} }
metadata.caption = iptcData.caption; if (iptcData.caption) {
metadata.caption = iptcData.caption.replace(/\0/g, '').trim();
}
metadata.keywords = iptcData.keywords || []; metadata.keywords = iptcData.keywords || [];
metadata.creationDate = <number>(iptcData.date_time ? iptcData.date_time.getTime() : metadata.creationDate); metadata.creationDate = <number>(iptcData.date_time ? iptcData.date_time.getTime() : metadata.creationDate);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 894 KiB

After

Width:  |  Height:  |  Size: 901 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 690 KiB

After

Width:  |  Height:  |  Size: 695 KiB

View File

@ -68,7 +68,7 @@ app-gallery-lightbox-photo {
opacity: 0; opacity: 0;
} }
#swipeable-container{ #swipeable-container {
height: 100%; height: 100%;
} }
@ -101,15 +101,25 @@ app-gallery-lightbox-photo {
.controls-top { .controls-top {
top: 0; top: 0;
} }
.controls-caption {
opacity: 0.5;
top: 0;
position: absolute;
height: initial;
text-align: left;
width: 75%;
padding: 5px 13px;
font-size: 1.5rem;
}
.controls-playback { .controls-playback {
padding-right: 15px; padding-right: 15px;
bottom: 0; bottom: 0;
position: absolute; position: absolute;
} }
.controls-video { .controls-video {
padding-right: 15px; padding-right: 15px;
bottom: 0; bottom: 0;
@ -117,13 +127,13 @@ app-gallery-lightbox-photo {
} }
.controls-video .oi, .controls-video .oi,
.controls-video input{ .controls-video input {
color: white; color: white;
cursor: pointer; cursor: pointer;
} }
.controls-big-play span{ .controls-big-play span {
font-size: 20vh; font-size: 20vh;
position: absolute; position: absolute;
top: 50%; top: 50%;
@ -131,12 +141,12 @@ app-gallery-lightbox-photo {
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
} }
.controls-video input[type=range]{ .controls-video input[type=range] {
padding: 0; padding: 0;
margin-top: 6px; margin-top: 6px;
} }
.controls-video .oi{ .controls-video .oi {
text-align: center; text-align: center;
max-width: 45px; max-width: 45px;
margin-left: 10px; margin-left: 10px;

View File

@ -17,7 +17,7 @@
#controls #controls
[style.width.px]="getPhotoFrameWidth()" [style.width.px]="getPhotoFrameWidth()"
[ngClass]="!controllersDimmed ? (activePhoto && activePhoto.gridPhoto.isVideo() ? 'dim-controls-video' :'dim-controls'): ''"> [ngClass]="!controllersDimmed ? (activePhoto && activePhoto.gridPhoto.isVideo() ? 'dim-controls-video' :'dim-controls'): ''">
<div class="controls-caption" *ngIf="Title">{{Title}}</div>
<div class="controls controls-top"> <div class="controls controls-top">
<a *ngIf="activePhoto" <a *ngIf="activePhoto"
class="highlight control-button" class="highlight control-button"

View File

@ -24,6 +24,7 @@ import {QueryService} from '../../model/query.service';
import {MediaDTO} from '../../../../common/entities/MediaDTO'; import {MediaDTO} from '../../../../common/entities/MediaDTO';
import {QueryParams} from '../../../../common/QueryParams'; import {QueryParams} from '../../../../common/QueryParams';
import {GalleryService} from '../gallery.service'; import {GalleryService} from '../gallery.service';
import {PhotoDTO} from '../../../../common/entities/PhotoDTO';
export enum LightboxStates { export enum LightboxStates {
Open = 1, Open = 1,
@ -96,6 +97,7 @@ export class GalleryLightboxComponent implements OnDestroy, OnInit {
}); });
} }
ngOnDestroy(): void { ngOnDestroy(): void {
this.pause(); this.pause();
if (this.subscription.photosChange != null) { if (this.subscription.photosChange != null) {
@ -510,5 +512,13 @@ export class GalleryLightboxComponent implements OnDestroy, OnInit {
public isVisible(): boolean { public isVisible(): boolean {
return this.status !== LightboxStates.Closed; return this.status !== LightboxStates.Closed;
} }
get Title(): string {
if (!this.activePhoto) {
return null;
}
return (<PhotoDTO>this.activePhoto.gridPhoto.media).metadata.caption;
}
} }

View File

@ -94,6 +94,7 @@ describe('SearchManager', () => {
new AutoCompleteItem('death star', SearchTypes.keyword), new AutoCompleteItem('death star', SearchTypes.keyword),
new AutoCompleteItem('Padmé Amidala', SearchTypes.keyword), new AutoCompleteItem('Padmé Amidala', SearchTypes.keyword),
new AutoCompleteItem('Natalie Portman', SearchTypes.keyword), new AutoCompleteItem('Natalie Portman', SearchTypes.keyword),
new AutoCompleteItem('Han Solo\'s dice', SearchTypes.photo),
new AutoCompleteItem('Kamino', SearchTypes.position), new AutoCompleteItem('Kamino', SearchTypes.position),
new AutoCompleteItem('Tatooine', SearchTypes.position), new AutoCompleteItem('Tatooine', SearchTypes.position),
new AutoCompleteItem('wars dir', SearchTypes.directory), new AutoCompleteItem('wars dir', SearchTypes.directory),
@ -154,6 +155,24 @@ describe('SearchManager', () => {
metaFile: [], metaFile: [],
resultOverflow: false resultOverflow: false
})); }));
expect(Utils.clone(await sm.search('han', SearchTypes.photo))).to.deep.equal(Utils.clone(<SearchResultDTO>{
searchText: 'han',
searchType: SearchTypes.photo,
directories: [],
media: [p],
metaFile: [],
resultOverflow: false
}));
expect(Utils.clone(await sm.search('han', SearchTypes.keyword))).to.deep.equal(Utils.clone(<SearchResultDTO>{
searchText: 'han',
searchType: SearchTypes.keyword,
directories: [],
media: [],
metaFile: [],
resultOverflow: false
}));
}); });
@ -199,6 +218,14 @@ describe('SearchManager', () => {
metaFile: [], metaFile: [],
resultOverflow: false resultOverflow: false
})); }));
expect(Utils.clone(await sm.instantSearch('han'))).to.deep.equal(Utils.clone({
searchText: 'han',
directories: [],
media: [p],
metaFile: [],
resultOverflow: false
}));
}); });

View File

@ -93,6 +93,7 @@ export class TestHelper {
public static getPhotoEntry1(dir: DirectoryEntity) { public static getPhotoEntry1(dir: DirectoryEntity) {
const p = TestHelper.getPhotoEntry(dir); const p = TestHelper.getPhotoEntry(dir);
p.metadata.caption = 'Han Solo\'s dice';
p.metadata.keywords = ['Boba Fett', 'star wars', 'Anakin', 'death star']; p.metadata.keywords = ['Boba Fett', 'star wars', 'Anakin', 'death star'];
p.metadata.positionData.city = 'Mos Eisley'; p.metadata.positionData.city = 'Mos Eisley';
p.metadata.positionData.country = 'Tatooine'; p.metadata.positionData.country = 'Tatooine';