mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
AAE-49653 Removing dead code and improvements
This commit is contained in:
@@ -35,11 +35,6 @@ Manages task filters.
|
|||||||
Gets all task filters for a task app.
|
Gets all task filters for a task app.
|
||||||
- _appName:_ `string` - (Optional) Name of the target app
|
- _appName:_ `string` - (Optional) Name of the target app
|
||||||
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`TaskFilterCloudModel`](../../../lib/process-services-cloud/src/lib/task/task-filters/models/filter-cloud.model.ts)`[]>` - Observable of task filter details
|
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`TaskFilterCloudModel`](../../../lib/process-services-cloud/src/lib/task/task-filters/models/filter-cloud.model.ts)`[]>` - Observable of task filter details
|
||||||
- **getTaskNotificationSubscription**(appName: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`TaskCloudEngineEvent`](../../../lib/process-services-cloud/src/lib/models/engine-event-cloud.model.ts)`[]>`<br/>
|
|
||||||
|
|
||||||
- _appName:_ `string` -
|
|
||||||
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`TaskCloudEngineEvent`](../../../lib/process-services-cloud/src/lib/models/engine-event-cloud.model.ts)`[]>` -
|
|
||||||
|
|
||||||
- **isDefaultFilter**(filterName: `string`): `boolean`<br/>
|
- **isDefaultFilter**(filterName: `string`): `boolean`<br/>
|
||||||
Checks if given filter is a default filter
|
Checks if given filter is a default filter
|
||||||
- _filterName:_ `string` - Name of the target task filter
|
- _filterName:_ `string` - Name of the target task filter
|
||||||
|
|||||||
+30
-28
@@ -75,10 +75,10 @@ export class ProcessFiltersCloudComponent implements OnInit, OnChanges {
|
|||||||
currentFilter?: ProcessFilterCloudModel;
|
currentFilter?: ProcessFilterCloudModel;
|
||||||
filters: ProcessFilterCloudModel[] = [];
|
filters: ProcessFilterCloudModel[] = [];
|
||||||
counters: { [key: string]: number } = {};
|
counters: { [key: string]: number } = {};
|
||||||
currentFiltersValues: { [key: string]: number } = {};
|
|
||||||
updatedFiltersSet = new Set<string>();
|
|
||||||
enableNotifications = true;
|
enableNotifications = true;
|
||||||
notificationDebounceTime = 3000;
|
notificationDebounceTime = 3000;
|
||||||
|
currentFiltersValues: { [key: string]: number } = {};
|
||||||
|
updatedFiltersSet = new Set<string>();
|
||||||
private filtersLoadedFor?: string;
|
private filtersLoadedFor?: string;
|
||||||
private countersSubscription?: Subscription;
|
private countersSubscription?: Subscription;
|
||||||
|
|
||||||
@@ -93,7 +93,6 @@ export class ProcessFiltersCloudComponent implements OnInit, OnChanges {
|
|||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.enableNotifications = this.appConfigService.get('notifications', true);
|
this.enableNotifications = this.appConfigService.get('notifications', true);
|
||||||
this.notificationDebounceTime = this.appConfigService.get('notificationDebounceTime', 3000);
|
this.notificationDebounceTime = this.appConfigService.get('notificationDebounceTime', 3000);
|
||||||
|
|
||||||
if (!this.filtersLoadedFor) {
|
if (!this.filtersLoadedFor) {
|
||||||
this.getFilters(this.appName);
|
this.getFilters(this.appName);
|
||||||
}
|
}
|
||||||
@@ -139,7 +138,7 @@ export class ProcessFiltersCloudComponent implements OnInit, OnChanges {
|
|||||||
/**
|
/**
|
||||||
* Initialize counter collection for filters
|
* Initialize counter collection for filters
|
||||||
*/
|
*/
|
||||||
initFilterCounters(): void {
|
initFilterCounters() {
|
||||||
this.filters.forEach((filter) => (this.counters[filter.key] = 0));
|
this.filters.forEach((filter) => (this.counters[filter.key] = 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,6 +164,20 @@ export class ProcessFiltersCloudComponent implements OnInit, OnChanges {
|
|||||||
); // fallback to preserve the previous behavior
|
); // fallback to preserve the previous behavior
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check equality of the filter names by translating the given name strings
|
||||||
|
*
|
||||||
|
* @param name1 source name
|
||||||
|
* @param name2 target name
|
||||||
|
* @returns `true` if filter names are equal, otherwise `false`
|
||||||
|
*/
|
||||||
|
private checkFilterNamesEquality(name1: string, name2: string): boolean {
|
||||||
|
const translatedName1 = this.translationService.instant(name1);
|
||||||
|
const translatedName2 = this.translationService.instant(name2);
|
||||||
|
|
||||||
|
return translatedName1.toLocaleLowerCase() === translatedName2.toLocaleLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Selects and emits the given filter
|
* Selects and emits the given filter
|
||||||
*
|
*
|
||||||
@@ -231,6 +244,14 @@ export class ProcessFiltersCloudComponent implements OnInit, OnChanges {
|
|||||||
return this.filters === undefined || (this.filters && this.filters.length === 0);
|
return this.filters === undefined || (this.filters && this.filters.length === 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset the filters
|
||||||
|
*/
|
||||||
|
private resetFilter() {
|
||||||
|
this.filters = [];
|
||||||
|
this.currentFilter = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
isActiveFilter(filter: ProcessFilterCloudModel): boolean {
|
isActiveFilter(filter: ProcessFilterCloudModel): boolean {
|
||||||
return this.currentFilter.name === filter.name;
|
return this.currentFilter.name === filter.name;
|
||||||
}
|
}
|
||||||
@@ -243,37 +264,18 @@ export class ProcessFiltersCloudComponent implements OnInit, OnChanges {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Flags the counter of a filter as read whenever the filter is refreshed elsewhere */
|
|
||||||
getFilterKeysAfterExternalRefreshing(): void {
|
|
||||||
this.processFilterCloudService.filterKeyToBeRefreshed$
|
|
||||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
||||||
.subscribe((filterKey: string) => this.updatedFiltersSet.delete(filterKey));
|
|
||||||
}
|
|
||||||
|
|
||||||
isFilterUpdated(filterName: string): boolean {
|
isFilterUpdated(filterName: string): boolean {
|
||||||
return this.updatedFiltersSet.has(filterName);
|
return this.updatedFiltersSet.has(filterName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check equality of the filter names by translating the given name strings
|
* Get filer key when filter was refreshed by external action
|
||||||
*
|
*
|
||||||
* @param name1 source name
|
|
||||||
* @param name2 target name
|
|
||||||
* @returns `true` if filter names are equal, otherwise `false`
|
|
||||||
*/
|
*/
|
||||||
private checkFilterNamesEquality(name1: string, name2: string): boolean {
|
getFilterKeysAfterExternalRefreshing(): void {
|
||||||
const translatedName1 = this.translationService.instant(name1);
|
this.processFilterCloudService.filterKeyToBeRefreshed$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((filterKey: string) => {
|
||||||
const translatedName2 = this.translationService.instant(name2);
|
this.updatedFiltersSet.delete(filterKey);
|
||||||
|
});
|
||||||
return translatedName1.toLocaleLowerCase() === translatedName2.toLocaleLowerCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reset the filters
|
|
||||||
*/
|
|
||||||
private resetFilter() {
|
|
||||||
this.filters = [];
|
|
||||||
this.currentFilter = undefined;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private loadFilterCounters(appName: string, filters$: Observable<ProcessFilterCloudModel[]>): void {
|
private loadFilterCounters(appName: string, filters$: Observable<ProcessFilterCloudModel[]>): void {
|
||||||
|
|||||||
-22
@@ -189,25 +189,3 @@ const mockAppVersion2: ApplicationVersionModel = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const mockAppVersions = [mockAppVersion1, mockAppVersion2];
|
export const mockAppVersions = [mockAppVersion1, mockAppVersion2];
|
||||||
|
|
||||||
export const processNotifications = [
|
|
||||||
{
|
|
||||||
eventType: 'PROCESS_CREATED',
|
|
||||||
entity: {
|
|
||||||
appVersion: '1',
|
|
||||||
id: 'bccc1217-7036-11ef-86f2-bae4749e773e',
|
|
||||||
processDefinitionId: 'Process_XmWTFMqf:1:1b30709b-6ff3-11ef-86f2-bae4749e773e',
|
|
||||||
processDefinitionKey: 'Process_XmWTFMqf',
|
|
||||||
initiator: 'hruser',
|
|
||||||
status: 'CREATED',
|
|
||||||
processDefinitionVersion: 1,
|
|
||||||
processDefinitionName: 'processchild'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
export const processCloudEngineEventsMock = {
|
|
||||||
data: {
|
|
||||||
engineEvents: processNotifications
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|||||||
+1
-14
@@ -25,12 +25,10 @@ import {
|
|||||||
fakeProcessCloudFilterEntries,
|
fakeProcessCloudFilterEntries,
|
||||||
fakeProcessCloudFilters,
|
fakeProcessCloudFilters,
|
||||||
fakeProcessCloudFilterWithDifferentEntries,
|
fakeProcessCloudFilterWithDifferentEntries,
|
||||||
fakeProcessFilter,
|
fakeProcessFilter
|
||||||
processCloudEngineEventsMock
|
|
||||||
} from '../mock/process-filters-cloud.mock';
|
} from '../mock/process-filters-cloud.mock';
|
||||||
import { ProcessFilterCloudModel } from '../models/process-filter-cloud.model';
|
import { ProcessFilterCloudModel } from '../models/process-filter-cloud.model';
|
||||||
import { IdentityUserService } from '../../../people/services/identity-user.service';
|
import { IdentityUserService } from '../../../people/services/identity-user.service';
|
||||||
import { NotificationCloudService } from '../../../services/notification-cloud.service';
|
|
||||||
import { ApolloTestingModule } from 'apollo-angular/testing';
|
import { ApolloTestingModule } from 'apollo-angular/testing';
|
||||||
import { NoopTranslateModule, NoopAuthModule } from '@alfresco/adf-core';
|
import { NoopTranslateModule, NoopAuthModule } from '@alfresco/adf-core';
|
||||||
|
|
||||||
@@ -41,7 +39,6 @@ describe('ProcessFilterCloudService', () => {
|
|||||||
let updatePreferenceSpy: jasmine.Spy;
|
let updatePreferenceSpy: jasmine.Spy;
|
||||||
let createPreferenceSpy: jasmine.Spy;
|
let createPreferenceSpy: jasmine.Spy;
|
||||||
let getCurrentUserInfoSpy: jasmine.Spy;
|
let getCurrentUserInfoSpy: jasmine.Spy;
|
||||||
let notificationCloudService: NotificationCloudService;
|
|
||||||
|
|
||||||
const identityUserMock = {
|
const identityUserMock = {
|
||||||
username: 'mock-username',
|
username: 'mock-username',
|
||||||
@@ -59,7 +56,6 @@ describe('ProcessFilterCloudService', () => {
|
|||||||
|
|
||||||
const preferenceCloudService = TestBed.inject(PROCESS_FILTERS_SERVICE_TOKEN);
|
const preferenceCloudService = TestBed.inject(PROCESS_FILTERS_SERVICE_TOKEN);
|
||||||
const identityUserService = TestBed.inject(IdentityUserService);
|
const identityUserService = TestBed.inject(IdentityUserService);
|
||||||
notificationCloudService = TestBed.inject(NotificationCloudService);
|
|
||||||
|
|
||||||
createPreferenceSpy = spyOn(preferenceCloudService, 'createPreference').and.returnValue(of(fakeProcessCloudFilters));
|
createPreferenceSpy = spyOn(preferenceCloudService, 'createPreference').and.returnValue(of(fakeProcessCloudFilters));
|
||||||
updatePreferenceSpy = spyOn(preferenceCloudService, 'updatePreference').and.returnValue(of(fakeProcessCloudFilters));
|
updatePreferenceSpy = spyOn(preferenceCloudService, 'updatePreference').and.returnValue(of(fakeProcessCloudFilters));
|
||||||
@@ -250,13 +246,4 @@ describe('ProcessFilterCloudService', () => {
|
|||||||
|
|
||||||
expect(updatePreferenceSpy).toHaveBeenCalledWith('mock-appName', 'process-filters-mock-appName-mock-username', fakeProcessCloudFilters);
|
expect(updatePreferenceSpy).toHaveBeenCalledWith('mock-appName', 'process-filters-mock-appName-mock-username', fakeProcessCloudFilters);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return engine event task subscription', async () => {
|
|
||||||
spyOn(notificationCloudService, 'makeGQLQuery').and.returnValue(of(processCloudEngineEventsMock));
|
|
||||||
|
|
||||||
const result = await firstValueFrom(service.getProcessNotificationSubscription('testApp'));
|
|
||||||
expect(result.length).toBe(1);
|
|
||||||
expect(result[0].eventType).toBe('PROCESS_CREATED');
|
|
||||||
expect(result[0].entity.status).toBe('CREATED');
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
-31
@@ -22,24 +22,6 @@ import { switchMap, map } from 'rxjs/operators';
|
|||||||
import { PROCESS_FILTERS_SERVICE_TOKEN } from '../../../services/cloud-token.service';
|
import { PROCESS_FILTERS_SERVICE_TOKEN } from '../../../services/cloud-token.service';
|
||||||
import { PreferenceCloudServiceInterface } from '../../../services/preference-cloud.interface';
|
import { PreferenceCloudServiceInterface } from '../../../services/preference-cloud.interface';
|
||||||
import { IdentityUserService } from '../../../people/services/identity-user.service';
|
import { IdentityUserService } from '../../../people/services/identity-user.service';
|
||||||
import { NotificationCloudService } from '../../../services/notification-cloud.service';
|
|
||||||
import { TaskCloudEngineEvent } from '../../../models/engine-event-cloud.model';
|
|
||||||
|
|
||||||
const PROCESS_EVENT_SUBSCRIPTION_QUERY = `
|
|
||||||
subscription {
|
|
||||||
engineEvents(eventType: [
|
|
||||||
PROCESS_CANCELLED
|
|
||||||
PROCESS_COMPLETED
|
|
||||||
PROCESS_CREATED
|
|
||||||
PROCESS_RESUMED
|
|
||||||
PROCESS_SUSPENDED
|
|
||||||
PROCESS_STARTED
|
|
||||||
]) {
|
|
||||||
eventType
|
|
||||||
entity
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@@ -52,7 +34,6 @@ export class ProcessFilterCloudService {
|
|||||||
|
|
||||||
protected readonly preferenceService = inject<PreferenceCloudServiceInterface>(PROCESS_FILTERS_SERVICE_TOKEN);
|
protected readonly preferenceService = inject<PreferenceCloudServiceInterface>(PROCESS_FILTERS_SERVICE_TOKEN);
|
||||||
protected readonly identityUserService = inject(IdentityUserService);
|
protected readonly identityUserService = inject(IdentityUserService);
|
||||||
private readonly notificationCloudService = inject(NotificationCloudService);
|
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.filtersSubject = new BehaviorSubject([]);
|
this.filtersSubject = new BehaviorSubject([]);
|
||||||
@@ -404,18 +385,6 @@ export class ProcessFilterCloudService {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated use FilterCountersCloudService.getEngineEvents instead.
|
|
||||||
*
|
|
||||||
* @param appName Name of the target app
|
|
||||||
* @returns Process engine events
|
|
||||||
*/
|
|
||||||
getProcessNotificationSubscription(appName: string): Observable<TaskCloudEngineEvent[]> {
|
|
||||||
return this.notificationCloudService
|
|
||||||
.makeGQLQuery(appName, PROCESS_EVENT_SUBSCRIPTION_QUERY)
|
|
||||||
.pipe(map((events: any) => events?.data?.engineEvents));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refresh filter key
|
* Refresh filter key
|
||||||
*
|
*
|
||||||
|
|||||||
+15
-13
@@ -77,7 +77,6 @@ export class TaskFiltersCloudComponent extends BaseTaskFiltersCloudComponent imp
|
|||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.enableNotifications = this.appConfigService.get('notifications', true);
|
this.enableNotifications = this.appConfigService.get('notifications', true);
|
||||||
this.notificationDebounceTime = this.appConfigService.get('notificationDebounceTime', 3000);
|
this.notificationDebounceTime = this.appConfigService.get('notificationDebounceTime', 3000);
|
||||||
|
|
||||||
if (!this.filtersLoadedFor) {
|
if (!this.filtersLoadedFor) {
|
||||||
this.getFilters(this.appName);
|
this.getFilters(this.appName);
|
||||||
}
|
}
|
||||||
@@ -223,6 +222,14 @@ export class TaskFiltersCloudComponent extends BaseTaskFiltersCloudComponent imp
|
|||||||
return this.filters === undefined || (this.filters && this.filters.length === 0);
|
return this.filters === undefined || (this.filters && this.filters.length === 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset the filters properties
|
||||||
|
*/
|
||||||
|
private resetFilter() {
|
||||||
|
this.filters = [];
|
||||||
|
this.currentFilter = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
checkIfFilterValuesHasBeenUpdated(filterKey: string, filterValue: number) {
|
checkIfFilterValuesHasBeenUpdated(filterKey: string, filterValue: number) {
|
||||||
if (this.currentFiltersValues[filterKey] === undefined || this.currentFiltersValues[filterKey] !== filterValue) {
|
if (this.currentFiltersValues[filterKey] === undefined || this.currentFiltersValues[filterKey] !== filterValue) {
|
||||||
this.currentFiltersValues = { ...this.currentFiltersValues, [filterKey]: filterValue };
|
this.currentFiltersValues = { ...this.currentFiltersValues, [filterKey]: filterValue };
|
||||||
@@ -231,11 +238,14 @@ export class TaskFiltersCloudComponent extends BaseTaskFiltersCloudComponent imp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Flags the counter of a filter as read whenever the filter is refreshed elsewhere */
|
/**
|
||||||
|
* Get filer key when filter was refreshed by external action
|
||||||
|
*
|
||||||
|
*/
|
||||||
getFilterKeysAfterExternalRefreshing(): void {
|
getFilterKeysAfterExternalRefreshing(): void {
|
||||||
this.taskFilterCloudService.filterKeyToBeRefreshed$
|
this.taskFilterCloudService.filterKeyToBeRefreshed$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((filterKey: string) => {
|
||||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
this.updatedCountersSet.delete(filterKey);
|
||||||
.subscribe((filterKey: string) => this.updatedCountersSet.delete(filterKey));
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private loadFilterCounters(appName: string, filters$: Observable<TaskFilterCloudModel[]>): void {
|
private loadFilterCounters(appName: string, filters$: Observable<TaskFilterCloudModel[]>): void {
|
||||||
@@ -261,12 +271,4 @@ export class TaskFiltersCloudComponent extends BaseTaskFiltersCloudComponent imp
|
|||||||
this.counters = { ...this.counters, [filter.key]: counter };
|
this.counters = { ...this.counters, [filter.key]: counter };
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Reset the filters properties
|
|
||||||
*/
|
|
||||||
private resetFilter() {
|
|
||||||
this.filters = [];
|
|
||||||
this.currentFilter = undefined;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -285,12 +285,6 @@ export const taskNotifications = [
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
export const taskCloudEngineEventsMock = {
|
|
||||||
data: {
|
|
||||||
engineEvents: taskNotifications
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const defaultTaskFiltersMock: TaskFilterCloudModel[] = [
|
export const defaultTaskFiltersMock: TaskFilterCloudModel[] = [
|
||||||
new TaskFilterCloudModel({
|
new TaskFilterCloudModel({
|
||||||
name: 'CREATED_TASK_FILTER',
|
name: 'CREATED_TASK_FILTER',
|
||||||
|
|||||||
+1
-16
@@ -25,12 +25,10 @@ import {
|
|||||||
fakePreferenceWithNoTaskFilterPreference,
|
fakePreferenceWithNoTaskFilterPreference,
|
||||||
fakeTaskCloudFilters,
|
fakeTaskCloudFilters,
|
||||||
fakeTaskCloudPreferenceList,
|
fakeTaskCloudPreferenceList,
|
||||||
fakeTaskFilter,
|
fakeTaskFilter
|
||||||
taskCloudEngineEventsMock
|
|
||||||
} from '../mock/task-filters-cloud.mock';
|
} from '../mock/task-filters-cloud.mock';
|
||||||
import { UserPreferenceCloudService } from '../../../services/user-preference-cloud.service';
|
import { UserPreferenceCloudService } from '../../../services/user-preference-cloud.service';
|
||||||
import { PreferenceCloudServiceInterface } from '../../../services/preference-cloud.interface';
|
import { PreferenceCloudServiceInterface } from '../../../services/preference-cloud.interface';
|
||||||
import { NotificationCloudService } from '../../../services/notification-cloud.service';
|
|
||||||
import { IdentityUserService } from '../../../people/services/identity-user.service';
|
import { IdentityUserService } from '../../../people/services/identity-user.service';
|
||||||
import { ApolloTestingModule } from 'apollo-angular/testing';
|
import { ApolloTestingModule } from 'apollo-angular/testing';
|
||||||
import { StorageService, NoopAuthModule, NoopTranslateModule } from '@alfresco/adf-core';
|
import { StorageService, NoopAuthModule, NoopTranslateModule } from '@alfresco/adf-core';
|
||||||
@@ -38,7 +36,6 @@ import { TaskStatusFilter } from '../models/filter-cloud.model';
|
|||||||
|
|
||||||
describe('TaskFilterCloudService', () => {
|
describe('TaskFilterCloudService', () => {
|
||||||
let service: TaskFilterCloudService;
|
let service: TaskFilterCloudService;
|
||||||
let notificationCloudService: NotificationCloudService;
|
|
||||||
|
|
||||||
let getPreferencesSpy: jasmine.Spy;
|
let getPreferencesSpy: jasmine.Spy;
|
||||||
let getPreferenceByKeySpy: jasmine.Spy;
|
let getPreferenceByKeySpy: jasmine.Spy;
|
||||||
@@ -58,7 +55,6 @@ describe('TaskFilterCloudService', () => {
|
|||||||
providers: [{ provide: TASK_FILTERS_SERVICE_TOKEN, useClass: UserPreferenceCloudService }]
|
providers: [{ provide: TASK_FILTERS_SERVICE_TOKEN, useClass: UserPreferenceCloudService }]
|
||||||
});
|
});
|
||||||
service = TestBed.inject(TaskFilterCloudService);
|
service = TestBed.inject(TaskFilterCloudService);
|
||||||
notificationCloudService = TestBed.inject(NotificationCloudService);
|
|
||||||
|
|
||||||
const preferenceCloudService = service.preferenceService;
|
const preferenceCloudService = service.preferenceService;
|
||||||
createPreferenceSpy = spyOn(preferenceCloudService, 'createPreference').and.returnValue(of(fakeTaskCloudFilters));
|
createPreferenceSpy = spyOn(preferenceCloudService, 'createPreference').and.returnValue(of(fakeTaskCloudFilters));
|
||||||
@@ -234,17 +230,6 @@ describe('TaskFilterCloudService', () => {
|
|||||||
expect(service.isDefaultFilter(defaultFilterName)).toBe(true);
|
expect(service.isDefaultFilter(defaultFilterName)).toBe(true);
|
||||||
expect(service.isDefaultFilter(fakeFilterName)).toBe(false);
|
expect(service.isDefaultFilter(fakeFilterName)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return engine event task subscription', (done) => {
|
|
||||||
spyOn(notificationCloudService, 'makeGQLQuery').and.returnValue(of(taskCloudEngineEventsMock));
|
|
||||||
|
|
||||||
service.getTaskNotificationSubscription('myAppName').subscribe((res) => {
|
|
||||||
expect(res.length).toBe(1);
|
|
||||||
expect(res[0].eventType).toBe('TASK_ASSIGNED');
|
|
||||||
expect(res[0].entity.name).toBe('This is a new task');
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Inject [LocalPreferenceCloudService] into the TaskFilterCloudService', () => {
|
describe('Inject [LocalPreferenceCloudService] into the TaskFilterCloudService', () => {
|
||||||
|
|||||||
-31
@@ -22,32 +22,12 @@ import { switchMap, map } from 'rxjs/operators';
|
|||||||
import { BaseCloudService } from '../../../services/base-cloud.service';
|
import { BaseCloudService } from '../../../services/base-cloud.service';
|
||||||
import { PreferenceCloudServiceInterface } from '../../../services/preference-cloud.interface';
|
import { PreferenceCloudServiceInterface } from '../../../services/preference-cloud.interface';
|
||||||
import { TASK_FILTERS_SERVICE_TOKEN } from '../../../services/cloud-token.service';
|
import { TASK_FILTERS_SERVICE_TOKEN } from '../../../services/cloud-token.service';
|
||||||
import { NotificationCloudService } from '../../../services/notification-cloud.service';
|
|
||||||
import { TaskCloudEngineEvent } from '../../../models/engine-event-cloud.model';
|
|
||||||
import { IdentityUserService } from '../../../people/services/identity-user.service';
|
import { IdentityUserService } from '../../../people/services/identity-user.service';
|
||||||
|
|
||||||
const TASK_EVENT_SUBSCRIPTION_QUERY = `
|
|
||||||
subscription {
|
|
||||||
engineEvents(eventType: [
|
|
||||||
TASK_COMPLETED
|
|
||||||
TASK_ASSIGNED
|
|
||||||
TASK_ACTIVATED
|
|
||||||
TASK_SUSPENDED
|
|
||||||
TASK_CANCELLED,
|
|
||||||
TASK_CREATED
|
|
||||||
]) {
|
|
||||||
eventType
|
|
||||||
entity
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class TaskFilterCloudService extends BaseCloudService {
|
export class TaskFilterCloudService extends BaseCloudService {
|
||||||
private readonly notificationCloudService = inject(NotificationCloudService);
|
|
||||||
|
|
||||||
public preferenceService = inject<PreferenceCloudServiceInterface>(TASK_FILTERS_SERVICE_TOKEN);
|
public preferenceService = inject<PreferenceCloudServiceInterface>(TASK_FILTERS_SERVICE_TOKEN);
|
||||||
|
|
||||||
protected identityUserService = inject(IdentityUserService);
|
protected identityUserService = inject(IdentityUserService);
|
||||||
@@ -323,17 +303,6 @@ export class TaskFilterCloudService extends BaseCloudService {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated use FilterCountersCloudService.getEngineEvents instead.
|
|
||||||
* @param appName Name of the target app
|
|
||||||
* @returns Task engine events
|
|
||||||
*/
|
|
||||||
getTaskNotificationSubscription(appName: string): Observable<TaskCloudEngineEvent[]> {
|
|
||||||
return this.notificationCloudService
|
|
||||||
.makeGQLQuery(appName, TASK_EVENT_SUBSCRIPTION_QUERY)
|
|
||||||
.pipe(map((events: any) => events.data.engineEvents));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refresh filter key
|
* Refresh filter key
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user