- - -
- - - - - - - - - - - - {{ title }} app is running! - - - - - + + +
+
- - -

Resources

-

Here are some links to help you get started:

- - - - -

Next Steps

-

What do you want to do next with your app?

- - - -
-
- - - New Component -
- -
- - - Angular Material -
- -
- - - Add PWA Support -
- -
- - - Add Dependency -
- -
- - - Run and Watch Tests -
- -
- - - Build for Production -
-
- - -
-
ng generate component xyz
-
ng add @angular/material
-
ng add @angular/pwa
-
ng add _____
-
ng test
-
ng build --prod
-
- - - - - - - - - - - -
- - - - - - - - - - + diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts index db98510..5105ce1 100644 --- a/src/app/app.component.spec.ts +++ b/src/app/app.component.spec.ts @@ -1,6 +1,7 @@ import { TestBed, async } from '@angular/core/testing'; import { AppComponent } from './app.component'; +/* describe('AppComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ @@ -29,3 +30,4 @@ describe('AppComponent', () => { expect(compiled.querySelector('.content span').textContent).toContain('EPAClient app is running!'); }); }); +*/ diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 02c51e8..599316b 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -7,4 +7,8 @@ import { Component } from '@angular/core'; }) export class AppComponent { title = 'EPAClient'; + + constructor() { + + } } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index f657163..82c6cc7 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -1,16 +1,48 @@ import { BrowserModule } from '@angular/platform-browser'; -import { NgModule } from '@angular/core'; +import { NgModule, DoBootstrap } from '@angular/core'; + +import { KeycloakAngularModule, KeycloakService } from 'keycloak-angular'; import { AppComponent } from './app.component'; +import { AppRoutingModule } from './app-routing.module'; + + +import { HomeComponent, HomeAssistanteComponent, HomeCollaborateurComponent, + HomeCommercialComponent, HomeRHComponent } from './home'; + +import { environment } from '../environments/environment'; + +let keycloakService: KeycloakService = new KeycloakService(); @NgModule({ declarations: [ - AppComponent + AppComponent, HomeComponent, HomeAssistanteComponent + , HomeCollaborateurComponent, HomeCommercialComponent, HomeRHComponent ], imports: [ - BrowserModule + BrowserModule, + KeycloakAngularModule, + AppRoutingModule ], - providers: [], - bootstrap: [AppComponent] + providers: [ + { + provide: KeycloakService, + useValue: keycloakService + } + ], + entryComponents: [AppComponent] }) -export class AppModule { } + +export class AppModule implements DoBootstrap { + async ngDoBootstrap(app) { + const { keycloakConfig } = environment; + + try { + await keycloakService.init({ config: keycloakConfig }); + app.bootstrap(AppComponent); + + } catch (error) { + console.error('Keycloak init failed', error); + } + } +} diff --git a/src/app/home/home-assistante/home-assistante.component.html b/src/app/home/home-assistante/home-assistante.component.html new file mode 100644 index 0000000..63ce996 --- /dev/null +++ b/src/app/home/home-assistante/home-assistante.component.html @@ -0,0 +1 @@ +

Page assistante

diff --git a/src/app/home/home-assistante/home-assistante.component.ts b/src/app/home/home-assistante/home-assistante.component.ts new file mode 100644 index 0000000..d4b6106 --- /dev/null +++ b/src/app/home/home-assistante/home-assistante.component.ts @@ -0,0 +1,13 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector : 'home-assistante', + templateUrl : 'home-assistante.component.html' +}) +export class HomeAssistanteComponent implements OnInit { + constructor() { + } + + ngOnInit() { + } +} diff --git a/src/app/home/home-collaborateur/home-collaborateur.component.html b/src/app/home/home-collaborateur/home-collaborateur.component.html new file mode 100644 index 0000000..319236e --- /dev/null +++ b/src/app/home/home-collaborateur/home-collaborateur.component.html @@ -0,0 +1 @@ +

Page collaborateur

diff --git a/src/app/home/home-collaborateur/home-collaborateur.component.ts b/src/app/home/home-collaborateur/home-collaborateur.component.ts new file mode 100644 index 0000000..bc3f311 --- /dev/null +++ b/src/app/home/home-collaborateur/home-collaborateur.component.ts @@ -0,0 +1,13 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector : 'home-collaborateur', + templateUrl : 'home-collaborateur.component.html' +}) +export class HomeCollaborateurComponent implements OnInit { + constructor() { + } + + ngOnInit() { + } +} diff --git a/src/app/home/home-commercial/home-commercial.component.html b/src/app/home/home-commercial/home-commercial.component.html new file mode 100644 index 0000000..f0700da --- /dev/null +++ b/src/app/home/home-commercial/home-commercial.component.html @@ -0,0 +1 @@ +

Page Commercial

diff --git a/src/app/home/home-commercial/home-commercial.component.ts b/src/app/home/home-commercial/home-commercial.component.ts new file mode 100644 index 0000000..34ff3cc --- /dev/null +++ b/src/app/home/home-commercial/home-commercial.component.ts @@ -0,0 +1,13 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector : 'home-commercial', + templateUrl : 'home-commercial.component.html' +}) +export class HomeCommercialComponent implements OnInit { + constructor() { + } + + ngOnInit() { + } +} diff --git a/src/app/home/home-rh/home-rh.component.html b/src/app/home/home-rh/home-rh.component.html new file mode 100644 index 0000000..b9efd22 --- /dev/null +++ b/src/app/home/home-rh/home-rh.component.html @@ -0,0 +1 @@ +

Page RH

diff --git a/src/app/home/home-rh/home-rh.component.ts b/src/app/home/home-rh/home-rh.component.ts new file mode 100644 index 0000000..b65c0e3 --- /dev/null +++ b/src/app/home/home-rh/home-rh.component.ts @@ -0,0 +1,13 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector : 'home-rh', + templateUrl : 'home-rh.component.html' +}) +export class HomeRHComponent implements OnInit { + constructor() { + } + + ngOnInit() { + } +} diff --git a/src/app/home/home.compenent.html b/src/app/home/home.compenent.html deleted file mode 100644 index e69de29..0000000 diff --git a/src/app/home/home.component.html b/src/app/home/home.component.html new file mode 100644 index 0000000..3f3f19d --- /dev/null +++ b/src/app/home/home.component.html @@ -0,0 +1,6 @@ + +

Bonjour {{ keycloakService.getKeycloakInstance().profile.firstName }} {{ keycloakService.getKeycloakInstance().profile.lastName }}

+ + + + diff --git a/src/app/home/home.component.ts b/src/app/home/home.component.ts index e69de29..f68aefc 100644 --- a/src/app/home/home.component.ts +++ b/src/app/home/home.component.ts @@ -0,0 +1,30 @@ +import { Component, OnInit } from '@angular/core'; + +import { KeycloakService } from 'keycloak-angular'; + +import { HomeAssistanteComponent } from './home-assistante/home-assistante.component'; +import { HomeCollaborateurComponent } from './home-collaborateur/home-collaborateur.component'; +import { HomeCommercialComponent } from './home-commercial/home-commercial.component'; +import { HomeRHComponent } from './home-rh/home-rh.component'; + +import { Role } from '../utils/roles'; + +@Component({ + selector: 'app-home', + templateUrl: './home.component.html' +}) +export class HomeComponent implements OnInit { + + role = Role; + constructor(public keycloakService : KeycloakService) { + } + + ngOnInit() { + } + + async logout() { + console.log("Disconnected button clicked"); + await this.keycloakService.logout(); + } + +} diff --git a/src/app/home/index.ts b/src/app/home/index.ts new file mode 100644 index 0000000..56591d2 --- /dev/null +++ b/src/app/home/index.ts @@ -0,0 +1,5 @@ +export * from './home-assistante/home-assistante.component'; +export * from './home-collaborateur/home-collaborateur.component'; +export * from './home-commercial/home-commercial.component'; +export * from './home-rh/home-rh.component'; +export * from './home.component'; diff --git a/src/app/utils/roles.ts b/src/app/utils/roles.ts new file mode 100644 index 0000000..cecbb1b --- /dev/null +++ b/src/app/utils/roles.ts @@ -0,0 +1,6 @@ +export enum Role { + collaborateur = "Collaborateur", + assistante = "Assistante", + rh = "RH", + commercial = "Commercial" +} diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 7b4f817..659b45c 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -2,8 +2,20 @@ // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`. // The list of file replacements can be found in `angular.json`. +import { KeycloakConfig } from 'keycloak-angular'; + +// Add here your keycloak setup infos +const keycloakConfig: KeycloakConfig = { + url: 'http://localhost:8080/auth', + realm: 'Apside', + clientId: 'GestionEPA' +}; + + + export const environment = { - production: false + production: false, + keycloakConfig }; /*