#441 add dynamic host to activiti components

This commit is contained in:
Mario Romano
2016-07-25 19:31:27 +01:00
parent d604a1f766
commit 126fecdf34
7 changed files with 24 additions and 27 deletions

View File

@@ -68,7 +68,7 @@ export class AppComponent {
constructor(public auth: AlfrescoAuthenticationService, constructor(public auth: AlfrescoAuthenticationService,
public router: Router, public router: Router,
translate: AlfrescoTranslationService, translate: AlfrescoTranslationService,
alfrescoSettingsService: AlfrescoSettingsService) { public alfrescoSettingsService: AlfrescoSettingsService) {
alfrescoSettingsService.bpmHost = this.bpmHost; alfrescoSettingsService.bpmHost = this.bpmHost;
alfrescoSettingsService.ecmHost = this.ecmHost; alfrescoSettingsService.ecmHost = this.ecmHost;

View File

@@ -19,17 +19,16 @@ import { Injectable } from '@angular/core';
import { Response, Http, Headers, RequestOptions } from '@angular/http'; import { Response, Http, Headers, RequestOptions } from '@angular/http';
import { Observable } from 'rxjs/Rx'; import { Observable } from 'rxjs/Rx';
import { FormValues } from './../components/widgets/widget.model'; import { FormValues } from './../components/widgets/widget.model';
import { AlfrescoSettingsService } from 'ng2-alfresco-core';
@Injectable() @Injectable()
export class FormService { export class FormService {
private basePath: string = 'http://localhost:9999/activiti-app'; constructor(private http: Http, private alfrescoSettingsService: AlfrescoSettingsService) {
constructor(private http: Http) {
} }
getTasks(): Observable<any> { getTasks(): Observable<any> {
let url = `${this.basePath}/api/enterprise/tasks/query`; let url = `${this.alfrescoSettingsService.bpmHost}/activiti-app/api/enterprise/tasks/query`;
let body = JSON.stringify({}); let body = JSON.stringify({});
let options = this.getRequestOptions(); let options = this.getRequestOptions();
@@ -40,7 +39,7 @@ export class FormService {
} }
getTask(id: string): Observable<any> { getTask(id: string): Observable<any> {
let url = `${this.basePath}/api/enterprise/tasks/${id}`; let url = `${this.alfrescoSettingsService.bpmHost}/activiti-app/api/enterprise/tasks/${id}`;
let options = this.getRequestOptions(); let options = this.getRequestOptions();
return this.http return this.http
@@ -50,7 +49,7 @@ export class FormService {
} }
saveTaskForm(id: string, formValues: FormValues): Observable<Response> { saveTaskForm(id: string, formValues: FormValues): Observable<Response> {
let url = `${this.basePath}/api/enterprise/task-forms/${id}/save-form`; let url = `${this.alfrescoSettingsService.bpmHost}/activiti-app/api/enterprise/task-forms/${id}/save-form`;
let body = JSON.stringify({ let body = JSON.stringify({
values: formValues values: formValues
}); });
@@ -62,8 +61,8 @@ export class FormService {
} }
completeTaskForm(id: string, formValues: FormValues, outcome?: string): Observable<Response> { completeTaskForm(id: string, formValues: FormValues, outcome?: string): Observable<Response> {
let url = `${this.basePath}/api/enterprise/task-forms/${id}`; let url = `${this.alfrescoSettingsService.bpmHost}/activiti-app/api/enterprise/task-forms/${id}`;
let data: any = { values: formValues }; let data: any = {values: formValues};
if (outcome) { if (outcome) {
data.outcome = outcome; data.outcome = outcome;
} }
@@ -76,7 +75,7 @@ export class FormService {
} }
getTaskForm(id: string): Observable<any> { getTaskForm(id: string): Observable<any> {
let url = `${this.basePath}/api/enterprise/task-forms/${id}`; let url = `${this.alfrescoSettingsService.bpmHost}/activiti-app/api/enterprise/task-forms/${id}`;
let options = this.getRequestOptions(); let options = this.getRequestOptions();
return this.http return this.http
@@ -95,7 +94,7 @@ export class FormService {
private getRequestOptions(): RequestOptions { private getRequestOptions(): RequestOptions {
let headers = this.getHeaders(); let headers = this.getHeaders();
return new RequestOptions({ headers: headers }); return new RequestOptions({headers: headers});
} }
private toJson(res: Response) { private toJson(res: Response) {
@@ -108,7 +107,7 @@ export class FormService {
return body.data || []; return body.data || [];
} }
private handleError (error: any) { private handleError(error: any) {
// In a real world app, we might use a remote logging infrastructure // In a real world app, we might use a remote logging infrastructure
// We'd also dig deeper into the error to get a better message // We'd also dig deeper into the error to get a better message
let errMsg = (error.message) ? error.message : let errMsg = (error.message) ? error.message :

View File

@@ -15,9 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { import { AlfrescoSettingsService } from 'ng2-alfresco-core';
AlfrescoSettingsService
} from 'ng2-alfresco-core';
import { ProcessInstance } from '../models/process-instance'; import { ProcessInstance } from '../models/process-instance';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Http, Response, RequestOptions, Headers } from '@angular/http'; import { Http, Response, RequestOptions, Headers } from '@angular/http';
@@ -28,7 +26,6 @@ import 'rxjs/add/operator/catch';
@Injectable() @Injectable()
export class ActivitiProcessService { export class ActivitiProcessService {
private processesUrl = 'http://localhost:9999/activiti-app/api/enterprise/process-instances/query';
constructor(private alfrescoSettingsService: AlfrescoSettingsService, private http: Http) { constructor(private alfrescoSettingsService: AlfrescoSettingsService, private http: Http) {
} }
@@ -38,7 +35,7 @@ export class ActivitiProcessService {
headers.append('Content-Type', 'application/json'); headers.append('Content-Type', 'application/json');
// headers.append('Authorization', 'Basic ' + btoa('admin@app.activiti.com:admin')); // headers.append('Authorization', 'Basic ' + btoa('admin@app.activiti.com:admin'));
return this.http.post( return this.http.post(
this.processesUrl, this.alfrescoSettingsService.bpmHost + '/activiti-app/api/enterprise/process-instances/query',
'{"page":0,"sort":"created-desc","state":"all"}', '{"page":0,"sort":"created-desc","state":"all"}',
new RequestOptions({ new RequestOptions({
headers: headers headers: headers

View File

@@ -81,7 +81,7 @@ describe('ActivitiTaskList', () => {
}); });
beforeEach(() => { beforeEach(() => {
let activitiSerevice = new ActivitiTaskListService(null); let activitiSerevice = new ActivitiTaskListService(null, null);
taskList = new ActivitiTaskList(null, null, activitiSerevice); taskList = new ActivitiTaskList(null, null, activitiSerevice);
}); });

View File

@@ -16,6 +16,7 @@
*/ */
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { AlfrescoSettingsService } from 'ng2-alfresco-core';
import { Http, Headers, RequestOptions, Response } from '@angular/http'; import { Http, Headers, RequestOptions, Response } from '@angular/http';
import { Observable } from 'rxjs/Rx'; import { Observable } from 'rxjs/Rx';
import { FilterModel } from '../models/filter.model'; import { FilterModel } from '../models/filter.model';
@@ -23,7 +24,7 @@ import { FilterModel } from '../models/filter.model';
@Injectable() @Injectable()
export class ActivitiTaskListService { export class ActivitiTaskListService {
constructor(private http: Http) { constructor(private http: Http, public alfrescoSettingsService: AlfrescoSettingsService) {
} }
/** /**
@@ -56,7 +57,7 @@ export class ActivitiTaskListService {
} }
private callApiTasksFiltered(data: Object) { private callApiTasksFiltered(data: Object) {
let url = 'http://localhost:9999/activiti-app/app/rest/filter/tasks'; let url = this.alfrescoSettingsService.getBPMApiBaseUrl() + '/rest/filter/tasks';
let headers = new Headers({ let headers = new Headers({
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Cache-Control': 'no-cache' 'Cache-Control': 'no-cache'
@@ -68,7 +69,7 @@ export class ActivitiTaskListService {
} }
private callApiTaskFilters() { private callApiTaskFilters() {
let url = 'http://localhost:9999/activiti-app/app/rest/filters/tasks'; let url = this.alfrescoSettingsService.getBPMApiBaseUrl() + '/rest/filters/tasks';
let headers = new Headers({ let headers = new Headers({
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Cache-Control': 'no-cache' 'Cache-Control': 'no-cache'

View File

@@ -72,7 +72,7 @@ export class AlfrescoAuthenticationBPM extends AlfrescoAuthenticationBase implem
} }
private apiActivitiLogin(username: string, password: string) { private apiActivitiLogin(username: string, password: string) {
let url = this.alfrescoSettingsService.getBPMApiBaseUrl + '/authentication'; let url = this.alfrescoSettingsService.getBPMApiBaseUrl() + '/authentication';
let headers = new Headers({ let headers = new Headers({
'Content-Type': 'application/x-www-form-urlencoded' 'Content-Type': 'application/x-www-form-urlencoded'
}); });
@@ -88,7 +88,7 @@ export class AlfrescoAuthenticationBPM extends AlfrescoAuthenticationBase implem
} }
private apiActivitiLogout() { private apiActivitiLogout() {
let url = this.alfrescoSettingsService.getBPMApiBaseUrl + '/logout'; let url = this.alfrescoSettingsService.getBPMApiBaseUrl() + '/logout';
return this.http.get(url).toPromise(); return this.http.get(url).toPromise();
} }

View File

@@ -56,19 +56,19 @@ export class AlfrescoSettingsService {
this._bpmHost = value; this._bpmHost = value;
} }
getBPMApiBaseUrl(): string { public getBPMApiBaseUrl(): string {
return this._bpmHost + this._bpmContextPath + this._apiBPMBasePath; return this._bpmHost + this._bpmContextPath + this._apiBPMBasePath;
} }
getECMApiBaseUrl(): string { public getECMApiBaseUrl(): string {
return this._ecmHost + this._ecmContextPath + this._apiECMBasePath; return this._ecmHost + this._ecmContextPath + this._apiECMBasePath;
} }
getProviders(): string [] { public getProviders(): string [] {
return this.providers; return this.providers;
} }
setProviders(providers: string []) { public setProviders(providers: string []) {
this.providers = providers; this.providers = providers;
} }
} }