mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
[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:
committed by
Denys Vuika
parent
93b738cf31
commit
8a11137eed
@@ -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_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. |
|
| 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. |
|
| 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
|
## Rules
|
||||||
|
|
||||||
|
@@ -4,7 +4,9 @@
|
|||||||
[fileNodeId]="nodeId"
|
[fileNodeId]="nodeId"
|
||||||
[allowNavigate]="navigateMultiple"
|
[allowNavigate]="navigateMultiple"
|
||||||
[allowSidebar]="true"
|
[allowSidebar]="true"
|
||||||
[allowPrint] ="true"
|
[allowPrint] ="false"
|
||||||
|
[allowDownload]="false"
|
||||||
|
[allowFullScreen]="false"
|
||||||
[canNavigateBefore]="previousNodeId"
|
[canNavigateBefore]="previousNodeId"
|
||||||
[canNavigateNext]="nextNodeId"
|
[canNavigateNext]="nextNodeId"
|
||||||
[overlayMode]="true"
|
[overlayMode]="true"
|
||||||
|
@@ -57,7 +57,7 @@ import { NodeInfo, DeletedNodeInfo, DeleteStatus } from '../store/models';
|
|||||||
import { ContentApiService } from './content-api.service';
|
import { ContentApiService } from './content-api.service';
|
||||||
import { sharedUrl } from '../store/selectors/app.selectors';
|
import { sharedUrl } from '../store/selectors/app.selectors';
|
||||||
import { NodeActionsService } from './node-actions.service';
|
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 { NodeVersionsDialogComponent } from '../dialogs/node-versions/node-versions.dialog';
|
||||||
import { take, map, tap, mergeMap, catchError } from 'rxjs/operators';
|
import { take, map, tap, mergeMap, catchError } from 'rxjs/operators';
|
||||||
import { NodePermissionsDialogComponent } from '../components/permissions/permission-dialog/node-permissions.dialog';
|
import { NodePermissionsDialogComponent } from '../components/permissions/permission-dialog/node-permissions.dialog';
|
||||||
@@ -90,7 +90,8 @@ export class ContentManagementService {
|
|||||||
private dialogRef: MatDialog,
|
private dialogRef: MatDialog,
|
||||||
private nodeActionsService: NodeActionsService,
|
private nodeActionsService: NodeActionsService,
|
||||||
private translation: TranslationService,
|
private translation: TranslationService,
|
||||||
private snackBar: MatSnackBar
|
private snackBar: MatSnackBar,
|
||||||
|
private viewUtils: ViewUtilService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
addFavorite(nodes: Array<MinimalNodeEntity>) {
|
addFavorite(nodes: Array<MinimalNodeEntity>) {
|
||||||
@@ -1050,4 +1051,38 @@ export class ContentManagementService {
|
|||||||
|
|
||||||
return i18nMessageString;
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -40,6 +40,8 @@ export const COPY_NODES = 'COPY_NODES';
|
|||||||
export const MOVE_NODES = 'MOVE_NODES';
|
export const MOVE_NODES = 'MOVE_NODES';
|
||||||
export const MANAGE_PERMISSIONS = 'MANAGE_PERMISSIONS';
|
export const MANAGE_PERMISSIONS = 'MANAGE_PERMISSIONS';
|
||||||
export const MANAGE_VERSIONS = 'MANAGE_VERSIONS';
|
export const MANAGE_VERSIONS = 'MANAGE_VERSIONS';
|
||||||
|
export const PRINT_FILE = 'PRINT_FILE';
|
||||||
|
export const FULLSCREEN_VIEWER = 'FULLSCREEN_VIEWER';
|
||||||
|
|
||||||
export class SetSelectedNodesAction implements Action {
|
export class SetSelectedNodesAction implements Action {
|
||||||
readonly type = SET_SELECTED_NODES;
|
readonly type = SET_SELECTED_NODES;
|
||||||
@@ -110,3 +112,13 @@ export class ManageVersionsAction implements Action {
|
|||||||
readonly type = MANAGE_VERSIONS;
|
readonly type = MANAGE_VERSIONS;
|
||||||
constructor(public payload: MinimalNodeEntity) {}
|
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) {}
|
||||||
|
}
|
||||||
|
@@ -56,7 +56,11 @@ import {
|
|||||||
ManagePermissionsAction,
|
ManagePermissionsAction,
|
||||||
MANAGE_PERMISSIONS,
|
MANAGE_PERMISSIONS,
|
||||||
ManageVersionsAction,
|
ManageVersionsAction,
|
||||||
MANAGE_VERSIONS
|
MANAGE_VERSIONS,
|
||||||
|
PRINT_FILE,
|
||||||
|
PrintFileAction,
|
||||||
|
FULLSCREEN_VIEWER,
|
||||||
|
FullscreenViewerAction
|
||||||
} from '../actions/node.actions';
|
} from '../actions/node.actions';
|
||||||
|
|
||||||
@Injectable()
|
@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();
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
@@ -628,8 +628,32 @@
|
|||||||
"viewer": {
|
"viewer": {
|
||||||
"toolbarActions": [
|
"toolbarActions": [
|
||||||
{
|
{
|
||||||
"id": "app.viewer.share",
|
"id": "app.toolbar.download",
|
||||||
"order": 100,
|
"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",
|
"title": "APP.ACTIONS.SHARE",
|
||||||
"icon": "share",
|
"icon": "share",
|
||||||
"actions": {
|
"actions": {
|
||||||
@@ -638,6 +662,18 @@
|
|||||||
"rules": {
|
"rules": {
|
||||||
"visible": "app.selection.file.canShare"
|
"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": [
|
"toolbarMoreMenu": [
|
||||||
|
@@ -128,7 +128,9 @@
|
|||||||
"DETAILS": "View details",
|
"DETAILS": "View details",
|
||||||
"VERSIONS": "Manage Versions",
|
"VERSIONS": "Manage Versions",
|
||||||
"TOGGLE-SIDENAV": "Toggle side navigation bar",
|
"TOGGLE-SIDENAV": "Toggle side navigation bar",
|
||||||
"SHARE": "Share"
|
"SHARE": "Share",
|
||||||
|
"PRINT": "Print",
|
||||||
|
"FULLSCREEN": "Activate full-screen mode"
|
||||||
},
|
},
|
||||||
"DIALOGS": {
|
"DIALOGS": {
|
||||||
"CONFIRM_PURGE": {
|
"CONFIRM_PURGE": {
|
||||||
|
Reference in New Issue
Block a user