-
-
+
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';
+ }
+}