From efe479cefb4a21ea537f549f3978862b045dad51 Mon Sep 17 00:00:00 2001 From: mauriziovitale84 Date: Fri, 22 Apr 2016 16:56:20 +0100 Subject: [PATCH] #17 Basic JS Doc Basic Component Doc --- ng2-components/ng2-alfresco-login/README.md | 21 +++++++++- .../src/authentication.service.js | 42 ++++++++++++++++++- .../src/authentication.service.js.map | 2 +- .../src/authentication.service.ts | 42 ++++++++++++++++++- .../ng2-alfresco-login/src/login.component.js | 36 +++++++++++----- .../src/login.component.js.map | 2 +- .../ng2-alfresco-login/src/login.component.ts | 36 +++++++++++----- 7 files changed, 153 insertions(+), 28 deletions(-) diff --git a/ng2-components/ng2-alfresco-login/README.md b/ng2-components/ng2-alfresco-login/README.md index 6b8d8fd0ca..b1466d3df9 100644 --- a/ng2-components/ng2-alfresco-login/README.md +++ b/ng2-components/ng2-alfresco-login/README.md @@ -1,7 +1,24 @@ -# Alfresco Components for Angular 2 +# Alfresco Login Component for Angular 2 Components included: -TBD + +* Login Component +* Alfresco Authentication Service (TBD) + +### Custom Login Component + +```ts +import {Component} from 'angular2/core'; +import {Login} from 'ng2-alfresco-login/ng2-alfresco-login'; + +@Component({ + selector: 'my-login', + template: ' ', + directives: [Login] +}) +export class MyLoginComponent { +} +``` ### Build diff --git a/ng2-components/ng2-alfresco-login/src/authentication.service.js b/ng2-components/ng2-alfresco-login/src/authentication.service.js index d68b6df5cc..a0ae3b898c 100644 --- a/ng2-components/ng2-alfresco-login/src/authentication.service.js +++ b/ng2-components/ng2-alfresco-login/src/authentication.service.js @@ -25,15 +25,30 @@ System.register(['angular2/core', 'rxjs/Rx', 'angular2/http'], function(exports_ }], execute: function() { Authentication = (function () { + /** + * Constructor + * @param http + */ function Authentication(http) { this.http = http; this._host = 'http://192.168.99.100:8080'; this._baseUrl = this._host + '/alfresco/service/api/'; this.token = localStorage.getItem('token'); } + /** + * The method return tru if the user is logged in + * @returns {boolean} + */ Authentication.prototype.isLoggedIn = function () { return !!localStorage.getItem('token'); }; + /** + * Method to delegate GET or POST login + * @param method + * @param username + * @param password + * @returns {Observable|Observable} + */ Authentication.prototype.login = function (method, username, password) { if (method === 'GET') { return this.loginGet(username, password); @@ -42,6 +57,12 @@ System.register(['angular2/core', 'rxjs/Rx', 'angular2/http'], function(exports_ return this.loginPost(username, password); } }; + /** + * The method provide the login with GET Request + * @param username + * @param password + * @returns {Observable|Observable} + */ Authentication.prototype.loginGet = function (username, password) { var _this = this; var searchParams = new http_1.URLSearchParams(); @@ -55,6 +76,12 @@ System.register(['angular2/core', 'rxjs/Rx', 'angular2/http'], function(exports_ }) .catch(this.handleError); }; + /** + * The method provide the login with POST Request + * @param username + * @param password + * @returns {Observable|Observable} + */ Authentication.prototype.loginPost = function (username, password) { var _this = this; var credentials = '{ username: ' + username + ', password: ' + password + ' }'; @@ -70,19 +97,30 @@ System.register(['angular2/core', 'rxjs/Rx', 'angular2/http'], function(exports_ }) .catch(this.handleError); }; + /** + * The method save the toke in the localStorage + * @param jwt + */ Authentication.prototype.saveJwt = function (jwt) { if (jwt) { localStorage.setItem('token', jwt); } }; + /** + * The method remove the token from the local storage + * @returns {Observable} + */ Authentication.prototype.logout = function () { this.token = undefined; localStorage.removeItem('token'); return Rx_1.Observable.of(true); }; + /** + * The method write the error in the console browser + * @param error + * @returns {ErrorObservable} + */ Authentication.prototype.handleError = function (error) { - // in a real world app, we may send the error to some remote logging infrastructure - // instead of just logging it to the console console.error(error); return Rx_1.Observable.throw(error.json().error || 'Server error'); }; diff --git a/ng2-components/ng2-alfresco-login/src/authentication.service.js.map b/ng2-components/ng2-alfresco-login/src/authentication.service.js.map index 53d3fd64b0..2faf94a48f 100644 --- a/ng2-components/ng2-alfresco-login/src/authentication.service.js.map +++ b/ng2-components/ng2-alfresco-login/src/authentication.service.js.map @@ -1 +1 @@ -{"version":3,"file":"authentication.service.js","sourceRoot":"","sources":["authentication.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;YAOA;gBAMI,wBAAmB,IAAS;oB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AC9B,mFAAmF;oBACnF,4CAA4C;oBAC5C,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;oBACrB,MAAM,CAAC,eAAU,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,cAAc,CAAC,CAAC;gBAClE,CAAC;gBAxEL;oBAAC,iBAAU,EAAE;;kCAAA;gBAyEb,qBAAC;YAAD,CAAC,AAxED,IAwEC;YAxED,2CAwEC,CAAA"} \ No newline at end of file +{"version":3,"file":"authentication.service.js","sourceRoot":"","sources":["authentication.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;YAOA;gBAMI;;;mBAGG;gBACH,wBAAmB,IAAS;oBAAT,SAAI,GAAJ,IAAI,CAAK;oBAPpB,UAAK,GAAU,4BAA4B,CAAC;oBAC5C,aAAQ,GAAU,IAAI,CAAC,KAAK,GAAG,wBAAwB,CAAC;oBAO5D,IAAI,CAAC,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;gBAC/C,CAAC;gBAED;;;mBAGG;gBACH,mCAAU,GAAV;oBACI,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;gBAC3C,CAAC;gBAED;;;;;;mBAMG;gBACH,8BAAK,GAAL,UAAM,MAAa,EAAE,QAAe,EAAE,QAAe;oBACjD,EAAE,CAAC,CAAC,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC;wBACnB,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;oBAC7C,CAAC;oBAAC,IAAI,CAAC,CAAC;wBACJ,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;oBAC9C,CAAC;gBACL,CAAC;gBAED;;;;;mBAKG;gBACH,iCAAQ,GAAR,UAAS,QAAe,EAAE,QAAe;oBAAzC,iBAYC;oBAXG,IAAM,YA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AC,OAAO,CAAC,KAAI,CAAC,KAAK,CAAC,CAAC;oBAC7B,CAAC,CAAC;yBACD,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;gBACjC,CAAC;gBAED;;;mBAGG;gBACH,gCAAO,GAAP,UAAQ,GAAG;oBACP,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;wBACN,YAAY,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;oBACvC,CAAC;gBACL,CAAC;gBAED;;;mBAGG;gBACH,+BAAM,GAAN;oBACI,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;oBACvB,YAAY,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;oBAEjC,MAAM,CAAC,eAAU,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;gBAC/B,CAAC;gBAED;;;;mBAIG;gBACK,oCAAW,GAAnB,UAAoB,KAAc;oBAC9B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;oBACrB,MAAM,CAAC,eAAU,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,cAAc,CAAC,CAAC;gBAClE,CAAC;gBA9GL;oBAAC,iBAAU,EAAE;;kCAAA;gBA+Gb,qBAAC;YAAD,CAAC,AA9GD,IA8GC;YA9GD,2CA8GC,CAAA"} \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-login/src/authentication.service.ts b/ng2-components/ng2-alfresco-login/src/authentication.service.ts index 6fa8776a1f..03266def17 100644 --- a/ng2-components/ng2-alfresco-login/src/authentication.service.ts +++ b/ng2-components/ng2-alfresco-login/src/authentication.service.ts @@ -11,14 +11,29 @@ export class Authentication { private _host:string = 'http://192.168.99.100:8080'; private _baseUrl:string = this._host + '/alfresco/service/api/'; + /** + * Constructor + * @param http + */ constructor(public http:Http) { this.token = localStorage.getItem('token'); } + /** + * The method return tru if the user is logged in + * @returns {boolean} + */ isLoggedIn() { return !!localStorage.getItem('token'); } + /** + * Method to delegate GET or POST login + * @param method + * @param username + * @param password + * @returns {Observable|Observable} + */ login(method:string, username:string, password:string) { if (method === 'GET') { return this.loginGet(username, password); @@ -27,6 +42,12 @@ export class Authentication { } } + /** + * The method provide the login with GET Request + * @param username + * @param password + * @returns {Observable|Observable} + */ loginGet(username:string, password:string) { const searchParams = new URLSearchParams(); searchParams.set('u', username); @@ -41,6 +62,12 @@ export class Authentication { .catch(this.handleError); } + /** + * The method provide the login with POST Request + * @param username + * @param password + * @returns {Observable|Observable} + */ loginPost(username:string, password:string) { let credentials = '{ username: ' + username + ', password: ' + password + ' }'; @@ -58,12 +85,20 @@ export class Authentication { .catch(this.handleError); } + /** + * The method save the toke in the localStorage + * @param jwt + */ saveJwt(jwt) { if (jwt) { localStorage.setItem('token', jwt); } } + /** + * The method remove the token from the local storage + * @returns {Observable} + */ logout() { this.token = undefined; localStorage.removeItem('token'); @@ -71,9 +106,12 @@ export class Authentication { return Observable.of(true); } + /** + * The method write the error in the console browser + * @param error + * @returns {ErrorObservable} + */ private handleError(error:Response) { - // in a real world app, we may send the error to some remote logging infrastructure - // instead of just logging it to the console console.error(error); return Observable.throw(error.json().error || 'Server error'); } diff --git a/ng2-components/ng2-alfresco-login/src/login.component.js b/ng2-components/ng2-alfresco-login/src/login.component.js index afcfd93000..9c19ff13e8 100644 --- a/ng2-components/ng2-alfresco-login/src/login.component.js +++ b/ng2-components/ng2-alfresco-login/src/login.component.js @@ -28,6 +28,12 @@ System.register(['angular2/core', 'angular2/router', 'angular2/common', './authe }], execute: function() { Login = (function () { + /** + * Constructor + * @param fb + * @param auth + * @param router + */ function Login(fb, auth, router) { this.auth = auth; this.router = router; @@ -37,15 +43,11 @@ System.register(['angular2/core', 'angular2/router', 'angular2/common', './authe password: ['', common_1.Validators.required] }); } - Login.prototype.isErrorStyle = function (field) { - componentHandler.upgradeAllRegistered(); - if (field.valid) { - return false; - } - else { - return true; - } - }; + /** + * Method called on submit form + * @param value + * @param event + */ Login.prototype.onSubmit = function (value, event) { var _this = this; if (event) { @@ -56,9 +58,23 @@ System.register(['angular2/core', 'angular2/router', 'angular2/common', './authe _this.error = true; }); }; + /** + * The method return if a field is valid or not + * @param field + * @returns {boolean} + */ + Login.prototype.isErrorStyle = function (field) { + componentHandler.upgradeAllRegistered(); + if (field.valid) { + return false; + } + else { + return true; + } + }; Login = __decorate([ core_1.Component({ - selector: 'login', + selector: 'alfresco-login', moduleId: 'node_modules/ng2-alfresco-login/src/', directives: [router_1.ROUTER_DIRECTIVES, common_1.FORM_DIRECTIVES], templateUrl: 'login.component.html', diff --git a/ng2-components/ng2-alfresco-login/src/login.component.js.map b/ng2-components/ng2-alfresco-login/src/login.component.js.map index 7e1849cd7d..e2ea2ebf31 100644 --- a/ng2-components/ng2-alfresco-login/src/login.component.js.map +++ b/ng2-components/ng2-alfresco-login/src/login.component.js.map @@ -1 +1 @@ -{"version":3,"file":"login.component.js","sourceRoot":"","sources":["login.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAcA;gBAaI,eAAY,EAAc,EAAS,IAAmB,EAAS,MAAa;oBAAzC,SAAI,GAAJ,IAAI,CAAe;oBAAS,WAAM,GAAN,MAAM,CAAO;oBAX5E,UAAK,GAAW,KAAK,CAAC;oBAYlB,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC,KAAK,CAAC;wBACjB,QAAQ,EAAE,CAAC,EAAE,EAAE,mBAAU,CAAC,OAAO,CAAC,CAAC,mBAAU,CAAC,QAAQ,EAAE,mBAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;wBAClF,QAAQ,EAAE,CAAC,EAAE,EAAE,mBAAU,CAAC,QAAQ,CAAC;qBACtC,CAAC,CAAC;gBACP,CAAC;gBAdD,4BAAY,GAAZ,UAAa,KAAkB;oBAC3B,gBAAgB,CAAC,oBAAoB,EAAE,CAAC;oBACxC,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;wBACd,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CAAC,AAhDD,IAgDC;YAhDD,yBAgDC,CAAA"} \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-login/src/login.component.ts b/ng2-components/ng2-alfresco-login/src/login.component.ts index d20c8a0144..a826abb57f 100644 --- a/ng2-components/ng2-alfresco-login/src/login.component.ts +++ b/ng2-components/ng2-alfresco-login/src/login.component.ts @@ -5,7 +5,7 @@ import {Authentication} from './authentication.service'; declare let componentHandler; @Component({ - selector: 'login', + selector: 'alfresco-login', moduleId: 'node_modules/ng2-alfresco-login/src/', directives: [ROUTER_DIRECTIVES, FORM_DIRECTIVES], templateUrl: 'login.component.html', @@ -16,15 +16,12 @@ export class Login { form:ControlGroup; error:boolean = false; - isErrorStyle(field:ControlGroup) { - componentHandler.upgradeAllRegistered(); - if (field.valid) { - return false; - } else { - return true; - } - } - + /** + * Constructor + * @param fb + * @param auth + * @param router + */ constructor(fb:FormBuilder, public auth:Authentication, public router:Router) { this.form = fb.group({ username: ['', Validators.compose([Validators.required, Validators.minLength(4)])], @@ -32,6 +29,11 @@ export class Login { }); } + /** + * Method called on submit form + * @param value + * @param event + */ onSubmit(value:any, event) { if (event) { event.preventDefault(); @@ -44,4 +46,18 @@ export class Login { } ); } + + /** + * The method return if a field is valid or not + * @param field + * @returns {boolean} + */ + isErrorStyle(field:ControlGroup) { + componentHandler.upgradeAllRegistered(); + if (field.valid) { + return false; + } else { + return true; + } + } }