Working demo page

Refs #344
This commit is contained in:
Will Abson
2016-07-15 16:05:55 +01:00
parent 1fc36b6ded
commit c9600ef5b6
4 changed files with 76 additions and 10 deletions

View File

@@ -17,6 +17,9 @@
<script src="node_modules/reflect-metadata/Reflect.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<!-- Additional Alfresco libraries -->
<script src="node_modules/alfresco-js-api/dist/alfresco-js-api.js"></script>
<script src="systemjs.config.js"></script>
<script>
System.import('app').catch(function(err){ console.error(err); });

View File

@@ -39,6 +39,7 @@
"rxjs": "5.0.0-beta.6",
"zone.js": "^0.6.12",
"ng2-activiti-processlist": "file:../",
"alfresco-js-api": "^0.1.0",
"material-design-icons": "^2.2.3",
"material-design-lite": "^1.1.3"
},

View File

@@ -14,14 +14,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Component } from '@angular/core';
import { Component, OnInit, Injectable, provide } from '@angular/core';
import { bootstrap } from '@angular/platform-browser-dynamic';
import {
ACTIVITI_PROCESSLIST_PROVIDERS,
ACTIVITI_PROCESSLIST_DIRECTIVES
} from 'ng2-activiti-processlist/dist/ng2-activiti-processlist';
import { ALFRESCO_CORE_PROVIDERS } from 'ng2-alfresco-core';
import { HTTP_PROVIDERS } from '@angular/http';
import {
AlfrescoAuthenticationService,
AlfrescoSettingsService,
ALFRESCO_CORE_PROVIDERS
} from 'ng2-alfresco-core';
import { HTTP_PROVIDERS, BrowserXhr } from '@angular/http';
@Component({
selector: 'my-app',
@@ -29,12 +33,63 @@ import { HTTP_PROVIDERS } from '@angular/http';
providers: [ACTIVITI_PROCESSLIST_PROVIDERS],
directives: [ACTIVITI_PROCESSLIST_DIRECTIVES]
})
class MyDemoApp {
constructor() {
class MyDemoApp implements OnInit {
authenticated: boolean;
host: string = 'http://127.0.0.1:9999';
token: string;
constructor(
private authService: AlfrescoAuthenticationService,
private alfrescoSettingsService: AlfrescoSettingsService
) {
console.log('constructor');
alfrescoSettingsService.host = this.host;
if (this.authService.getTicket()) {
this.token = this.authService.getTicket();
}
}
ngOnInit() {
this.login();
}
public updateToken(): void {
localStorage.setItem('token', this.token);
}
public updateHost(): void {
this.alfrescoSettingsService.host = this.host;
this.login();
}
login() {
this.authService.login('admin@app.activiti.com', 'admin', ['BPM']).subscribe(
token => {
console.log(token);
this.token = token;
this.authenticated = true;
},
error => {
console.log(error);
this.authenticated = false;
});
}
}
@Injectable()
export class CustomBrowserXhr extends BrowserXhr {
constructor() {}
build(): any {
let xhr = super.build();
xhr.withCredentials = true;
return <any>(xhr);
}
}
bootstrap(MyDemoApp, [
ALFRESCO_CORE_PROVIDERS,
HTTP_PROVIDERS
HTTP_PROVIDERS,
provide(BrowserXhr, { useClass: CustomBrowserXhr })
]);

View File

@@ -20,7 +20,7 @@ import {
} from 'ng2-alfresco-core';
import { ProcessInstance } from '../models/process-instance';
import { Injectable } from '@angular/core';
import { Http, Response } from '@angular/http';
import { Http, Response, RequestOptions, Headers } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
@@ -34,7 +34,14 @@ export class ActivitiProcessService {
}
getProcesses(): Observable<ProcessInstance[]> {
return this.http.get(this.processesUrl)
let headers = new Headers();
headers.append('Content-Type', 'application/json');
return this.http.post(
this.processesUrl,
'{"page":0,"filterId":6,"filter":{"sort":"created-desc","name":"","state":"all"},"appDefinitionId":null}',
new RequestOptions({
headers: headers
}))
.map(this.extractData)
.catch(this.handleError);
}