mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
move app process service in process-service (#8087)
This commit is contained in:
@@ -18,7 +18,8 @@
|
||||
import { DebugElement, Component } from '@angular/core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { AppsProcessService, setupTestBed } from '@alfresco/adf-core';
|
||||
import { setupTestBed } from '@alfresco/adf-core';
|
||||
import { AppsProcessService } from './services/apps-process.service';
|
||||
import { of, throwError } from 'rxjs';
|
||||
|
||||
import { defaultApp, deployedApps, nonDeployedApps } from '../mock/apps-list.mock';
|
||||
|
@@ -15,7 +15,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { AppsProcessService, TranslationService, CustomEmptyContentTemplateDirective } from '@alfresco/adf-core';
|
||||
import { TranslationService, CustomEmptyContentTemplateDirective } from '@alfresco/adf-core';
|
||||
import { AppsProcessService } from './services/apps-process.service';
|
||||
import { AfterContentInit, Component, EventEmitter, Input, OnInit, Output, ContentChild, OnDestroy, ViewEncapsulation } from '@angular/core';
|
||||
import { Observable, Observer, of, Subject } from 'rxjs';
|
||||
import { AppDefinitionRepresentationModel } from '../task-list';
|
||||
|
@@ -0,0 +1,30 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2019 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.
|
||||
*/
|
||||
|
||||
export const fakeApps = {
|
||||
size: 2, total: 2, start: 0,
|
||||
data: [
|
||||
{
|
||||
id: 1, defaultAppId: null, name: 'Sales-Fakes-App', description: 'desc-fake1', modelId: 22,
|
||||
theme: 'theme-1-fake', icon: 'glyphicon-asterisk', deploymentId: '111', tenantId: null
|
||||
},
|
||||
{
|
||||
id: 2, defaultAppId: null, name: 'health-care-Fake', description: 'desc-fake2', modelId: 33,
|
||||
theme: 'theme-2-fake', icon: 'glyphicon-asterisk', deploymentId: '444', tenantId: null
|
||||
}
|
||||
]
|
||||
};
|
@@ -18,4 +18,6 @@
|
||||
export * from './apps-list.component';
|
||||
export * from './select-apps-dialog.component';
|
||||
|
||||
export * from './services/apps-process.service';
|
||||
|
||||
export * from './apps-list.module';
|
||||
|
@@ -19,7 +19,8 @@ import { Component } from '@angular/core';
|
||||
import { TestBed, ComponentFixture } from '@angular/core/testing';
|
||||
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||
import { OverlayContainer } from '@angular/cdk/overlay';
|
||||
import { AppsProcessService, setupTestBed } from '@alfresco/adf-core';
|
||||
import { setupTestBed } from '@alfresco/adf-core';
|
||||
import { AppsProcessService } from './services/apps-process.service';
|
||||
import { deployedApps } from '../mock/apps-list.mock';
|
||||
import { of } from 'rxjs';
|
||||
|
||||
|
@@ -15,9 +15,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { AppsProcessService } from '@alfresco/adf-core';
|
||||
import { Component, Inject } from '@angular/core';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
import { AppsProcessService } from './services/apps-process.service';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-select-apps-dialog',
|
||||
|
@@ -0,0 +1,106 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2019 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 { TestBed } from '@angular/core/testing';
|
||||
import { fakeApps } from '../mocks/apps-service.mock';
|
||||
import { AppsProcessService } from './apps-process.service';
|
||||
import { setupTestBed, CoreTestingModule } from '@alfresco/adf-core';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
describe('AppsProcessService', () => {
|
||||
|
||||
let service: AppsProcessService;
|
||||
|
||||
setupTestBed({
|
||||
imports: [
|
||||
TranslateModule.forRoot(),
|
||||
CoreTestingModule
|
||||
]
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
service = TestBed.inject(AppsProcessService);
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
jasmine.Ajax.install();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jasmine.Ajax.uninstall();
|
||||
});
|
||||
|
||||
it('should get the deployed apps ', (done) => {
|
||||
service.getDeployedApplications().subscribe(
|
||||
(res: any) => {
|
||||
expect(res).toBeDefined();
|
||||
expect(res.length).toEqual(2);
|
||||
expect(res[0].name).toEqual('Sales-Fakes-App');
|
||||
expect(res[0].description).toEqual('desc-fake1');
|
||||
expect(res[0].deploymentId).toEqual('111');
|
||||
expect(res[1].name).toEqual('health-care-Fake');
|
||||
expect(res[1].description).toEqual('desc-fake2');
|
||||
expect(res[1].deploymentId).toEqual('444');
|
||||
done();
|
||||
}
|
||||
);
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify(fakeApps)
|
||||
});
|
||||
});
|
||||
|
||||
it('should get the filter deployed app ', (done) => {
|
||||
service.getDeployedApplicationsByName('health-care-Fake').subscribe(
|
||||
(res: any) => {
|
||||
expect(res).toBeDefined();
|
||||
expect(res.name).toEqual('health-care-Fake');
|
||||
expect(res.description).toEqual('desc-fake2');
|
||||
expect(res.deploymentId).toEqual('444');
|
||||
done();
|
||||
}
|
||||
);
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify(fakeApps)
|
||||
});
|
||||
});
|
||||
|
||||
it('should get the deployed app details by id ', (done) => {
|
||||
service.getApplicationDetailsById(1).subscribe(
|
||||
(app: any) => {
|
||||
expect(app).toBeDefined();
|
||||
expect(app.name).toEqual('Sales-Fakes-App');
|
||||
expect(app.description).toEqual('desc-fake1');
|
||||
expect(app.deploymentId).toEqual('111');
|
||||
done();
|
||||
}
|
||||
);
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify(fakeApps)
|
||||
});
|
||||
});
|
||||
});
|
@@ -0,0 +1,85 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2019 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 { RuntimeAppDefinitionsApi, AppDefinitionRepresentation } from '@alfresco/js-api';
|
||||
import { Observable, from, throwError } from 'rxjs';
|
||||
import { AlfrescoApiService, LogService } from '@alfresco/adf-core';
|
||||
import { map, catchError } from 'rxjs/operators';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class AppsProcessService {
|
||||
|
||||
_appsApi: RuntimeAppDefinitionsApi;
|
||||
get appsApi(): RuntimeAppDefinitionsApi {
|
||||
this._appsApi = this._appsApi ?? new RuntimeAppDefinitionsApi(this.apiService.getInstance());
|
||||
return this._appsApi;
|
||||
}
|
||||
|
||||
constructor(private apiService: AlfrescoApiService,
|
||||
private logService: LogService) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of deployed apps for this user.
|
||||
*
|
||||
* @returns The list of deployed apps
|
||||
*/
|
||||
getDeployedApplications(): Observable<AppDefinitionRepresentation[]> {
|
||||
return from(this.appsApi.getAppDefinitions())
|
||||
.pipe(
|
||||
map((response: any) => response.data),
|
||||
catchError((err) => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of deployed apps for this user, where the app name is `name`.
|
||||
*
|
||||
* @param name Name of the app
|
||||
* @returns The list of deployed apps
|
||||
*/
|
||||
getDeployedApplicationsByName(name: string): Observable<AppDefinitionRepresentation> {
|
||||
return from(this.appsApi.getAppDefinitions())
|
||||
.pipe(
|
||||
map((response: any) => response.data.find((app) => app.name === name)),
|
||||
catchError((err) => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the details for a specific app ID number.
|
||||
*
|
||||
* @param appId ID of the target app
|
||||
* @returns Details of the app
|
||||
*/
|
||||
getApplicationDetailsById(appId: number): Observable<AppDefinitionRepresentation> {
|
||||
return from(this.appsApi.getAppDefinitions())
|
||||
.pipe(
|
||||
map((response: any) => response.data.find((app) => app.id === appId)),
|
||||
catchError((err) => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
private handleError(error: any) {
|
||||
this.logService.error(error);
|
||||
return throwError(error || 'Server error');
|
||||
}
|
||||
|
||||
}
|
@@ -16,9 +16,10 @@
|
||||
*/
|
||||
|
||||
import { CUSTOM_ELEMENTS_SCHEMA, SimpleChange } from '@angular/core';
|
||||
import { AppsProcessService, setupTestBed } from '@alfresco/adf-core';
|
||||
import { setupTestBed } from '@alfresco/adf-core';
|
||||
import { from, of } from 'rxjs';
|
||||
import { FilterProcessRepresentationModel } from '../models/filter-process.model';
|
||||
import { AppsProcessService } from '../../app-list/services/apps-process.service';
|
||||
import { ProcessFilterService } from '../services/process-filter.service';
|
||||
import { ProcessFiltersComponent } from './process-filters.component';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
@@ -15,12 +15,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { AppsProcessService } from '@alfresco/adf-core';
|
||||
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewEncapsulation } from '@angular/core';
|
||||
import { ProcessInstanceFilterRepresentation, UserProcessInstanceFilterRepresentation } from '@alfresco/js-api';
|
||||
import { Observable } from 'rxjs';
|
||||
import { FilterProcessRepresentationModel } from '../models/filter-process.model';
|
||||
import { ProcessFilterService } from './../services/process-filter.service';
|
||||
import { AppsProcessService } from '../../app-list/services/apps-process.service';
|
||||
import { IconModel } from '../../app-list/icon.model';
|
||||
|
||||
@Component({
|
||||
|
@@ -17,7 +17,8 @@
|
||||
|
||||
import { DebugElement, SimpleChange } from '@angular/core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { AppConfigService, setupTestBed, AppsProcessService } from '@alfresco/adf-core';
|
||||
import { AppConfigService, setupTestBed } from '@alfresco/adf-core';
|
||||
import { AppsProcessService } from '../../app-list/services/apps-process.service';
|
||||
import { of, throwError } from 'rxjs';
|
||||
import { MatSelectChange } from '@angular/material/select';
|
||||
import { ProcessInstanceVariable } from '../models/process-instance-variable.model';
|
||||
|
@@ -22,9 +22,9 @@ import {
|
||||
import {
|
||||
AppConfigService,
|
||||
AppConfigValues,
|
||||
AppsProcessService,
|
||||
FormValues
|
||||
} from '@alfresco/adf-core';
|
||||
import { AppsProcessService } from '../../app-list/services/apps-process.service';
|
||||
import { ProcessInstanceVariable } from '../models/process-instance-variable.model';
|
||||
import { ProcessDefinitionRepresentation } from './../models/process-definition.model';
|
||||
import { ProcessInstance } from './../models/process-instance.model';
|
||||
|
@@ -17,7 +17,8 @@
|
||||
|
||||
import { SimpleChange } from '@angular/core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { AppConfigService, AppsProcessService, setupTestBed } from '@alfresco/adf-core';
|
||||
import { AppsProcessService } from '../../app-list/services/apps-process.service';
|
||||
import { AppConfigService, setupTestBed } from '@alfresco/adf-core';
|
||||
import { from, of } from 'rxjs';
|
||||
import { FilterParamsModel, FilterRepresentationModel } from '../models/filter.model';
|
||||
import { TaskListService } from '../services/tasklist.service';
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { AppsProcessService } from '@alfresco/adf-core';
|
||||
import { AppsProcessService } from '../../app-list/services/apps-process.service';
|
||||
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewEncapsulation } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { FilterParamsModel, FilterRepresentationModel } from '../models/filter.model';
|
||||
|
Reference in New Issue
Block a user