Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ACA-2077] viewer - filter recent files #866

Merged
merged 2 commits into from
Dec 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 26 additions & 23 deletions src/app/components/preview/preview.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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<AppStore>,
Expand Down Expand Up @@ -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);
Expand Down
48 changes: 24 additions & 24 deletions src/app/services/data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -45,29 +68,6 @@ export class AppDataService extends CustomResourcesService {
personId: string,
pagination: PaginationModel
): Observable<ResultSetPaging> {
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) => {
Expand All @@ -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'],
Expand Down