1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00
pigallery2/frontend/app/model/query.service.ts

27 lines
738 B
TypeScript
Raw Normal View History

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';
@Injectable()
export class QueryService {
public static readonly PHOTO_PARAM = 'p';
2018-11-29 06:49:33 +08:00
public static readonly SHARING_KEY = 'sk';
constructor(private shareService: ShareService) {
}
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) {
query[QueryService.PHOTO_PARAM] = media.name;
}
if (this.shareService.isSharing()) {
2018-11-29 06:49:33 +08:00
query[QueryService.SHARING_KEY] = this.shareService.getSharingKey();
}
return query;
}
}