diff --git a/ng2-components/ng2-alfresco-search/demo/src/main.ts b/ng2-components/ng2-alfresco-search/demo/src/main.ts index 4386921fac..becc39edc9 100644 --- a/ng2-components/ng2-alfresco-search/demo/src/main.ts +++ b/ng2-components/ng2-alfresco-search/demo/src/main.ts @@ -29,8 +29,7 @@ import { import { ALFRESCO_SEARCH_PROVIDERS, - ALFRESCO_SEARCH_DIRECTIVES, - AlfrescoService + ALFRESCO_SEARCH_DIRECTIVES } from 'ng2-alfresco-search'; @Component({ @@ -65,11 +64,9 @@ class SearchDemo implements OnInit { token: string; - constructor( - private authService: AlfrescoAuthenticationService, - private alfrescoSettingsService: AlfrescoSettingsService, - translation: AlfrescoTranslationService, - searchService: AlfrescoService) { + constructor(private authService: AlfrescoAuthenticationService, + private alfrescoSettingsService: AlfrescoSettingsService, + translation: AlfrescoTranslationService) { alfrescoSettingsService.host = this.host; if (localStorage.getItem('token')) { @@ -93,9 +90,15 @@ class SearchDemo implements OnInit { } login() { - this.authService.login('admin', 'admin').subscribe(token => { - this.authenticated = true; - }); + this.authService.login('admin', 'admin').subscribe( + token => { + console.log(token); + this.authenticated = true; + }, + error => { + console.log(error); + this.authenticated = false; + }); } searchTermChange(event) { @@ -106,5 +109,6 @@ class SearchDemo implements OnInit { bootstrap(SearchDemo, [ HTTP_PROVIDERS, - ALFRESCO_CORE_PROVIDERS + ALFRESCO_CORE_PROVIDERS, + ALFRESCO_SEARCH_PROVIDERS ]); diff --git a/ng2-components/ng2-alfresco-search/index.ts b/ng2-components/ng2-alfresco-search/index.ts index 7a7d55c706..ce1d9c8e4a 100644 --- a/ng2-components/ng2-alfresco-search/index.ts +++ b/ng2-components/ng2-alfresco-search/index.ts @@ -15,13 +15,14 @@ * limitations under the License. */ -import { AlfrescoService } from './src/services/alfresco.service'; +import { AlfrescoSearchService } from './src/services/alfresco-search.service'; +import { AlfrescoThumbnailService } from './src/services/alfresco-thumbnail.service'; import { AlfrescoSearchComponent } from './src/components/alfresco-search.component'; import { AlfrescoSearchControlComponent } from './src/components/alfresco-search-control.component'; // services -export * from './src/services/alfresco.service'; - +export * from './src/services/alfresco-search.service'; +export * from './src/services/alfresco-thumbnail.service'; export * from './src/components/alfresco-search.component'; export * from './src/components/alfresco-search-control.component'; @@ -31,7 +32,8 @@ export default { AlfrescoSearchControlComponent ], providers: [ - AlfrescoService + AlfrescoSearchService, + AlfrescoThumbnailService ] }; @@ -41,5 +43,6 @@ export const ALFRESCO_SEARCH_DIRECTIVES: [any] = [ ]; export const ALFRESCO_SEARCH_PROVIDERS: [any] = [ - AlfrescoService + AlfrescoSearchService, + AlfrescoThumbnailService ]; diff --git a/ng2-components/ng2-alfresco-search/package.json b/ng2-components/ng2-alfresco-search/package.json index 544af99cdd..efbfc9e1be 100644 --- a/ng2-components/ng2-alfresco-search/package.json +++ b/ng2-components/ng2-alfresco-search/package.json @@ -13,11 +13,13 @@ "tslint": "npm run tslint-src && npm run tslint-root", "tslint-src": "tslint -c tslint.json src/**/*.ts", "tslint-root": "tslint -c tslint.json *.ts", - "copytemplates": "npm run copy-html-css && npm run copy-i18n", - "copytemplates:w": "concurrently \"npm run copy-html-css:w\" \"npm run copy-i18n:w\"", + "copytemplates": "npm run copy-html-css && npm run copy-i18n && npm run copy-images", + "copytemplates:w": "concurrently \"npm run copy-html-css:w\" \"npm run copy-i18n:w\" \"npm run copy-images:w\"", "copy-html-css": "cpx './src/**/*.{html,css}' dist/src", "copy-html-css:w": "cpx './src/**/*.{html,css}' dist/src -w", "copy-i18n": "cpx './i18n/**/*.json' dist/i18n", + "copy-images": "cpx './src/**/*.{png,jpg,gif,svg}' dist/src", + "copy-images:w": "cpx './src/**/*.{png,jpg,gif,svg}' dist/src -w", "copy-i18n:w": "cpx './i18n/**/*.json' dist/i18n -w", "tsc": "tsc", "tsc:w": "tsc -w", diff --git a/ng2-components/ng2-alfresco-search/src/assets/alfresco.service.mock.ts b/ng2-components/ng2-alfresco-search/src/assets/alfresco.service.mock.ts index 3ddef936fd..7072b33403 100644 --- a/ng2-components/ng2-alfresco-search/src/assets/alfresco.service.mock.ts +++ b/ng2-components/ng2-alfresco-search/src/assets/alfresco.service.mock.ts @@ -22,9 +22,9 @@ import { AlfrescoAuthenticationService, AlfrescoContentService } from 'ng2-alfresco-core'; -import {AlfrescoService} from './../../src/services/alfresco.service'; +import {AlfrescoSearchService} from './../../src/services/alfresco-search.service'; -export class AlfrescoServiceMock extends AlfrescoService { +export class AlfrescoServiceMock extends AlfrescoSearchService { _folderToReturn: any = {}; diff --git a/ng2-components/ng2-alfresco-search/src/components/alfresco-search-autocomplete.component.css b/ng2-components/ng2-alfresco-search/src/components/alfresco-search-autocomplete.component.css new file mode 100644 index 0000000000..2f022f6db0 --- /dev/null +++ b/ng2-components/ng2-alfresco-search/src/components/alfresco-search-autocomplete.component.css @@ -0,0 +1,38 @@ +:host { + position: absolute; + z-index: 1; + display: none; + color: #555; + margin: -21px 0px 0px 0px; +} +:host a { + color: #555; + text-decoration: none; +} +:host table { + width: 300px; +} +:host .mdl-data-table tbody tr { + height: 32px; +} +:host .mdl-data-table td { + height: 32px; + padding: 8px; + text-align: left; + border-top: none; + border-bottom: none; +} +:host.active.valid { + display: block; +} + +.img-td{ + width: 30px; +} + +.truncate{ + width: 240px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} diff --git a/ng2-components/ng2-alfresco-search/src/components/alfresco-search-autocomplete.component.html b/ng2-components/ng2-alfresco-search/src/components/alfresco-search-autocomplete.component.html index 868ca1dcf2..3b280380cd 100644 --- a/ng2-components/ng2-alfresco-search/src/components/alfresco-search-autocomplete.component.html +++ b/ng2-components/ng2-alfresco-search/src/components/alfresco-search-autocomplete.component.html @@ -1,7 +1,9 @@ - - + + +
{{result.entry.name}}
{{result.entry.name}}
{{result.entry.createdByUser.displayName}}
diff --git a/ng2-components/ng2-alfresco-search/src/components/alfresco-search-autocomplete.component.ts b/ng2-components/ng2-alfresco-search/src/components/alfresco-search-autocomplete.component.ts index efabc8765d..615595d9f7 100644 --- a/ng2-components/ng2-alfresco-search/src/components/alfresco-search-autocomplete.component.ts +++ b/ng2-components/ng2-alfresco-search/src/components/alfresco-search-autocomplete.component.ts @@ -17,15 +17,13 @@ import { Component, - ElementRef, EventEmitter, Input, OnChanges, - Output, - Renderer + Output } from '@angular/core'; -import { AlfrescoService } from './../services/alfresco.service'; - +import { AlfrescoSearchService } from './../services/alfresco-search.service'; +import { AlfrescoThumbnailService } from './../services/alfresco-thumbnail.service'; import { AlfrescoPipeTranslate, AlfrescoTranslationService } from 'ng2-alfresco-core'; declare let __moduleName: string; @@ -33,40 +31,15 @@ declare let __moduleName: string; @Component({ moduleId: __moduleName, selector: 'alfresco-search-autocomplete', - styles: [ - `:host { - position: absolute; - z-index: 1; - display: none; - color: #555; - } - :host a { - color: #555; - text-decoration: none; - } - :host table { - width: 300px; - } - :host .mdl-data-table tbody tr { - height: 32px; - } - :host .mdl-data-table td { - height: 32px; - padding: 8px; - text-align: left; - border-top: none; - border-bottom: none; - } - :host.active.valid { - display: block; - }` - ], templateUrl: './alfresco-search-autocomplete.component.html', - providers: [AlfrescoService], + styleUrls: ['./alfresco-search-autocomplete.component.css'], + providers: [AlfrescoSearchService], pipes: [AlfrescoPipeTranslate] }) export class AlfrescoSearchAutocompleteComponent implements OnChanges { + baseComponentPath = __moduleName.replace('/components/alfresco-search-autocomplete.component.js', ''); + @Input() searchTerm: string = ''; @@ -81,18 +54,17 @@ export class AlfrescoSearchAutocompleteComponent implements OnChanges { preview: EventEmitter = new EventEmitter(); constructor( - private _alfrescoService: AlfrescoService, + private _alfrescoSearchService: AlfrescoSearchService, private translate: AlfrescoTranslationService, - private el: ElementRef, - private renderer: Renderer + private _alfrescoThumbnailService: AlfrescoThumbnailService ) { translate.addTranslationFolder('node_modules/ng2-alfresco-search'); this.results = null; } - ngOnChanges(changes) { + ngOnChanges(changes): void { if (changes.searchTerm) { - this.displaySearchResults(this.searchTerm); + this._displaySearchResults(this.searchTerm); } } @@ -100,9 +72,9 @@ export class AlfrescoSearchAutocompleteComponent implements OnChanges { * Loads and displays search results * @param searchTerm Search query entered by user */ - displaySearchResults(searchTerm) { + private _displaySearchResults(searchTerm) { if (searchTerm !== null && searchTerm !== '') { - this._alfrescoService + this._alfrescoSearchService .getLiveSearchResults(searchTerm) .subscribe( results => { @@ -117,7 +89,19 @@ export class AlfrescoSearchAutocompleteComponent implements OnChanges { } } - onItemClick(node, event?: Event) { + /** + * Gets thumbnail URL for the given document node. + * @param node Node to get URL for. + * @returns {string} URL address. + */ + _getMimeTypeIcon(node: any): string { + if (node.entry.content && node.entry.content.mimeType) { + let icon = this._alfrescoThumbnailService.getMimeTypeIcon(node.entry.content.mimeType); + return `${this.baseComponentPath}/img/${icon}`; + } + } + + _onItemClick(node, event?: Event): void { if (event) { event.preventDefault(); } diff --git a/ng2-components/ng2-alfresco-search/src/components/alfresco-search-control.component.css b/ng2-components/ng2-alfresco-search/src/components/alfresco-search-control.component.css new file mode 100644 index 0000000000..5678ec3a6c --- /dev/null +++ b/ng2-components/ng2-alfresco-search/src/components/alfresco-search-control.component.css @@ -0,0 +1,3 @@ +.search-field{ + width: 267px; +} diff --git a/ng2-components/ng2-alfresco-search/src/components/alfresco-search-control.component.html b/ng2-components/ng2-alfresco-search/src/components/alfresco-search-control.component.html index bb4f039fd7..55a2b9c4b9 100644 --- a/ng2-components/ng2-alfresco-search/src/components/alfresco-search-control.component.html +++ b/ng2-components/ng2-alfresco-search/src/components/alfresco-search-control.component.html @@ -1,13 +1,15 @@ -
-
+ +
-
- +
+
- + diff --git a/ng2-components/ng2-alfresco-search/src/components/alfresco-search-control.component.ts b/ng2-components/ng2-alfresco-search/src/components/alfresco-search-control.component.ts index d10e959a05..7ea00e6dcb 100644 --- a/ng2-components/ng2-alfresco-search/src/components/alfresco-search-control.component.ts +++ b/ng2-components/ng2-alfresco-search/src/components/alfresco-search-control.component.ts @@ -17,9 +17,7 @@ import { Control, Validators } from '@angular/common'; import { Component, Input, Output, EventEmitter, AfterViewInit } from '@angular/core'; - import { AlfrescoPipeTranslate, AlfrescoTranslationService } from 'ng2-alfresco-core'; - import { AlfrescoSearchAutocompleteComponent } from './alfresco-search-autocomplete.component'; declare let __moduleName: string; @@ -31,6 +29,7 @@ declare var componentHandler: any; styles: [ ], templateUrl: './alfresco-search-control.component.html', + styleUrls: ['./alfresco-search-control.component.css'], directives: [AlfrescoSearchAutocompleteComponent], pipes: [AlfrescoPipeTranslate] }) @@ -43,7 +42,7 @@ export class AlfrescoSearchControlComponent implements AfterViewInit { inputType = 'text'; @Input() - autocomplete: boolean = true; + autocomplete: boolean = false; @Input() expandable: boolean = true; @@ -81,21 +80,21 @@ export class AlfrescoSearchControlComponent implements AfterViewInit { translate.addTranslationFolder('node_modules/ng2-alfresco-search'); } - ngAfterViewInit() { + ngAfterViewInit(): void { if (componentHandler) { componentHandler.upgradeAllRegistered(); } } - getTextFieldClassName(): string { + _getTextFieldClassName(): string { return 'mdl-textfield mdl-js-textfield' + (this.expandable ? ' mdl-textfield--expandable' : ''); } - getTextFieldHolderClassName(): string { - return this.expandable ? ' mdl-textfield__expandable-holder' : ''; + _getTextFieldHolderClassName(): string { + return this.expandable ? 'search-field mdl-textfield__expandable-holder' : 'search-field'; } - getAutoComplete(): string { + _getAutoComplete(): string { return this.autocomplete ? 'on' : 'off'; } @@ -104,7 +103,7 @@ export class AlfrescoSearchControlComponent implements AfterViewInit { * * @param event Submit event that was fired */ - onSearch(event) { + _onSearch(event): void { if (event) { event.preventDefault(); } @@ -116,20 +115,20 @@ export class AlfrescoSearchControlComponent implements AfterViewInit { } } - onFileClicked(event) { + _onFileClicked(event): void { this.preview.emit({ value: event.value }); } - onFocus() { + _onFocus(): void { this.searchActive = true; } - onBlur() { + _onBlur(): void { window.setTimeout(() => { this.searchActive = false; - }, 100); + }, 200); } } diff --git a/ng2-components/ng2-alfresco-search/src/components/alfresco-search.component.html b/ng2-components/ng2-alfresco-search/src/components/alfresco-search.component.html index cb719c4938..f72976ca50 100644 --- a/ng2-components/ng2-alfresco-search/src/components/alfresco-search.component.html +++ b/ng2-components/ng2-alfresco-search/src/components/alfresco-search.component.html @@ -18,11 +18,13 @@ - - - {{result.entry.name}} - {{result.entry.modifiedByUser.displayName}} - {{result.entry.modifiedAt}} + + + + {{result.entry.name}} + {{result.entry.modifiedByUser + .displayName}} + {{result.entry.modifiedAt | date}} diff --git a/ng2-components/ng2-alfresco-search/src/components/alfresco-search.component.ts b/ng2-components/ng2-alfresco-search/src/components/alfresco-search.component.ts index 656bed63c9..e1be282162 100644 --- a/ng2-components/ng2-alfresco-search/src/components/alfresco-search.component.ts +++ b/ng2-components/ng2-alfresco-search/src/components/alfresco-search.component.ts @@ -17,8 +17,8 @@ import { Component, Input, Optional, OnChanges, OnInit } from '@angular/core'; import { RouteParams } from '@angular/router-deprecated'; -import { AlfrescoService } from './../services/alfresco.service'; - +import { AlfrescoSearchService } from './../services/alfresco-search.service'; +import { AlfrescoThumbnailService } from './../services/alfresco-thumbnail.service'; import { AlfrescoPipeTranslate, AlfrescoTranslationService } from 'ng2-alfresco-core'; declare let __moduleName: string; @@ -28,11 +28,13 @@ declare let __moduleName: string; selector: 'alfresco-search', styles: [], templateUrl: './alfresco-search.component.html', - providers: [AlfrescoService], + providers: [AlfrescoSearchService], pipes: [AlfrescoPipeTranslate] }) export class AlfrescoSearchComponent implements OnChanges, OnInit { + baseComponentPath = __moduleName.replace('/components/alfresco-search.component.js', ''); + @Input() searchTerm: string = ''; @@ -42,8 +44,9 @@ export class AlfrescoSearchComponent implements OnChanges, OnInit { route: any[] = []; - constructor(private _alfrescoService: AlfrescoService, + constructor(private _alfrescoSearchService: AlfrescoSearchService, private translate: AlfrescoTranslationService, + private _alfrescoThumbnailService: AlfrescoThumbnailService, @Optional() params: RouteParams) { translate.addTranslationFolder('node_modules/ng2-alfresco-search'); @@ -53,12 +56,12 @@ export class AlfrescoSearchComponent implements OnChanges, OnInit { } } - ngOnInit() { - this.displaySearchResults(this.searchTerm); + ngOnInit(): void { + this._displaySearchResults(this.searchTerm); } - ngOnChanges(changes) { - this.displaySearchResults(this.searchTerm); + ngOnChanges(changes): void { + this._displaySearchResults(this.searchTerm); } /** @@ -66,20 +69,20 @@ export class AlfrescoSearchComponent implements OnChanges, OnInit { * @param node Node to get URL for. * @returns {string} URL address. */ - getDocumentThumbnailUrl(node: any): string { - if (this._alfrescoService) { - return this._alfrescoService.getDocumentThumbnailUrl(node); + _getMimeTypeIcon(node: any): string { + if (node.entry.content && node.entry.content.mimeType) { + let icon = this._alfrescoThumbnailService.getMimeTypeIcon(node.entry.content.mimeType); + return `${this.baseComponentPath}/img/${icon}`; } - return null; } /** * Loads and displays search results * @param searchTerm Search query entered by user */ - displaySearchResults(searchTerm) { + private _displaySearchResults(searchTerm): void { if (searchTerm !== null) { - this._alfrescoService + this._alfrescoSearchService .getLiveSearchResults(searchTerm) .subscribe( results => { diff --git a/ng2-components/ng2-alfresco-search/src/img/document-list.empty-folder.png b/ng2-components/ng2-alfresco-search/src/img/document-list.empty-folder.png new file mode 100644 index 0000000000..7a23727b20 Binary files /dev/null and b/ng2-components/ng2-alfresco-search/src/img/document-list.empty-folder.png differ diff --git a/ng2-components/ng2-alfresco-search/src/img/ft_ic_archive.svg b/ng2-components/ng2-alfresco-search/src/img/ft_ic_archive.svg new file mode 100755 index 0000000000..b010f8065d --- /dev/null +++ b/ng2-components/ng2-alfresco-search/src/img/ft_ic_archive.svg @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-search/src/img/ft_ic_audio.svg b/ng2-components/ng2-alfresco-search/src/img/ft_ic_audio.svg new file mode 100755 index 0000000000..f3836172dd --- /dev/null +++ b/ng2-components/ng2-alfresco-search/src/img/ft_ic_audio.svg @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-search/src/img/ft_ic_database.svg b/ng2-components/ng2-alfresco-search/src/img/ft_ic_database.svg new file mode 100755 index 0000000000..6f7cbdb5dd --- /dev/null +++ b/ng2-components/ng2-alfresco-search/src/img/ft_ic_database.svg @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-search/src/img/ft_ic_document.svg b/ng2-components/ng2-alfresco-search/src/img/ft_ic_document.svg new file mode 100755 index 0000000000..62e011d124 --- /dev/null +++ b/ng2-components/ng2-alfresco-search/src/img/ft_ic_document.svg @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-search/src/img/ft_ic_ebook.svg b/ng2-components/ng2-alfresco-search/src/img/ft_ic_ebook.svg new file mode 100755 index 0000000000..c26452389f --- /dev/null +++ b/ng2-components/ng2-alfresco-search/src/img/ft_ic_ebook.svg @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-search/src/img/ft_ic_folder.svg b/ng2-components/ng2-alfresco-search/src/img/ft_ic_folder.svg new file mode 100755 index 0000000000..aff7d2871d --- /dev/null +++ b/ng2-components/ng2-alfresco-search/src/img/ft_ic_folder.svg @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-search/src/img/ft_ic_folder_empty.svg b/ng2-components/ng2-alfresco-search/src/img/ft_ic_folder_empty.svg new file mode 100755 index 0000000000..54d0b9003a --- /dev/null +++ b/ng2-components/ng2-alfresco-search/src/img/ft_ic_folder_empty.svg @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-search/src/img/ft_ic_form.svg b/ng2-components/ng2-alfresco-search/src/img/ft_ic_form.svg new file mode 100755 index 0000000000..d46e889326 --- /dev/null +++ b/ng2-components/ng2-alfresco-search/src/img/ft_ic_form.svg @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-search/src/img/ft_ic_google_docs.svg b/ng2-components/ng2-alfresco-search/src/img/ft_ic_google_docs.svg new file mode 100755 index 0000000000..1d9a03515b --- /dev/null +++ b/ng2-components/ng2-alfresco-search/src/img/ft_ic_google_docs.svg @@ -0,0 +1,147 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-search/src/img/ft_ic_google_drawings.svg b/ng2-components/ng2-alfresco-search/src/img/ft_ic_google_drawings.svg new file mode 100755 index 0000000000..a1eae45e65 --- /dev/null +++ b/ng2-components/ng2-alfresco-search/src/img/ft_ic_google_drawings.svg @@ -0,0 +1,147 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-search/src/img/ft_ic_google_forms.svg b/ng2-components/ng2-alfresco-search/src/img/ft_ic_google_forms.svg new file mode 100755 index 0000000000..d8946f40f9 --- /dev/null +++ b/ng2-components/ng2-alfresco-search/src/img/ft_ic_google_forms.svg @@ -0,0 +1,147 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-search/src/img/ft_ic_google_sheets.svg b/ng2-components/ng2-alfresco-search/src/img/ft_ic_google_sheets.svg new file mode 100755 index 0000000000..d6a96c144a --- /dev/null +++ b/ng2-components/ng2-alfresco-search/src/img/ft_ic_google_sheets.svg @@ -0,0 +1,148 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-search/src/img/ft_ic_google_slides.svg b/ng2-components/ng2-alfresco-search/src/img/ft_ic_google_slides.svg new file mode 100755 index 0000000000..61fab21ab7 --- /dev/null +++ b/ng2-components/ng2-alfresco-search/src/img/ft_ic_google_slides.svg @@ -0,0 +1,146 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-search/src/img/ft_ic_miscellaneous.svg b/ng2-components/ng2-alfresco-search/src/img/ft_ic_miscellaneous.svg new file mode 100755 index 0000000000..a6bd024609 --- /dev/null +++ b/ng2-components/ng2-alfresco-search/src/img/ft_ic_miscellaneous.svg @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-search/src/img/ft_ic_ms_excel.svg b/ng2-components/ng2-alfresco-search/src/img/ft_ic_ms_excel.svg new file mode 100755 index 0000000000..b98380dd76 --- /dev/null +++ b/ng2-components/ng2-alfresco-search/src/img/ft_ic_ms_excel.svg @@ -0,0 +1,157 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-search/src/img/ft_ic_ms_powerpoint.svg b/ng2-components/ng2-alfresco-search/src/img/ft_ic_ms_powerpoint.svg new file mode 100755 index 0000000000..a6166744c7 --- /dev/null +++ b/ng2-components/ng2-alfresco-search/src/img/ft_ic_ms_powerpoint.svg @@ -0,0 +1,152 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-search/src/img/ft_ic_ms_word.svg b/ng2-components/ng2-alfresco-search/src/img/ft_ic_ms_word.svg new file mode 100755 index 0000000000..046efc4f83 --- /dev/null +++ b/ng2-components/ng2-alfresco-search/src/img/ft_ic_ms_word.svg @@ -0,0 +1,151 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-search/src/img/ft_ic_pdf.svg b/ng2-components/ng2-alfresco-search/src/img/ft_ic_pdf.svg new file mode 100755 index 0000000000..4d6d4b388d --- /dev/null +++ b/ng2-components/ng2-alfresco-search/src/img/ft_ic_pdf.svg @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-search/src/img/ft_ic_presentation.svg b/ng2-components/ng2-alfresco-search/src/img/ft_ic_presentation.svg new file mode 100755 index 0000000000..7dce6d633c --- /dev/null +++ b/ng2-components/ng2-alfresco-search/src/img/ft_ic_presentation.svg @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-search/src/img/ft_ic_raster_image.svg b/ng2-components/ng2-alfresco-search/src/img/ft_ic_raster_image.svg new file mode 100755 index 0000000000..d48242ce6d --- /dev/null +++ b/ng2-components/ng2-alfresco-search/src/img/ft_ic_raster_image.svg @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-search/src/img/ft_ic_spreadsheet.svg b/ng2-components/ng2-alfresco-search/src/img/ft_ic_spreadsheet.svg new file mode 100755 index 0000000000..9de2326880 --- /dev/null +++ b/ng2-components/ng2-alfresco-search/src/img/ft_ic_spreadsheet.svg @@ -0,0 +1,151 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-search/src/img/ft_ic_vector_image.svg b/ng2-components/ng2-alfresco-search/src/img/ft_ic_vector_image.svg new file mode 100755 index 0000000000..cfa5dbe4bd --- /dev/null +++ b/ng2-components/ng2-alfresco-search/src/img/ft_ic_vector_image.svg @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-search/src/img/ft_ic_video.svg b/ng2-components/ng2-alfresco-search/src/img/ft_ic_video.svg new file mode 100755 index 0000000000..b93d993619 --- /dev/null +++ b/ng2-components/ng2-alfresco-search/src/img/ft_ic_video.svg @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-search/src/img/ft_ic_website.svg b/ng2-components/ng2-alfresco-search/src/img/ft_ic_website.svg new file mode 100755 index 0000000000..220bab2a91 --- /dev/null +++ b/ng2-components/ng2-alfresco-search/src/img/ft_ic_website.svg @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-search/src/services/alfresco.service.ts b/ng2-components/ng2-alfresco-search/src/services/alfresco-search.service.ts similarity index 78% rename from ng2-components/ng2-alfresco-search/src/services/alfresco.service.ts rename to ng2-components/ng2-alfresco-search/src/services/alfresco-search.service.ts index 72752faab1..7808ccb321 100644 --- a/ng2-components/ng2-alfresco-search/src/services/alfresco.service.ts +++ b/ng2-components/ng2-alfresco-search/src/services/alfresco-search.service.ts @@ -30,13 +30,11 @@ declare let AlfrescoApi: any; * Internal service used by Document List component. */ @Injectable() -export class AlfrescoService { +export class AlfrescoSearchService { - constructor( - private settings: AlfrescoSettingsService, - private authService: AlfrescoAuthenticationService, - private contentService: AlfrescoContentService - ) { + constructor(private settings: AlfrescoSettingsService, + private authService: AlfrescoAuthenticationService, + private contentService: AlfrescoContentService) { } private getAlfrescoClient() { @@ -60,23 +58,14 @@ export class AlfrescoService { * @param term Search term * @returns {Observable} Search results */ - getLiveSearchResults(term: string) { + public getLiveSearchResults(term: string): Observable { return Observable.fromPromise(this.getSearchNodesPromise(term)) .map(res => res) .do(data => console.log('Search data', data)) // eyeball results in the console .catch(this.handleError); } - /** - * Get thumbnail URL for the given document node. - * @param document Node to get URL for. - * @returns {string} URL address. - */ - getDocumentThumbnailUrl(document: any) { - return this.contentService.getDocumentThumbnailUrl(document); - } - - private handleError(error: any) { + private handleError(error: any): Observable { // in a real world app, we may send the error to some remote logging infrastructure // instead of just logging it to the console console.error(error); diff --git a/ng2-components/ng2-alfresco-search/src/services/alfresco-thumbnail.service.ts b/ng2-components/ng2-alfresco-search/src/services/alfresco-thumbnail.service.ts new file mode 100644 index 0000000000..e50a70d142 --- /dev/null +++ b/ng2-components/ng2-alfresco-search/src/services/alfresco-thumbnail.service.ts @@ -0,0 +1,74 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Injectable } from '@angular/core'; +import { + AlfrescoContentService +} from 'ng2-alfresco-core'; + +declare let AlfrescoApi: any; + +@Injectable() +export class AlfrescoThumbnailService { + 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 contentService: AlfrescoContentService + ) { + } + + /** + * Get thumbnail URL for the given document node. + * @param document Node to get URL for. + * @returns {string} URL address. + */ + public getDocumentThumbnailUrl(document: any): string { + return this.contentService.getDocumentThumbnailUrl(document); + } + + public getMimeTypeIcon(mimeType: string): string { + let icon = this.mimeTypeIcons[mimeType]; + return icon || 'ft_ic_miscellaneous.svg'; + } +}