From 8698395bd48c59b68d181c3d402b58c97c334aed Mon Sep 17 00:00:00 2001 From: Eugenio Romano Date: Tue, 16 Aug 2016 15:14:07 +0100 Subject: [PATCH] change demo and add information about auth in the core reame --- ng2-components/ng2-alfresco-core/README.md | 60 +++++++++++++++++++ .../demo/src/main.ts | 3 +- .../ng2-alfresco-login/demo/src/main.ts | 18 +++--- .../alfresco-login.component.spec.ts | 2 +- .../ng2-alfresco-search/demo/src/main.ts | 2 +- .../ng2-alfresco-upload/demo/src/main.ts | 2 +- .../ng2-alfresco-viewer/demo/src/main.ts | 2 +- 7 files changed, 76 insertions(+), 13 deletions(-) diff --git a/ng2-components/ng2-alfresco-core/README.md b/ng2-components/ng2-alfresco-core/README.md index b7fec9eac1..d77abaa509 100644 --- a/ng2-components/ng2-alfresco-core/README.md +++ b/ng2-components/ng2-alfresco-core/README.md @@ -92,6 +92,66 @@ export class MyComponent implements OnInit { - Translation Service - Context Menu Service +#### Authentication Service + +The authentication service is used inside the [login component](../ng2-alfresco-login) and is possible to find there an example of how to use it. + +```javascript +import { Component } from '@angular/core'; +import { bootstrap } from '@angular/platform-browser-dynamic'; +import { HTTP_PROVIDERS } from '@angular/http'; + +import { + ALFRESCO_CORE_PROVIDERS, + AlfrescoSettingsService, + AlfrescoAuthenticationService +} from 'ng2-alfresco-core'; + +@Component({ + selector: 'my-app', + template: ` +
+ Authentication failed to ip {{ ecmHost }} with user: admin, admin +
+
+ Authentication successfull to ip {{ ecmHost }} with user: admin, admin, your token is {{ token }} +
` +}) +class MyDemoApp { + authenticated: boolean = false; + + ecmHost: string = 'http://127.0.0.1:8080'; + + token: string; + + constructor(public alfrescoAuthenticationService: AlfrescoAuthenticationService, + private alfrescoSettingsService: AlfrescoSettingsService) { + } + + ngOnInit() { + this.login(); + } + + login() { + this.alfrescoAuthenticationService.login('admin', 'admin', 'ECM').subscribe( + token => { + this.token = token.ticket; + this.authenticated = true; + }, + error => { + console.log(error); + this.authenticated = false; + }); + } +} +bootstrap(MyDemoApp, [ + HTTP_PROVIDERS, + ALFRESCO_CORE_PROVIDERS +]); + +``` + + ## Build from sources Alternatively you can build component from sources with the following commands: diff --git a/ng2-components/ng2-alfresco-documentlist/demo/src/main.ts b/ng2-components/ng2-alfresco-documentlist/demo/src/main.ts index d3893bdaaf..889b008da8 100644 --- a/ng2-components/ng2-alfresco-documentlist/demo/src/main.ts +++ b/ng2-components/ng2-alfresco-documentlist/demo/src/main.ts @@ -144,7 +144,6 @@ class DocumentListDemo implements OnInit { authenticated: boolean; ecmHost: string = 'http://devproducts-platform.alfresco.me'; - // ecmHost: string = 'http://127.0.0.1:8080'; token: string; @@ -190,7 +189,7 @@ class DocumentListDemo implements OnInit { } login() { - this.authService.login('admin', 'admin', ['ECM']).subscribe( + this.authService.login('admin', 'admin', 'ECM').subscribe( token => { console.log(token); this.token = token; diff --git a/ng2-components/ng2-alfresco-login/demo/src/main.ts b/ng2-components/ng2-alfresco-login/demo/src/main.ts index 83ec4d1ac6..6bfe71ab2b 100644 --- a/ng2-components/ng2-alfresco-login/demo/src/main.ts +++ b/ng2-components/ng2-alfresco-login/demo/src/main.ts @@ -62,7 +62,7 @@ export class AppComponent { public status: string = ''; - public providers: string [] = ['ECM']; + public providers: string = 'ECM'; constructor(public auth: AlfrescoAuthenticationService, private alfrescoSettingsService: AlfrescoSettingsService) { @@ -84,18 +84,22 @@ export class AppComponent { } toggleECM(checked) { - if (checked) { - this.providers[0] = 'ECM'; + if (checked && this.providers === 'BPM') { + this.providers = 'ALL'; + } else if (checked) { + this.providers = 'ECM'; } else { - this.providers[0] = ''; + this.providers = undefined; } } toggleBPM(checked) { - if (checked) { - this.providers[1] = 'BPM'; + if (checked && this.providers === 'ECM') { + this.providers = 'ALL'; + } else if (checked) { + this.providers = 'BPM'; } else { - this.providers[1] = ''; + this.providers = undefined; } } } diff --git a/ng2-components/ng2-alfresco-login/src/components/alfresco-login.component.spec.ts b/ng2-components/ng2-alfresco-login/src/components/alfresco-login.component.spec.ts index a5e7cf1df1..8c8432c156 100644 --- a/ng2-components/ng2-alfresco-login/src/components/alfresco-login.component.spec.ts +++ b/ng2-components/ng2-alfresco-login/src/components/alfresco-login.component.spec.ts @@ -11,7 +11,7 @@ * 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 speific language governing permissions and + * See the License for the specific language governing permissions and * limitations under the License. */ diff --git a/ng2-components/ng2-alfresco-search/demo/src/main.ts b/ng2-components/ng2-alfresco-search/demo/src/main.ts index 506d26513b..1e3f9fddc6 100644 --- a/ng2-components/ng2-alfresco-search/demo/src/main.ts +++ b/ng2-components/ng2-alfresco-search/demo/src/main.ts @@ -81,7 +81,7 @@ class SearchDemo implements OnInit { } login() { - this.authService.login('admin', 'admin', ['ECM']).subscribe( + this.authService.login('admin', 'admin', 'ECM').subscribe( token => { console.log(token); this.token = token; diff --git a/ng2-components/ng2-alfresco-upload/demo/src/main.ts b/ng2-components/ng2-alfresco-upload/demo/src/main.ts index a9d7dc92cb..6471746c14 100644 --- a/ng2-components/ng2-alfresco-upload/demo/src/main.ts +++ b/ng2-components/ng2-alfresco-upload/demo/src/main.ts @@ -106,7 +106,7 @@ export class MyDemoApp implements OnInit { } login() { - this.authService.login('admin', 'admin', ['ECM']).subscribe( + this.authService.login('admin', 'admin', 'ECM').subscribe( token => { console.log(token); this.token = token; diff --git a/ng2-components/ng2-alfresco-viewer/demo/src/main.ts b/ng2-components/ng2-alfresco-viewer/demo/src/main.ts index 169ab30808..fbbfdb7862 100644 --- a/ng2-components/ng2-alfresco-viewer/demo/src/main.ts +++ b/ng2-components/ng2-alfresco-viewer/demo/src/main.ts @@ -79,7 +79,7 @@ class MyDemoApp { } login() { - this.authService.login('admin', 'admin', ['ECM']).subscribe( + this.authService.login('admin', 'admin', 'ECM').subscribe( token => { console.log(token); this.token = token;