diff --git a/src/app/common/common.module.ts b/src/app/common/common.module.ts
index 1625705af..96b3f78c6 100644
--- a/src/app/common/common.module.ts
+++ b/src/app/common/common.module.ts
@@ -35,7 +35,6 @@ import { MaterialModule } from './material.module';
import { NodeCopyDirective } from './directives/node-copy.directive';
import { NodeDeleteDirective } from './directives/node-delete.directive';
import { NodeMoveDirective } from './directives/node-move.directive';
-import { DownloadFileDirective } from './directives/node-download.directive';
import { NodeRestoreDirective } from './directives/node-restore.directive';
import { NodePermanentDeleteDirective } from './directives/node-permanent-delete.directive';
import { NodeUnshareDirective } from './directives/node-unshare.directive';
@@ -60,7 +59,6 @@ export function declarations() {
NodeCopyDirective,
NodeDeleteDirective,
NodeMoveDirective,
- DownloadFileDirective,
NodeRestoreDirective,
NodePermanentDeleteDirective,
NodeUnshareDirective
diff --git a/src/app/common/directives/node-download.directive.spec.ts b/src/app/common/directives/node-download.directive.spec.ts
deleted file mode 100644
index cc7018b3b..000000000
--- a/src/app/common/directives/node-download.directive.spec.ts
+++ /dev/null
@@ -1,147 +0,0 @@
-/*!
- * @license
- * Alfresco Example Content Application
- *
- * Copyright (C) 2005 - 2017 Alfresco Software Limited
- *
- * This file is part of the Alfresco Example Content Application.
- * If the software was purchased under a paid Alfresco license, the terms of
- * the paid license agreement will prevail. Otherwise, the software is
- * provided under the following open source license terms:
- *
- * The Alfresco Example Content Application is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * The Alfresco Example Content Application is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- */
-
-import { TestBed, ComponentFixture } from '@angular/core/testing';
-import { By } from '@angular/platform-browser';
-import { AlfrescoApiService } from '@alfresco/adf-core';
-import { MatDialog } from '@angular/material';
-import { Component, DebugElement } from '@angular/core';
-
-import { CommonModule } from '../common.module';
-import { DownloadFileDirective } from './node-download.directive';
-
-@Component({
- template: '
'
-})
-class TestComponent {
- selection;
-}
-
-describe('DownloadFileDirective', () => {
- let component: TestComponent;
- let fixture: ComponentFixture;
- let element: DebugElement;
- let dialog: MatDialog;
- let apiService: AlfrescoApiService;
- let contentService;
- let dialogSpy;
-
- beforeEach(() => {
- TestBed.configureTestingModule({
- imports: [
- CommonModule
- ],
- declarations: [
- TestComponent
- ]
- });
-
- fixture = TestBed.createComponent(TestComponent);
- component = fixture.componentInstance;
- element = fixture.debugElement.query(By.directive(DownloadFileDirective));
- dialog = TestBed.get(MatDialog);
- apiService = TestBed.get(AlfrescoApiService);
- contentService = apiService.getInstance().content;
- dialogSpy = spyOn(dialog, 'open');
- });
-
- it('should not download node when selection is empty', () => {
- spyOn(apiService, 'getInstance');
- component.selection = [];
-
- fixture.detectChanges();
- element.triggerEventHandler('click', null);
-
- expect(apiService.getInstance).not.toHaveBeenCalled();
- });
-
- it('should not download zip when selection has no nodes', () => {
- component.selection = [];
-
- fixture.detectChanges();
- element.triggerEventHandler('click', null);
-
- expect(dialogSpy).not.toHaveBeenCalled();
- });
-
- it('should download selected node as file', () => {
- spyOn(contentService, 'getContentUrl');
- const node = { entry: { id: 'node-id', isFile: true } };
- component.selection = [node];
-
- fixture.detectChanges();
- element.triggerEventHandler('click', null);
-
- expect(contentService.getContentUrl).toHaveBeenCalledWith(node.entry.id, true);
- });
-
- it('should download selected files nodes as zip', () => {
- const node1 = { entry: { id: 'node-1' } };
- const node2 = { entry: { id: 'node-2' } };
- component.selection = [node1, node2];
-
- fixture.detectChanges();
- element.triggerEventHandler('click', null);
-
- expect(dialogSpy.calls.argsFor(0)[1].data).toEqual({ nodeIds: [ 'node-1', 'node-2' ] });
- });
-
- it('should download selected folder node as zip', () => {
- const node = { entry: { isFolder: true, id: 'node-id' } };
- component.selection = [node];
-
- fixture.detectChanges();
- element.triggerEventHandler('click', null);
-
- expect(dialogSpy.calls.argsFor(0)[1].data).toEqual({ nodeIds: [ 'node-id' ] });
- });
-
- it('should create link element to download file node', () => {
- const dummyLinkElement = {
- download: null,
- href: null,
- click: () => null,
- style: {
- display: null
- }
- };
-
- const node = { entry: { name: 'dummy', isFile: true, id: 'node-id' } };
-
- spyOn(contentService, 'getContentUrl').and.returnValue('somewhere-over-the-rainbow');
- spyOn(document, 'createElement').and.returnValue(dummyLinkElement);
- spyOn(document.body, 'appendChild').and.stub();
- spyOn(document.body, 'removeChild').and.stub();
-
- component.selection = [node];
-
- fixture.detectChanges();
- element.triggerEventHandler('click', null);
-
- expect(document.createElement).toHaveBeenCalled();
- expect(dummyLinkElement.download).toBe('dummy');
- expect(dummyLinkElement.href).toContain('somewhere-over-the-rainbow');
- });
-});
diff --git a/src/app/common/directives/node-download.directive.ts b/src/app/common/directives/node-download.directive.ts
deleted file mode 100644
index 7c9a9a777..000000000
--- a/src/app/common/directives/node-download.directive.ts
+++ /dev/null
@@ -1,120 +0,0 @@
-/*!
- * @license
- * Alfresco Example Content Application
- *
- * Copyright (C) 2005 - 2017 Alfresco Software Limited
- *
- * This file is part of the Alfresco Example Content Application.
- * If the software was purchased under a paid Alfresco license, the terms of
- * the paid license agreement will prevail. Otherwise, the software is
- * provided under the following open source license terms:
- *
- * The Alfresco Example Content Application is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * The Alfresco Example Content Application is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- */
-
-import { Directive, Input, HostListener } from '@angular/core';
-import { MatDialog } from '@angular/material';
-import { MinimalNodeEntity } from 'alfresco-js-api';
-import { AlfrescoApiService } from '@alfresco/adf-core';
-import { DownloadZipDialogComponent } from '@alfresco/adf-content-services';
-
-@Directive({
- selector: '[app-download-node]'
-})
-export class DownloadFileDirective {
-
- @Input('app-download-node')
- nodes: MinimalNodeEntity[];
-
- @HostListener('click')
- onClick() {
- this.downloadNodes(this.nodes);
- }
-
- constructor(
- private apiService: AlfrescoApiService,
- private dialog: MatDialog
- ) {}
-
- private downloadNodes(selection: Array) {
- if (!selection || selection.length === 0) {
- return;
- }
-
- if (selection.length === 1) {
- this.downloadNode(selection[0]);
- } else {
- this.downloadZip(selection);
- }
- }
-
- private downloadNode(node: MinimalNodeEntity) {
- if (node && node.entry) {
- const entry = node.entry;
-
- if (entry.isFile) {
- this.downloadFile(node);
- }
-
- if (entry.isFolder) {
- this.downloadZip([node]);
- }
-
- // Check if there's nodeId for Shared Files
- if (!entry.isFile && !entry.isFolder && (entry).nodeId) {
- this.downloadFile(node);
- }
- }
- }
-
- private downloadFile(node: MinimalNodeEntity) {
- if (node && node.entry) {
- const contentApi = this.apiService.getInstance().content;
-
- const url = contentApi.getContentUrl(node.entry.id, true);
- const fileName = node.entry.name;
-
- this.download(url, fileName);
- }
- }
-
- private downloadZip(selection: Array) {
- if (selection && selection.length > 0) {
- // nodeId for Shared node
- const nodeIds = selection.map((node: any) => (node.entry.nodeId || node.entry.id));
-
- this.dialog.open(DownloadZipDialogComponent, {
- width: '600px',
- disableClose: true,
- data: {
- nodeIds
- }
- });
- }
- }
-
- private download(url: string, fileName: string) {
- if (url && fileName) {
- const link = document.createElement('a');
-
- link.style.display = 'none';
- link.download = fileName;
- link.href = url;
-
- document.body.appendChild(link);
- link.click();
- document.body.removeChild(link);
- }
- }
-}
diff --git a/src/app/components/favorites/favorites.component.html b/src/app/components/favorites/favorites.component.html
index 8f9849b46..574d197a3 100644
--- a/src/app/components/favorites/favorites.component.html
+++ b/src/app/components/favorites/favorites.component.html
@@ -17,7 +17,7 @@
mat-icon-button
*ngIf="hasSelection(documentList.selection)"
title="{{ 'APP.ACTIONS.DOWNLOAD' | translate }}"
- [app-download-node]="documentList.selection">
+ [adfNodeDownload]="documentList.selection">
get_app
diff --git a/src/app/components/files/files.component.html b/src/app/components/files/files.component.html
index e68c71787..2c52b116d 100644
--- a/src/app/components/files/files.component.html
+++ b/src/app/components/files/files.component.html
@@ -19,7 +19,7 @@
mat-icon-button
*ngIf="hasSelection(documentList.selection)"
title="{{ 'APP.ACTIONS.DOWNLOAD' | translate }}"
- [app-download-node]="documentList.selection">
+ [adfNodeDownload]="documentList.selection">
get_app
diff --git a/src/app/components/recent-files/recent-files.component.html b/src/app/components/recent-files/recent-files.component.html
index b51490ca8..25d6ec207 100644
--- a/src/app/components/recent-files/recent-files.component.html
+++ b/src/app/components/recent-files/recent-files.component.html
@@ -17,7 +17,7 @@
mat-icon-button
*ngIf="hasSelection(documentList.selection)"
title="{{ 'APP.ACTIONS.DOWNLOAD' | translate }}"
- [app-download-node]="documentList.selection">
+ [adfNodeDownload]="documentList.selection">
get_app
diff --git a/src/app/components/shared-files/shared-files.component.html b/src/app/components/shared-files/shared-files.component.html
index 9a813a5d8..649176b2b 100644
--- a/src/app/components/shared-files/shared-files.component.html
+++ b/src/app/components/shared-files/shared-files.component.html
@@ -17,7 +17,7 @@
mat-icon-button
*ngIf="hasSelection(documentList.selection)"
title="{{ 'APP.ACTIONS.DOWNLOAD' | translate }}"
- [app-download-node]="documentList.selection">
+ [adfNodeDownload]="documentList.selection">
get_app