[ADF-506] Unify thumbnail service (#2014)

* move thumbnail service in core

* fix folder
This commit is contained in:
Eugenio Romano
2017-07-06 10:43:13 +02:00
parent f07876df7e
commit ee871ba578
72 changed files with 477 additions and 3926 deletions

View File

@@ -19,48 +19,18 @@ import { Injectable } from '@angular/core';
import { Response } from '@angular/http';
import { Observable } from 'rxjs/Rx';
import { NodePaging, MinimalNodeEntity, MinimalNodeEntryEntity } from 'alfresco-js-api';
import { AlfrescoAuthenticationService, AlfrescoContentService, AlfrescoApiService, LogService } from 'ng2-alfresco-core';
import { AlfrescoAuthenticationService, AlfrescoContentService, AlfrescoApiService, LogService, ThumbnailService } from 'ng2-alfresco-core';
@Injectable()
export class DocumentListService {
static DEFAULT_MIME_TYPE_ICON: string = 'ft_ic_miscellaneous.svg';
static ROOT_ID = '-root-';
mimeTypeIcons: any = {
'image/png': 'ft_ic_raster_image.svg',
'image/jpeg': 'ft_ic_raster_image.svg',
'image/gif': 'ft_ic_raster_image.svg',
'application/pdf': 'ft_ic_pdf.svg',
'application/vnd.ms-excel': 'ft_ic_ms_excel.svg',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': 'ft_ic_ms_excel.svg',
'application/vnd.openxmlformats-officedocument.spreadsheetml.template': 'ft_ic_ms_excel.svg',
'application/msword': 'ft_ic_ms_word.svg',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document': 'ft_ic_ms_word.svg',
'application/vnd.openxmlformats-officedocument.wordprocessingml.template': 'ft_ic_ms_word.svg',
'application/vnd.ms-powerpoint': 'ft_ic_ms_powerpoint.svg',
'application/vnd.openxmlformats-officedocument.presentationml.presentation': 'ft_ic_ms_powerpoint.svg',
'application/vnd.openxmlformats-officedocument.presentationml.template': 'ft_ic_ms_powerpoint.svg',
'application/vnd.openxmlformats-officedocument.presentationml.slideshow': 'ft_ic_ms_powerpoint.svg',
'video/mp4': 'ft_ic_video.svg',
'text/plain': 'ft_ic_document.svg',
'application/x-javascript': 'ft_ic_document.svg',
'application/json': 'ft_ic_document.svg',
'image/svg+xml': 'ft_ic_vector_image.svg',
'text/html': 'ft_ic_website.svg',
'application/x-compressed': 'ft_ic_archive.svg',
'application/x-zip-compressed': 'ft_ic_archive.svg',
'application/zip': 'ft_ic_archive.svg',
'application/vnd.apple.keynote': 'ft_ic_presentation.svg',
'application/vnd.apple.pages': 'ft_ic_document.svg',
'application/vnd.apple.numbers': 'ft_ic_spreadsheet.svg'
};
constructor(private authService: AlfrescoAuthenticationService,
private contentService: AlfrescoContentService,
private apiService: AlfrescoApiService,
private logService: LogService) {
private logService: LogService,
private thumbnailService: ThumbnailService) {
}
private getNodesPromise(folder: string, opts?: any): Promise<NodePaging> {
@@ -134,15 +104,15 @@ export class DocumentListService {
* @returns {string} URL address.
*/
getDocumentThumbnailUrl(node: MinimalNodeEntity) {
if (node && this.contentService) {
return this.contentService.getDocumentThumbnailUrl(node);
}
return null;
return this.thumbnailService.getDocumentThumbnailUrl(node);
}
getMimeTypeIcon(mimeType: string): string {
let icon = this.mimeTypeIcons[mimeType];
return icon || DocumentListService.DEFAULT_MIME_TYPE_ICON;
return this.thumbnailService.getMimeTypeIcon(mimeType);
}
getDefaultMimeTypeIcon(): string {
return this.thumbnailService.getDefaultMimeTypeIcon();
}
private handleError(error: Response) {