mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
@@ -17,6 +17,9 @@
|
|||||||
<script src="node_modules/reflect-metadata/Reflect.js"></script>
|
<script src="node_modules/reflect-metadata/Reflect.js"></script>
|
||||||
<script src="node_modules/systemjs/dist/system.src.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 src="systemjs.config.js"></script>
|
||||||
<script>
|
<script>
|
||||||
System.import('app').catch(function(err){ console.error(err); });
|
System.import('app').catch(function(err){ console.error(err); });
|
||||||
|
@@ -39,6 +39,7 @@
|
|||||||
"rxjs": "5.0.0-beta.6",
|
"rxjs": "5.0.0-beta.6",
|
||||||
"zone.js": "^0.6.12",
|
"zone.js": "^0.6.12",
|
||||||
"ng2-activiti-processlist": "file:../",
|
"ng2-activiti-processlist": "file:../",
|
||||||
|
"alfresco-js-api": "^0.1.0",
|
||||||
"material-design-icons": "^2.2.3",
|
"material-design-icons": "^2.2.3",
|
||||||
"material-design-lite": "^1.1.3"
|
"material-design-lite": "^1.1.3"
|
||||||
},
|
},
|
||||||
|
@@ -14,14 +14,18 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* 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 { bootstrap } from '@angular/platform-browser-dynamic';
|
||||||
import {
|
import {
|
||||||
ACTIVITI_PROCESSLIST_PROVIDERS,
|
ACTIVITI_PROCESSLIST_PROVIDERS,
|
||||||
ACTIVITI_PROCESSLIST_DIRECTIVES
|
ACTIVITI_PROCESSLIST_DIRECTIVES
|
||||||
} from 'ng2-activiti-processlist/dist/ng2-activiti-processlist';
|
} from 'ng2-activiti-processlist/dist/ng2-activiti-processlist';
|
||||||
import { ALFRESCO_CORE_PROVIDERS } from 'ng2-alfresco-core';
|
import {
|
||||||
import { HTTP_PROVIDERS } from '@angular/http';
|
AlfrescoAuthenticationService,
|
||||||
|
AlfrescoSettingsService,
|
||||||
|
ALFRESCO_CORE_PROVIDERS
|
||||||
|
} from 'ng2-alfresco-core';
|
||||||
|
import { HTTP_PROVIDERS, BrowserXhr } from '@angular/http';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'my-app',
|
selector: 'my-app',
|
||||||
@@ -29,12 +33,63 @@ import { HTTP_PROVIDERS } from '@angular/http';
|
|||||||
providers: [ACTIVITI_PROCESSLIST_PROVIDERS],
|
providers: [ACTIVITI_PROCESSLIST_PROVIDERS],
|
||||||
directives: [ACTIVITI_PROCESSLIST_DIRECTIVES]
|
directives: [ACTIVITI_PROCESSLIST_DIRECTIVES]
|
||||||
})
|
})
|
||||||
class MyDemoApp {
|
class MyDemoApp implements OnInit {
|
||||||
constructor() {
|
|
||||||
|
authenticated: boolean;
|
||||||
|
host: string = 'http://127.0.0.1:9999';
|
||||||
|
token: string;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private authService: AlfrescoAuthenticationService,
|
||||||
|
private alfrescoSettingsService: AlfrescoSettingsService
|
||||||
|
) {
|
||||||
console.log('constructor');
|
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, [
|
bootstrap(MyDemoApp, [
|
||||||
ALFRESCO_CORE_PROVIDERS,
|
ALFRESCO_CORE_PROVIDERS,
|
||||||
HTTP_PROVIDERS
|
HTTP_PROVIDERS,
|
||||||
|
provide(BrowserXhr, { useClass: CustomBrowserXhr })
|
||||||
]);
|
]);
|
||||||
|
@@ -20,7 +20,7 @@ import {
|
|||||||
} from 'ng2-alfresco-core';
|
} 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 } from '@angular/http';
|
import { Http, Response, RequestOptions, Headers } from '@angular/http';
|
||||||
import { Observable } from 'rxjs/Observable';
|
import { Observable } from 'rxjs/Observable';
|
||||||
import 'rxjs/add/operator/map';
|
import 'rxjs/add/operator/map';
|
||||||
import 'rxjs/add/operator/catch';
|
import 'rxjs/add/operator/catch';
|
||||||
@@ -34,7 +34,14 @@ export class ActivitiProcessService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getProcesses(): Observable<ProcessInstance[]> {
|
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)
|
.map(this.extractData)
|
||||||
.catch(this.handleError);
|
.catch(this.handleError);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user