[ACA-1548][ACA-1807] Set viewer toolbar actions via extensions (#640)

* [ACA-1548][ACA-1807] add download action via extension

* [ACA-1548][ACA-1807] add print action via extension

* [ACA-1548][ACA-1807] add fullscreen viewer action via extension

* [ACA-1548][ACA-1807] prettier formatting
This commit is contained in:
Suzana Dirla
2018-09-18 18:01:25 +03:00
committed by Denys Vuika
parent 93b738cf31
commit 8a11137eed
7 changed files with 126 additions and 6 deletions

View File

@@ -4,7 +4,9 @@
[fileNodeId]="nodeId"
[allowNavigate]="navigateMultiple"
[allowSidebar]="true"
[allowPrint] ="true"
[allowPrint] ="false"
[allowDownload]="false"
[allowFullScreen]="false"
[canNavigateBefore]="previousNodeId"
[canNavigateNext]="nextNodeId"
[overlayMode]="true"

View File

@@ -57,7 +57,7 @@ import { NodeInfo, DeletedNodeInfo, DeleteStatus } from '../store/models';
import { ContentApiService } from './content-api.service';
import { sharedUrl } from '../store/selectors/app.selectors';
import { NodeActionsService } from './node-actions.service';
import { TranslationService } from '@alfresco/adf-core';
import { TranslationService, ViewUtilService } from '@alfresco/adf-core';
import { NodeVersionsDialogComponent } from '../dialogs/node-versions/node-versions.dialog';
import { take, map, tap, mergeMap, catchError } from 'rxjs/operators';
import { NodePermissionsDialogComponent } from '../components/permissions/permission-dialog/node-permissions.dialog';
@@ -90,7 +90,8 @@ export class ContentManagementService {
private dialogRef: MatDialog,
private nodeActionsService: NodeActionsService,
private translation: TranslationService,
private snackBar: MatSnackBar
private snackBar: MatSnackBar,
private viewUtils: ViewUtilService
) {}
addFavorite(nodes: Array<MinimalNodeEntity>) {
@@ -1050,4 +1051,38 @@ export class ContentManagementService {
return i18nMessageString;
}
printFile(node: MinimalNodeEntity) {
if (node && node.entry) {
// shared and favorite
const id = node.entry.nodeId || (<any>node).entry.guid || node.entry.id;
const mimeType = node.entry.content.mimeType;
if (id) {
this.viewUtils.printFileGeneric(id, mimeType);
}
}
}
/**
* Triggers full screen mode with a main content area displayed.
*/
fullscreenViewer() {
const container = <any>(
document.documentElement.querySelector(
'.adf-viewer__fullscreen-container'
)
);
if (container) {
if (container.requestFullscreen) {
container.requestFullscreen();
} else if (container.webkitRequestFullscreen) {
container.webkitRequestFullscreen();
} else if (container.mozRequestFullScreen) {
container.mozRequestFullScreen();
} else if (container.msRequestFullscreen) {
container.msRequestFullscreen();
}
}
}
}

View File

@@ -40,6 +40,8 @@ export const COPY_NODES = 'COPY_NODES';
export const MOVE_NODES = 'MOVE_NODES';
export const MANAGE_PERMISSIONS = 'MANAGE_PERMISSIONS';
export const MANAGE_VERSIONS = 'MANAGE_VERSIONS';
export const PRINT_FILE = 'PRINT_FILE';
export const FULLSCREEN_VIEWER = 'FULLSCREEN_VIEWER';
export class SetSelectedNodesAction implements Action {
readonly type = SET_SELECTED_NODES;
@@ -110,3 +112,13 @@ export class ManageVersionsAction implements Action {
readonly type = MANAGE_VERSIONS;
constructor(public payload: MinimalNodeEntity) {}
}
export class PrintFileAction implements Action {
readonly type = PRINT_FILE;
constructor(public payload: MinimalNodeEntity) {}
}
export class FullscreenViewerAction implements Action {
readonly type = FULLSCREEN_VIEWER;
constructor(public payload: MinimalNodeEntity) {}
}

View File

@@ -56,7 +56,11 @@ import {
ManagePermissionsAction,
MANAGE_PERMISSIONS,
ManageVersionsAction,
MANAGE_VERSIONS
MANAGE_VERSIONS,
PRINT_FILE,
PrintFileAction,
FULLSCREEN_VIEWER,
FullscreenViewerAction
} from '../actions/node.actions';
@Injectable()
@@ -285,4 +289,31 @@ export class NodeEffects {
}
})
);
@Effect({ dispatch: false })
printFile$ = this.actions$.pipe(
ofType<PrintFileAction>(PRINT_FILE),
map(action => {
if (action && action.payload) {
this.contentService.printFile(action.payload);
} else {
this.store
.select(appSelection)
.pipe(take(1))
.subscribe(selection => {
if (selection && selection.file) {
this.contentService.printFile(selection.file);
}
});
}
})
);
@Effect({ dispatch: false })
fullscreenViewer$ = this.actions$.pipe(
ofType<FullscreenViewerAction>(FULLSCREEN_VIEWER),
map(() => {
this.contentService.fullscreenViewer();
})
);
}