diff --git a/ng2-components/ng2-alfresco-activiti-form/src/components/activiti-form.component.html b/ng2-components/ng2-alfresco-activiti-form/src/components/activiti-form.component.html
new file mode 100644
index 0000000000..31c08f2f64
--- /dev/null
+++ b/ng2-components/ng2-alfresco-activiti-form/src/components/activiti-form.component.html
@@ -0,0 +1,9 @@
+
+
Task form content
+
+
Task
+
{{debugTask | json}}
+
+
Form
+
{{debugForm | json}}
+
diff --git a/ng2-components/ng2-alfresco-activiti-form/src/components/activiti-form.component.ts b/ng2-components/ng2-alfresco-activiti-form/src/components/activiti-form.component.ts
index e2fda465fa..1bcacd3d14 100644
--- a/ng2-components/ng2-alfresco-activiti-form/src/components/activiti-form.component.ts
+++ b/ng2-components/ng2-alfresco-activiti-form/src/components/activiti-form.component.ts
@@ -15,15 +15,38 @@
* limitations under the License.
*/
-import { Component } from '@angular/core';
+import { Component, OnInit, Injectable } from '@angular/core';
+import { FormService } from './../services/form.service';
declare let __moduleName: string;
@Component({
moduleId: __moduleName,
selector: 'activiti-form',
- template: 'Activiti Form Content
'
+ templateUrl: './activiti-form.component.html',
+ providers: [
+ FormService
+ ]
})
-export class ActivitiForm {
+export class ActivitiForm implements OnInit {
+
+ debugTask: any;
+ debugForm: any;
+
+ constructor(private formService: FormService) {
+
+ }
+
+ ngOnInit() {
+ this.formService.getTask('1').subscribe(task => {
+ console.log(task);
+ this.debugTask = task;
+
+ this.formService.getTaskForm('1').subscribe(form => {
+ console.log(form);
+ this.debugForm = form;
+ })
+ });
+ }
}
diff --git a/ng2-components/ng2-alfresco-activiti-form/src/services/form.service.ts b/ng2-components/ng2-alfresco-activiti-form/src/services/form.service.ts
new file mode 100644
index 0000000000..cc730c049c
--- /dev/null
+++ b/ng2-components/ng2-alfresco-activiti-form/src/services/form.service.ts
@@ -0,0 +1,75 @@
+/*!
+ * @license
+ * Copyright 2016 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 { Response, Http, Headers, RequestOptions } from '@angular/http';
+import { Observable } from 'rxjs/Rx';
+
+@Injectable()
+export class FormService {
+
+ private basePath: string = 'http://localhost:9999/activiti-app';
+
+ constructor(private http: Http) {
+ }
+
+ getTask(id: string): Observable {
+ let url = `${this.basePath}/api/enterprise/tasks/${id}`;
+ let options = this.getRequestOptions();
+
+ return this.http.get(url, options)
+ .map(this.toJson)
+ .catch(this.handleError);
+ }
+
+ getTaskForm(id: string): Observable {
+ let url = `${this.basePath}/api/enterprise/task-forms/${id}`;
+ let options = this.getRequestOptions();
+
+ return this.http.get(url, options)
+ .map(this.toJson)
+ .catch(this.handleError);
+ }
+
+ private getHeaders(): Headers {
+ return new Headers({
+ 'Accept': 'application/json',
+ 'Content-Type': 'application/json',
+ 'Authorization': 'Basic ' + btoa('admin' + ':' + 'admin')
+ });
+ }
+
+ private getRequestOptions(): RequestOptions {
+ let headers = this.getHeaders();
+ return new RequestOptions({ headers: headers });
+ }
+
+ private toJson(res: Response) {
+ let body = res.json();
+ return body || {};
+ }
+
+ 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 :
+ error.status ? `${error.status} - ${error.statusText}` : 'Server error';
+ console.error(errMsg); // log to console instead
+ return Observable.throw(errMsg);
+ }
+
+}