mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[AAE-1501] EditProcessCloud/EditTaskCloud - Ability to fetch applications by role (#5380)
* ProcessFilter - Be able to fetch applications based on the role * TaskFilter - be able to fetch the applications by role
This commit is contained in:
@@ -40,8 +40,8 @@ export class AppsProcessCloudService {
|
|||||||
* @param status Required status value
|
* @param status Required status value
|
||||||
* @returns The list of deployed apps
|
* @returns The list of deployed apps
|
||||||
*/
|
*/
|
||||||
getDeployedApplicationsByStatus(status: string): Observable<ApplicationInstanceModel[]> {
|
getDeployedApplicationsByStatus(status: string, role?: string): Observable<ApplicationInstanceModel[]> {
|
||||||
return this.hasDeployedApps() ? of(this.deployedApps) : this.getApplicationsByStatus(status);
|
return this.hasDeployedApps() ? of(this.deployedApps) : this.getApplicationsByStatus(status, role);
|
||||||
}
|
}
|
||||||
|
|
||||||
hasDeployedApps(): boolean {
|
hasDeployedApps(): boolean {
|
||||||
@@ -57,13 +57,13 @@ export class AppsProcessCloudService {
|
|||||||
this.deployedApps = apps;
|
this.deployedApps = apps;
|
||||||
}
|
}
|
||||||
|
|
||||||
private getApplicationsByStatus(status: string): Observable<ApplicationInstanceModel[]> {
|
private getApplicationsByStatus(status: string, role?: string): Observable<ApplicationInstanceModel[]> {
|
||||||
if (status === '') {
|
if (status === '') {
|
||||||
return of([]);
|
return of([]);
|
||||||
}
|
}
|
||||||
const api: Oauth2Auth = this.apiService.getInstance().oauth2Auth;
|
const api: Oauth2Auth = this.apiService.getInstance().oauth2Auth;
|
||||||
const path = this.getApplicationUrl();
|
const path = this.getApplicationUrl();
|
||||||
const pathParams = {}, queryParams = { status: status, sort: 'name' },
|
const pathParams = {}, queryParams = { status: status, roles : role, sort: 'name' },
|
||||||
headerParams = {}, formParams = {}, bodyParam = {},
|
headerParams = {}, formParams = {}, bodyParam = {},
|
||||||
contentTypes = ['application/json'], accepts = ['application/json'];
|
contentTypes = ['application/json'], accepts = ['application/json'];
|
||||||
|
|
||||||
|
@@ -28,6 +28,7 @@ import { ProcessFilterCloudModel, ProcessFilterProperties, ProcessFilterAction,
|
|||||||
import { TranslationService, UserPreferencesService, UserPreferenceValues } from '@alfresco/adf-core';
|
import { TranslationService, UserPreferencesService, UserPreferenceValues } from '@alfresco/adf-core';
|
||||||
import { ProcessFilterCloudService } from '../services/process-filter-cloud.service';
|
import { ProcessFilterCloudService } from '../services/process-filter-cloud.service';
|
||||||
import { ProcessFilterDialogCloudComponent } from './process-filter-dialog-cloud.component';
|
import { ProcessFilterDialogCloudComponent } from './process-filter-dialog-cloud.component';
|
||||||
|
import { ApplicationInstanceModel } from '../../../app/models/application-instance.model';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'adf-cloud-edit-process-filter',
|
selector: 'adf-cloud-edit-process-filter',
|
||||||
@@ -53,6 +54,9 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes
|
|||||||
@Input()
|
@Input()
|
||||||
appName: string = '';
|
appName: string = '';
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
role: string = '';
|
||||||
|
|
||||||
/** Id of the process instance filter. */
|
/** Id of the process instance filter. */
|
||||||
@Input()
|
@Input()
|
||||||
id: string;
|
id: string;
|
||||||
@@ -116,7 +120,8 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes
|
|||||||
private userPreferencesService: UserPreferencesService,
|
private userPreferencesService: UserPreferencesService,
|
||||||
private translateService: TranslationService,
|
private translateService: TranslationService,
|
||||||
private processFilterCloudService: ProcessFilterCloudService,
|
private processFilterCloudService: ProcessFilterCloudService,
|
||||||
private appsProcessCloudService: AppsProcessCloudService) { }
|
private appsProcessCloudService: AppsProcessCloudService) {
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.userPreferencesService
|
this.userPreferencesService
|
||||||
@@ -132,9 +137,11 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
ngOnDestroy() {
|
||||||
* Build process filter edit form
|
this.onDestroy$.next(true);
|
||||||
*/
|
this.onDestroy$.complete();
|
||||||
|
}
|
||||||
|
|
||||||
buildForm(processFilterProperties: ProcessFilterProperties[]) {
|
buildForm(processFilterProperties: ProcessFilterProperties[]) {
|
||||||
this.formHasBeenChanged = false;
|
this.formHasBeenChanged = false;
|
||||||
this.editProcessFilterForm = this.formBuilder.group(this.getFormControlsConfig(processFilterProperties));
|
this.editProcessFilterForm = this.formBuilder.group(this.getFormControlsConfig(processFilterProperties));
|
||||||
@@ -155,7 +162,10 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes
|
|||||||
this.isLoading = true;
|
this.isLoading = true;
|
||||||
this.processFilterCloudService
|
this.processFilterCloudService
|
||||||
.getFilterById(this.appName, this.id)
|
.getFilterById(this.appName, this.id)
|
||||||
.pipe(finalize(() => this.isLoading = false))
|
.pipe(
|
||||||
|
finalize(() => this.isLoading = false),
|
||||||
|
takeUntil(this.onDestroy$)
|
||||||
|
)
|
||||||
.subscribe(response => {
|
.subscribe(response => {
|
||||||
this.processFilter = new ProcessFilterCloudModel(response);
|
this.processFilter = new ProcessFilterCloudModel(response);
|
||||||
this.processFilterProperties = this.createAndFilterProperties();
|
this.processFilterProperties = this.createAndFilterProperties();
|
||||||
@@ -295,8 +305,9 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes
|
|||||||
|
|
||||||
getRunningApplications() {
|
getRunningApplications() {
|
||||||
this.appsProcessCloudService
|
this.appsProcessCloudService
|
||||||
.getDeployedApplicationsByStatus(EditProcessFilterCloudComponent.APP_RUNNING_STATUS)
|
.getDeployedApplicationsByStatus(EditProcessFilterCloudComponent.APP_RUNNING_STATUS, this.role)
|
||||||
.subscribe(applications => {
|
.pipe(takeUntil(this.onDestroy$))
|
||||||
|
.subscribe((applications: ApplicationInstanceModel[]) => {
|
||||||
if (applications && applications.length > 0) {
|
if (applications && applications.length > 0) {
|
||||||
applications.map((application) => {
|
applications.map((application) => {
|
||||||
this.applicationNames.push({ label: application.name, value: application.name });
|
this.applicationNames.push({ label: application.name, value: application.name });
|
||||||
@@ -315,12 +326,10 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Save a process instance filter
|
|
||||||
*/
|
|
||||||
save(saveAction: ProcessFilterAction) {
|
save(saveAction: ProcessFilterAction) {
|
||||||
this.processFilterCloudService
|
this.processFilterCloudService
|
||||||
.updateFilter(this.changedProcessFilter)
|
.updateFilter(this.changedProcessFilter)
|
||||||
|
.pipe(takeUntil(this.onDestroy$))
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
saveAction.filter = this.changedProcessFilter;
|
saveAction.filter = this.changedProcessFilter;
|
||||||
this.action.emit(saveAction);
|
this.action.emit(saveAction);
|
||||||
@@ -334,6 +343,7 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes
|
|||||||
delete(deleteAction: ProcessFilterAction) {
|
delete(deleteAction: ProcessFilterAction) {
|
||||||
this.processFilterCloudService
|
this.processFilterCloudService
|
||||||
.deleteFilter(this.processFilter)
|
.deleteFilter(this.processFilter)
|
||||||
|
.pipe(takeUntil(this.onDestroy$))
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
deleteAction.filter = this.processFilter;
|
deleteAction.filter = this.processFilter;
|
||||||
this.action.emit(deleteAction);
|
this.action.emit(deleteAction);
|
||||||
@@ -364,6 +374,7 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes
|
|||||||
const resultFilter: ProcessFilterCloudModel = Object.assign({}, this.changedProcessFilter, newFilter);
|
const resultFilter: ProcessFilterCloudModel = Object.assign({}, this.changedProcessFilter, newFilter);
|
||||||
this.processFilterCloudService
|
this.processFilterCloudService
|
||||||
.addFilter(resultFilter)
|
.addFilter(resultFilter)
|
||||||
|
.pipe(takeUntil(this.onDestroy$))
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
saveAsAction.filter = resultFilter;
|
saveAsAction.filter = resultFilter;
|
||||||
this.action.emit(saveAsAction);
|
this.action.emit(saveAsAction);
|
||||||
@@ -540,8 +551,4 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
|
||||||
this.onDestroy$.next(true);
|
|
||||||
this.onDestroy$.complete();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -54,6 +54,10 @@ export class EditTaskFilterCloudComponent implements OnInit, OnChanges, OnDestro
|
|||||||
@Input()
|
@Input()
|
||||||
appName: string = '';
|
appName: string = '';
|
||||||
|
|
||||||
|
/** user role. */
|
||||||
|
@Input()
|
||||||
|
role: string = '';
|
||||||
|
|
||||||
/** (required) ID of the task filter. */
|
/** (required) ID of the task filter. */
|
||||||
@Input()
|
@Input()
|
||||||
id: string;
|
id: string;
|
||||||
@@ -317,9 +321,9 @@ export class EditTaskFilterCloudComponent implements OnInit, OnChanges, OnDestro
|
|||||||
return JSON.stringify(editedQuery).toLowerCase() === JSON.stringify(currentQuery).toLowerCase();
|
return JSON.stringify(editedQuery).toLowerCase() === JSON.stringify(currentQuery).toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
getRunningApplications(): void {
|
getRunningApplications() {
|
||||||
this.appsProcessCloudService
|
this.appsProcessCloudService
|
||||||
.getDeployedApplicationsByStatus(EditTaskFilterCloudComponent.APP_RUNNING_STATUS)
|
.getDeployedApplicationsByStatus(EditTaskFilterCloudComponent.APP_RUNNING_STATUS, this.role)
|
||||||
.pipe(takeUntil(this.onDestroy$))
|
.pipe(takeUntil(this.onDestroy$))
|
||||||
.subscribe((applications: ApplicationInstanceModel[]) => {
|
.subscribe((applications: ApplicationInstanceModel[]) => {
|
||||||
if (applications && applications.length > 0) {
|
if (applications && applications.length > 0) {
|
||||||
|
Reference in New Issue
Block a user