diff --git a/src/app/components/preview/preview.component.ts b/src/app/components/preview/preview.component.ts index 9a433a5b0b..b6283e7e2e 100644 --- a/src/app/components/preview/preview.component.ts +++ b/src/app/components/preview/preview.component.ts @@ -47,6 +47,8 @@ import { ContentApiService } from '../../services/content-api.service'; import { AppExtensionService } from '../../extensions/extension.service'; import { ContentManagementService } from '../../services/content-management.service'; import { ContentActionRef, ViewerExtensionRef } from '@alfresco/adf-extensions'; +import { SearchRequest } from 'alfresco-js-api'; +import { AppDataService } from '../../services/data.service'; @Component({ selector: 'app-preview', @@ -79,6 +81,7 @@ export class PreviewComponent extends PageComponent constructor( private contentApi: ContentApiService, private preferences: UserPreferencesService, + private appDataService: AppDataService, private route: ActivatedRoute, private router: Router, store: Store, @@ -336,29 +339,29 @@ export class PreviewComponent extends PageComponent const sortingDirection = this.preferences.get('recent-files.sorting.direction') || 'desc'; - const nodes = await this.contentApi - .search({ - query: { - query: '*', - language: 'afts' - }, - filterQueries: [ - { query: `cm:modified:[NOW/DAY-30DAYS TO NOW/DAY+1DAY]` }, - { query: `cm:modifier:${username} OR cm:creator:${username}` }, - { - query: `TYPE:"content" AND -TYPE:"app:filelink" AND -TYPE:"fm:post"` - } - ], - fields: ['id', this.getRootField(sortingKey)], - sort: [ - { - type: 'FIELD', - field: 'cm:modified', - ascending: false - } - ] - }) - .toPromise(); + const query: SearchRequest = { + query: { + query: '*', + language: 'afts' + }, + filterQueries: [ + { query: `cm:modified:[NOW/DAY-30DAYS TO NOW/DAY+1DAY]` }, + { query: `cm:modifier:${username} OR cm:creator:${username}` }, + { + query: this.appDataService.recentFileFilters.join(' AND ') + } + ], + fields: ['id', this.getRootField(sortingKey)], + include: ['path', 'properties', 'allowableOperations'], + sort: [ + { + type: 'FIELD', + field: 'cm:modified', + ascending: false + } + ] + }; + const nodes = await this.contentApi.search(query).toPromise(); const entries = nodes.list.entries.map(obj => obj.entry); this.sort(entries, sortingKey, sortingDirection); diff --git a/src/app/services/data.service.ts b/src/app/services/data.service.ts index b239f9093b..f3feeee4fa 100644 --- a/src/app/services/data.service.ts +++ b/src/app/services/data.service.ts @@ -37,6 +37,29 @@ import { PersonEntry, SearchRequest, ResultSetPaging } from 'alfresco-js-api'; providedIn: 'root' }) export class AppDataService extends CustomResourcesService { + recentFileFilters = [ + 'TYPE:"content"', + '-PNAME:"0/wiki"', + '-TYPE:"app:filelink"', + '-TYPE:"fm:post"', + '-TYPE:"cm:thumbnail"', + '-TYPE:"cm:failedThumbnail"', + '-TYPE:"cm:rating"', + '-TYPE:"dl:dataList"', + '-TYPE:"dl:todoList"', + '-TYPE:"dl:issue"', + '-TYPE:"dl:contact"', + '-TYPE:"dl:eventAgenda"', + '-TYPE:"dl:event"', + '-TYPE:"dl:task"', + '-TYPE:"dl:simpletask"', + '-TYPE:"dl:meetingAgenda"', + '-TYPE:"dl:location"', + '-TYPE:"fm:topic"', + '-TYPE:"fm:post"', + '-TYPE:"lnk:link"' + ]; + constructor(private api: AlfrescoApiService, logService: LogService) { super(api, logService); } @@ -45,29 +68,6 @@ export class AppDataService extends CustomResourcesService { personId: string, pagination: PaginationModel ): Observable { - const filters = [ - 'TYPE:"content"', - '-PNAME:"0/wiki"', - '-TYPE:"app:filelink"', - '-TYPE:"fm:post"', - '-TYPE:"cm:thumbnail"', - '-TYPE:"cm:failedThumbnail"', - '-TYPE:"cm:rating"', - '-TYPE:"dl:dataList"', - '-TYPE:"dl:todoList"', - '-TYPE:"dl:issue"', - '-TYPE:"dl:contact"', - '-TYPE:"dl:eventAgenda"', - '-TYPE:"dl:event"', - '-TYPE:"dl:task"', - '-TYPE:"dl:simpletask"', - '-TYPE:"dl:meetingAgenda"', - '-TYPE:"dl:location"', - '-TYPE:"fm:topic"', - '-TYPE:"fm:post"', - '-TYPE:"lnk:link"' - ]; - return new Observable(observer => { this.api.peopleApi.getPerson(personId).then( (person: PersonEntry) => { @@ -81,7 +81,7 @@ export class AppDataService extends CustomResourcesService { { query: `cm:modified:[NOW/DAY-30DAYS TO NOW/DAY+1DAY]` }, { query: `cm:modifier:${username} OR cm:creator:${username}` }, { - query: filters.join(' AND ') + query: this.recentFileFilters.join(' AND ') } ], include: ['path', 'properties', 'allowableOperations'],