[ADF-4424] Pdf Viewer - password dialog does not close when pressing Escape (#4622)

* return to previous page on close

* update e2e

* [ADF-4424] Improve PreviousRouteService to use it in pdfViewer

* change previous Url logic

* remove navigation logic

* remove test

* Update pdfViewer.component.spec.ts

* back button logic for viewer outlet

* unit tests

* remove fdescribe

* remove unused service

* e2e

* return to location

* remove click filter step

* remove unnecessary test steps

* remove un existen export

* unify preview between PS and CS in demo shell

* fix dispalyname property
This commit is contained in:
Cilibiu Bogdan
2019-07-11 19:33:15 +03:00
committed by Eugenio Romano
parent 72b3a75a85
commit ccdcba8778
18 changed files with 149 additions and 317 deletions

View File

@@ -93,7 +93,7 @@ export const appRoutes: Routes = [
children: [
{
path: '',
loadChildren: 'app/components/blob-preview/blob-preview.module#BlobPreviewModule'
loadChildren: 'app/components/file-view/file-view.module#FileViewModule'
}
]
},

View File

@@ -1,38 +0,0 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Component } from '@angular/core';
import { PreviewService } from '../../services/preview.service';
import { Router } from '@angular/router';
@Component({
templateUrl: 'bob-preview.component.html'
})
export class BlobPreviewComponent {
content: Blob;
name: string;
constructor(preview: PreviewService, router: Router) {
if (preview.content === null || preview.name === null) {
router.navigate([{ outlets: { overlay: null } }]);
return;
}
this.content = preview.content;
this.name = preview.name;
}
}

View File

@@ -1,49 +0,0 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { CommonModule } from '@angular/common';
import { CoreModule, InfoDrawerModule } from '@alfresco/adf-core';
import { ContentDirectiveModule, ContentMetadataModule, VersionManagerModule } from '@alfresco/adf-content-services';
import { BlobPreviewComponent } from './blob-preview.component';
const routes: Routes = [
{
path: '',
component: BlobPreviewComponent
}
];
@NgModule({
imports: [
CommonModule,
RouterModule.forChild(routes),
CoreModule.forChild(),
InfoDrawerModule,
ContentDirectiveModule,
ContentMetadataModule,
VersionManagerModule
],
declarations: [
BlobPreviewComponent
],
exports: [
BlobPreviewComponent
]
})
export class BlobPreviewModule {}

View File

@@ -1,5 +0,0 @@
<adf-viewer
[showViewer]="true"
[blobFile]="content"
[displayName]="name">
</adf-viewer>

View File

@@ -1,4 +1,4 @@
<ng-container *ngIf="nodeId">
<ng-container *ngIf="nodeId || content">
<ng-template let-node="node" #sidebarRightTemplate>
<adf-info-drawer [title]="'APP.INFO_DRAWER.TITLE' | translate">
@@ -284,14 +284,16 @@
</p>
<p class="toggle">
<button mat-raised-button id="adf-switch-showrightsidebar" (click)="toggleShowRightSidebar()" color="primary">
Toggle Right Sidebar
<button mat-raised-button id="adf-switch-showrightsidebar" (click)="toggleShowRightSidebar()"
color="primary">
Toggle Right Sidebar
</button>
</p>
<p class="toggle">
<button mat-raised-button id="adf-switch-showleftsidebar" (click)="hideLeftSidebar()" color="primary">
Hide Left Sidebar
<button mat-raised-button id="adf-switch-showleftsidebar" (click)="hideLeftSidebar()"
color="primary">
Hide Left Sidebar
</button>
</p>
@@ -314,6 +316,7 @@
</ng-template>
<adf-viewer
[blobFile]="content"
[nodeId]="nodeId"
[showRightSidebar]="showRightSidebar"
[showLeftSidebar]="showLeftSidebar"
@@ -325,6 +328,7 @@
[allowRightSidebar]="allowRightSidebar"
[allowLeftSidebar]="allowLeftSidebar"
[urlFile]="urlFile"
(showViewerChange)="onViewerVisibilityChanged($event)"
[sidebarLeftTemplate]="sidebarLeftTemplate"
[sidebarRightTemplate]="sidebarRightTemplate">

View File

@@ -16,9 +16,10 @@
*/
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { ActivatedRoute, Router, PRIMARY_OUTLET } from '@angular/router';
import { ContentService, AllowableOperationsEnum, PermissionsEnum, NodesApiService } from '@alfresco/adf-core';
import { MatSnackBar } from '@angular/material';
import { PreviewService } from '../../services/preview.service';
@Component({
selector: 'app-file-view',
@@ -57,12 +58,15 @@ export class FileViewComponent implements OnInit {
showTabWithIconAndLabel = false;
desiredAspect: string = null;
showAspect: string = null;
content: Blob;
name: string;
constructor(private router: Router,
private route: ActivatedRoute,
private snackBar: MatSnackBar,
private nodeApiService: NodesApiService,
private contentServices: ContentService) {
private contentServices: ContentService,
private preview: PreviewService) {
}
ngOnInit() {
@@ -81,10 +85,18 @@ export class FileViewComponent implements OnInit {
},
() => this.router.navigate(['/files', id])
);
} else if (this.preview.content) {
this.content = this.preview.content;
this.displayName = this.preview.name;
}
});
}
onViewerVisibilityChanged() {
const primaryUrl = this.router.parseUrl(this.router.url).root.children[PRIMARY_OUTLET].toString();
this.router.navigateByUrl(primaryUrl);
}
onUploadError(errorMessage: string) {
this.snackBar.open(errorMessage, '', { duration: 4000 });
}