[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

@@ -619,6 +619,8 @@ Below is the list of public actions types you can use in the plugin definitions
| UPLOAD_FILES | n/a | Invoke "Upload Files" dialog and upload files to the currently opened folder. |
| UPLOAD_FOLDER | n/a | Invoke "Upload Folder" dialog and upload selected folder to the currently opened one. |
| VIEW_FILE | MinimalNodeEntity | Preview the file (or selection) in the Viewer. |
| PRINT_FILE | MinimalNodeEntity | Print the file opened in the Viewer (or selected). |
| FULLSCREEN_VIEWER | n/a | Enters fullscreen mode to view the file opened in the Viewer. |
## Rules

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();
})
);
}

View File

@@ -628,8 +628,32 @@
"viewer": {
"toolbarActions": [
{
"id": "app.viewer.share",
"id": "app.toolbar.download",
"order": 100,
"title": "APP.ACTIONS.DOWNLOAD",
"icon": "get_app",
"actions": {
"click": "DOWNLOAD_NODES"
},
"rules": {
"visible": "app.toolbar.canDownload"
}
},
{
"id": "app.viewer.print",
"order": 200,
"title": "APP.ACTIONS.PRINT",
"icon": "print",
"actions": {
"click": "PRINT_FILE"
},
"rules": {
"visible": "app.toolbar.canViewFile"
}
},
{
"id": "app.viewer.share",
"order": 300,
"title": "APP.ACTIONS.SHARE",
"icon": "share",
"actions": {
@@ -638,6 +662,18 @@
"rules": {
"visible": "app.selection.file.canShare"
}
},
{
"id": "app.viewer.fullscreen",
"order": 400,
"title": "APP.ACTIONS.FULLSCREEN",
"icon": "fullscreen",
"actions": {
"click": "FULLSCREEN_VIEWER"
},
"rules": {
"visible": "app.toolbar.canViewFile"
}
}
],
"toolbarMoreMenu": [

View File

@@ -128,7 +128,9 @@
"DETAILS": "View details",
"VERSIONS": "Manage Versions",
"TOGGLE-SIDENAV": "Toggle side navigation bar",
"SHARE": "Share"
"SHARE": "Share",
"PRINT": "Print",
"FULLSCREEN": "Activate full-screen mode"
},
"DIALOGS": {
"CONFIRM_PURGE": {