test login demo

This commit is contained in:
Mario Romano 2016-05-31 14:12:30 +01:00
parent 654321780d
commit 74e89cef1e
7 changed files with 129 additions and 141 deletions

View File

@ -1,4 +1,4 @@
/**
/*!
* @license
* Copyright 2016 Alfresco Software, Ltd.
*

View File

@ -85,41 +85,24 @@ Example of an App that use Alfresco login component :
main.ts
```ts
import { bootstrap } from 'angular2/platform/browser';
import { AppComponent } from './components/app-component';
import { ALFRESCO_AUTHENTICATION } from 'ng2-alfresco-login/dist/ng2-alfresco-login';
import { bootstrap } from 'angular2/platform/browser';
import { Component } from 'angular2/core';
import { Router, RouteConfig, ROUTER_DIRECTIVES } from 'angular2/router';
import { AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core/dist/ng2-alfresco-core';
import { AlfrescoLoginComponent } from 'ng2-alfresco-login/dist/ng2-alfresco-login';
import { ROUTER_PROVIDERS } from 'angular2/router';
import { HTTP_PROVIDERS } from 'angular2/http';
import { HTTP_PROVIDERS } from 'angular2/http';
import { ALFRESCO_CORE_PROVIDERS, AlfrescoTranslationService, AlfrescoTranslationLoader } from 'ng2-alfresco-core/dist/ng2-alfresco-core';
bootstrap(AppComponent, [
ROUTER_PROVIDERS,
HTTP_PROVIDERS,
AlfrescoTranslationLoader,
AlfrescoTranslationService,
ALFRESCO_AUTHENTICATION,
ALFRESCO_CORE_PROVIDERS
]);
```
app-components.ts
```ts
import { Component } from 'angular2/core';
import { AlfrescoLoginComponent, AlfrescoAuthenticationService } from 'ng2-alfresco-login/dist/ng2-alfresco-login';
import { Router, RouteConfig, ROUTER_DIRECTIVES } from 'angular2/router';
import { AlfrescoSettingsService } from 'ng2-alfresco-core/dist/ng2-alfresco-core';
@Component({
selector: 'my-login',
template: '<alfresco-login method="POST" (onSuccess)="mySuccessMethod($event)" (onError)="myErrorMethod($event)"></alfresco-login>',
directives: [ROUTER_DIRECTIVES, AlfrescoLoginComponent]
})
@RouteConfig([
{path: '/', name: 'Login', component: AlfrescoLoginComponent, useAsDefault: true}
])
@Component({
selector: 'my-app',
template: '<alfresco-login method="POST" (onSuccess)="mySuccessMethod($event)" (onError)="myErrorMethod($event)"></alfresco-login>',
directives: [ROUTER_DIRECTIVES, AlfrescoLoginComponent]
})
export class AppComponent {
constructor(public auth: AlfrescoAuthenticationService,
@ -139,6 +122,15 @@ export class AppComponent {
}
bootstrap(AppComponent, [
ROUTER_PROVIDERS,
HTTP_PROVIDERS,
AlfrescoTranslationLoader,
AlfrescoTranslationService,
AlfrescoAuthenticationService,
ALFRESCO_CORE_PROVIDERS
]);
```
#### Events
**onSuccess**: The event is emitted when the login is done

View File

@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Angular 2 Testing</title>
<title>Alfresco Angular 2 Testing - Demo</title>
<base href="/">
<!-- Google Material Design Lite -->
@ -31,7 +31,7 @@
</head>
<body>
<my-login></my-login>
<my-app></my-app>
</body>
</html>

View File

@ -1,54 +1,70 @@
{
"name": "ng2-alfresco-login-demo",
"description": "Alfresco Angular2 Login Component - Demo",
"version": "0.1.0",
"author": "Alfresco Software, Ltd.",
"main": "index.js",
"scripts": {
"postinstall": "npm run build && npm run typings",
"typings": "typings install",
"start": "rm -rf dist && npm install && npm run server",
"server": "lite-server",
"build": "npm run tslint && rm -rf dist && tsc",
"tslint": "npm run tslint-src && npm run tslint-root",
"tslint-src": "tslint -c tslint.json src/**/*.ts",
"tslint-root": "tslint -c tslint.json *.ts"
},
"license": "Apache-2.0",
"contributors": [
{
"name": "Maurizio Vitale",
"email": "maurizio.vitale@alfresco.com"
"name": "ng2-alfresco-login-demo",
"description": "Alfresco Angular2 Login Component - Demo",
"version": "0.1.0",
"author": "Alfresco Software, Ltd.",
"main": "index.js",
"scripts": {
"postinstall": "npm run typings && npm run typings",
"typings": "typings install",
"start": "rm -rf dist && npm install && npm run server",
"server": "lite-server",
"build": "npm run tslint && rm -rf dist && tsc",
"tslint": "npm run tslint-src && npm run tslint-root",
"tslint-src": "tslint -c tslint.json src/**/*.ts",
"tslint-root": "tslint -c tslint.json *.ts"
},
"license": "Apache-2.0",
"contributors": [
{
"name": "Denys Vuika",
"email": "denis.vuyka@gmail.com"
},
{
"name": "Mario Romano",
"email": "mario.romano83@gmail.com"
},
{
"name": "Will Abson",
"email": "will.abson@alfresco.com"
},
{
"name": "Eugenio Romano",
"email": "eugenio.romano@alfresco.com"
},
{
"name": "Maurizio Vitale",
"email": "maurizio.vitale@alfresco.com"
}
],
"keywords": [
"ng2",
"angular",
"angular2",
"alfresco"
],
"dependencies": {
"alfresco-core-rest-api": "^0.1.0",
"angular2": "2.0.0-beta.15",
"es6-shim": "^0.35.0",
"material-design-icons": "^2.2.3",
"material-design-lite": "^1.1.3",
"ng2-alfresco-core": "^0.1.0",
"ng2-alfresco-login": "^0.1.0",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.2",
"systemjs": "0.19.26",
"zone.js": "0.6.10"
},
"devDependencies": {
"browser-sync": "^2.10.0",
"concurrently": "^2.0.0",
"lite-server": "^2.2.0",
"tslint": "^3.8.1",
"typescript": "^1.8.10",
"typings": "^0.7.12"
},
"publishConfig": {
"registry": "http://devproducts.alfresco.me:4873/"
}
],
"keywords": [
"ng2",
"angular",
"angular2",
"alfresco"
],
"dependencies": {
"alfresco-core-rest-api": "^0.1.0",
"angular2": "2.0.0-beta.15",
"es6-shim": "^0.35.0",
"material-design-icons": "^2.2.3",
"material-design-lite": "^1.1.3",
"ng2-alfresco-core": "^0.1.0",
"ng2-alfresco-login": "^0.1.0",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.2",
"systemjs": "0.19.26",
"zone.js": "0.6.10"
},
"devDependencies": {
"browser-sync": "^2.10.0",
"concurrently": "^2.0.0",
"lite-server": "^2.2.0",
"tslint": "^3.8.1",
"typescript": "^1.8.10",
"typings": "^0.7.12"
},
"publishConfig": {
"registry": "http://devproducts.alfresco.me:4873/"
}
}

View File

@ -1,51 +0,0 @@
///<reference path="../../node_modules/angular2/typings/browser.d.ts"/>
/**
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Component } from 'angular2/core';
import { AlfrescoLoginComponent, AlfrescoAuthenticationService } from 'ng2-alfresco-login/dist/ng2-alfresco-login';
import { Router, RouteConfig, ROUTER_DIRECTIVES } from 'angular2/router';
import { AlfrescoSettingsService } from 'ng2-alfresco-core/dist/ng2-alfresco-core';
@Component({
selector: 'my-login',
template: '<alfresco-login method="POST" (onSuccess)="mySuccessMethod($event)" (onError)="myErrorMethod($event)"></alfresco-login>',
directives: [ROUTER_DIRECTIVES, AlfrescoLoginComponent]
})
@RouteConfig([
{path: '/', name: 'Login', component: AlfrescoLoginComponent, useAsDefault: true}
])
export class AppComponent {
constructor(public auth: AlfrescoAuthenticationService,
public router: Router,
alfrescoSettingsService: AlfrescoSettingsService) {
alfrescoSettingsService.host = 'http://192.168.99.100:8080';
}
mySuccessMethod($event) {
console.log('Success Login EventEmitt called with: ' + $event.value);
}
myErrorMethod($event) {
console.log('Error Login EventEmitt called with: ' + $event.value);
}
}

View File

@ -1,4 +1,4 @@
/**
/*!
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
@ -16,17 +16,47 @@
*/
import { bootstrap } from 'angular2/platform/browser';
import { AppComponent } from './components/app-component';
import { ALFRESCO_AUTHENTICATION } from 'ng2-alfresco-login/dist/ng2-alfresco-login';
import { Component } from 'angular2/core';
import { Router, RouteConfig, ROUTER_DIRECTIVES } from 'angular2/router';
import { AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core/dist/ng2-alfresco-core';
import { AlfrescoLoginComponent } from 'ng2-alfresco-login/dist/ng2-alfresco-login';
import { ROUTER_PROVIDERS } from 'angular2/router';
import { HTTP_PROVIDERS } from 'angular2/http';
import { ALFRESCO_CORE_PROVIDERS, AlfrescoTranslationService, AlfrescoTranslationLoader } from 'ng2-alfresco-core/dist/ng2-alfresco-core';
@RouteConfig([
{path: '/', name: 'Login', component: AlfrescoLoginComponent, useAsDefault: true}
])
@Component({
selector: 'my-app',
template: '<alfresco-login method="POST" (onSuccess)="mySuccessMethod($event)" (onError)="myErrorMethod($event)"></alfresco-login>',
directives: [ROUTER_DIRECTIVES, AlfrescoLoginComponent]
})
export class AppComponent {
constructor(public auth: AlfrescoAuthenticationService,
public router: Router,
alfrescoSettingsService: AlfrescoSettingsService) {
alfrescoSettingsService.host = 'http://192.168.99.100:8080';
}
mySuccessMethod($event) {
console.log('Success Login EventEmitt called with: ' + $event.value);
}
myErrorMethod($event) {
console.log('Error Login EventEmitt called with: ' + $event.value);
}
}
bootstrap(AppComponent, [
ROUTER_PROVIDERS,
HTTP_PROVIDERS,
AlfrescoTranslationLoader,
AlfrescoTranslationService,
ALFRESCO_AUTHENTICATION,
AlfrescoAuthenticationService,
ALFRESCO_CORE_PROVIDERS
]);

View File

@ -1,7 +1,7 @@
{
"compilerOptions": {
"target": "ES5",
"module": "commonjs",
"target": "es5",
"module": "system",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
@ -11,8 +11,9 @@
"outDir": "dist"
},
"exclude": [
"dist",
"node_modules",
"typings",
"dist"
"typings/main",
"typings/main.d.ts"
]
}