sgc-share-lib
Version:
Share the basics Models for create custom SGC UI Components. This library implements the basic data structure used to describe SGC graphics components.
1,628 lines • 71.4 kB
JavaScript
import * as i0 from '@angular/core';
import { Injectable, Inject, Component, EventEmitter, Output, Input } from '@angular/core';
import * as i2 from '@angular/material/dialog';
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
import * as i1 from '@angular/material/snack-bar';
import { HttpHeaders, HttpParams } from '@angular/common/http';
import { Subject, of, map, BehaviorSubject } from 'rxjs';
class NotificationService {
constructor(snackBar, dialog) {
this.snackBar = snackBar;
this.dialog = dialog;
}
/**
* Presents a toast displaying the message with a green background
* @param message Message to display
* @example
* this.notificationService.success("confirm oked");
*/
success(message) {
this.openSnackBar(message, '', 'success-snackbar');
}
/**
* Presents a toast displaying the message with a red background
* @param message Message to display
* @example
* this.notificationService.error("confirm canceled");
*/
error(message) {
this.openSnackBar(message, '', 'error-snackbar');
}
/**
* Shows a confirmation modal, presenting the user with
* an OK and Cancel button.
* @param message Body of the modal
* @param okCallback Optional function to call when the user clicks Ok
* @param title Optional modal title
* @param cancelCallback Option function to call when the user clicks Cancel
* @example
* //displays a success or error message depending on what button is clicked.
* this.notificationService.confirmation(
* 'it will be gone forever', //message body
* () => { //okCallback
this.notificationService.success("confirm oked");
},
'Are you sure?', //title
() => { //cancelCallback
this.notificationService.error("confirm canceled");
});
*/
confirmation(message, title = 'Are you sure?', okCallback, cancelCallback = () => { }) {
const dialogRef = this.dialog.open(ConfirmationDialog, {
width: '250px',
data: { message: message, title: title }
});
dialogRef.afterClosed().subscribe(result => {
if (result && okCallback) {
okCallback();
}
if (!result && cancelCallback) {
cancelCallback();
}
});
}
/**
* Shows a modal, presenting the user with an OK button.
* @param message Body of the modal
* @param okCallback Optional function to call when the user clicks Ok
* @param title Optional modal title
* @example
* //displays a success when the Ok button is clicked.
* this.notificationService.alert("an alert", "notice", () => {
this.notificationService.success("alert oked");
});
*/
alert(message, title = 'Notice', okCallback = () => { }) {
const dialogRef = this.dialog.open(AlertDialog, {
width: '250px',
data: { message: message, title: title },
disableClose: true
});
dialogRef.afterClosed().subscribe(result => {
if (result && okCallback) {
okCallback();
}
});
}
/**
* Displays a toast with provided message
* @param message Message to display
* @param action Action text, e.g. Close, Done, etc
* @param className Optional extra css class to apply
* @param duration Optional number of SECONDS to display the notification for
*/
openSnackBar(message, action, className = '', duration = 2000) {
this.snackBar.open(message, action, {
horizontalPosition: 'center',
verticalPosition: 'top',
duration: duration,
panelClass: [className]
});
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: NotificationService, deps: [{ token: i1.MatSnackBar }, { token: i2.MatDialog }], target: i0.ɵɵFactoryTarget.Injectable }); }
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: NotificationService, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: NotificationService, decorators: [{
type: Injectable,
args: [{
providedIn: 'root'
}]
}], ctorParameters: () => [{ type: i1.MatSnackBar }, { type: i2.MatDialog }] });
class ConfirmationDialog {
constructor(dialogRef, data) {
this.dialogRef = dialogRef;
this.data = data;
}
onNoClick() {
this.dialogRef.close(false);
}
onYesClick() {
this.dialogRef.close(true);
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: ConfirmationDialog, deps: [{ token: i2.MatDialogRef }, { token: MAT_DIALOG_DATA }], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.14", type: ConfirmationDialog, isStandalone: false, selector: "ng-component", ngImport: i0, template: `
<h1 mat-dialog-title>{{ data.title }}</h1>
<div mat-dialog-content>
{{data.message}}
</div>
<div mat-dialog-actions>
<button mat-raised-button color="warn" (click)="onNoClick()">
Cancel
</button>
<button mat-raised-button color="primary" (click)="onYesClick()" cdkFocusInitial>
Ok
</button>
</div>
`, isInline: true }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: ConfirmationDialog, decorators: [{
type: Component,
args: [{
template: `
<h1 mat-dialog-title>{{ data.title }}</h1>
<div mat-dialog-content>
{{data.message}}
</div>
<div mat-dialog-actions>
<button mat-raised-button color="warn" (click)="onNoClick()">
Cancel
</button>
<button mat-raised-button color="primary" (click)="onYesClick()" cdkFocusInitial>
Ok
</button>
</div>
`,
standalone: false
}]
}], ctorParameters: () => [{ type: i2.MatDialogRef }, { type: undefined, decorators: [{
type: Inject,
args: [MAT_DIALOG_DATA]
}] }] });
class AlertDialog {
constructor(dialogRef, data) {
this.dialogRef = dialogRef;
this.data = data;
}
onYesClick() {
this.dialogRef.close(true);
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: AlertDialog, deps: [{ token: i2.MatDialogRef }, { token: MAT_DIALOG_DATA }], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.14", type: AlertDialog, isStandalone: false, selector: "ng-component", ngImport: i0, template: `
<h1 mat-dialog-title>{{ data.title }}</h1>
<div mat-dialog-content>
{{data.message}}
</div>
<div mat-dialog-actions>
<button mat-raised-button color="primary" (click)="onYesClick()" cdkFocusInitial>
Ok
</button>
</div>
`, isInline: true }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: AlertDialog, decorators: [{
type: Component,
args: [{
template: `
<h1 mat-dialog-title>{{ data.title }}</h1>
<div mat-dialog-content>
{{data.message}}
</div>
<div mat-dialog-actions>
<button mat-raised-button color="primary" (click)="onYesClick()" cdkFocusInitial>
Ok
</button>
</div>
`,
standalone: false
}]
}], ctorParameters: () => [{ type: i2.MatDialogRef }, { type: undefined, decorators: [{
type: Inject,
args: [MAT_DIALOG_DATA]
}] }] });
//import { CustomMenuItem } from '../models/menu-item.model';
/**
* menu data service
*/
class FiltreRechercheService {
//public crudFiltreRecherche_Utilisateur: CrudFiltreRecherche = new CrudFiltreRecherche();
constructor() {
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: FiltreRechercheService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: FiltreRechercheService, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: FiltreRechercheService, decorators: [{
type: Injectable,
args: [{
providedIn: 'root',
}]
}], ctorParameters: () => [] });
class SgcBiblio {
}
function padTo2Digits(num) {
return String(num).padStart(2, '0');
}
/**
* Get client side timezone.
*
* @returns {(+|-)HH:mm} - Where `HH` is 2 digits hours and `mm` 2 digits minutes.
* @example
* // From Indian/Reunion with UTC+4
* // '+04:00'
* getTimeZone()
*/
const getTimeZone = () => {
const timezoneOffset = new Date().getTimezoneOffset();
const offset = Math.abs(timezoneOffset);
const offsetOperator = timezoneOffset < 0 ? '+' : '-';
const offsetHours = padTo2Digits(Math.floor(offset / 60));
const offsetMinutes = padTo2Digits(Math.floor(offset % 60));
return `${offsetOperator}${offsetHours}:${offsetMinutes}`;
};
//********************************************************** */
//---------- DATA MODELS FOR BASICS SGC UI ------------------
/**
*
*/
var TypeCrudView;
(function (TypeCrudView) {
TypeCrudView[TypeCrudView["LIST"] = 0] = "LIST";
TypeCrudView[TypeCrudView["CREATE"] = 1] = "CREATE";
TypeCrudView[TypeCrudView["EDIT"] = 2] = "EDIT";
TypeCrudView[TypeCrudView["IMPORT"] = 3] = "IMPORT";
TypeCrudView[TypeCrudView["REPORT"] = 4] = "REPORT";
TypeCrudView[TypeCrudView["STATS"] = 5] = "STATS";
})(TypeCrudView || (TypeCrudView = {}));
//----------------------------------
var TypeFieldFormEdit;
(function (TypeFieldFormEdit) {
TypeFieldFormEdit["TEXTE"] = "TEXT";
TypeFieldFormEdit["TEXTE_MULTILIGNE"] = "TEXT_MULTILINE";
TypeFieldFormEdit["TEXTE_SECRET"] = "TEXT_SECRET";
TypeFieldFormEdit["NOMBRE"] = "NUMERIC";
TypeFieldFormEdit["DATE"] = "DATE";
TypeFieldFormEdit["DATE_HEURE"] = "DATE_HEURE";
TypeFieldFormEdit["HEURE"] = "HEURE";
TypeFieldFormEdit["BOOLEEN"] = "BOOLEAN";
TypeFieldFormEdit["SELECT_VALUE"] = "SELECT_VALUE";
TypeFieldFormEdit["LISTE_OBJECT"] = "LIST_OBJECT";
TypeFieldFormEdit["FILE"] = "FILE";
})(TypeFieldFormEdit || (TypeFieldFormEdit = {}));
//----------------------------------
var TExportFormat;
(function (TExportFormat) {
TExportFormat["PDF"] = "pdf";
TExportFormat["EXCEL"] = "xlsx";
TExportFormat["CSV"] = "csv";
})(TExportFormat || (TExportFormat = {}));
function getListeTypeExportFormat() {
return Object.keys(TExportFormat).map(myKey => ({ label: myKey, value: TExportFormat[myKey] }));
}
//----------------------------------
var TExportPageOrientation;
(function (TExportPageOrientation) {
TExportPageOrientation["PORTRAIT"] = "0";
TExportPageOrientation["LANDSCAPE"] = "1";
})(TExportPageOrientation || (TExportPageOrientation = {}));
function getListeTypeExportOrientation() {
return Object.keys(TExportPageOrientation).map(myKey => ({ label: myKey, value: TExportPageOrientation[myKey] }));
}
//----------------------------------
var TExportHeaderDataValueFrom;
(function (TExportHeaderDataValueFrom) {
TExportHeaderDataValueFrom["FIELD_NAME"] = "name";
TExportHeaderDataValueFrom["FIELD_LABEL"] = "label";
})(TExportHeaderDataValueFrom || (TExportHeaderDataValueFrom = {}));
function getListeTypeExportHeaderDataValueFrom() {
return Object.keys(TExportHeaderDataValueFrom).map(myKey => ({ label: myKey, value: TExportHeaderDataValueFrom[myKey] }));
}
//----------------------------------
var TImportFormat;
(function (TImportFormat) {
TImportFormat["EXCEL"] = "xlsx";
TImportFormat["EXCEL_OLD"] = "xls";
TImportFormat["CSV"] = "csv";
})(TImportFormat || (TImportFormat = {}));
function getListeTypeImportFormat() {
return Object.keys(TImportFormat).map(myKey => ({ label: myKey, value: TImportFormat[myKey] }));
}
var TypeFileImportExportNames;
(function (TypeFileImportExportNames) {
TypeFileImportExportNames["WORD"] = "application/msword";
TypeFileImportExportNames["WORD_OLD"] = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
TypeFileImportExportNames["EXCEL"] = "application/vnd.ms-excel";
TypeFileImportExportNames["EXCEL_OLD"] = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
TypeFileImportExportNames["CSV"] = "text/csv";
TypeFileImportExportNames["PDF"] = "application/pdf";
TypeFileImportExportNames["IMAGE_PNG"] = "image/png";
TypeFileImportExportNames["IMAGE_JPEG"] = "image/jpeg";
})(TypeFileImportExportNames || (TypeFileImportExportNames = {}));
function getListeTypeImportExportNames() {
return Object.keys(TypeFileImportExportNames).map(myKey => ({ label: myKey, value: TypeFileImportExportNames[myKey] }));
}
var TypeHidePasswordSymbol;
(function (TypeHidePasswordSymbol) {
TypeHidePasswordSymbol["ASTERISK"] = "*";
TypeHidePasswordSymbol["DOT"] = ".";
})(TypeHidePasswordSymbol || (TypeHidePasswordSymbol = {}));
const TFieldFormEditDefault = {
showLabel: false,
label: '',
required: false,
requiredMsg: 'Required value',
disabled: false,
//hasSelectValues: false,
selectMultivalue: false,
rowNumberInForm: 1,
indexInRow: 1,
widthInResponsiveGridWiew: 12,
typeFieldForm: TypeFieldFormEdit.TEXTE,
};
//-----------------------------------------------------
class BaseFieldFormEditUI {
constructor() {
this.dataChange = new EventEmitter();
this.isDisabled = () => {
if (this.data?.isDisabled) {
return this.data.isDisabled();
}
else if (this.data?.disabled) {
return this.data.disabled;
}
return false;
};
this.getLabel = () => {
let myLabel = '';
if (this.data.showLabel && this.data.label) {
myLabel = this.data.label;
}
//myLabel+= (this.data.required ? ' *' : '');
return myLabel;
};
this.isHide = () => {
return (this.data != undefined &&
this.data.isHide != undefined &&
this.data.isHide());
};
}
/*****************************************************/
useField_TEXT() {
return useField_TEXT(this.data);
}
useField_PASSWORD() {
return useField_PASSWORD(this.data);
}
useField_TEXTAREA() {
return useField_TEXTAREA(this.data);
}
useField_NUMBER() {
return useField_NUMBER(this.data);
}
useField_DATE() {
return useField_DATE(this.data);
}
useField_DATEHEURE() {
return useField_DATEHEURE(this.data);
}
useField_HEURE() {
return useField_HEURE(this.data);
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: BaseFieldFormEditUI, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.14", type: BaseFieldFormEditUI, isStandalone: false, selector: "sgc-ng-baseui", inputs: { data: "data" }, outputs: { dataChange: "dataChange" }, ngImport: i0, template: '', isInline: true }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: BaseFieldFormEditUI, decorators: [{
type: Component,
args: [{
selector: 'sgc-ng-baseui',
template: '',
standalone: false
}]
}], propDecorators: { data: [{
type: Input
}], dataChange: [{
type: Output
}] } });
//---------------------------------------------------------------------------------------
//------ STRUCTURE DE DONNÉES POUR LE GROUPE DE CHAMPS DES FORMULAIRES (TGROUPFORMEDIT)--
const Min_WidthFieldInResponsiveGridWiew = 10;
const Max_WidthFieldInResponsiveGridWiew = 100;
const DefaultRowGapBetweenFields = 10;
const DefaultRowHeight = 60;
class TGroupFieldFormEdit {
get listeFiedsForm() {
return this._listeFiedsForm;
}
constructor(myIdOrder, myLabel, myShowLabel, myShowBorder) {
this.showLabel = false;
this.showBorder = false;
this._listeFiedsForm = [];
//groupIDView?: string;
this.isHide = () => false;
this.idOrder = myIdOrder ? myIdOrder : this.idOrder;
this.label = myLabel ? myLabel : this.label;
this.showLabel = myShowLabel ? myShowLabel : this.showLabel;
this.showBorder = myShowBorder ? myShowBorder : this.showBorder;
}
addFieldsToGroup(listeFields) {
/*listeFields = listeFields.map((elt) => {
if (
elt.typeFieldForm == TypeFieldFormEdit.NOMBRE &&
elt.value == undefined
) {
elt.value = 0;
}
return {...elt};
});*/
this._listeFiedsForm = listeFields.map((elt) => ({ ...elt }));
}
}
//-------------------------------------------------------------------------------
//------ STRUCTURE DE DONNÉES POUR LE FORMULAIRE D'ÉDITION (TFORMEDIT)-----------
class TFormEdit {
get listeGroupeFields() {
return this._listeGroupeFields;
}
constructor() {
this._listeGroupeFields = [];
this._listeAllFieldsGroup = [];
}
addGridFieldsToGroup(group, grilleFields) {
if (group != undefined &&
grilleFields != undefined &&
grilleFields.listeRows != undefined) {
grilleFields.listeRows = grilleFields.listeRows.map((elt0) => {
return {
indexRow: elt0.indexRow,
listeFieldsRow: elt0.listeFieldsRow.map((elt) => {
if (elt.typeFieldForm == TypeFieldFormEdit.NOMBRE &&
elt.value == undefined) {
elt.value = 0;
}
return elt;
}),
};
});
//group.listeGrilleFiedsForm = grilleFields;
let listeRowsFields = grilleFields.listeRows.map((row) => {
return row.listeFieldsRow;
});
for (let i = 0; i < listeRowsFields.length; i++) {
this._listeAllFieldsGroup.push(...listeRowsFields[i]);
}
group.listeGrilleFiedsForm = group.listeGrilleFiedsForm
? [...group.listeGrilleFiedsForm, grilleFields]
: [grilleFields];
console.log('******* EDITCRUD - GROUP - LISTEGRID *************');
console.log(grilleFields);
console.log(group);
}
}
addGroupToForm(group) {
this._listeGroupeFields.push(group);
this._listeAllFieldsGroup.push(...group.listeFiedsForm);
}
getValueOfFieldForm(nameField) {
let myField = this._listeAllFieldsGroup.find((elt) => elt.name == nameField);
return myField?.value;
}
setBlobValueOfFieldForm(listeBlobFields, nameField) {
let myField = this._listeAllFieldsGroup.find((elt) => elt.name == nameField && elt.fileToUpload != undefined);
if (myField) {
let myExistBlobField = listeBlobFields.find(elt => elt.nameField == nameField);
if (myExistBlobField) {
myExistBlobField.optionsFile = myField.fileUploadDowloadOption;
myExistBlobField.file = myField.fileToUpload;
}
else {
listeBlobFields.push({ nameField: myField.name, optionsFile: myField.fileUploadDowloadOption, file: myField.fileToUpload });
}
}
}
setValueOfFieldForm(nameField, value) {
let myField = this._listeAllFieldsGroup.find((elt) => elt.name == nameField);
if (myField) {
myField.value = value;
}
}
}
//--------------------------------------------------------------------------
//---------------------------------------------------------------------
function typeDataIs_TEXTE(fieldform) {
return fieldform.typeFieldForm == TypeFieldFormEdit.TEXTE;
}
function typeDataIs_TEXTE_SECRET(fieldform) {
return fieldform.typeFieldForm == TypeFieldFormEdit.TEXTE_SECRET;
}
function typeDataIs_TEXTE_MULTILIGNE(fieldform) {
return fieldform.typeFieldForm == TypeFieldFormEdit.TEXTE_MULTILIGNE;
}
function typeDataIs_NOMBRE(fieldform) {
return fieldform.typeFieldForm == TypeFieldFormEdit.NOMBRE;
}
function typeDataIs_BOOLEEN(fieldform) {
return fieldform.typeFieldForm == TypeFieldFormEdit.BOOLEEN;
}
function typeDataIs_DATE(fieldform) {
return fieldform.typeFieldForm == TypeFieldFormEdit.DATE;
}
function typeDataIs_DATEHEURE(fieldform) {
return fieldform.typeFieldForm == TypeFieldFormEdit.DATE_HEURE;
}
function typeDataIs_HEURE(fieldform) {
return fieldform?.typeFieldForm == TypeFieldFormEdit.HEURE;
}
function typeDataIs_SELECTVALUE(fieldform) {
return fieldform?.typeFieldForm == TypeFieldFormEdit.SELECT_VALUE;
}
function typeDataIs_FILEINPUT(fieldform) {
return fieldform?.typeFieldForm == TypeFieldFormEdit.FILE;
}
function typeDataIs_LISTE_OBJECT(fieldform) {
return fieldform.typeFieldForm == TypeFieldFormEdit.LISTE_OBJECT;
}
//--------------------------------------------------------
function useField_TEXT(fieldform) {
return /*!fieldform.hasSelectValues && */ typeDataIs_TEXTE(fieldform);
}
function useField_PASSWORD(fieldform) {
return /*!fieldform.hasSelectValues &&*/ typeDataIs_TEXTE_SECRET(fieldform);
}
function useField_TEXTAREA(fieldform) {
return /*!fieldform.hasSelectValues &&*/ typeDataIs_TEXTE_MULTILIGNE(fieldform);
}
function useField_NUMBER(fieldform) {
return /*!fieldform.hasSelectValues &&*/ typeDataIs_NOMBRE(fieldform);
}
function useField_DATE(fieldform) {
if (typeDataIs_DATE(fieldform)) {
fieldform.showTime = false;
return true;
}
return false;
//return /*!fieldform.hasSelectValues && */ typeDataIs_DATE(fieldform);
}
function useField_DATEHEURE(fieldform) {
if (typeDataIs_DATEHEURE(fieldform)) {
fieldform.showTime = true;
return true;
}
return false;
//return /*!fieldform.hasSelectValues && */ typeDataIs_DATEHEURE(fieldform);
}
function useField_HEURE(fieldform) {
return /*!fieldform.hasSelectValues &&*/ typeDataIs_HEURE(fieldform);
}
function useField_SELECTVALUE(fieldform) {
return /*!fieldform.hasSelectValues &&*/ typeDataIs_SELECTVALUE(fieldform);
}
function useField_FILEINPUT(fieldform) {
return /*!fieldform.hasSelectValues &&*/ typeDataIs_FILEINPUT(fieldform);
}
//-----------------------------------------------------------------------------------
//--- STRUCTURES DES DONNÉES POUR GÉRER les CSS ---------------------
var FONTWEIGHT_CONSTANT;
(function (FONTWEIGHT_CONSTANT) {
FONTWEIGHT_CONSTANT[FONTWEIGHT_CONSTANT["FW_100"] = 100] = "FW_100";
FONTWEIGHT_CONSTANT[FONTWEIGHT_CONSTANT["FW_200"] = 200] = "FW_200";
FONTWEIGHT_CONSTANT[FONTWEIGHT_CONSTANT["FW_300"] = 300] = "FW_300";
FONTWEIGHT_CONSTANT[FONTWEIGHT_CONSTANT["FW_400_NORMAL"] = 400] = "FW_400_NORMAL";
FONTWEIGHT_CONSTANT[FONTWEIGHT_CONSTANT["FW_500"] = 500] = "FW_500";
FONTWEIGHT_CONSTANT[FONTWEIGHT_CONSTANT["FW_600"] = 600] = "FW_600";
FONTWEIGHT_CONSTANT[FONTWEIGHT_CONSTANT["FW_700_BOLD"] = 700] = "FW_700_BOLD";
FONTWEIGHT_CONSTANT[FONTWEIGHT_CONSTANT["FW_800"] = 800] = "FW_800";
FONTWEIGHT_CONSTANT[FONTWEIGHT_CONSTANT["FW_900"] = 900] = "FW_900";
})(FONTWEIGHT_CONSTANT || (FONTWEIGHT_CONSTANT = {}));
var H_ALIGN_CONSTANT;
(function (H_ALIGN_CONSTANT) {
H_ALIGN_CONSTANT["LEFT"] = "left";
H_ALIGN_CONSTANT["CENTER"] = "center";
H_ALIGN_CONSTANT["RIGHT"] = "right";
})(H_ALIGN_CONSTANT || (H_ALIGN_CONSTANT = {}));
var Enum_FilterMatchMode;
(function (Enum_FilterMatchMode) {
Enum_FilterMatchMode["EXACT"] = "EXACT";
Enum_FilterMatchMode["CONTAINS"] = "CONTAINS";
Enum_FilterMatchMode["STARTS_WITH"] = "START";
Enum_FilterMatchMode["ENDS_WITH"] = "END";
})(Enum_FilterMatchMode || (Enum_FilterMatchMode = {}));
var Enum_FilterOperator;
(function (Enum_FilterOperator) {
Enum_FilterOperator["EQUALS"] = "eq";
Enum_FilterOperator["CONTAINS"] = "contains";
Enum_FilterOperator["STARTS_WITH"] = "startWith";
Enum_FilterOperator["ENDS_WITH"] = "endWith";
Enum_FilterOperator["DATE_IS"] = "date_is";
Enum_FilterOperator["GREATER_THAN"] = "gt";
Enum_FilterOperator["GREATER_THAN_OR_EQUAL_TO"] = "gte";
Enum_FilterOperator["LESS_THAN"] = "lt";
Enum_FilterOperator["LESS_THAN_OR_EQUAL_TO"] = "lte";
Enum_FilterOperator["BETWEEN"] = "between";
Enum_FilterOperator["IN"] = "in";
Enum_FilterOperator["LIKE"] = "like";
})(Enum_FilterOperator || (Enum_FilterOperator = {}));
var TypeFieldDataView;
(function (TypeFieldDataView) {
TypeFieldDataView["TEXTE"] = "TEXT";
TypeFieldDataView["TEXTE_SECRET"] = "TEXT_SECRET";
TypeFieldDataView["NOMBRE"] = "NUMERIC";
TypeFieldDataView["DATE"] = "DATE";
TypeFieldDataView["DATE_HEURE"] = "DATE_HEURE";
TypeFieldDataView["HEURE"] = "HEURE";
TypeFieldDataView["BOOLEEN"] = "BOOLEAN";
TypeFieldDataView["FILE_IMAGE"] = "FILE_IMAGE";
TypeFieldDataView["FILE_DOC"] = "FILE_DOC";
TypeFieldDataView["FILE"] = "FILE";
})(TypeFieldDataView || (TypeFieldDataView = {}));
var TCss_ColumnDataTableTextAlign;
(function (TCss_ColumnDataTableTextAlign) {
TCss_ColumnDataTableTextAlign["LEFT"] = "left";
TCss_ColumnDataTableTextAlign["RIGHT"] = "right";
TCss_ColumnDataTableTextAlign["CENTER"] = "center";
TCss_ColumnDataTableTextAlign["JUSTIFY"] = "justify";
})(TCss_ColumnDataTableTextAlign || (TCss_ColumnDataTableTextAlign = {}));
function generateCritereTxtFromFiltres(listefiltres = []) {
console.log('*********** BIBLIO INIT CRITERES ****************');
console.log(listefiltres?.length);
let tabCriteresTxt = [];
if (listefiltres != undefined && listefiltres.length > 0) {
if (listefiltres.length == 1) {
//---- PROVISOIRE - POUR RESOUDRE LE PROBLEME POSE AU NIVEAU DE L'API PAR UNE LIGNE DE FILTRE
listefiltres.push(listefiltres[0]);
}
listefiltres.forEach((filtres, index) => {
console.log('*********** BIBLIO INIT CRITERES (listefiltres.foreach Index) ****************');
console.log(index);
let criteresTxt = '';
filtres.value.forEach((element) => {
if (element.active) {
if (element.value != undefined || !element.ignoreWhenNull) {
if (criteresTxt.length > 0) {
criteresTxt += ', ';
}
criteresTxt +=
'"' +
element.name +
'"' +
':"{' +
element.operator +
',' +
(element.value != undefined
? element.value
: element.defaultNullValue) +
'}"';
//criteresTxt += '"' + element.name + '"' + ':"' + (element.value != undefined ? element.value : element.defaultNullValue) + '"';
}
}
});
if (criteresTxt.trim().length > 0) {
criteresTxt = '{' + criteresTxt + '}';
tabCriteresTxt.push(criteresTxt);
}
});
}
console.log('*********** BIBLIO INIT CRITERES ****************');
console.log(tabCriteresTxt);
console.log(tabCriteresTxt.length);
return tabCriteresTxt;
}
function createBasicAuthToken(username, password) {
//return 'Basic ' + btoa(username + ":" + password);
//return 'Basic ' + btoa(username + ":" + password);
return 'Basic ' + window.btoa(username + ':' + password);
//return 'Basic ' + window.btoa(username + ":" + password);
}
function addOptionHeaderRequeteAPI_ContentType_JSON(myHttpOptionsApi) {
addOptionHeaderRequeteAPI(myHttpOptionsApi, 'Content-Type', 'application/json; charset=utf-8');
}
function addOptionHeaderRequeteAPI_ContentType_MULTIPART(myHttpOptionsApi) {
addOptionHeaderRequeteAPI(myHttpOptionsApi, 'Content-Type', 'multipart/form-data; boundary=----WebKitFormBoundarySGC46902');
/*addOptionHeaderRequeteAPI(
myHttpOptionsApi,
'mode',
'cors'
);*/
}
/*export function addOptionHeaderRequeteAPI_ContentType_BLOB(
myHttpOptionsApi: HttpOptionsRequeteAPI
): void {
addOptionHeaderRequeteAPI(
myHttpOptionsApi,
'Content-Type',
'blob'
);
}*/
function addOptionHeaderRequeteAPI_ResponseType_BLOB(myHttpOptionsApi) {
addOptionHeaderRequeteAPI(myHttpOptionsApi, 'ResponseType', 'blob');
}
function addOptionHeaderRequeteAPI_ACCEPT_JSON(myHttpOptionsApi) {
addOptionHeaderRequeteAPI(myHttpOptionsApi, 'Accept', 'application/json');
}
function addOptionHeaderRequeteAPI_JSON(myHttpOptionsApi) {
addOptionHeaderRequeteAPI_ACCEPT_JSON(myHttpOptionsApi);
addOptionHeaderRequeteAPI_ContentType_JSON(myHttpOptionsApi);
}
function generateNewMapOptionsFromHttpHeadersAndNewKeyValue(myHttpHeaders, myKeyHeader, myValueHeader) {
let newHttpHeaders = {};
//console.log('NEWHTTPHEADERS - BEFORE');
//console.log(newHttpHeaders);
myHttpHeaders.keys().forEach((key) => {
const value = myHttpHeaders.getAll(key);
//console.log(key + ' : ' + value);
if (value != null) {
newHttpHeaders[key] = value.length > 1 ? value : value[0];
//newHttpHeaders[key] = value.length < 1 ? value : value[0];
//console.log(newHttpHeaders);
}
});
//console.log('NEWHTTPHEADERS - AFTER');
//console.log(newHttpHeaders);
newHttpHeaders[myKeyHeader] = myValueHeader;
//console.log(newHttpHeaders);
return newHttpHeaders;
}
function addOptionHeaderRequeteAPI(myHttpOptionsApi, myKeyHeader, myValueHeader) {
if (myHttpOptionsApi.headers == undefined) {
myHttpOptionsApi.headers = new HttpHeaders();
}
if (myHttpOptionsApi.headers.has(myKeyHeader)) {
myHttpOptionsApi.headers.append(myKeyHeader, myValueHeader);
}
else {
//myHttpOptionsApi.headers.append(myKeyHeader, myKeyValue);
myHttpOptionsApi.headers = new HttpHeaders(generateNewMapOptionsFromHttpHeadersAndNewKeyValue(myHttpOptionsApi.headers, myKeyHeader, myValueHeader));
}
//console.log('****** BIBLIO -- ADDOPTIONHEADERREQUETEAPI **************');
//console.log(myHttpOptionsApi);
}
function addOptionHeaderRequeteAPI_Authorization(myHttpOptionsApi, username, password) {
addOptionHeaderRequeteAPI(myHttpOptionsApi, 'Authorization', createBasicAuthToken(username, password));
/* myHttpOptionsApi.headers = new HttpHeaders({
Authorization: createBasicAuthToken(username, password),
});*/
}
//----------------------------------------------------------
/************************/
function generateNewMapOptionsFromHttpParamsAndNewKeyValue(myHttpParams, myKeyParam, myValueParam) {
let newHttpParams = {};
//console.log('NEWHTTPPARAMS - BEFORE');
//console.log(newHttpParams);
myHttpParams.keys().forEach((key) => {
const value = myHttpParams.getAll(key);
//console.log(key + ' : ' + value);
if (value != null) {
newHttpParams[key] = value.length > 1 ? value : value[0];
//console.log(newHttpParams);
}
});
//console.log('NEWHTTPPARAMS - AFTER');
//console.log(newHttpParams);
newHttpParams[myKeyParam] = myValueParam;
//console.log(newHttpParams);
return newHttpParams;
}
/** */
function addOptionParamRequeteAPI(myHttpOptionsApi, myKeyParam, myKeyValue) {
if (myHttpOptionsApi.params == undefined) {
myHttpOptionsApi.params = new HttpParams();
}
if (myHttpOptionsApi.params.has(myKeyParam)) {
myHttpOptionsApi.params = myHttpOptionsApi.params.append(myKeyParam, myKeyValue);
//console.log('PARAM EXIST');
//console.log(myHttpOptionsApi.params);
}
else {
myHttpOptionsApi.params = new HttpParams({
fromObject: generateNewMapOptionsFromHttpParamsAndNewKeyValue(myHttpOptionsApi.params, myKeyParam, myKeyValue),
});
//myHttpOptionsApi.params = myHttpOptionsApi.params.append('test', 'value');
//console.log('DOES NOT');
//console.log(myHttpOptionsApi.params);
}
}
//****************************************** */
function isColTypeDate(col) {
return (col != null &&
col != undefined &&
col.typeData == TypeFieldDataView.DATE);
}
function isColTypeDateHeure(col) {
return (col != null &&
col != undefined &&
col.typeData == TypeFieldDataView.DATE_HEURE);
}
function isColTypeBooleen(col) {
return (col != null && col != undefined && col.typeData == TypeFieldDataView.BOOLEEN);
}
function isColTypeNombre(col) {
return (col != null && col != undefined && col.typeData == TypeFieldDataView.NOMBRE);
}
function isColTypeTexte(col) {
return (col != null &&
col != undefined &&
(col.typeData == null ||
col.typeData == undefined ||
col.typeData == TypeFieldDataView.TEXTE));
}
//*********************** STRUCTURES DE DONNEES ET FONCTIONS POUR STATISTIQUES ************************************ */
//**************** PARAMETRES POUR LES STATISTIQUES *************************************** */
const defaultMaxYAxesChart = 10;
var TypeChartStats;
(function (TypeChartStats) {
TypeChartStats["BAR"] = "bar";
TypeChartStats["PIE"] = "pie";
TypeChartStats["DOUGHNUT"] = "doughnut";
})(TypeChartStats || (TypeChartStats = {}));
var ListePositionAffichage;
(function (ListePositionAffichage) {
ListePositionAffichage["BOTTOM"] = "bottom";
ListePositionAffichage["TOP"] = "top";
ListePositionAffichage["RIGHT"] = "right";
ListePositionAffichage["LEFT"] = "left";
})(ListePositionAffichage || (ListePositionAffichage = {}));
//------------------------------------------------------------
//---------------------------------------------------------------
//******************************** */
class CrudFiltreRecherche {
constructor() {
this.criteresFiltresAsTxt = [];
this.filtresModalitesAsTxt = [];
this.reloadOnFiltreChange = new Subject();
}
// on Filtre change
emitSubjectChange() {
console.log('******** BIBLIO : EMITSUBJECTCHANGE ************');
console.log(this.criteresFiltresAsTxt);
this.reloadOnFiltreChange.next(this.criteresFiltresAsTxt);
}
validateChangeFiltre(filtres) {
this.initCritereTxtFromFiltres(filtres);
this.emitSubjectChange();
}
validateChangeStatsFiltre(modalites, filtres) {
this.initCritereTxtFromFiltres(filtres);
//this.initFiltresModalitesAsTxtFromFiltres(modalites);
this.emitSubjectChange();
}
initCritereTxtFromFiltres(listefiltres) {
this.criteresFiltresAsTxt = generateCritereTxtFromFiltres(listefiltres);
}
getCriteresFiltresAsTxt() {
return this.criteresFiltresAsTxt;
}
getFiltresModalitesAsTxt() {
return this.filtresModalitesAsTxt;
}
}
//---------------------------------------------
/*** DEFAULT FILE DATA SERVICE ** */
class FileDataService {
//******************************
//zoomLocationCec: ZoomLocationData;
constructor(myHttpClient, myApiSettings) {
this.optionRequeteAPI = {
headers: new HttpHeaders(),
params: new HttpParams(),
};
//this.nbRowsDatatablePage = this.crudSettings.nbRowsDatatablePage? this.crudSettings.nbRowsDatatablePage : 15;
this.httpClient = myHttpClient;
this.default_apiSettings = {
api_viewName: '',
apiUrl_fileUpload: 'fileupload',
apiUrl_fileDownload: 'filedownload',
baseUrlApi: '',
api_authorization_username: 'admin',
api_authorization_password: 'admin',
api_keyHttpHeader_clientParamsAsTxt: 'clientParamsAsTxt',
};
this.default_dateHeureSettings = {
defaultCustomDateFormat: 'dd-MM-yyy',
defaultCustomDateHeureFormat: 'dd/MM/yyyy hh:mm',
defaultCustomHeureFormat: 'hh:mm',
};
this.apiSettings = myApiSettings ? myApiSettings : this.default_apiSettings;
this.resetHttpHeadersRequeteAPI();
}
/**************************************************/
/** */
getCompleteUrlEntity(suffixeEntityUrl = '') {
let str = this.apiSettings?.baseUrlApi
? this.apiSettings.baseUrlApi
: this.default_apiSettings.baseUrlApi;
if (str.length > 0 && str.charAt(str.length - 1) == '/') {
str = str.substring(0, str.length - 2);
}
let str2 = suffixeEntityUrl;
if (str2.length > 0 && str2.charAt(0) == '/') {
str2 = str2.substring(1, str2.length - 1);
}
str = str + '/' + str2;
//console.log('****** DEFAULTCRUDSERVICE --- getCompletePrefixUrlEntity');
//console.log('--api_prefixUrlEntityCrud = '+this.api_prefixUrlEntityCrud);
//console.log('--suffixeEntityUrl = '+suffixeEntityUrl);
//console.log(str);
return str;
}
//****************************************** */
getApi_keyHttpHeader_clientParamsAsTxt() {
return this.apiSettings?.api_keyHttpHeader_clientParamsAsTxt
? this.apiSettings.api_keyHttpHeader_clientParamsAsTxt
: this.default_apiSettings.api_keyHttpHeader_clientParamsAsTxt
? this.default_apiSettings.api_keyHttpHeader_clientParamsAsTxt
: '';
}
getApi_clientParams() {
return this.apiSettings?.api_clientParams
? this.apiSettings.api_clientParams
: this.default_apiSettings.api_clientParams
? this.default_apiSettings.api_clientParams
: {};
}
getApi_authorization_username() {
return this.apiSettings?.api_authorization_username
? this.apiSettings.api_authorization_username
: this.default_apiSettings.api_authorization_username
? this.default_apiSettings.api_authorization_username
: '';
}
getApi_authorization_password() {
return this.apiSettings?.api_authorization_password
? this.apiSettings.api_authorization_password
: this.default_apiSettings.api_authorization_password
? this.default_apiSettings.api_authorization_password
: '';
}
getCompleteUrlEntity_filedownload() {
return this.getCompleteUrlEntity(this.apiSettings?.apiUrl_fileDownload
? this.apiSettings?.apiUrl_fileDownload
: (this.default_apiSettings.apiUrl_fileDownload ? this.default_apiSettings.apiUrl_fileDownload : ''));
}
getCompleteUrlEntity_fileupload() {
return this.getCompleteUrlEntity(this.apiSettings?.apiUrl_fileUpload
? this.apiSettings?.apiUrl_fileUpload
: (this.default_apiSettings.apiUrl_fileUpload ? this.default_apiSettings.apiUrl_fileUpload : ''));
}
/**************************************************/
/********** */
resetHttpParamsRequeteAPI() {
this.optionRequeteAPI.params = new HttpParams();
this.setOptionParamRequeteAPI_HttpClientParams();
}
/********** */
resetHttpHeadersRequeteAPI() {
this.optionRequeteAPI.headers = new HttpHeaders();
addOptionHeaderRequeteAPI_Authorization(this.optionRequeteAPI, this.getApi_authorization_username(), this.getApi_authorization_password()
//this.crudSettings.httpHeaderAPI_authorization_password
);
//addOptionHeaderRequeteAPI(this.optionRequeteAPI, 'Access-Control-Allow-Origin','*');
//addOptionHeaderRequeteAPI(this.optionRequeteAPI, 'Access-Control-Allow-Headers', 'Authorization, Origin, Content-Type, X-CSRF-Token');
//addOptionHeaderRequeteAPI(this.optionRequeteAPI, 'Access-Control-Allow-Origin','*');
}
/***** */
setOptionParamRequeteAPI_HttpClientParams() {
addOptionParamRequeteAPI(this.optionRequeteAPI, this.getApi_keyHttpHeader_clientParamsAsTxt(), JSON.stringify(this.getApi_clientParams()));
}
//-------------------------------------------------------------------------
downloadFileFromServer(downloadParams) {
//this.resetHttpHeadersRequeteAPI();
//addOptionHeaderRequeteAPI_ContentType_JSON(this.optionRequeteAPI);
//this.resetHttpParamsRequeteAPI();
const myUrl = this.getCompleteUrlEntity_filedownload();
let params = new HttpParams();
params = params.set('fileData', JSON.stringify(downloadParams));
let myOptionQuery = {
...this.getOptionRequeteDownload(),
params: params,
responseType: 'blob',
observe: 'response',
};
/*addOptionParamRequeteAPI(
this.optionRequeteAPI,
'fileData',
JSON.stringify(downloadParams)
);*/
console.log('******* CRUD-SERVICE -- downloadFileFromServer -- myOptionQuery **************************');
console.log(myOptionQuery);
if (myUrl) {
return this.httpClient.get(myUrl, myOptionQuery);
}
else {
return of(null);
}
/*if (myUrl) {
return this.httpClient.get<Blob>(myUrl, this.optionRequeteAPI)
} else {
return of(null);
}*/
}
//------------------------
getOptionRequeteDownload() {
return {
headers: new HttpHeaders({
Authorization: createBasicAuthToken(this.getApi_authorization_username(), this.getApi_authorization_password()),
}),
};
}
}
/*** DEFAULT CRUD DATA SERVICE ** */
class CrudDataService {
//******************************
constructor(myHttpClient, myDataKeyField, mytypeview, myApiSettings) {
this.optionRequeteAPI = {
headers: new HttpHeaders(),
params: new HttpParams(),
};
this.useEchelleInfo_listData = false;
this.useEchelleInfo_statsData = false;
this.convertDataResponseApi_PaginateListView = (myResApi) => myResApi;
this.convertDataResponseApi_ListView = (myResApi) => myResApi;
//this.nbRowsDatatablePage = this.crudSettings.nbRowsDatatablePage? this.crudSettings.nbRowsDatatablePage : 15;
this.httpClient = myHttpClient;
this.dataKeyField = myDataKeyField;
this.typeView = mytypeview;
this.default_apiSettings = {
api_viewName: '',
baseUrlApi: '',
apiUrl_findAll: 'listAll',
apiUrl_findByPage: 'listByPage',
apiUrl_findById: 'findByID',
apiUrl_findAllForStats: 'listAllStats',
apiUrl_findAllForStats2: 'listAllStats2',
apiUrl_editOrCreate: '',
apiUrl_delete: '',
apiUrl_previewUpload: 'previewupload',
apiUrl_validateUpload: 'validateupload',
apiUrl_upload: 'upload',
apiUrl_exportData: 'download',
apiUrl_fileDownload: 'filedownload',
apiUrl_exportStats: '',
api_authorization_username: 'admin',
api_authorization_password: 'admin',
api_keyHttpHeader_clientParamsAsTxt: 'clientParamsAsTxt',
};
this.default_dateHeureSettings = {
defaultCustomDateFormat: 'dd-MM-yyy',
defaultCustomDateHeureFormat: 'dd/MM/yyyy hh:mm',
defaultCustomHeureFormat: 'hh:mm',
};
this.apiSettings = myApiSettings;
this.resetHttpHeadersRequeteAPI();
this.listeAllFieldsFormEdit = [];
}
/**************************************************/
/** */
getCompleteUrlEntity(suffixeEntityUrl = '') {
let str = this.apiSettings?.baseUrlApi
? this.apiSettings.baseUrlApi
: this.default_apiSettings.baseUrlApi;
if (str.length > 0 && str.charAt(str.length - 1) == '/') {
str = str.substring(0, str.length - 2);
}
let str2 = suffixeEntityUrl;
if (str2.length > 0 && str2.charAt(0) == '/') {
str2 = str2.substring(1, str2.length - 1);
}
str = str + '/' + str2;
//console.log('****** DEFAULTCRUDSERVICE --- getCompletePrefixUrlEntity');
//console.log('--api_prefixUrlEntityCrud = '+this.api_prefixUrlEntityCrud);
//console.log('--suffixeEntityUrl = '+suffixeEntityUrl);
//console.log(str);
return str;
}
getCompleteUrlEntity_listAll() {
return this.getCompleteUrlEntity(this.apiSettings?.apiUrl_findAll
? this.apiSettings?.apiUrl_findAll
: this.default_apiSettings.apiUrl_findAll);
}
getCompleteUrlEntity_listAllStats() {
return this.getCompleteUrlEntity(this.apiSettings?.apiUrl_findAllForStats
? this.apiSettings?.apiUrl_findAllForStats
: this.default_apiSettings.apiUrl_findAllForStats);
}
getCompleteUrlEntity_listAllStats2() {
return this.getCompleteUrlEntity(this.apiSettings?.apiUrl_findAllForStats2
? this.apiSettings?.apiUrl_findAllForStats2
: this.default_apiSettings.apiUrl_findAllForStats2);
}
getCompleteUrlEntity_listByPage() {
return this.getCompleteUrlEntity(this.apiSettings?.apiUrl_findByPage
? this.apiSettings?.apiUrl_findByPage
: this.default_apiSettings.apiUrl_findByPage);
}
getCompleteUrlEntity_findById() {
return this.getCompleteUrlEntity(this.apiSettings?.apiUrl_findById
? this.apiSettings?.apiUrl_findById
: this.default_apiSettings.apiUrl_findById);
}
getCompleteUrlEntity_editOrCreate() {
return this.getCompleteUrlEntity(this.apiSettings?.apiUrl_editOrCreate
? this.apiSettings?.apiUrl_editOrCreate
: this.default_apiSettings.apiUrl_editOrCreate);
}
getCompleteUrlEntity_delete() {
return this.getCompleteUrlEntity(this.apiSettings?.apiUrl_delete
? this.apiSettings?.apiUrl_delete
: this.default_apiSettings.apiUrl_delete);
}
getCompleteUrlEntity_previewUpload() {
return this.getCompleteUrlEntity(this.apiSettings?.apiUrl_previewUpload
? this.apiSettings?.apiUrl_previewUpload
: this.default_apiSettings.apiUrl_previewUpload);
}
getCompleteUrlEntity_validateUpload() {
return this.getCompleteUrlEntity(this.apiSettings?.apiUrl_validateUpload
? this.apiSettings?.apiUrl_validateUpload
: this.default_apiSettings.apiUrl_validateUpload);
}
getCompleteUrlEntity_upload() {
return this.getCompleteUrlEntity(this.apiSettings?.apiUrl_upload
? this.apiSettings?.apiUrl_upload
: this.default_apiSettings.apiUrl_upload);
}
getCompleteUrlEntity_exportData() {
return this.getCompleteUrlEntity(this.apiSettings?.apiUrl_exportData
? this.apiSettings?.apiUrl_exportData
: this.default_apiSettings.apiUrl_exportData);
}
getCompleteUrlEntity_filedownload() {
return this.getCompleteUrlEntity(this.apiSettings?.apiUrl_fileDownload
? this.apiSettings?.apiUrl_fileDownload
: (this.default_apiSettings.apiUrl_fileDownload ? this.default_apiSettings.apiUrl_fileDownload : ''));
}
getCompleteUrlEntity_exportStats() {
return this.getCompleteUrlEntity(this.apiSettings?.apiUrl_exportStats
? this.apiSettings?.apiUrl_exportStats
: this.default_apiSettings.apiUrl_exportStats);
}
//****************************************** */
getApi_keyHttpHeader_clientParamsAsTxt() {
return this.apiSettings?.api_keyHttpHeader_clientParamsAsTxt
? this.apiSettings.api_keyHttpHeader_clientParamsAsTxt
: this.default_apiSettings.api_keyHttpHeader_clientParamsAsTxt
? this.default_apiSettings.api_keyHttpHeader_clientParamsAsTxt
: '';
}
getApi_keyHttpHeader_criteresAsTxt() {
return 'criteresAsTxt';
}
getApi_clientParams() {
return this.apiSettings?.api_clientParams
? this.apiSettings.api_clientParams
: this.default_apiSettings.api_clientParams
? this.default_apiSettings.api_clientParams
: {};
}
getApi_authorization_username() {
return this.apiSettings?.api_authorization_username
? this.apiSettings.api_authorization_username
: this.default_apiSettings.api_authorization_username
? this.default_apiSettings.api_authorization_username
: '';
}
getApi_authorization_password() {
return this.apiSettings?.api_authorization_password
? this.apiSettings.api_authorization_password
: this.default_apiSettings.api_authorization_password
? this.default_apiSettings.api_authorization_password
: '';
}
/**************************************************/
/********** */
resetHttpParamsRequeteAPI() {
this.optionRequeteAPI.params = new HttpParams();
this.setOptionParamRequeteAPI_HttpClientParams();
}
/********** */
resetHttpHeadersRequeteAPI() {
this.optionRequeteAPI.headers = new HttpHeaders();
addOptionHeaderRequeteAPI_Authorization(this.optionRequeteAPI, this.getApi_authorization_username(), this.getApi_authorization_password()
//this.crudSettings.httpHeaderAPI_authorization_password
);
}
/***** */
setOptionParamRequeteAPI_HttpClientParams() {
addOptionParamRequeteAPI(this.optionRequeteAPI, this.getApi_keyHttpHeader_clientParamsAsTxt(), JSON.stringify(this.getApi_clientParams()));
}
//-------------------------------------------------------------------------
/******************************************************************* */
//----------------------------------------------------------
findDataAll(listeFiltres) {
this.resetHttpHeadersRequeteAPI();
addOptionHeaderRequeteAPI_JSON(this.optionRequeteAPI);
this.resetHttpParamsRequeteAPI();
let tabOrCriteresOfAndPredicat = generateCritereTxtFromFiltres(listeFiltres);
if (tabOrCriteresOfAndPredicat != undefined &&
tabOrCriteresOfAndPredicat.length > 0) {
tabOrCriteresOfAndPredicat.forEach((andCriteres) => {
addOptionParamRequeteAPI(this.optionRequeteAPI, this.getApi_keyHttpHeader_criteresAsTxt(), andCriteres);
});
}
const myUrl = this.getCompleteUrlEntity_listAll();
if (myUrl) {
return this.httpClient
.get(myUrl, this.optionRequeteAPI)
.pipe(map((data) => this.convertDataResponseApi_ListView(data)));
}
else {
return of({
data: [],
reponseOK: false,
message: 'URL Error : {' + myUrl + '}',
});
}
}
//----------------------------------------------------------
findDataFromServer(findParams) {
this.resetHttpHeadersRequeteAPI();
addOptionHeaderRequeteAPI_JSON(this.optionRequeteAPI);
this.resetHttpParamsRequeteAPI();
//this.setOptionParamRequeteAPI_HttpClientParams(); //-- Déjà inclus dans resetHttpParamsRequeteAPI
//console.log("******* GET DATA FROM SERVER 0 - Params Find ************")
//console.log(findParams);
//findParams.listeFiltres = this.refreshFiltresWithZoomlocationInfo(findParams.listeFiltres,this.useEchelleInfo_listData);
let criteresAsTxt = generateCritereTxtFromFiltres(findParams.listeFiltres);
if (criteresAsTxt != undefined && criteresAsTxt.length > 0) {
criteresAsTxt.forEach((andCriteres) => {
addOptionParamRequeteAPI(this.optionRequeteAPI, this.getApi_keyHttpHeader_criteresAsTxt(), andCriteres);
});
}
addOptionParamRequeteAPI(this.optionRequeteAPI, 'page', String(findParams.page));
addOptionParamRequeteAPI(this.optionRequeteAPI, 'size', String(findParams.size));
console.log('******* CRUD-SERVICE -- FINDDATAFROMSERVER PAGINATE -- OptionsRequeteAPI **************************');
console.log(this.optionRequeteAPI);
const myUrl = this.getCompleteUrlEntity_listByPage();
if (myUrl) {
return this.httpClient
.get(myUrl, this.optionRequeteAPI)
.pipe(map((data) => this.convertDataResponseApi_PaginateListView(data)));
}
else {
return of({
data: {},
reponseOK: false,
message: 'URL Error : {' + myUrl + '}',
});
}
}
//-----------------------------------------------
findById(idData) {
this.resetHttpHeadersRequeteAPI();
addOptionHeaderRequeteAPI_JSON(this.optionRequeteAPI);
this.resetHttpParamsRequeteAPI();
addOptionParamRequeteAPI(this.optionRequeteAPI, 'id', idData);
const myOptionQuery = { ...this.optionRequeteAPI };
const myUrl = this.getCompleteUrlEntity_findById();
console.log('**** CRUD SERVICE - FINDBYID 00 *******');
console.log(idData);
console.log(myUrl);
console.log(this.optionRequeteAPI);
if (myUrl != undefined) {
console.log('**** CRUD SERVICE - FINDBYID URL OK *******');
return this.httpClient.get(myUrl, myOptionQuery);
}
else {
console.log('**** CRUD SERVICE - FINDBYID URL NON-OK *******');
return of({
data: undefined,
reponseOK: false,
message: 'URL Error : {' + myUrl + '}',
});
}
}
//-----------------------------------------------
deleteById(idData) {
this.resetHttpHeadersRequeteAPI();
addOptionHeaderRequeteAPI_JSON(this.optionRequeteAPI);
this.resetHttpParamsRequeteAPI();
//addOptionParamRequeteAPI(this.optionRequeteAPI, 'id', idData);
const myOptionQuery = { ...this.optionRequeteAPI };
const myUrl = this.getCompleteUrlEntity_delete() + idData;
console.log('**** CRUD SERVICE - DELETEBYID 00 *******');
console.log(idData);
console.log(myUrl);
if (myUrl) {
return this.httpClient.delete(myUrl, myOptionQuery);
}
else {
return of({
data: false,
reponseOK: false,
message: 'URL Error : {' + myUrl + '}',
});
}
}
deleteAll() {
this.resetHttpHeadersRequeteAPI();
addOptionHeaderRequeteAPI_JSON(this.optionRequeteAPI);
this.resetHttpParamsRequeteAPI();
const myOptionQuery = { ...this.optionRequeteAPI };
const myUrl = this.getCompleteUrlEntity_delete();
if (myUrl) {
return this.httpClient.delete(myUrl, myOptionQuery);
}
else {
return of({
data: false,
reponseOK: false,
message: 'URL Error : {' + myUrl + '}',
});
}
}
//--------------- EXPORTATION -------------------------------------------------------
exportData(type, exportParams, listefiltres) {
this.resetHttpHeadersRequeteAPI();
addOptionHeaderRequeteAPI_JSON(this.optionRequeteAPI);
this.resetHttpParamsRequeteAPI();
let params = new HttpParams();
params = params.set('p_title', exportParams.title);
params = params.set('p_useLandscape', exportParams.useLandscape);
params = params.set('p_useHeaderDataFieldName', exportParams.useHeaderDataFieldName);
params = params.set('p_showRowNumber', exportParams.addNumeroOrdre);
const pkey_listeCols = 'p_listeColsData';
exportParams.listeColsData.forEach(colData => {
if (params.has(pkey_listeCols)) {
params = params.append(pkey_listeCols, colData);
}
else {
params = params.set(pkey_listeCols, colData);
}
});
//listefiltres = this.refreshFiltresWithZoomlocationInfo(listefiltres,this.useEchelleInfo_listData);
let tabOrCriteresOfAndPredicat = generateCritereTxtFromFiltres(listefiltres);
if (tabOrCriteresOfAndPredicat != undefined &&
tabOrCriteresOfAndPredicat.length > 0) {
tabOrCriteresOfAndPredicat.forEach((andCriteres) => {
if (params.has(this.getApi_keyHttpHeader_clientParamsAsTxt())) {
params = params.append(this.getApi_keyHttpHeader_clientParamsAsTxt(), andCriteres);
}
else {
params = params.set(this.getApi_keyHttpHeader_clientParamsAsTxt(), andCriteres);
}
});
}
//console.log("********** CRUDSERVICE - EXPORT DATA - HttpParams ************")
//console.log(params)
let myOptionQuery = {
...this.getOptionRequeteReport(),
params: params,
responseType: 'blob',
observe: 'response',
};
//console.log("********** CRUDSERVICE - EXPORT DATA - myOptionQuery ************")
//console.log(myOptionQuery)
let myUrl = this.getCompleteUrlEntity_exportData() + '/' + type;
if (myUrl) {
return this.httpClient.get(myUrl, myOptionQuery);
}
else {
return of(null);
}
}
getOptionRequeteReport() {
return {
headers: new HttpHeaders({
//'Content-Type': 'application/pdf; charset=UTF-8',
//'Content-Disposition': 'inline; filename='
//'Accept': 'application/json',
//'Access-Control-Allow-Origin': '*',
Authorization: createBasicAuthToken(this.getApi_authorization_username(), this.getApi_authorization_password()),
}),
};
}
//----
getAllFieldOfCreateTypeData() {
return this.listeAllFieldsFormEdit != undefined ? this.listeAllFieldsFormEdit.filter(elt => elt.useInCreateView == true && elt.name != undefined) : [];
}
//----
getAllFieldOfEditTypeData() {
return this.listeAllFieldsFormEdit != undefined ? this.listeAllFieldsFormEdit.filter(elt => elt.useInEditView == true && elt.name != undefined) : [];
}
//----
getAllFieldOfImportTypeData() {
return this.listeAllFieldsFormEdit != undefined ? this.listeAllFieldsFormEdit.filter(elt => elt.useInImportView == true && elt.name != undefined) : [];
}
//----------------------------
downloadFileFromServer(downloadParams) {
//this.resetHttpHeadersRequeteAPI();
//addOptionHeaderRequeteAPI_ContentType_JSON(this.optionRequeteAPI);
//this.resetHttpParamsRequeteAPI();
const myUrl = this.getCompleteUrlEntity_filedownload();
let params = new HttpParams();
params = params.set('fileData', JSON.stringify(downloadParams));
let myOptionQuery = {
...this.getOptionRequeteDownload(),
params: params,
responseType: 'blob',
observe: 'response',
};
/*addOptionParamRequeteAPI(
this.optionRequeteAPI,
'fileData',
JSON.stringify(downloadParams)
);*/
console.log('******* CRUD-SERVICE -- downloadFileFromServer -- myOptionQuery **************************');
console.log(myOptionQuery);
if (myUrl) {
return this.httpClient.get(myUrl, myOptionQuery);
}
else {
return of(null);
}
/*if (myUrl) {
return this.httpClient.get<Blob>(myUrl, this.optionRequeteAPI)
} else {
return of(null);
}*/
}
//------------------------
getOptionRequeteDownload() {
return {
headers: new HttpHeaders({
Authorization: createBasicAuthToken(this.getApi_authorization_username(), this.getApi_authorization_password()),
}),
};
}
}
//-------------------------------------------------------------------------------
//---------------- STRUCTURE DE DONNÉES DE CRUDDATASERVICE_LISTVIEW -------------
class CrudDataService_ListView extends CrudDataService {
//getHttpDataResponseApi_ListView!: Observable<HttpResponse<TDataList>>;
constructor(myHttpClient, myDataKeyField, myColsDatatable, myTitreView, myNbRowsAuto, myNbRowsDataTableByPage, mySelectNbRowsDataTableByPage_template) {
super(myHttpClient, myDataKeyField, TypeCrudView.LIST);
this.navigateToEdit_Subject = new BehaviorSubject(false);
this.navigateToCreate_Subject = new BehaviorSubject(false);
this.navigateToImport_Subject = new BehaviorSubject(false);
this.myInit_ListView = () => { };
this.onPrepare_ListView = (responseResolveData) => { };
this.setStaticParameters_ListView = () => { };
this.getIDValue = (data) => {
return undefined;
};
this.cols_Datatable = myColsDatatable ? myColsDatatable : [];
this.titreViewDataList = myTitreView ? myTitreView : 'List Data';
this.nbRowsAuto = myNbRowsAuto ? myNbRowsAuto : false;
this.nbRowsDataTableByPage = myNbRowsDataTableByPage
? myNbRowsDataTableByPage
: 15;
this.selectNbRowsDataTableByPage_template =
mySelectNbRowsDataTableByPage_template
? mySelectNbRowsDataTableByPage_template
: '10,15,20,25,30,35,40,50';
}
}
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
//----------------------------------------------------------------------------
/** Read the custom property of body section with given name: **/
function readProperty(name) {
let bodyStyles = window.getComputedStyle(document.body);
return bodyStyles.getPropertyValue('--' + name);
}
function escapeDoubleQuotes(str) {
return str.replace(/"/g, '\\"');
}
/**
*
*/
class CrudDataService_CreateOrEditView extends CrudDataService {
//validateDataToSave : (()=> boolean) = ()=>{return true;};
constructor(myHttpClient, myDataKeyField, mytypeview, myTitreView, myUrlNavigateListView) {
super(myHttpClient, myDataKeyField, mytypeview);
this.navigateToList_Subject = new BehaviorSubject(false);
this.newDataCreate = () => {
return {};
};
this.initFieldsValuesFromApiDataEdit = (apidata) => { };
this.initFieldsValuesFromApiDataCreate = (apidata) => { };
this.initApiDataFromFieldsValuesEdit = (apidata, listeBlobFields) => { };
this.initApiDataFromFieldsValuesCreate = (apidata, listeBlobFields) => { };
//-------------------
this.convertDataListToCreate = (datalistElt) => {
return { datalistElt };
};
this.convertDataListToEdit = (datalistElt) => {
return { datalistElt };
};
this.onPrepareEdit = () => { };
this.onPrepareCreate = () => { };
this.validateDataToSaveCreate = () => {
return true;
};
this.validateDataToSaveEdit = () => {
return true;
};
this.afterSaveCreate = () => {
//this.crudFiltreRecherhe.validateChangeFiltre(undefined);
};
this.afterSaveEdit = () => {
//this.crudFiltreRecherhe.validateChangeFiltre(undefined);
};
this.titreCreateOrEditView = myTitreView
? myTitreView
: this.isCreateView()
? 'CREATE DATA VIEW'
: 'EDIT DATA VIEW';
this.urlNavigatePageListView = myUrlNavigateListView
? myUrlNavigateListView
: '';
if (this.formEdit == undefined) {
this.formEdit = new TFormEdit();
}
}
isCreateView() {
return this.typeView === TypeCrudView.CREATE;
}
isEditView() {
return this.typeView === TypeCrudView.EDIT;
}
saveNew(newData, uploadfiles, optionsUploadfiles) {
console.log("****** GENERIC CRUD EDIT - MODEL SAVENEW *******");
console.log(newData);
console.log(optionsUploadfiles);
console.log(uploadfiles);
this.resetHttpHeadersRequeteAPI();
this.resetHttpParamsRequeteAPI();
//addOptionHeaderRequeteAPI(this.optionRequeteAPI, 'Access-Control-Allow-Origin', '*');
//addOptionHeaderRequeteAPI(this.optionRequeteAPI, 'Access-Control-Allow-Headers', 'Authorization, Origin, Content-Type, X-CSRF-Token');
//addOptionHeaderRequeteAPI(this.optionRequeteAPI, 'Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
//this.optionRequeteAPI.withCredentials = true;
//addOptionHeaderRequeteAPI_ACCEPT_JSON(this.optionRequeteAPI);
//addOptionHeaderRequeteAPI_ContentType_MULTIPART(this.optionRequeteAPI);
//addOptionHeaderRequeteAPI(this.optionRequeteAPI, "Content-Type", "multipart/form-data; boundary=----WebKitFormBoundarySGC46902");
//addOptionHeaderRequeteAPI_ContentType_JSON(this.optionRequeteAPI);
//addOptionParamRequeteAPI(this.optionRequeteAPI, "model", JSON.stringify(this.updateDataCreateBeforeSave(newData)));
let formData = new FormData();
formData.append("model", JSON.stringify(this.updateDataCreateBeforeSave(newData)));
formData.append("clientParams", JSON.stringify(this.getApi_clientParams()));
if (uploadfiles && uploadfiles.length > 0 && optionsUploadfiles && optionsUploadfiles.length > 0 && uploadfiles.length == optionsUploadfiles.length) {
let strOptionsUploadFiles = optionsUploadfiles.map(elt => JSON.stringify(elt)).join(',');
formData.append("optionsUploadfiles", strOptionsUploadFiles);
for (let i = 0; i < uploadfiles.length; i++) {
formData.append("uploadfiles", uploadfiles[i]);
//addOptionParamRequeteAPI(this.optionRequeteAPI, "uploadfiles", uploadfiles[i]);
//formData.append("optionsUploadfiles", JSON.stringify(optionsUploadfiles[i]));
//formData.append("optionsUploadfiles", JSON.stringify(JSON.stringify(optionsUploadfiles[i]))) ;
//formData.append("optionsUploadfiles", JSON.stringify(optionsUploadfiles[i]));
//addOptionParamRequeteAPI(this.optionRequeteAPI, "optionsUploadfiles", JSON.stringify(optionsUploadfiles[i]));
}
}
//console.log(Array.from(formData));
const myOptionQuery = { ...this.optionRequeteAPI };
//const myOptionQuery = { ...this.optionRequeteAPI, 'Content-Type': 'multipart/form-data', params: myParams };
console.log(myOptionQuery);
const myUrl = this.getCompleteUrlEntity_editOrCreate();
if (myUrl) {
return this.httpClient.post(myUrl, formData, myOptionQuery);
}
else {
return of({
data: null,
reponseOK: false,
message: 'URL Error : {' + myUrl + '}',
});
}
}
save(editData) {
this.resetHttpHeadersRequeteAPI();
addOptionHeaderRequeteAPI_JSON(this.optionRequeteAPI);
this.resetHttpParamsRequeteAPI();
const myOptionQuery = { ...this.optionRequeteAPI };
const myUrl = this.getCompleteUrlEntity_editOrCreate();
if (myUrl) {
return this.httpClient.patch(myUrl, this.updateDataEditBeforeSave(editData), myOptionQuery);
}
else {
return of({
data: null,
reponseOK: false,
message: 'URL Error : {' + myUrl + '}',
});
}
}
updateDataCreateBeforeSave(data) {
return data;
}
updateDataEditBeforeSave(data) {
return data;
}
getListeFileUploadFieldsFromData() {
return this.listeAllFieldsFormEdit.filter(elt => typeDataIs_FILEINPUT(elt));
}
}
/*
* Public API Surface of sgc-share-lib
*/
//export * from './lib/sgc-share-lib.service';
//export * from './lib/sgc-share-lib.component';
//export * from './lib/sgc-share-lib.module';
/**
* Generated bundle index. Do not edit.
*/
export { AlertDialog, BaseFieldFormEditUI, ConfirmationDialog, CrudDataService, CrudDataService_CreateOrEditView, CrudDataService_ListView, CrudFiltreRecherche, DefaultRowGapBetweenFields, DefaultRowHeight, Enum_FilterMatchMode, Enum_FilterOperator, FONTWEIGHT_CONSTANT, FileDataService, FiltreRechercheService, H_ALIGN_CONSTANT, ListePositionAffichage, Max_WidthFieldInResponsiveGridWiew, Min_WidthFieldInResponsiveGridWiew, NotificationService, SgcBiblio, TCss_ColumnDataTableTextAlign, TExportFormat, TExportHeaderDataValueFrom, TExportPageOrientation, TFieldFormEditDefault, TFormEdit, TGroupFieldFormEdit, TImportFormat, TypeChartStats, TypeCrudView, TypeFieldDataView, TypeFieldFormEdit, TypeFileImportExportNames, TypeHidePasswordSymbol, addOptionHeaderRequeteAPI, addOptionHeaderRequeteAPI_ACCEPT_JSON, addOptionHeaderRequeteAPI_Authorization, addOptionHeaderRequeteAPI_ContentType_JSON, addOptionHeaderRequeteAPI_ContentType_MULTIPART, addOptionHeaderRequeteAPI_JSON, addOptionHeaderRequeteAPI_ResponseType_BLOB, addOptionParamRequeteAPI, defaultMaxYAxesChart, generateCritereTxtFromFiltres, getListeTypeExportFormat, getListeTypeExportHeaderDataValueFrom, getListeTypeExportOrientation, getListeTypeImportExportNames, getListeTypeImportFormat, getTimeZone, isColTypeBooleen, isColTypeDate, isColTypeDateHeure, isColTypeNombre, isColTypeTexte, padTo2Digits, readProperty, typeDataIs_BOOLEEN, typeDataIs_DATE, typeDataIs_DATEHEURE, typeDataIs_FILEINPUT, typeDataIs_HEURE, typeDataIs_LISTE_OBJECT, typeDataIs_NOMBRE, typeDataIs_SELECTVALUE, typeDataIs_TEXTE, typeDataIs_TEXTE_MULTILIGNE, typeDataIs_TEXTE_SECRET, useField_DATE, useField_DATEHEURE, useField_FILEINPUT, useField_HEURE, useField_NUMBER, useField_PASSWORD, useField_SELECTVALUE, useField_TEXT, useField_TEXTAREA };
//# sourceMappingURL=sgc-share-lib.mjs.map