change demo and add information about auth in the core reame

This commit is contained in:
Eugenio Romano 2016-08-16 15:14:07 +01:00
parent 1e8440c0a0
commit 8698395bd4
7 changed files with 76 additions and 13 deletions

View File

@ -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: `
<div *ngIf="!authenticated" >
Authentication failed to ip {{ ecmHost }} with user: admin, admin
</div>
<div *ngIf="authenticated">
Authentication successfull to ip {{ ecmHost }} with user: admin, admin, your token is {{ token }}
</div>`
})
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:

View File

@ -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;

View File

@ -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;
}
}
}

View File

@ -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.
*/

View File

@ -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;

View File

@ -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;

View File

@ -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;