mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
added functionality to view a previous version (#5913)
This commit is contained in:
@@ -74,6 +74,19 @@ export const appRoutes: Routes = [
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: 'files/:nodeId/:versionId/view',
|
||||
component: AppComponent,
|
||||
canActivate: [AuthGuardEcm],
|
||||
canActivateChild: [AuthGuardEcm],
|
||||
outlet: 'overlay',
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
loadChildren: () => import('./components/file-view/file-view.module').then(m => m.FileViewModule)
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: 'preview/blob',
|
||||
component: AppComponent,
|
||||
|
@@ -108,7 +108,8 @@
|
||||
<mat-card>
|
||||
<mat-card-content>
|
||||
<adf-version-manager [node]="node"
|
||||
(uploadError)="onUploadError($event)">
|
||||
(uploadError)="onUploadError($event)"
|
||||
(viewVersion)="onViewVersion($event)">
|
||||
</adf-version-manager>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
@@ -318,6 +319,7 @@
|
||||
<adf-viewer
|
||||
[blobFile]="content"
|
||||
[nodeId]="nodeId"
|
||||
[versionId]="versionId"
|
||||
[showRightSidebar]="showRightSidebar"
|
||||
[showLeftSidebar]="showLeftSidebar"
|
||||
[allowGoBack]="allowGoBack"
|
||||
|
@@ -30,6 +30,7 @@ import { PreviewService } from '../../services/preview.service';
|
||||
export class FileViewComponent implements OnInit {
|
||||
|
||||
nodeId: string = null;
|
||||
versionId: string = null;
|
||||
displayEmptyMetadata = false;
|
||||
expanded: boolean;
|
||||
multi = false;
|
||||
@@ -72,6 +73,7 @@ export class FileViewComponent implements OnInit {
|
||||
ngOnInit() {
|
||||
this.route.params.subscribe((params) => {
|
||||
const id = params.nodeId;
|
||||
this.versionId = params.versionId;
|
||||
if (id) {
|
||||
this.nodeApiService.getNode(id).subscribe(
|
||||
(node) => {
|
||||
@@ -92,6 +94,10 @@ export class FileViewComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
onViewVersion(versionId: string) {
|
||||
this.preview.showResource(this.nodeId, versionId);
|
||||
}
|
||||
|
||||
onViewerVisibilityChanged() {
|
||||
const primaryUrl = this.router.parseUrl(this.router.url).root.children[PRIMARY_OUTLET].toString();
|
||||
this.router.navigateByUrl(primaryUrl);
|
||||
|
@@ -32,7 +32,9 @@
|
||||
[newFileVersion]="newFileVersion"
|
||||
[allowDownload]="allowDownload"
|
||||
[showComments]="showComments"
|
||||
(uploadError)="uploadError($event)"></adf-version-manager>
|
||||
(uploadError)="uploadError($event)"
|
||||
(viewVersion)="onViewVersion($event)"
|
||||
></adf-version-manager>
|
||||
</section>
|
||||
<section mat-dialog-content *ngIf="readOnly">
|
||||
<adf-version-list [node]="contentEntry" [showActions]="false"></adf-version-list>
|
||||
|
@@ -19,6 +19,7 @@ import { Component, Inject, ViewEncapsulation } from '@angular/core';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
import { MinimalNodeEntryEntity } from '@alfresco/js-api';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { PreviewService } from '../../services/preview.service';
|
||||
|
||||
@Component({
|
||||
templateUrl: './version-manager-dialog-adapter.component.html',
|
||||
@@ -34,7 +35,8 @@ export class VersionManagerDialogAdapterComponent {
|
||||
readOnly = false;
|
||||
showVersionComparison = false;
|
||||
|
||||
constructor(@Inject(MAT_DIALOG_DATA) data: any,
|
||||
constructor(private previewService: PreviewService,
|
||||
@Inject(MAT_DIALOG_DATA) data: any,
|
||||
private snackBar: MatSnackBar,
|
||||
private containingDialog?: MatDialogRef<VersionManagerDialogAdapterComponent>) {
|
||||
this.contentEntry = data.contentEntry;
|
||||
@@ -51,6 +53,11 @@ export class VersionManagerDialogAdapterComponent {
|
||||
this.containingDialog.close();
|
||||
}
|
||||
|
||||
onViewVersion(versionId: string) {
|
||||
this.previewService.showResource(this.contentEntry.id, versionId);
|
||||
this.close();
|
||||
}
|
||||
|
||||
hideVersionComparison(isCancelled: boolean | Node) {
|
||||
if (isCancelled) {
|
||||
this.showVersionComparison = false;
|
||||
|
@@ -26,8 +26,12 @@ export class PreviewService {
|
||||
|
||||
constructor(private router: Router) {}
|
||||
|
||||
showResource(resourceId): void {
|
||||
this.router.navigate([{ outlets: { overlay: ['files', resourceId, 'view'] } }]);
|
||||
showResource(resourceId, versionId?): void {
|
||||
if (versionId) {
|
||||
this.router.navigate([{outlets: {overlay: ['files', resourceId, versionId, 'view']}}]);
|
||||
} else {
|
||||
this.router.navigate([{outlets: {overlay: ['files', resourceId, 'view']}}]);
|
||||
}
|
||||
}
|
||||
|
||||
showBlob(name: string, content: Blob): void {
|
||||
|
Reference in New Issue
Block a user