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