diff --git a/ng2-components/ng2-alfresco-userinfo/demo/package.json b/ng2-components/ng2-alfresco-userinfo/demo/package.json index 5cb3aff079..7776b1fe0d 100644 --- a/ng2-components/ng2-alfresco-userinfo/demo/package.json +++ b/ng2-components/ng2-alfresco-userinfo/demo/package.json @@ -16,7 +16,8 @@ }, "license": "Apache-2.0", "dependencies": { - "ng2-alfresco-userinfo": "0.3.2" + "ng2-alfresco-userinfo": "0.3.2", + "ng2-alfresco-login": "^0.3.2" }, "devDependencies": { "@types/core-js": "^0.9.32", diff --git a/ng2-components/ng2-alfresco-userinfo/demo/src/main.ts b/ng2-components/ng2-alfresco-userinfo/demo/src/main.ts index d7981d6240..68224a8190 100644 --- a/ng2-components/ng2-alfresco-userinfo/demo/src/main.ts +++ b/ng2-components/ng2-alfresco-userinfo/demo/src/main.ts @@ -20,45 +20,54 @@ import { BrowserModule } from '@angular/platform-browser'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { UserInfoComponentModule } from 'ng2-alfresco-userinfo'; import { CoreModule } from 'ng2-alfresco-core'; - +import { LoginModule } from 'ng2-alfresco-login'; import { AlfrescoAuthenticationService, AlfrescoSettingsService } from 'ng2-alfresco-core'; @Component({ selector: 'alfresco-app-demo', - template: `

START DEMO USERINFO

-
-

- -

-

- -

+ template: ` +
+ ECM Host:
+ BPM Host:
+
+ +

+ +

+

+ +

+

+ +

+

+ +

+
+ {{ status }} +
+ + +
+
-
- -
-

-
-

- Username - -

-

- Password - -

- -
- {{loginErrorMessage}} - `, + + + + `, styles: [ ':host > .container {padding: 10px}', '.p-10 { padding: 10px; }' @@ -66,80 +75,93 @@ import { AlfrescoAuthenticationService, AlfrescoSettingsService } from 'ng2-alfr }) class UserInfoDemo implements OnInit { - public userToLogin: string = 'admin'; - public password: string = 'admin'; - public loginErrorMessage: string; - public providers: string = 'BPM'; - private authenticated: boolean; - private token: any; + public ecmHost: string = 'http://localhost:8080'; + + public bpmHost: string = 'http://localhost:9999'; + + public userToLogin: string = 'admin'; + + public password: string = 'admin'; + + public loginErrorMessage: string; + + public providers: string = 'BPM'; + + private authenticated: boolean; - constructor(private authService: AlfrescoAuthenticationService, - private settingsService: AlfrescoSettingsService) { - } + private token: any; - ngOnInit() { + public disableCsrf: boolean = false; + + constructor(private authService: AlfrescoAuthenticationService, + private settingsService: AlfrescoSettingsService) { + settingsService.ecmHost = this.ecmHost; + settingsService.bpmHost = this.bpmHost; + } + + ngOnInit() { + this.settingsService.setProviders(this.providers); + } + + logout() { + this.authService.logout(); + } + + login(user, password) { this.settingsService.setProviders(this.providers); - } - - attemptLogin() { - this.loginErrorMessage = ''; - this.login(this.userToLogin, this.password); - } - - logout() { - this.authService.logout(); - } - - login(user, password) { - this.settingsService.setProviders(this.providers); - this.authService.login(user, password).subscribe( - token => { - console.log(token); - this.token = token; - this.authenticated = true; - }, - error => { - console.log(error); - this.authenticated = false; - this.loginErrorMessage = error; - }); - } - - isLoggedIn(): boolean { - return this.authService.isLoggedIn(); - } - - toggleECM(checked) { - if (checked && this.providers === 'BPM') { - this.providers = 'ALL'; - } else if (checked) { - this.providers = 'ECM'; - } else { - this.providers = undefined; - } - } - - toggleBPM(checked) { - if (checked && this.providers === 'ECM') { - this.providers = 'ALL'; - } else if (checked) { - this.providers = 'BPM'; - } else { - this.providers = undefined; - } - } + this.authService.login(user, password).subscribe( + token => { + console.log(token); + this.token = token; + this.authenticated = true; + }, + error => { + console.log(error); + this.authenticated = false; + this.loginErrorMessage = error; + }); + } + isLoggedIn(): boolean { + return this.authService.isLoggedIn(); + } + + toggleECM(checked) { + if (checked && this.providers === 'BPM') { + this.providers = 'ALL'; + } else if (checked) { + this.providers = 'ECM'; + } else { + this.providers = undefined; + } + } + + toggleBPM(checked) { + if (checked && this.providers === 'ECM') { + this.providers = 'ALL'; + } else if (checked) { + this.providers = 'BPM'; + } else { + this.providers = undefined; + } + } + + toggleCSRF() { + this.disableCsrf = !this.disableCsrf; + } } @NgModule({ imports: [ BrowserModule, CoreModule.forRoot(), - UserInfoComponentModule.forRoot() + UserInfoComponentModule.forRoot(), + LoginModule ], - declarations: [ UserInfoDemo ], - bootstrap: [ UserInfoDemo ] + declarations: [UserInfoDemo], + bootstrap: [UserInfoDemo] }) -export class AppModule { } +export class AppModule { +} platformBrowserDynamic().bootstrapModule(AppModule); diff --git a/ng2-components/ng2-alfresco-userinfo/demo/systemjs.config.js b/ng2-components/ng2-alfresco-userinfo/demo/systemjs.config.js index 772783f002..485f49580e 100644 --- a/ng2-components/ng2-alfresco-userinfo/demo/systemjs.config.js +++ b/ng2-components/ng2-alfresco-userinfo/demo/systemjs.config.js @@ -26,7 +26,8 @@ 'ng2-translate': 'npm:ng2-translate', 'alfresco-js-api': 'npm:alfresco-js-api/dist', 'ng2-alfresco-core': 'npm:ng2-alfresco-core/dist', - 'ng2-alfresco-userinfo': 'npm:ng2-alfresco-userinfo/dist' + 'ng2-alfresco-userinfo': 'npm:ng2-alfresco-userinfo/dist', + 'ng2-alfresco-login': 'npm:ng2-alfresco-login/dist' }, // packages tells the System loader how to load when no filename and/or no extension packages: { @@ -40,7 +41,8 @@ 'ng2-translate': { defaultExtension: 'js' }, 'ng2-alfresco-core': { main: './index.js', defaultExtension: 'js'}, 'ng2-alfresco-userinfo': { main: './index.js', defaultExtension: 'js'}, - 'alfresco-js-api': { main: './alfresco-js-api.js', defaultExtension: 'js'} + 'alfresco-js-api': { main: './alfresco-js-api.js', defaultExtension: 'js'}, + 'ng2-alfresco-login': { main: './index.js', defaultExtension: 'js'} } }); })(this);