From e686034026a6ed0f610fd3c4e70f7289cb3dd6b1 Mon Sep 17 00:00:00 2001 From: Cilibiu Bogdan Date: Wed, 21 Mar 2018 01:55:34 +0200 Subject: [PATCH] [ACA-1101] Metadata - Image Properties (#246) --- src/app.config.json | 30 ++++++++++++++++++- .../directives/node-info.directive.spec.ts | 24 ++++++++++++--- .../common/directives/node-info.directive.ts | 16 ++++++---- .../favorites/favorites.component.html | 6 +++- src/app/components/files/files.component.html | 6 +++- .../recent-files/recent-files.component.html | 6 +++- .../shared-files/shared-files.component.html | 6 +++- src/assets/i18n/en.json | 3 ++ 8 files changed, 82 insertions(+), 15 deletions(-) diff --git a/src/app.config.json b/src/app.config.json index 99f2f0cd9..9ad8ced78 100644 --- a/src/app.config.json +++ b/src/app.config.json @@ -126,5 +126,33 @@ "key": "zh-CN", "label": "Simplified Chinese" } - ] + ], + "content-metadata": { + "presets": { + "custom": [ + { + "title": "APP.CONTENT_METADATA.EXIF_GROUP_TITLE", + "items": [ + { + "aspect": "exif:exif", + "properties": [ + "exif:pixelXDimension", + "exif:pixelYDimension", + "exif:dateTimeOriginal", + "exif:exposureTime", + "exif:fNumber", + "exif:flash", + "exif:focalLength", + "exif:isoSpeedRatings", + "exif:orientation", + "exif:manufacturer", + "exif:model", + "exif:software" + ] + } + ] + } + ] + } + } } diff --git a/src/app/common/directives/node-info.directive.spec.ts b/src/app/common/directives/node-info.directive.spec.ts index 4fcff8c88..ff377f5fd 100644 --- a/src/app/common/directives/node-info.directive.spec.ts +++ b/src/app/common/directives/node-info.directive.spec.ts @@ -55,8 +55,6 @@ describe('NodeInfoDirective', () => { component = fixture.componentInstance; apiService = TestBed.get(AlfrescoApiService); nodeService = apiService.getInstance().nodes; - - fixture.detectChanges(); })); beforeEach(() => { @@ -65,19 +63,37 @@ describe('NodeInfoDirective', () => { })); }); - it('should not get node info when selection is empty', () => { + it('should not get node info onInit when selection is empty', () => { component.selection = []; fixture.detectChanges(); + + expect(nodeService.getNodeInfo).not.toHaveBeenCalled(); + }); + + it('should get node info onInit when selection is not empty', () => { + component.selection = [{ entry: { id: 'id' } }]; + + fixture.detectChanges(); + + expect(nodeService.getNodeInfo).toHaveBeenCalled(); + }); + + it('should not get node info on event when selection is empty', () => { + component.selection = []; + + fixture.detectChanges(); + document.dispatchEvent(new CustomEvent('click')); expect(nodeService.getNodeInfo).not.toHaveBeenCalled(); }); - it('should get node info from selection', () => { + it('should get node info on event from selection', () => { component.selection = [{ entry: { id: 'id' } }]; fixture.detectChanges(); + document.dispatchEvent(new CustomEvent('click')); expect(nodeService.getNodeInfo).toHaveBeenCalledWith('id'); diff --git a/src/app/common/directives/node-info.directive.ts b/src/app/common/directives/node-info.directive.ts index 1e20cca09..b05b13dd5 100644 --- a/src/app/common/directives/node-info.directive.ts +++ b/src/app/common/directives/node-info.directive.ts @@ -23,30 +23,34 @@ * along with Alfresco. If not, see . */ -import { Directive, HostListener, Input, Output, EventEmitter } from '@angular/core'; +import { Directive, HostListener, Input, Output, EventEmitter, OnInit } from '@angular/core'; import { AlfrescoApiService } from '@alfresco/adf-core'; -import { MinimalNodeEntity, MinimalNodeEntryEntity, Node } from 'alfresco-js-api'; +import { MinimalNodeEntity, MinimalNodeEntryEntity } from 'alfresco-js-api'; @Directive({ selector: '[app-node-info]', exportAs: 'nodeInfo' }) -export class NodeInfoDirective { +export class NodeInfoDirective implements OnInit { @Input('app-node-info') selection: MinimalNodeEntity[]; - @Output() changed: EventEmitter = new EventEmitter(); + @Output() changed: EventEmitter = new EventEmitter(); @Output() error: EventEmitter = new EventEmitter(); - node: Node; + node: MinimalNodeEntryEntity; loading: boolean = null; - @HostListener('document:click', ['$event']) + @HostListener('document:node-click', ['$event']) onClick(event) { this.getNodeInfo(); } constructor(private apiService: AlfrescoApiService) {} + ngOnInit() { + this.getNodeInfo(); + } + getNodeInfo() { if (!this.selection.length) { this.node = null; diff --git a/src/app/components/favorites/favorites.component.html b/src/app/components/favorites/favorites.component.html index 96d0e93e6..84421da79 100644 --- a/src/app/components/favorites/favorites.component.html +++ b/src/app/components/favorites/favorites.component.html @@ -166,7 +166,11 @@ - + + diff --git a/src/app/components/files/files.component.html b/src/app/components/files/files.component.html index af5eade2e..06e848843 100644 --- a/src/app/components/files/files.component.html +++ b/src/app/components/files/files.component.html @@ -173,7 +173,11 @@ - + + diff --git a/src/app/components/recent-files/recent-files.component.html b/src/app/components/recent-files/recent-files.component.html index 614854ff0..80feffe68 100644 --- a/src/app/components/recent-files/recent-files.component.html +++ b/src/app/components/recent-files/recent-files.component.html @@ -155,7 +155,11 @@ - + + diff --git a/src/app/components/shared-files/shared-files.component.html b/src/app/components/shared-files/shared-files.component.html index 3d5bdc965..e955df7d8 100644 --- a/src/app/components/shared-files/shared-files.component.html +++ b/src/app/components/shared-files/shared-files.component.html @@ -173,7 +173,11 @@ - + + diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index 841c3373a..a179114cd 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -185,6 +185,9 @@ } } } + }, + "CONTENT_METADATA": { + "EXIF_GROUP_TITLE": "Image EXIF" } }, "NODE_SELECTOR": {