mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
demo tag
This commit is contained in:
parent
530ca19b1d
commit
8dfef264e3
@ -31,12 +31,12 @@ import {TAGCOMPONENT, TAGSERVICES} from 'ng2-alfresco-tag';
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'alfresco-tag-demo',
|
selector: 'alfresco-tag-demo',
|
||||||
template: `
|
template: `
|
||||||
<label for="token"><b>Insert a valid access token / ticket:</b></label><br>
|
<label for="ticket"><b>Insert a valid access ticket / ticket:</b></label><br>
|
||||||
<input id="token" type="text" size="48" (change)="updateToken();documentList.reload()" [(ngModel)]="token"><br>
|
<input id="ticket" type="text" size="48" (change)="updateTicket()" [(ngModel)]="ticket"><br>
|
||||||
<label for="host"><b>Insert the ip of your Alfresco instance:</b></label><br>
|
<label for="host"><b>Insert the ip of your Alfresco instance:</b></label><br>
|
||||||
<input id="host" type="text" size="48" (change)="updateHost();documentList.reload()" [(ngModel)]="ecmHost"><br><br>
|
<input id="host" type="text" size="48" (change)="updateHost()" [(ngModel)]="ecmHost"><br><br>
|
||||||
<div *ngIf="!authenticated" style="color:#FF2323">
|
<div *ngIf="!authenticated" style="color:#FF2323">
|
||||||
Authentication failed to ip {{ ecmHost }} with user: admin, admin, you can still try to add a valid token to perform
|
Authentication failed to ip {{ ecmHost }} with user: admin, admin, you can still try to add a valid ticket to perform
|
||||||
operations.
|
operations.
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
@ -73,24 +73,17 @@ class TagDemo implements OnInit {
|
|||||||
|
|
||||||
ecmHost: string = 'http://127.0.0.1:8080';
|
ecmHost: string = 'http://127.0.0.1:8080';
|
||||||
|
|
||||||
token: string;
|
ticket: string;
|
||||||
|
|
||||||
constructor(private authService: AlfrescoAuthenticationService,
|
constructor(private authService: AlfrescoAuthenticationService,
|
||||||
private settingsService: AlfrescoSettingsService) {
|
private settingsService: AlfrescoSettingsService) {
|
||||||
|
|
||||||
settingsService.ecmHost = this.ecmHost;
|
settingsService.ecmHost = this.ecmHost;
|
||||||
if (this.authService.getTicket()) {
|
settingsService.setProviders('ECM');
|
||||||
this.token = this.authService.getTicket();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public updateToken(): void {
|
if (this.authService.getTicketEcm()) {
|
||||||
localStorage.setItem('token', this.token);
|
this.ticket = this.authService.getTicketEcm();
|
||||||
}
|
}
|
||||||
|
|
||||||
public updateHost(): void {
|
|
||||||
this.settingsService.ecmHost = this.ecmHost;
|
|
||||||
this.login();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@ -98,10 +91,10 @@ class TagDemo implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
login() {
|
login() {
|
||||||
this.authService.login('admin', 'admin', ['ECM']).subscribe(
|
this.authService.login('admin', 'admin').subscribe(
|
||||||
token => {
|
ticket => {
|
||||||
console.log(token);
|
console.log(ticket);
|
||||||
this.token = token;
|
this.ticket = this.authService.getTicketEcm();
|
||||||
this.authenticated = true;
|
this.authenticated = true;
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
@ -110,11 +103,19 @@ class TagDemo implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public updateTicket(): void {
|
||||||
|
localStorage.setItem('ticket-ECM', this.ticket);
|
||||||
|
}
|
||||||
|
|
||||||
|
public updateHost(): void {
|
||||||
|
this.settingsService.ecmHost = this.ecmHost;
|
||||||
|
this.login();
|
||||||
|
}
|
||||||
|
|
||||||
logData(data) {
|
logData(data) {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bootstrap(TagDemo, [
|
bootstrap(TagDemo, [
|
||||||
HTTP_PROVIDERS,
|
HTTP_PROVIDERS,
|
||||||
ALFRESCO_CORE_PROVIDERS
|
ALFRESCO_CORE_PROVIDERS
|
||||||
|
Loading…
x
Reference in New Issue
Block a user