diff --git a/ng-package.json b/ng-package.json index d7b34df..2a68285 100644 --- a/ng-package.json +++ b/ng-package.json @@ -2,6 +2,6 @@ "$schema": "./node_modules/ng-packagr/ng-package.schema.json", "dest": "./dist/kar-cw", "lib": { - "entryFile": "src/**/index.ts" + "entryFile": "src/index.ts" } } \ No newline at end of file diff --git a/src/component/index.ts b/src/component/index.ts index 290012e..184ba21 100644 --- a/src/component/index.ts +++ b/src/component/index.ts @@ -11,7 +11,7 @@ import { PopInComponent } from './popin/popin'; import { RenderFormComponent } from './render-settings/render-form'; import { RenderSettingsComponent } from './render-settings/render-settings'; import { SpinnerComponent } from './spinner/spinner'; -import { TopMenuComponent } from './top-menu/top-menu'; +import { EventOnMenu, TopMenuComponent } from './top-menu/top-menu'; import { UploadFileComponent } from './upload-file/upload-file'; -export { BurgerPropertyComponent, EntryNumberComponent, CheckboxComponent, RenderFormComponent, RenderSettingsComponent, ErrorMessageStateComponent, AsyncActionState, AsyncActionStatusComponent, EntryValidatorComponent, PopInComponent, TopMenuComponent, UploadFileComponent, ErrorComponent, SpinnerComponent, PasswordEntryComponent, EntryComponent }; +export { EventOnMenu, BurgerPropertyComponent, EntryNumberComponent, CheckboxComponent, RenderFormComponent, RenderSettingsComponent, ErrorMessageStateComponent, AsyncActionState, AsyncActionStatusComponent, EntryValidatorComponent, PopInComponent, TopMenuComponent, UploadFileComponent, ErrorComponent, SpinnerComponent, PasswordEntryComponent, EntryComponent }; diff --git a/src/component/public_api.ts b/src/component/public_api.ts new file mode 100644 index 0000000..b8dd7e8 --- /dev/null +++ b/src/component/public_api.ts @@ -0,0 +1,2 @@ + +export * from '.' diff --git a/src/index.ts b/src/index.ts index c5b1727..633fe72 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,3 @@ -import { KarCWModule } from './kar-cw.module'; export * from './kar-cw.service'; export * from './kar-cw.module'; @@ -11,5 +10,3 @@ export * from './scene'; export * from './popin'; export * from './model'; export * from './component'; - -export default KarCWModule; \ No newline at end of file diff --git a/src/kar-cw.component.ts b/src/kar-cw.component.ts index 61ba858..65b0f92 100644 --- a/src/kar-cw.component.ts +++ b/src/kar-cw.component.ts @@ -1,4 +1,3 @@ -import { Component } from '@angular/core'; import { PopInComponent, TopMenuComponent, UploadFileComponent, ErrorComponent, PasswordEntryComponent, EntryComponent, EntryValidatorComponent, SpinnerComponent, AsyncActionStatusComponent, ErrorMessageStateComponent, CheckboxComponent, BurgerPropertyComponent, RenderSettingsComponent, RenderFormComponent, EntryNumberComponent } from './component'; import { PopInUploadProgress, PopInDeleteConfirm } from './popin'; diff --git a/src/kar-cw.module.ts b/src/kar-cw.module.ts index a93e688..9ef3ad4 100644 --- a/src/kar-cw.module.ts +++ b/src/kar-cw.module.ts @@ -11,9 +11,6 @@ import { ALL_COMPONENTS } from "./kar-cw.component"; import { ALL_SCENES } from "./kar-cw.scene"; import { ALL_SERVICES } from "./kar-cw.service"; import { ALL_GUARDS } from "./kar-cw.guard"; -import { DataStore, DataTools } from "./utils"; - - @NgModule({ declarations: [ @@ -21,13 +18,13 @@ import { DataStore, DataTools } from "./utils"; ...ALL_SCENES, ], imports: [ + CommonModule, FormsModule, ReactiveFormsModule, - CommonModule, ], providers: [ - ...ALL_SERVICES, - ...ALL_GUARDS, + //...ALL_SERVICES, + //...ALL_GUARDS, ], exports: [ ...ALL_COMPONENTS, @@ -35,6 +32,6 @@ import { DataStore, DataTools } from "./utils"; //...ALL_SERVICES, //...ALL_GUARDS, ], - schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA], + //schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA], }) export class KarCWModule { } diff --git a/src/kar-cw.service.ts b/src/kar-cw.service.ts index 23d5238..71ab7be 100644 --- a/src/kar-cw.service.ts +++ b/src/kar-cw.service.ts @@ -14,7 +14,7 @@ export const ALL_SERVICES = [ StorageService, PopInService, SessionService, - UserService, SSOService, + UserService, NotificationService, ]; \ No newline at end of file diff --git a/src/model/environment.ts b/src/model/environment.ts index cbd9ce1..19f922d 100644 --- a/src/model/environment.ts +++ b/src/model/environment.ts @@ -1,5 +1,6 @@ +import { Injectable } from "@angular/core"; export interface Environment { @@ -13,4 +14,18 @@ export interface Environment { ssoSignUp: string, ssoSignOut: string, tokenStoredInPermanentStorage: boolean, +}; + +@Injectable() +export class EnvironmentService { + public production: boolean; + // URL of development API + public applName: string; + public defaultServer: string; + public server: any; + public ssoSite: string; + public ssoSignIn: string; + public ssoSignUp: string; + public ssoSignOut: string; + public tokenStoredInPermanentStorage: boolean; }; \ No newline at end of file diff --git a/src/model/index.ts b/src/model/index.ts index 13abdce..830ebb5 100644 --- a/src/model/index.ts +++ b/src/model/index.ts @@ -1,3 +1,4 @@ +import { Environment, EnvironmentService } from './environment'; import { isMenuItem, isMenuPosition, MenuItem, MenuPosition } from './menu-item'; -export { MenuPosition, isMenuPosition, MenuItem, isMenuItem }; +export { MenuPosition, isMenuPosition, MenuItem, isMenuItem, Environment, EnvironmentService }; diff --git a/src/popin/index.ts b/src/popin/index.ts index e03a6b6..4330a01 100644 --- a/src/popin/index.ts +++ b/src/popin/index.ts @@ -1,4 +1,4 @@ import { PopInDeleteConfirm } from './delete-confirm/delete-confirm'; -import { PopInUploadProgress } from './upload-progress/upload-progress'; +import { PopInUploadProgress, UploadProgress } from './upload-progress/upload-progress'; -export { PopInDeleteConfirm, PopInUploadProgress }; +export { PopInDeleteConfirm, PopInUploadProgress, UploadProgress }; diff --git a/src/public-api.ts__ b/src/public-api.ts__ deleted file mode 100644 index b3aa323..0000000 --- a/src/public-api.ts__ +++ /dev/null @@ -1,5 +0,0 @@ -/* - * Public API Surface of kar-cw - */ - -export * from '.'; diff --git a/src/service/cookies.ts b/src/service/cookies.ts index 075b126..3589860 100644 --- a/src/service/cookies.ts +++ b/src/service/cookies.ts @@ -6,9 +6,11 @@ import { Injectable } from '@angular/core'; -@Injectable() +@Injectable({ + providedIn: 'root', +}) export class CookiesService { - constructor() {} + constructor() { } set(cname: string, cvalue: string, exdays: number): void { if (this.get(cname) !== '') { diff --git a/src/service/http-wrapper_kjdhqslkjf.ts b/src/service/http-wrapper_kjdhqslkjf.ts index 18dc16b..eba910e 100644 --- a/src/service/http-wrapper_kjdhqslkjf.ts +++ b/src/service/http-wrapper_kjdhqslkjf.ts @@ -10,7 +10,7 @@ import { HttpClient, HttpHeaders, HttpEventType } from '@angular/common/http'; import { SessionService } from './session'; import { isArrayOfs, isBoolean, isNullOrUndefined, isNumber, isString } from '../utils'; -import { Environment } from '../model/environment'; +import { EnvironmentService } from '../model/environment'; export enum HTTPRequestModel { POST = 'POST', @@ -53,12 +53,14 @@ export interface ModelResponseHttp { /** * This service permit to add some data like token and authorization.. ir automatically get the token if needed and retake it if expired... */ -@Injectable() +@Injectable({ + providedIn: 'root', +}) export class HttpWrapperService { private displayReturn: boolean = false; constructor( // https://stackoverflow.com/questions/56883120/angular-service-provide-with-a-default-value - @Inject('ENVIRONMENT') private environment: Environment, + @Inject('ENVIRONMENT') private environment: EnvironmentService, private http: HttpClient, private session: SessionService) { } diff --git a/src/service/index.ts b/src/service/index.ts index afc4297..a7c6307 100644 --- a/src/service/index.ts +++ b/src/service/index.ts @@ -8,11 +8,13 @@ import { OnlyUsersGuard, OnlyUsersGuardHome, SessionService, + UserRoles222, } from './session'; import { SSOService } from './sso'; import { UserService } from './user'; export { + UserRoles222, CookiesService, StorageService, PopInService, diff --git a/src/service/local-storage.ts b/src/service/local-storage.ts index 5fe13d5..e40893b 100644 --- a/src/service/local-storage.ts +++ b/src/service/local-storage.ts @@ -5,14 +5,16 @@ */ import { Inject, Injectable } from '@angular/core'; -import { Environment } from '../model/environment'; +import { EnvironmentService } from '../model/environment'; -@Injectable() +@Injectable({ + providedIn: 'root', +}) export class StorageService { private baseLocalStorageName: string; constructor( - @Inject('ENVIRONMENT') environment: Environment, + @Inject('ENVIRONMENT') environment: EnvironmentService, ) { this.baseLocalStorageName = environment.applName + '_'; } diff --git a/src/service/notification.ts b/src/service/notification.ts index 96a6b75..dd76d57 100644 --- a/src/service/notification.ts +++ b/src/service/notification.ts @@ -6,7 +6,9 @@ import { Injectable } from '@angular/core'; -@Injectable() +@Injectable({ + providedIn: 'root', +}) export class NotificationService { constructor() { diff --git a/src/service/popin.ts b/src/service/popin.ts index 5585312..0b4e5d9 100644 --- a/src/service/popin.ts +++ b/src/service/popin.ts @@ -6,7 +6,9 @@ import { Injectable } from '@angular/core'; -@Injectable() +@Injectable({ + providedIn: 'root', +}) export class PopInService { private popinList: any[] = []; diff --git a/src/service/session.ts b/src/service/session.ts index adcb52d..33f3f3b 100644 --- a/src/service/session.ts +++ b/src/service/session.ts @@ -6,7 +6,7 @@ import { Injectable, Output, EventEmitter, Inject } from '@angular/core'; import { Router } from '@angular/router'; -import { Environment } from '../model/environment'; +import { EnvironmentService } from '../model/environment'; import { isNullOrUndefined } from '../utils'; export enum UserRoles222 { @@ -15,7 +15,9 @@ export enum UserRoles222 { guest = 'guest', } -@Injectable() +@Injectable({ + providedIn: 'root', +}) export class SessionService { private tokenJwt?: string; public userLogin?: string; @@ -24,8 +26,9 @@ export class SessionService { @Output() change: EventEmitter = new EventEmitter(); + private environment;//: EnvironmentService constructor( - @Inject('ENVIRONMENT') private environment: Environment, + //@Inject('ENVIRONMENT') private environment: EnvironmentService, ) { } /** @@ -123,7 +126,9 @@ export class SessionService { } } -@Injectable({ providedIn: 'root' }) +@Injectable({ + providedIn: 'root', +}) export class OnlyUsersGuard { constructor(private sessionService: SessionService, private router: Router) { } @@ -138,7 +143,9 @@ export class OnlyUsersGuard { } } -@Injectable({ providedIn: 'root' }) +@Injectable({ + providedIn: 'root', +}) export class OnlyUsersGuardHome { constructor(private sessionService: SessionService, private router: Router) { } @@ -151,7 +158,9 @@ export class OnlyUsersGuardHome { } } } -@Injectable({ providedIn: 'root' }) +@Injectable({ + providedIn: 'root', +}) export class OnlyUnregisteredGuardHome { constructor(private sessionService: SessionService, private router: Router) { } @@ -164,8 +173,9 @@ export class OnlyUnregisteredGuardHome { } } } - -@Injectable({ providedIn: 'root' }) +@Injectable({ + providedIn: 'root', +}) export class OnlyAdminGuard { constructor(private sessionService: SessionService, private router: Router) { } diff --git a/src/service/sso.ts b/src/service/sso.ts index b34f53c..8026f33 100644 --- a/src/service/sso.ts +++ b/src/service/sso.ts @@ -5,16 +5,18 @@ */ import { Inject, Injectable } from '@angular/core'; -import { Environment } from '../model/environment'; +import { EnvironmentService } from '../model/environment'; import { getApplicationLocation, isInArray, isNullOrUndefined } from '../utils'; import { HttpWrapperService, HTTPRequestModel, HTTPMimeType, ModelResponseHttp } from './http-wrapper_kjdhqslkjf'; -@Injectable() +@Injectable({ + providedIn: 'root', +}) export class SSOService { signUpEnable?: boolean; constructor( - @Inject('ENVIRONMENT') private environment: Environment, + @Inject('ENVIRONMENT') private environment: EnvironmentService, private http: HttpWrapperService, ) { console.log('Start SSOService'); diff --git a/src/service/user.ts b/src/service/user.ts index 611c71c..f2afda4 100644 --- a/src/service/user.ts +++ b/src/service/user.ts @@ -12,7 +12,7 @@ import { SessionService } from './session'; import { SSOService } from './sso'; import { getApplicationLocation, isNullOrUndefined, sha512 } from '../utils'; import { HttpWrapperService, HTTPRequestModel, HTTPMimeType, ModelResponseHttp } from './http-wrapper_kjdhqslkjf'; -import { Environment } from '../model/environment'; +import { EnvironmentService } from '../model/environment'; /* interface MessageLogIn { @@ -29,15 +29,16 @@ interface MessageAnswer_USER_CONNECT { avatar: string; } */ -@Injectable() +@Injectable({ + providedIn: 'root', +}) export class UserService { // 0: Not hide password; 1 hide password; private identificationVersion: number = 1; private cookiesRememberMe = 'remember-me'; private cookiesToken = 'token'; - constructor( - @Inject('ENVIRONMENT') private environment: Environment, + @Inject('ENVIRONMENT') private environment: EnvironmentService, private router: Router, private storageService: StorageService, private http: HttpWrapperService, @@ -48,7 +49,7 @@ export class UserService { } /** - * Disconnect the user from the current session ==> this remove the curreent Token + * Disconnect the user from the current session ==> this remove the current Token */ logOut(): void { this.removeSession();