2018-05-27 08:49:55 +08:00
|
|
|
import {Injectable} from '@angular/core';
|
|
|
|
import {ShareService} from '../gallery/share.service';
|
|
|
|
import {PhotoDTO} from '../../../common/entities/PhotoDTO';
|
2018-11-05 02:28:32 +08:00
|
|
|
import {MediaDTO} from '../../../common/entities/MediaDTO';
|
2018-11-30 22:36:42 +08:00
|
|
|
import {QueryParams} from '../../../common/QueryParams';
|
2018-12-05 04:43:07 +08:00
|
|
|
import {Utils} from '../../../common/Utils';
|
|
|
|
import {GalleryService} from '../gallery/gallery.service';
|
2018-05-27 08:49:55 +08:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class QueryService {
|
|
|
|
|
|
|
|
|
2018-12-05 04:43:07 +08:00
|
|
|
constructor(private shareService: ShareService,
|
|
|
|
private galleryService: GalleryService) {
|
|
|
|
}
|
|
|
|
|
|
|
|
getMediaStringId(media: MediaDTO): string {
|
|
|
|
if (this.galleryService.isSearchResult()) {
|
|
|
|
return Utils.concatUrls(media.directory.path, media.directory.name, media.name);
|
|
|
|
} else {
|
|
|
|
return media.name;
|
|
|
|
}
|
2018-05-27 08:49:55 +08:00
|
|
|
}
|
|
|
|
|
2018-11-05 02:28:32 +08:00
|
|
|
getParams(media?: MediaDTO): { [key: string]: string } {
|
2018-11-29 06:49:33 +08:00
|
|
|
const query: { [key: string]: string } = {};
|
2018-11-05 02:28:32 +08:00
|
|
|
if (media) {
|
2018-12-05 04:43:07 +08:00
|
|
|
query[QueryParams.gallery.photo] = this.getMediaStringId(media);
|
2018-05-27 08:49:55 +08:00
|
|
|
}
|
|
|
|
if (this.shareService.isSharing()) {
|
2018-11-30 22:36:42 +08:00
|
|
|
query[QueryParams.gallery.sharingKey_short] = this.shareService.getSharingKey();
|
2018-05-27 08:49:55 +08:00
|
|
|
}
|
|
|
|
return query;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|