[DEV] start to work

This commit is contained in:
Edouard DUPIN 2024-04-05 23:50:47 +02:00
parent 475035388f
commit 948816b0f7
20 changed files with 80 additions and 49 deletions

View File

@ -2,6 +2,6 @@
"$schema": "./node_modules/ng-packagr/ng-package.schema.json", "$schema": "./node_modules/ng-packagr/ng-package.schema.json",
"dest": "./dist/kar-cw", "dest": "./dist/kar-cw",
"lib": { "lib": {
"entryFile": "src/**/index.ts" "entryFile": "src/index.ts"
} }
} }

View File

@ -11,7 +11,7 @@ import { PopInComponent } from './popin/popin';
import { RenderFormComponent } from './render-settings/render-form'; import { RenderFormComponent } from './render-settings/render-form';
import { RenderSettingsComponent } from './render-settings/render-settings'; import { RenderSettingsComponent } from './render-settings/render-settings';
import { SpinnerComponent } from './spinner/spinner'; 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'; 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 };

View File

@ -0,0 +1,2 @@
export * from '.'

View File

@ -1,4 +1,3 @@
import { KarCWModule } from './kar-cw.module';
export * from './kar-cw.service'; export * from './kar-cw.service';
export * from './kar-cw.module'; export * from './kar-cw.module';
@ -11,5 +10,3 @@ export * from './scene';
export * from './popin'; export * from './popin';
export * from './model'; export * from './model';
export * from './component'; export * from './component';
export default KarCWModule;

View File

@ -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 { PopInComponent, TopMenuComponent, UploadFileComponent, ErrorComponent, PasswordEntryComponent, EntryComponent, EntryValidatorComponent, SpinnerComponent, AsyncActionStatusComponent, ErrorMessageStateComponent, CheckboxComponent, BurgerPropertyComponent, RenderSettingsComponent, RenderFormComponent, EntryNumberComponent } from './component';
import { PopInUploadProgress, PopInDeleteConfirm } from './popin'; import { PopInUploadProgress, PopInDeleteConfirm } from './popin';

View File

@ -11,9 +11,6 @@ import { ALL_COMPONENTS } from "./kar-cw.component";
import { ALL_SCENES } from "./kar-cw.scene"; import { ALL_SCENES } from "./kar-cw.scene";
import { ALL_SERVICES } from "./kar-cw.service"; import { ALL_SERVICES } from "./kar-cw.service";
import { ALL_GUARDS } from "./kar-cw.guard"; import { ALL_GUARDS } from "./kar-cw.guard";
import { DataStore, DataTools } from "./utils";
@NgModule({ @NgModule({
declarations: [ declarations: [
@ -21,13 +18,13 @@ import { DataStore, DataTools } from "./utils";
...ALL_SCENES, ...ALL_SCENES,
], ],
imports: [ imports: [
CommonModule,
FormsModule, FormsModule,
ReactiveFormsModule, ReactiveFormsModule,
CommonModule,
], ],
providers: [ providers: [
...ALL_SERVICES, //...ALL_SERVICES,
...ALL_GUARDS, //...ALL_GUARDS,
], ],
exports: [ exports: [
...ALL_COMPONENTS, ...ALL_COMPONENTS,
@ -35,6 +32,6 @@ import { DataStore, DataTools } from "./utils";
//...ALL_SERVICES, //...ALL_SERVICES,
//...ALL_GUARDS, //...ALL_GUARDS,
], ],
schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA], //schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
}) })
export class KarCWModule { } export class KarCWModule { }

View File

@ -14,7 +14,7 @@ export const ALL_SERVICES = [
StorageService, StorageService,
PopInService, PopInService,
SessionService, SessionService,
UserService,
SSOService, SSOService,
UserService,
NotificationService, NotificationService,
]; ];

View File

@ -1,5 +1,6 @@
import { Injectable } from "@angular/core";
export interface Environment { export interface Environment {
@ -13,4 +14,18 @@ export interface Environment {
ssoSignUp: string, ssoSignUp: string,
ssoSignOut: string, ssoSignOut: string,
tokenStoredInPermanentStorage: boolean, 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;
}; };

View File

@ -1,3 +1,4 @@
import { Environment, EnvironmentService } from './environment';
import { isMenuItem, isMenuPosition, MenuItem, MenuPosition } from './menu-item'; import { isMenuItem, isMenuPosition, MenuItem, MenuPosition } from './menu-item';
export { MenuPosition, isMenuPosition, MenuItem, isMenuItem }; export { MenuPosition, isMenuPosition, MenuItem, isMenuItem, Environment, EnvironmentService };

View File

@ -1,4 +1,4 @@
import { PopInDeleteConfirm } from './delete-confirm/delete-confirm'; 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 };

View File

@ -1,5 +0,0 @@
/*
* Public API Surface of kar-cw
*/
export * from '.';

View File

@ -6,9 +6,11 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
@Injectable() @Injectable({
providedIn: 'root',
})
export class CookiesService { export class CookiesService {
constructor() {} constructor() { }
set(cname: string, cvalue: string, exdays: number): void { set(cname: string, cvalue: string, exdays: number): void {
if (this.get(cname) !== '') { if (this.get(cname) !== '') {

View File

@ -10,7 +10,7 @@ import { HttpClient, HttpHeaders, HttpEventType } from '@angular/common/http';
import { SessionService } from './session'; import { SessionService } from './session';
import { isArrayOfs, isBoolean, isNullOrUndefined, isNumber, isString } from '../utils'; import { isArrayOfs, isBoolean, isNullOrUndefined, isNumber, isString } from '../utils';
import { Environment } from '../model/environment'; import { EnvironmentService } from '../model/environment';
export enum HTTPRequestModel { export enum HTTPRequestModel {
POST = 'POST', 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... * 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 { export class HttpWrapperService {
private displayReturn: boolean = false; private displayReturn: boolean = false;
constructor( constructor(
// https://stackoverflow.com/questions/56883120/angular-service-provide-with-a-default-value // 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 http: HttpClient,
private session: SessionService) { } private session: SessionService) { }

View File

@ -8,11 +8,13 @@ import {
OnlyUsersGuard, OnlyUsersGuard,
OnlyUsersGuardHome, OnlyUsersGuardHome,
SessionService, SessionService,
UserRoles222,
} from './session'; } from './session';
import { SSOService } from './sso'; import { SSOService } from './sso';
import { UserService } from './user'; import { UserService } from './user';
export { export {
UserRoles222,
CookiesService, CookiesService,
StorageService, StorageService,
PopInService, PopInService,

View File

@ -5,14 +5,16 @@
*/ */
import { Inject, Injectable } from '@angular/core'; import { Inject, Injectable } from '@angular/core';
import { Environment } from '../model/environment'; import { EnvironmentService } from '../model/environment';
@Injectable() @Injectable({
providedIn: 'root',
})
export class StorageService { export class StorageService {
private baseLocalStorageName: string; private baseLocalStorageName: string;
constructor( constructor(
@Inject('ENVIRONMENT') environment: Environment, @Inject('ENVIRONMENT') environment: EnvironmentService,
) { ) {
this.baseLocalStorageName = environment.applName + '_'; this.baseLocalStorageName = environment.applName + '_';
} }

View File

@ -6,7 +6,9 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
@Injectable() @Injectable({
providedIn: 'root',
})
export class NotificationService { export class NotificationService {
constructor() { constructor() {

View File

@ -6,7 +6,9 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
@Injectable() @Injectable({
providedIn: 'root',
})
export class PopInService { export class PopInService {
private popinList: any[] = []; private popinList: any[] = [];

View File

@ -6,7 +6,7 @@
import { Injectable, Output, EventEmitter, Inject } from '@angular/core'; import { Injectable, Output, EventEmitter, Inject } from '@angular/core';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { Environment } from '../model/environment'; import { EnvironmentService } from '../model/environment';
import { isNullOrUndefined } from '../utils'; import { isNullOrUndefined } from '../utils';
export enum UserRoles222 { export enum UserRoles222 {
@ -15,7 +15,9 @@ export enum UserRoles222 {
guest = 'guest', guest = 'guest',
} }
@Injectable() @Injectable({
providedIn: 'root',
})
export class SessionService { export class SessionService {
private tokenJwt?: string; private tokenJwt?: string;
public userLogin?: string; public userLogin?: string;
@ -24,8 +26,9 @@ export class SessionService {
@Output() change: EventEmitter<boolean> = new EventEmitter(); @Output() change: EventEmitter<boolean> = new EventEmitter();
private environment;//: EnvironmentService
constructor( 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 { export class OnlyUsersGuard {
constructor(private sessionService: SessionService, private router: Router) { } constructor(private sessionService: SessionService, private router: Router) { }
@ -138,7 +143,9 @@ export class OnlyUsersGuard {
} }
} }
@Injectable({ providedIn: 'root' }) @Injectable({
providedIn: 'root',
})
export class OnlyUsersGuardHome { export class OnlyUsersGuardHome {
constructor(private sessionService: SessionService, private router: Router) { } constructor(private sessionService: SessionService, private router: Router) { }
@ -151,7 +158,9 @@ export class OnlyUsersGuardHome {
} }
} }
} }
@Injectable({ providedIn: 'root' }) @Injectable({
providedIn: 'root',
})
export class OnlyUnregisteredGuardHome { export class OnlyUnregisteredGuardHome {
constructor(private sessionService: SessionService, private router: Router) { } constructor(private sessionService: SessionService, private router: Router) { }
@ -164,8 +173,9 @@ export class OnlyUnregisteredGuardHome {
} }
} }
} }
@Injectable({
@Injectable({ providedIn: 'root' }) providedIn: 'root',
})
export class OnlyAdminGuard { export class OnlyAdminGuard {
constructor(private sessionService: SessionService, private router: Router) { } constructor(private sessionService: SessionService, private router: Router) { }

View File

@ -5,16 +5,18 @@
*/ */
import { Inject, Injectable } from '@angular/core'; import { Inject, Injectable } from '@angular/core';
import { Environment } from '../model/environment'; import { EnvironmentService } from '../model/environment';
import { getApplicationLocation, isInArray, isNullOrUndefined } from '../utils'; import { getApplicationLocation, isInArray, isNullOrUndefined } from '../utils';
import { HttpWrapperService, HTTPRequestModel, HTTPMimeType, ModelResponseHttp } from './http-wrapper_kjdhqslkjf'; import { HttpWrapperService, HTTPRequestModel, HTTPMimeType, ModelResponseHttp } from './http-wrapper_kjdhqslkjf';
@Injectable() @Injectable({
providedIn: 'root',
})
export class SSOService { export class SSOService {
signUpEnable?: boolean; signUpEnable?: boolean;
constructor( constructor(
@Inject('ENVIRONMENT') private environment: Environment, @Inject('ENVIRONMENT') private environment: EnvironmentService,
private http: HttpWrapperService, private http: HttpWrapperService,
) { ) {
console.log('Start SSOService'); console.log('Start SSOService');

View File

@ -12,7 +12,7 @@ import { SessionService } from './session';
import { SSOService } from './sso'; import { SSOService } from './sso';
import { getApplicationLocation, isNullOrUndefined, sha512 } from '../utils'; import { getApplicationLocation, isNullOrUndefined, sha512 } from '../utils';
import { HttpWrapperService, HTTPRequestModel, HTTPMimeType, ModelResponseHttp } from './http-wrapper_kjdhqslkjf'; import { HttpWrapperService, HTTPRequestModel, HTTPMimeType, ModelResponseHttp } from './http-wrapper_kjdhqslkjf';
import { Environment } from '../model/environment'; import { EnvironmentService } from '../model/environment';
/* /*
interface MessageLogIn { interface MessageLogIn {
@ -29,15 +29,16 @@ interface MessageAnswer_USER_CONNECT {
avatar: string; avatar: string;
} }
*/ */
@Injectable() @Injectable({
providedIn: 'root',
})
export class UserService { export class UserService {
// 0: Not hide password; 1 hide password; // 0: Not hide password; 1 hide password;
private identificationVersion: number = 1; private identificationVersion: number = 1;
private cookiesRememberMe = 'remember-me'; private cookiesRememberMe = 'remember-me';
private cookiesToken = 'token'; private cookiesToken = 'token';
constructor( constructor(
@Inject('ENVIRONMENT') private environment: Environment, @Inject('ENVIRONMENT') private environment: EnvironmentService,
private router: Router, private router: Router,
private storageService: StorageService, private storageService: StorageService,
private http: HttpWrapperService, 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 { logOut(): void {
this.removeSession(); this.removeSession();