mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
Remove route from login component and delegate the route to the parent
This commit is contained in:
parent
4e47ce3327
commit
950cc4d076
@ -1 +1 @@
|
||||
<alfresco-login></alfresco-login>
|
||||
<alfresco-login (onSuccess)="onLogin($event)" (onError)="onError($event)"></alfresco-login>
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
import { Component } from '@angular/core';
|
||||
import { AlfrescoLoginComponent } from 'ng2-alfresco-login';
|
||||
import { Router, ROUTER_DIRECTIVES } from '@angular/router-deprecated';
|
||||
|
||||
declare let __moduleName: string;
|
||||
|
||||
@ -24,9 +25,21 @@ declare let __moduleName: string;
|
||||
moduleId: __moduleName,
|
||||
selector: 'login-demo',
|
||||
templateUrl: './login-demo.component.html',
|
||||
directives: [AlfrescoLoginComponent],
|
||||
directives: [ROUTER_DIRECTIVES, AlfrescoLoginComponent],
|
||||
pipes: []
|
||||
})
|
||||
export class LoginDemoComponent {
|
||||
|
||||
constructor(public router: Router) {
|
||||
}
|
||||
|
||||
onLogin($event) {
|
||||
console.log($event);
|
||||
this.router.navigate(['Home']);
|
||||
}
|
||||
|
||||
onError($event) {
|
||||
console.log($event);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,12 +17,6 @@
|
||||
|
||||
import { Component } from '@angular/core';
|
||||
import { bootstrap } from '@angular/platform-browser-dynamic';
|
||||
import {
|
||||
Router,
|
||||
RouteConfig,
|
||||
ROUTER_PROVIDERS,
|
||||
ROUTER_DIRECTIVES
|
||||
} from '@angular/router-deprecated';
|
||||
import { AlfrescoLoginComponent } from 'ng2-alfresco-login';
|
||||
import { HTTP_PROVIDERS } from '@angular/http';
|
||||
import {
|
||||
@ -32,17 +26,14 @@ import {
|
||||
} from 'ng2-alfresco-core';
|
||||
|
||||
|
||||
@RouteConfig([
|
||||
{path: '/', name: 'Login', component: AlfrescoLoginComponent, useAsDefault: true}
|
||||
])
|
||||
@Component({
|
||||
selector: 'my-app',
|
||||
template: `<label for="token"><b>Insert the ip of your Alfresco instance:</b></label><br>
|
||||
<input id="token" type="text" size="48" (change)="updateHost()" [(ngModel)]="host"><br><br>
|
||||
{{ status }}
|
||||
<hr>
|
||||
<alfresco-login method="POST" (onSuccess)="mySuccessMethod($event)" (onError)="myErrorMethod($event)"></alfresco-login>`,
|
||||
directives: [ROUTER_DIRECTIVES, AlfrescoLoginComponent]
|
||||
<alfresco-login (onSuccess)="mySuccessMethod($event)" (onError)="myErrorMethod($event)"></alfresco-login>`,
|
||||
directives: [AlfrescoLoginComponent]
|
||||
})
|
||||
export class AppComponent {
|
||||
|
||||
@ -53,7 +44,6 @@ export class AppComponent {
|
||||
public status: string = '';
|
||||
|
||||
constructor(public auth: AlfrescoAuthenticationService,
|
||||
public router: Router,
|
||||
private alfrescoSettingsService: AlfrescoSettingsService) {
|
||||
alfrescoSettingsService.host = this.host;
|
||||
}
|
||||
@ -74,7 +64,6 @@ export class AppComponent {
|
||||
}
|
||||
|
||||
bootstrap(AppComponent, [
|
||||
ROUTER_PROVIDERS,
|
||||
HTTP_PROVIDERS,
|
||||
ALFRESCO_CORE_PROVIDERS
|
||||
]);
|
||||
|
@ -16,7 +16,6 @@
|
||||
*/
|
||||
|
||||
import { Component, Output, EventEmitter } from '@angular/core';
|
||||
import { Router, ROUTER_DIRECTIVES } from '@angular/router-deprecated';
|
||||
import { FORM_DIRECTIVES, ControlGroup, FormBuilder, Validators } from '@angular/common';
|
||||
import {
|
||||
AlfrescoTranslationService,
|
||||
@ -30,7 +29,7 @@ declare let __moduleName: string;
|
||||
@Component({
|
||||
selector: 'alfresco-login',
|
||||
moduleId: __moduleName,
|
||||
directives: [ROUTER_DIRECTIVES, FORM_DIRECTIVES],
|
||||
directives: [FORM_DIRECTIVES],
|
||||
templateUrl: './alfresco-login.component.html',
|
||||
styleUrls: ['./alfresco-login.component.css'],
|
||||
pipes: [AlfrescoPipeTranslate]
|
||||
@ -60,12 +59,10 @@ export class AlfrescoLoginComponent {
|
||||
* Constructor
|
||||
* @param _fb
|
||||
* @param auth
|
||||
* @param router
|
||||
* @param translate
|
||||
*/
|
||||
constructor(private _fb: FormBuilder,
|
||||
public auth: AlfrescoAuthenticationService,
|
||||
public router: Router,
|
||||
private translate: AlfrescoTranslationService) {
|
||||
|
||||
this.formError = {
|
||||
@ -113,7 +110,6 @@ export class AlfrescoLoginComponent {
|
||||
this.onSuccess.emit({
|
||||
value: 'Login OK'
|
||||
});
|
||||
this.router.navigate(['Home']);
|
||||
} catch (error) {
|
||||
console.error(error.message);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user