mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
#441 add dynamic host to activiti components
This commit is contained in:
@@ -68,7 +68,7 @@ export class AppComponent {
|
||||
constructor(public auth: AlfrescoAuthenticationService,
|
||||
public router: Router,
|
||||
translate: AlfrescoTranslationService,
|
||||
alfrescoSettingsService: AlfrescoSettingsService) {
|
||||
public alfrescoSettingsService: AlfrescoSettingsService) {
|
||||
alfrescoSettingsService.bpmHost = this.bpmHost;
|
||||
alfrescoSettingsService.ecmHost = this.ecmHost;
|
||||
|
||||
|
@@ -19,17 +19,16 @@ import { Injectable } from '@angular/core';
|
||||
import { Response, Http, Headers, RequestOptions } from '@angular/http';
|
||||
import { Observable } from 'rxjs/Rx';
|
||||
import { FormValues } from './../components/widgets/widget.model';
|
||||
import { AlfrescoSettingsService } from 'ng2-alfresco-core';
|
||||
|
||||
@Injectable()
|
||||
export class FormService {
|
||||
|
||||
private basePath: string = 'http://localhost:9999/activiti-app';
|
||||
|
||||
constructor(private http: Http) {
|
||||
constructor(private http: Http, private alfrescoSettingsService: AlfrescoSettingsService) {
|
||||
}
|
||||
|
||||
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 options = this.getRequestOptions();
|
||||
|
||||
@@ -40,7 +39,7 @@ export class FormService {
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
return this.http
|
||||
@@ -50,7 +49,7 @@ export class FormService {
|
||||
}
|
||||
|
||||
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({
|
||||
values: formValues
|
||||
});
|
||||
@@ -62,8 +61,8 @@ export class FormService {
|
||||
}
|
||||
|
||||
completeTaskForm(id: string, formValues: FormValues, outcome?: string): Observable<Response> {
|
||||
let url = `${this.basePath}/api/enterprise/task-forms/${id}`;
|
||||
let data: any = { values: formValues };
|
||||
let url = `${this.alfrescoSettingsService.bpmHost}/activiti-app/api/enterprise/task-forms/${id}`;
|
||||
let data: any = {values: formValues};
|
||||
if (outcome) {
|
||||
data.outcome = outcome;
|
||||
}
|
||||
@@ -76,7 +75,7 @@ export class FormService {
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
return this.http
|
||||
@@ -95,7 +94,7 @@ export class FormService {
|
||||
|
||||
private getRequestOptions(): RequestOptions {
|
||||
let headers = this.getHeaders();
|
||||
return new RequestOptions({ headers: headers });
|
||||
return new RequestOptions({headers: headers});
|
||||
}
|
||||
|
||||
private toJson(res: Response) {
|
||||
@@ -108,7 +107,7 @@ export class FormService {
|
||||
return body.data || [];
|
||||
}
|
||||
|
||||
private handleError (error: any) {
|
||||
private handleError(error: any) {
|
||||
// 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
|
||||
let errMsg = (error.message) ? error.message :
|
||||
|
@@ -15,9 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {
|
||||
AlfrescoSettingsService
|
||||
} from 'ng2-alfresco-core';
|
||||
import { AlfrescoSettingsService } from 'ng2-alfresco-core';
|
||||
import { ProcessInstance } from '../models/process-instance';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Http, Response, RequestOptions, Headers } from '@angular/http';
|
||||
@@ -28,7 +26,6 @@ import 'rxjs/add/operator/catch';
|
||||
@Injectable()
|
||||
export class ActivitiProcessService {
|
||||
|
||||
private processesUrl = 'http://localhost:9999/activiti-app/api/enterprise/process-instances/query';
|
||||
|
||||
constructor(private alfrescoSettingsService: AlfrescoSettingsService, private http: Http) {
|
||||
}
|
||||
@@ -38,7 +35,7 @@ export class ActivitiProcessService {
|
||||
headers.append('Content-Type', 'application/json');
|
||||
// headers.append('Authorization', 'Basic ' + btoa('admin@app.activiti.com:admin'));
|
||||
return this.http.post(
|
||||
this.processesUrl,
|
||||
this.alfrescoSettingsService.bpmHost + '/activiti-app/api/enterprise/process-instances/query',
|
||||
'{"page":0,"sort":"created-desc","state":"all"}',
|
||||
new RequestOptions({
|
||||
headers: headers
|
||||
|
@@ -81,7 +81,7 @@ describe('ActivitiTaskList', () => {
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
let activitiSerevice = new ActivitiTaskListService(null);
|
||||
let activitiSerevice = new ActivitiTaskListService(null, null);
|
||||
taskList = new ActivitiTaskList(null, null, activitiSerevice);
|
||||
});
|
||||
|
||||
|
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AlfrescoSettingsService } from 'ng2-alfresco-core';
|
||||
import { Http, Headers, RequestOptions, Response } from '@angular/http';
|
||||
import { Observable } from 'rxjs/Rx';
|
||||
import { FilterModel } from '../models/filter.model';
|
||||
@@ -23,7 +24,7 @@ import { FilterModel } from '../models/filter.model';
|
||||
@Injectable()
|
||||
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) {
|
||||
let url = 'http://localhost:9999/activiti-app/app/rest/filter/tasks';
|
||||
let url = this.alfrescoSettingsService.getBPMApiBaseUrl() + '/rest/filter/tasks';
|
||||
let headers = new Headers({
|
||||
'Content-Type': 'application/json',
|
||||
'Cache-Control': 'no-cache'
|
||||
@@ -68,7 +69,7 @@ export class ActivitiTaskListService {
|
||||
}
|
||||
|
||||
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({
|
||||
'Content-Type': 'application/json',
|
||||
'Cache-Control': 'no-cache'
|
||||
|
@@ -72,7 +72,7 @@ export class AlfrescoAuthenticationBPM extends AlfrescoAuthenticationBase implem
|
||||
}
|
||||
|
||||
private apiActivitiLogin(username: string, password: string) {
|
||||
let url = this.alfrescoSettingsService.getBPMApiBaseUrl + '/authentication';
|
||||
let url = this.alfrescoSettingsService.getBPMApiBaseUrl() + '/authentication';
|
||||
let headers = new Headers({
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
});
|
||||
@@ -88,7 +88,7 @@ export class AlfrescoAuthenticationBPM extends AlfrescoAuthenticationBase implem
|
||||
}
|
||||
|
||||
private apiActivitiLogout() {
|
||||
let url = this.alfrescoSettingsService.getBPMApiBaseUrl + '/logout';
|
||||
let url = this.alfrescoSettingsService.getBPMApiBaseUrl() + '/logout';
|
||||
return this.http.get(url).toPromise();
|
||||
}
|
||||
|
||||
|
@@ -56,19 +56,19 @@ export class AlfrescoSettingsService {
|
||||
this._bpmHost = value;
|
||||
}
|
||||
|
||||
getBPMApiBaseUrl(): string {
|
||||
public getBPMApiBaseUrl(): string {
|
||||
return this._bpmHost + this._bpmContextPath + this._apiBPMBasePath;
|
||||
}
|
||||
|
||||
getECMApiBaseUrl(): string {
|
||||
public getECMApiBaseUrl(): string {
|
||||
return this._ecmHost + this._ecmContextPath + this._apiECMBasePath;
|
||||
}
|
||||
|
||||
getProviders(): string [] {
|
||||
public getProviders(): string [] {
|
||||
return this.providers;
|
||||
}
|
||||
|
||||
setProviders(providers: string []) {
|
||||
public setProviders(providers: string []) {
|
||||
this.providers = providers;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user