pigallery2-extension-kit 3.5.0 → 3.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@ import * as express from 'express';
2
2
  import { NextFunction, Request, Response } from 'express';
3
3
  import { UserDTO, UserRoles } from '../../../common/entities/UserDTO';
4
4
  import { ParamsDictionary } from 'express-serve-static-core';
5
- import { IExtensionRESTApi, IExtensionRESTRoute } from './IExtension';
5
+ import { IExtensionRESTApi, IExtensionRESTRoute, IMediaRequestBody } from './IExtension';
6
6
  import { ILogger } from '../../Logger';
7
7
  import { MediaEntity } from '../database/enitites/MediaEntity';
8
8
  import { Repository } from 'typeorm';
@@ -23,7 +23,7 @@ export declare class ExpressRouteWrapper implements IExtensionRESTRoute {
23
23
  private readonly func;
24
24
  private readonly extLogger;
25
25
  constructor(router: express.Router, name: string, func: 'get' | 'use' | 'put' | 'post' | 'delete', extLogger: ILogger);
26
- mediaJsonResponse(paths: string[], minRole: UserRoles, invalidateDirectory: boolean, cb: (params: ParamsDictionary, body: any, user: UserDTO, media: MediaEntity, repository: Repository<MediaEntity>) => Promise<unknown> | unknown): string;
26
+ mediaJsonResponse(paths: string[], minRole: UserRoles, invalidateDirectory: boolean, cb: (params: ParamsDictionary, body: IMediaRequestBody, user: UserDTO, media: MediaEntity, repository: Repository<MediaEntity>) => Promise<unknown> | unknown): string;
27
27
  jsonResponse(paths: string[], minRole: UserRoles, cb: (params?: ParamsDictionary, body?: any, user?: UserDTO) => Promise<unknown> | unknown): string;
28
28
  rawMiddleware(paths: string[], minRole: UserRoles, mw: (req: Request, res: Response, next: NextFunction) => void | Promise<void>): string;
29
29
  private getAuthMWs;
@@ -17,7 +17,7 @@ import { CoverPhotoDTOWithID } from '../database/CoverManager';
17
17
  import { ParentDirectoryDTO } from '../../../common/entities/DirectoryDTO';
18
18
  import { DirectoryScanSettings } from '../fileaccess/DiskManager';
19
19
  import { SessionContext } from '../SessionContext';
20
- import { IClientMediaButtonConfig } from '../../../common/entities/extension/IClientUIConfig';
20
+ import { IClientMediaButtonConfig, IMediaRequestBodyData } from '../../../common/entities/extension/IClientUIConfig';
21
21
  import { MediaEntity } from '../database/enitites/MediaEntity';
22
22
  import { VideoConverterInput } from '../fileaccess/VideoConverterWorker';
23
23
  import { ProjectedDirectoryCacheEntity } from '../database/enitites/ProjectedDirectoryCacheEntity';
@@ -122,6 +122,10 @@ export interface IExtensionApp {
122
122
  objectManagers: ObjectManagers;
123
123
  config: PrivateConfigClass;
124
124
  }
125
+ export interface IMediaRequestBody {
126
+ data: IMediaRequestBodyData;
127
+ media: string;
128
+ }
125
129
  export interface IExtensionRESTRoute {
126
130
  /**
127
131
  * Looks for req.body.media for the media path and calls the callback with that media entry.
@@ -133,7 +137,7 @@ export interface IExtensionRESTRoute {
133
137
  * @param cb function callback
134
138
  * @return newly added REST api path
135
139
  */
136
- mediaJsonResponse(paths: string[], minRole: UserRoles, invalidateDirectory: boolean, cb: (params: ParamsDictionary, body: any, user: UserDTO, media: MediaEntity, repository: Repository<MediaEntity>) => Promise<unknown> | unknown): string;
140
+ mediaJsonResponse(paths: string[], minRole: UserRoles, invalidateDirectory: boolean, cb: (params: ParamsDictionary, body: IMediaRequestBody, user: UserDTO, media: MediaEntity, repository: Repository<MediaEntity>) => Promise<unknown> | unknown): string;
137
141
  /**
138
142
  * Sends a pigallery2 standard JSON object with payload or error message back to the client.
139
143
  * @param paths RESTapi path, relative to the extension base endpoint
@@ -245,7 +249,7 @@ export interface IUIExtension<C> {
245
249
  * @param buttonConfig
246
250
  * @param serverSB If not set the button will be a fake button (i.e.: only show up not clickable)
247
251
  */
248
- addMediaButton(buttonConfig: IClientMediaButtonConfig, serverSB?: (params: ParamsDictionary, body: any, user: UserDTO, media: MediaEntity, repository: Repository<MediaEntity>) => Promise<void>): void;
252
+ addMediaButton(buttonConfig: IClientMediaButtonConfig, serverSB?: (params: ParamsDictionary, body: IMediaRequestBody, user: UserDTO, media: MediaEntity, repository: Repository<MediaEntity>) => Promise<void>): void;
249
253
  }
250
254
  export interface IExtensionConfigInit<C> {
251
255
  /**
@@ -3,11 +3,11 @@ import { IClientMediaButtonConfig } from '../../../common/entities/extension/ICl
3
3
  import { UserDTO } from '../../../common/entities/UserDTO';
4
4
  import { ParamsDictionary } from 'express-serve-static-core';
5
5
  import { MediaEntity } from '../database/enitites/MediaEntity';
6
- import { IUIExtension } from './IExtension';
6
+ import { IMediaRequestBody, IUIExtension } from './IExtension';
7
7
  import { Repository } from 'typeorm';
8
8
  export declare class UIExtension<C> implements IUIExtension<C> {
9
9
  private extensionObject;
10
10
  buttonConfigs: IClientMediaButtonConfig[];
11
11
  constructor(extensionObject: ExtensionObject<C>);
12
- addMediaButton(buttonConfig: IClientMediaButtonConfig, serverSB: (params: ParamsDictionary, body: any, user: UserDTO, media: MediaEntity, repository: Repository<MediaEntity>) => Promise<void>): void;
12
+ addMediaButton(buttonConfig: IClientMediaButtonConfig, serverSB: (params: ParamsDictionary, body: IMediaRequestBody, user: UserDTO, media: MediaEntity, repository: Repository<MediaEntity>) => Promise<void>): void;
13
13
  }
@@ -1,5 +1,5 @@
1
1
  import { UserRoles } from '../UserDTO';
2
- export type IClientMediaFields = 'title' | 'caption' | 'cameraData' | 'positionData' | 'faces' | 'size' | 'creationDate' | 'creationDateOffset' | 'bitRate' | 'duration' | 'fileSize' | 'fps';
2
+ export type IClientMediaFields = 'title' | 'caption' | 'cameraData' | 'positionData' | 'faces' | 'keywords' | 'size' | 'creationDate' | 'creationDateOffset' | 'bitRate' | 'duration' | 'fileSize' | 'fps';
3
3
  export interface IClientSVGIconConfig {
4
4
  /**
5
5
  * SVG path viewBox. See: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/viewBox
@@ -27,6 +27,10 @@ export interface IClientMediaButtonPopupFields {
27
27
  * Default value of the field. Should appropriately to the type.
28
28
  */
29
29
  defaultValue?: string | number | boolean;
30
+ /**
31
+ * Keep value across popups. Use this if you would like to use the same value on multiple popups (e.g.: like adding the same keyword to multiple photos).
32
+ */
33
+ keepValue: boolean;
30
34
  /**
31
35
  * If true, the field will be required.
32
36
  * If boolean, the field will be required to be true to click the button.
@@ -55,6 +59,33 @@ export interface IClientMediaButtonPopupConfig {
55
59
  */
56
60
  customFields?: IClientMediaButtonPopupFields[];
57
61
  }
62
+ /**
63
+ * Data that will be sent to the server side when the media button is clicked.
64
+ * The data will be sent as a JSON object.
65
+ * The keys of the object will be the field names.
66
+ * The values will be the field values.
67
+ */
68
+ export interface IMediaRequestBodyData {
69
+ /**
70
+ * Existing metadata fields of a media.
71
+ */
72
+ fields?: {
73
+ title?: string;
74
+ caption?: string;
75
+ cameraData?: string;
76
+ positionData?: string;
77
+ faces?: string;
78
+ size?: string;
79
+ creationDate?: string;
80
+ creationDateOffset?: string;
81
+ bitRate?: string;
82
+ duration?: string;
83
+ fileSize?: string;
84
+ fps?: string;
85
+ keywords?: string;
86
+ };
87
+ customFields?: Record<string, any>;
88
+ }
58
89
  export interface IClientMediaButtonConfig {
59
90
  /**
60
91
  * Name of the button. This is also used as id.
@@ -1,12 +1,10 @@
1
1
  import { OnDestroy, OnInit } from '@angular/core';
2
2
  import { MediaButtonModalData, MediaButtonModalService } from './media-button-modal.service';
3
- import { IClientMediaFields } from '../../../../../../../common/entities/extension/IClientUIConfig';
3
+ import { IClientMediaFields, IMediaRequestBodyData } from '../../../../../../../common/entities/extension/IClientUIConfig';
4
4
  export declare class MediaButtonModalComponent implements OnInit, OnDestroy {
5
5
  private modalService;
6
6
  modalData: MediaButtonModalData | null;
7
- formData: {
8
- [key: string]: any;
9
- };
7
+ formData: IMediaRequestBodyData;
10
8
  private subscription;
11
9
  constructor(modalService: MediaButtonModalService);
12
10
  ngOnInit(): void;
@@ -13,9 +13,15 @@ export declare class MediaButtonModalService {
13
13
  private networkService;
14
14
  private contentLoader;
15
15
  private modalData$;
16
+ private savedModalValues;
16
17
  constructor(notificationService: NotificationService, networkService: NetworkService, contentLoader: ContentLoaderService);
17
18
  get modalData(): import("rxjs").Observable<MediaButtonModalData>;
18
19
  showModal(button: IClientMediaButtonConfigWithBaseApiPath, media: GridMedia): void;
19
20
  hideModal(): void;
20
- executeButtonAction(button: IClientMediaButtonConfigWithBaseApiPath, media: GridMedia, formData?: any): Promise<void>;
21
+ executeButtonAction(button: IClientMediaButtonConfigWithBaseApiPath, media: GridMedia, formData?: {
22
+ fields?: Record<string, any>;
23
+ customFields?: Record<string, any>;
24
+ }): Promise<void>;
25
+ getValue(id: string): string | number | boolean;
26
+ setValue(id: string, value: string | number | boolean): void;
21
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pigallery2-extension-kit",
3
- "version": "3.5.0",
3
+ "version": "3.5.1",
4
4
  "description": "Interfaces for developing extensions for pigallery2",
5
5
  "author": "Patrik J. Braun",
6
6
  "homepage": "https://github.com/bpatrik/pigallery2",