[DEV] update version that is first full work

This commit is contained in:
Edouard DUPIN 2024-04-13 08:59:13 +02:00
parent da0e6ac9ea
commit 1950162a99
13 changed files with 1530 additions and 343 deletions

View File

@ -27,6 +27,10 @@ deploy the environment
cd dist/kar-cw cd dist/kar-cw
pnpm publish --no-git-checks pnpm publish --no-git-checks
``` ```
or
```bash
pnpm run deploy
```
Use development mode for the library: Use development mode for the library:
===================================== =====================================

View File

@ -1,12 +1,11 @@
{ {
"name": "@kangaroo-and-rabbit/kar-cw", "name": "@kangaroo-and-rabbit/kar-cw",
"version": "0.1.7", "version": "0.2.0",
"sideEffects": false, "sideEffects": false,
"scripts": { "scripts": {
"dev": "ng build kar-cw --watch --configuration development", "dev": "ng build kar-cw --watch --configuration development",
"build": "ng build kar-cw", "build": "ng build kar-cw --configuration production",
"deploy": "cd dist/kar-cw && pnpm publish --no-git-checks", "deploy": "cd dist/kar-cw && pnpm publish --no-git-checks",
"link": "cd dist/kar-cw && pnpm link # TODO this in sudo ...",
"test": "ng test", "test": "ng test",
"lint": "ng lint", "lint": "ng lint",
"style": "prettier --write .", "style": "prettier --write .",
@ -14,32 +13,33 @@
"install_dependency": "pnpm install" "install_dependency": "pnpm install"
}, },
"peerDependencies": { "peerDependencies": {
"@angular/common": "^17.3.0", "@angular/common": "^17.3.3",
"@angular/compiler": "^17.3.0", "@angular/compiler": "^17.3.3",
"@angular/core": "^17.3.0", "@angular/core": "^17.3.3",
"@angular/forms": "^17.3.0", "@angular/forms": "^17.3.3",
"@angular/platform-browser": "^17.3.0", "@angular/platform-browser": "^17.3.3",
"@angular/platform-browser-dynamic": "^17.3.0", "@angular/platform-browser-dynamic": "^17.3.3",
"@angular/router": "^17.3.0", "@angular/router": "^17.3.3",
"rxjs": "~7.8.0", "rxjs": "~7.8.0",
"zone.js": "~0.14.3" "zone.js": "~0.14.3"
}, },
"dependencies": { "dependencies": {
"tslib": "^2.3.0" "tslib": "^2.6.2"
}, },
"devDependencies": { "devDependencies": {
"@angular-devkit/build-angular": "^17.3.1", "@angular-devkit/build-angular": "^17.3.3",
"@angular/cli": "^17.3.1", "@angular/cli": "^17.3.3",
"@angular/compiler-cli": "^17.3.0", "@angular/compiler-cli": "^17.3.3",
"@types/jasmine": "~5.1.0", "@types/jasmine": "~5.1.4",
"jasmine-core": "~5.1.0", "jasmine-core": "~5.1.2",
"karma": "~6.4.0", "karma": "~6.4.3",
"karma-chrome-launcher": "~3.2.0", "karma-chrome-launcher": "~3.2.0",
"karma-coverage": "~2.2.0", "karma-coverage": "~2.2.1",
"karma-jasmine": "~5.1.0", "karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.1.0", "karma-jasmine-html-reporter": "~2.1.0",
"ng-packagr": "^17.3.0", "ng-packagr": "^17.3.3",
"typescript": "~5.4.2" "typescript": "~5.4.4",
"npm-check-updates": "^16.14.18"
}, },
"maintainers": [ "maintainers": [
{ {

File diff suppressed because it is too large Load Diff

View File

@ -29,8 +29,6 @@ import { ALL_GUARDS } from "./kar-cw.guard";
exports: [ exports: [
...ALL_COMPONENTS, ...ALL_COMPONENTS,
...ALL_SCENES, ...ALL_SCENES,
//...ALL_SERVICES,
//...ALL_GUARDS,
], ],
schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA], schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
}) })

View File

@ -6,9 +6,7 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
@Injectable({ @Injectable()
providedIn: 'root',
})
export class CookiesService { export class CookiesService {
constructor() { constructor() {
console.log("Start CookiesService"); console.log("Start CookiesService");

View File

@ -53,9 +53,7 @@ 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(

View File

@ -7,9 +7,7 @@
import { Inject, Injectable } from '@angular/core'; import { Inject, Injectable } from '@angular/core';
import { Environment } from '../model/environment'; import { Environment } from '../model/environment';
@Injectable({ @Injectable()
providedIn: 'root',
})
export class StorageService { export class StorageService {
private baseLocalStorageName: string; private baseLocalStorageName: string;

View File

@ -6,9 +6,7 @@
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,9 +6,7 @@
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

@ -15,21 +15,21 @@ 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;
public userId?: string; public userId?: string;
public applName?: string;
public right: any = {}; public right: any = {};
@Output() change: EventEmitter<boolean> = new EventEmitter(); @Output() change: EventEmitter<boolean> = new EventEmitter();
constructor( constructor(
@Inject('ENVIRONMENT') private environment: Environment, @Inject('ENVIRONMENT') environment: Environment,
) { ) {
console.log("Start SessionService"); console.log("Start SessionService");
this.applName = environment.applName;
} }
/** /**
@ -69,10 +69,10 @@ export class SessionService {
if (isNullOrUndefined(jsonModel.right)) { if (isNullOrUndefined(jsonModel.right)) {
return {}; return {};
} }
if (isNullOrUndefined(jsonModel.right[this.environment.applName])) { if (isNullOrUndefined(jsonModel.right[this.applName])) {
return {}; return {};
} }
return jsonModel.right[this.environment.applName]; return jsonModel.right[this.applName];
} }
/** /**
* @brief destroy the current session. * @brief destroy the current session.
@ -88,7 +88,7 @@ export class SessionService {
getToken(): string | undefined { getToken(): string | undefined {
return this.tokenJwt; return this.tokenJwt;
} }
islogged() { isLogged() {
return this.userId !== null; return this.userId !== null;
} }
hasRight(type: UserRoles222): boolean { hasRight(type: UserRoles222): boolean {
@ -127,66 +127,60 @@ export class SessionService {
} }
} }
@Injectable({ @Injectable()
providedIn: 'root',
})
export class OnlyUsersGuard { export class OnlyUsersGuard {
constructor(private sessionService: SessionService, private router: Router) { } constructor(private sessionService: SessionService, private router: Router) { }
canActivate() { canActivate() {
console.log(`OnlyUsersGuard : ${this.sessionService}`)
console.log('OnlyLoggedInUsers'); console.log('OnlyLoggedInUsers');
if (this.sessionService.hasRight(UserRoles222.user) || this.sessionService.hasRight(UserRoles222.admin)) { if (this.sessionService.hasRight(UserRoles222.user)
|| this.sessionService.hasRight(UserRoles222.admin)) {
return true; return true;
} else {
this.router.navigateByUrl('/forbidden');
return false;
} }
return true; this.router.navigateByUrl('/forbidden');
return false;
} }
} }
@Injectable({ @Injectable()
providedIn: 'root',
})
export class OnlyUsersGuardHome { export class OnlyUsersGuardHome {
constructor(private sessionService: SessionService, private router: Router) { } constructor(private sessionService: SessionService, private router: Router) { }
canActivate() { canActivate() {
if (this.sessionService.hasRight(UserRoles222.user) || this.sessionService.hasRight(UserRoles222.admin)) { if (!this.sessionService.isLogged()) {
return true;
} else {
this.router.navigateByUrl('/unregistered'); this.router.navigateByUrl('/unregistered');
return false; return false;
} }
return true; if (this.sessionService.hasRight(UserRoles222.user)
|| this.sessionService.hasRight(UserRoles222.admin)) {
return true;
}
this.router.navigateByUrl('/forbidden');
return false;
} }
} }
@Injectable({
providedIn: 'root', @Injectable()
})
export class OnlyUnregisteredGuardHome { export class OnlyUnregisteredGuardHome {
constructor(private sessionService: SessionService, private router: Router) { } constructor(private sessionService: SessionService, private router: Router) { }
canActivate() { canActivate() {
if (!this.sessionService.islogged()) { if (this.sessionService.isLogged()) {
return true;
} else {
this.router.navigateByUrl('/home'); this.router.navigateByUrl('/home');
return false; return false;
} }
return true; return true;
} }
} }
@Injectable({
providedIn: 'root',
}) @Injectable()
export class OnlyAdminGuard { export class OnlyAdminGuard {
constructor(private sessionService: SessionService, private router: Router) { } constructor(private sessionService: SessionService, private router: Router) { }
canActivate() { canActivate() {
if (this.sessionService.hasRight(UserRoles222.user)) { if (!this.sessionService.hasRight(UserRoles222.user)) {
return true;
} else {
this.router.navigateByUrl('/forbidden'); this.router.navigateByUrl('/forbidden');
return false; return false;
} }

View File

@ -9,9 +9,7 @@ import { Environment } 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;

View File

@ -15,9 +15,7 @@ import { HttpWrapperService, HTTPRequestModel, HTTPMimeType, ModelResponseHttp }
import { Environment } from '../model/environment'; import { Environment } from '../model/environment';
@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;

View File

@ -1,4 +1,5 @@
import { getApplicationLocation } from './applPath'; import { getApplicationLocation } from './applPath';
import { arrayUnique } from './arrayTools';
import { DataStore } from './data-store'; import { DataStore } from './data-store';
import { DataTools, TypeCheck } from './data-tools'; import { DataTools, TypeCheck } from './data-tools';
import { sha512 } from './sha512'; import { sha512 } from './sha512';
@ -50,4 +51,5 @@ export {
isStringNullOrUndefined, isStringNullOrUndefined,
isUndefined, isUndefined,
sha512, sha512,
arrayUnique,
}; };