UNPKG

@c10t/nice-component-library

Version:

nice-component-library

1,177 lines (1,132 loc) 564 kB
import * as i1$2 from '@angular/forms'; import { FormGroup, FormArray, FormControl, Validators, NgControl, NG_VALUE_ACCESSOR, FormsModule, ReactiveFormsModule } from '@angular/forms'; import * as i1$3 from '@angular/common/http'; import { HttpParams, HttpHeaders, HttpResponse, HttpResponseBase } from '@angular/common/http'; import * as i0 from '@angular/core'; import { InjectionToken, Self, Optional, Inject, Component, Injectable, Directive, EventEmitter, Output, Input, Host, Pipe, HostListener, forwardRef, ViewChild, ViewChildren, HostBinding, ViewEncapsulation, NgModule, NO_ERRORS_SCHEMA, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import * as i1$1 from '@angular/material/dialog'; import { MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog'; import * as i1 from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core'; import * as i2 from '@angular/common'; import { formatNumber, CommonModule } from '@angular/common'; import * as i3 from '@angular/material/button'; import { MatButtonModule } from '@angular/material/button'; import * as i6 from '@angular/material/form-field'; import { MatFormFieldModule } from '@angular/material/form-field'; import * as i8 from '@angular/material/input'; import { MAT_INPUT_VALUE_ACCESSOR, MatInputModule } from '@angular/material/input'; import * as i8$1 from '@angular/flex-layout/flex'; import * as i3$1 from 'ngx-toastr'; import { BehaviorSubject, Subject, of, forkJoin, debounceTime, distinctUntilChanged, filter, tap, switchMap, throwError } from 'rxjs'; import * as i5 from '@angular/material/table'; import { MatTableDataSource, MatTableModule } from '@angular/material/table'; import * as i1$4 from '@angular/router'; import { RouterModule } from '@angular/router'; import * as i2$1 from 'ngx-filesaver'; import { catchError, map, finalize } from 'rxjs/operators'; import * as i1$5 from '@angular/material/paginator'; import { MatPaginatorIntl, MatPaginatorModule } from '@angular/material/paginator'; import * as i4 from '@angular/material/checkbox'; import { MatCheckboxModule } from '@angular/material/checkbox'; import * as i7 from '@angular/material/icon'; import { MatIconModule } from '@angular/material/icon'; import * as i8$2 from '@angular/material/tooltip'; import { MatTooltipModule } from '@angular/material/tooltip'; import * as i9 from '@angular/flex-layout/extended'; import * as i7$1 from '@angular/material/menu'; import { MatMenuModule } from '@angular/material/menu'; import * as i2$2 from '@angular/platform-browser'; import * as i7$2 from '@angular/cdk/text-field'; import * as i4$1 from '@angular/material/core'; import { NativeDateAdapter, DateAdapter, MAT_DATE_FORMATS, MatRippleModule, MatCommonModule } from '@angular/material/core'; import * as i5$1 from '@angular/material/datepicker'; import { MatDatepickerModule } from '@angular/material/datepicker'; import * as i10 from '@angular/cdk/scrolling'; import { CdkVirtualScrollViewport, ScrollingModule } from '@angular/cdk/scrolling'; import * as i9$1 from '@angular/material/select'; import { MatSelectModule } from '@angular/material/select'; import * as i3$2 from '@angular/material/autocomplete'; import { MatAutocompleteModule } from '@angular/material/autocomplete'; import * as i9$2 from '@angular/material/progress-spinner'; import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; import * as i3$3 from '@angular/material/card'; import { MatCardModule } from '@angular/material/card'; import * as i3$4 from '@angular/material/progress-bar'; import { MatProgressBarModule } from '@angular/material/progress-bar'; import { NestedTreeControl, FlatTreeControl, CdkTreeModule, CdkTree, CdkTreeNode } from '@angular/cdk/tree'; import * as i6$1 from '@angular/material/tree'; import { MatTreeNestedDataSource, MatTreeFlattener, MatTreeFlatDataSource, MatTreeModule } from '@angular/material/tree'; import * as i4$2 from '@angular/material/radio'; import { MatRadioModule } from '@angular/material/radio'; import * as i6$2 from '@angular/material/divider'; import * as i4$3 from 'ngx-quill'; import { QuillModule } from 'ngx-quill'; import * as i1$6 from 'jsog-typescript'; import { OverlayModule } from '@angular/cdk/overlay'; import { A11yModule } from '@angular/cdk/a11y'; import { BidiModule } from '@angular/cdk/bidi'; import { ObserversModule } from '@angular/cdk/observers'; import { PortalModule } from '@angular/cdk/portal'; import { MatButtonToggleModule } from '@angular/material/button-toggle'; import { MatSlideToggleModule } from '@angular/material/slide-toggle'; import { MatSliderModule } from '@angular/material/slider'; import { MatSidenavModule } from '@angular/material/sidenav'; import { MatListModule } from '@angular/material/list'; import { MatGridListModule } from '@angular/material/grid-list'; import { MatChipsModule } from '@angular/material/chips'; import { MatSnackBarModule } from '@angular/material/snack-bar'; import { MatTabsModule } from '@angular/material/tabs'; import { MatToolbarModule } from '@angular/material/toolbar'; import { MatSortModule } from '@angular/material/sort'; import { MatStepperModule } from '@angular/material/stepper'; import { ScrollingModule as ScrollingModule$1 } from '@angular/cdk-experimental/scrolling'; import { FlexLayoutModule } from '@angular/flex-layout'; class NavigatorModel { displayName = ''; disabled = true; iconName = ''; roleMenu = ''; route = ''; children = []; isOnlyIcon = true; expanded = false; } class ButtonClickEvent { action; object; index; constructor(action, object, index) { this.action = action; this.object = object; this.index = index; } } var IconTypeEnum; (function (IconTypeEnum) { IconTypeEnum["MATERIAL_ICON"] = "MATERIAL_ICON"; IconTypeEnum["FONT_AWESOME"] = "FONT_AWESOME"; })(IconTypeEnum || (IconTypeEnum = {})); class ButtonModel { columnDef = ''; color = 'warn'; icon = ''; iconType = IconTypeEnum.MATERIAL_ICON; click = ''; isShowHeader; title = ''; display; disabled; className; header; alignHeader; } class CheckboxModel { id; viewValue; checked; disabled; constructor(id, viewValue, checked, disabled) { this.id = id; this.viewValue = viewValue; this.checked = checked; this.disabled = disabled; } } var ColumnTypeEnum; (function (ColumnTypeEnum) { ColumnTypeEnum["VIEW"] = "VIEW"; ColumnTypeEnum["INPUT_COUNTER"] = "INPUT_COUNTER"; ColumnTypeEnum["INPUT_CURRENCY"] = "INPUT_CURRENCY"; ColumnTypeEnum["DATE_PICKER"] = "DATE_PICKER"; ColumnTypeEnum["MULTI_SELECT_AUTOCOMPLETE"] = "MULTI_SELECT_AUTOCOMPLETE"; ColumnTypeEnum["CHECKBOX"] = "CHECKBOX"; ColumnTypeEnum["BASE64"] = "BASE64"; ColumnTypeEnum["IMG"] = "IMG"; ColumnTypeEnum["IMG_NO_SECURE"] = "IMG_NO_SECURE"; // HTML = 'HTML', // INNER_TEXT = 'INNER_TEXT', ColumnTypeEnum["BUTTON"] = "BUTTON"; ColumnTypeEnum["INPUT"] = "INPUT"; ColumnTypeEnum["LINK"] = "LINK"; ColumnTypeEnum["STYLE_CSS"] = "STYLE_CSS"; ColumnTypeEnum["LIVE_SEARCHING"] = "LIVE_SEARCHING"; })(ColumnTypeEnum || (ColumnTypeEnum = {})); var AlignEnum; (function (AlignEnum) { AlignEnum["LEFT"] = "start"; AlignEnum["CENTER"] = "center"; AlignEnum["RIGHT"] = "end"; })(AlignEnum || (AlignEnum = {})); class ColumnModel { columnDef = ''; header; title = (e) => `${e}`; cell = (e) => `${e}`; // set default theo ly thuyet, phai gan lai align = AlignEnum.LEFT; alignHeader; // phục vụ cho loại cột là hiển thị đường dẫn link; // Phục vụ cho style css style; className; headerClassName; columnType = ColumnTypeEnum.VIEW; onCellValueChange; onHeaderCellValueChange; disabled; optionValues; display; isShowHeader = false; isNotShowHeaderCheckbox = false; isRequired = false; min; max; hasWordBreakStyle = false; validate; errorMessage; isTree = false; isMultipleSelect = false; isDecimal = false; isExpandOptionColumn; footer; footers = []; button; // Dùng cho cva-live-searching displayKey; mappingConfig = {}; searchFn; rowSpan = 1; colSpan = 1; pattern; patternFilter; } class BaseModel { id; checked = false; invalid = false; createdDate; createdBy; lastModifiedDate; lastModifiedBy; } class MenuModel extends BaseModel { clientId = null; code = null; url = null; appType = null; parentMenu = null; constructor(form) { super(); if (form instanceof FormGroup) { this.id = form.get('id')?.value; this.clientId = form.get('clientId')?.value; this.code = form.get('code')?.value; this.url = form.get('url')?.value; this.appType = form.get('appType')?.value; if (form.get('parentMenu')?.value) { this.parentMenu = new MenuModel(form.get('parentMenu')?.value); } } else { this.id = form; } } } class OAuth2AuthenticationDto { userAuthentication = null; authorities = null; name = null; orgId = null; orgCode = null; orgName = null; orgType = null; orgForm = null; orgPath = null; orgIsApproveVo = null; sapId = null; voAuthentication = null; } class Authority { authority = ''; } class TablePagingResponseModel { content = []; page = { size: null, number: null, totalElements: null, totalPages: null, }; } class TablePagingRequestModel { text = ''; pageSize = 0; pageNumber = 0; totalElements = 0; } class RoleModel extends BaseModel { clientId = null; roleName = null; description = ''; permissions = []; menus = []; constructor(form) { super(); if (!form) { return; } if (form instanceof FormGroup) { const formId = form.get('id'); if (formId) { this.id = formId.value; } const formClientId = form.get('clientId'); if (formClientId) { this.clientId = formClientId.value; } const formRoleName = form.get('roleName'); if (formRoleName) { this.roleName = formRoleName.value; } const formDescription = form.get('description'); if (formDescription) { this.description = formDescription.value; } } else { this.id = form; } } } class SelectModel { value; displayValue; disabled; rawData; constructor(value, displayValue, disabled, rawData) { this.value = value; this.displayValue = displayValue; this.disabled = disabled; this.rawData = rawData; } } class UIState { moduleName = ''; formGroup = new FormGroup({}); } var FileTypeEnum; (function (FileTypeEnum) { FileTypeEnum["DOCX"] = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; FileTypeEnum["JPG"] = "image/jpeg"; FileTypeEnum["PDF"] = "application/pdf"; FileTypeEnum["PNG"] = "image/png"; FileTypeEnum["RTF"] = "application/msword"; FileTypeEnum["TXT"] = "text/plain"; FileTypeEnum["XLSX"] = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; FileTypeEnum["XML"] = "text/xml"; FileTypeEnum["ZIP"] = "application/x-zip-compressed"; FileTypeEnum["DOC"] = "application/msword"; FileTypeEnum["XLS"] = "application/vnd.ms-excel"; })(FileTypeEnum || (FileTypeEnum = {})); class UploadModel { id; name; type; binary; previewValue; constructor(name, binary, previewValue, type, id) { this.name = name; this.binary = binary; this.previewValue = previewValue; this.type = type; this.id = id; } static init(url) { const type = UploadModel.getFileType(url); const name = UploadModel.getFileName(url); return new UploadModel(name ? name : '', null, url, type); } static getFileType(url) { const fileTypes = url ? url.split('.') : []; const type = fileTypes.length > 0 ? fileTypes[fileTypes.length - 1] : ''; if (['png', 'jpg', 'jpeg', 'img'].includes(type?.toLowerCase())) { return 'image/' + type; } else if ('pdf' === type?.toLowerCase()) { return 'application/pdf'; } return type; } static getFileName(url) { let fileName = url ? url.split('/') : []; return fileName.pop(); } } class BreadCrumbModel { label; url; constructor(label, url) { this.label = label; this.url = url; } } class FlatTreeModel { rootData = []; value = (node) => `${node}`; display = (node) => `${node}`; children = (node) => []; } class TableFooterModel { columnDef = ''; title = (e) => `${e}`; cell = (e) => `${e}`; colspan = 1; align = AlignEnum.LEFT; className; display; // default is false } class RangeDatePickerModel { fromDate = ''; toDate = ''; constructor(fromDate, toDate) { this.fromDate = fromDate ? fromDate : ''; this.toDate = toDate ? toDate : ''; } isString(inputValue) { return typeof inputValue === 'string' || inputValue instanceof String; } reset() { this.toDate = ''; this.fromDate = ''; } } class FlatTreeConfigModel { isDynamicConfig = false; /* bằng true khi muốn call liên tục hàm display và hàm disabled */ display = true; disabled = false; } class FlatTreeNodeModel { children = []; value; displayValue = ''; iconClass = ''; checked; checkedDisplay; filterChecked; level = 0; expandable; isExpanded; // storage expanded status in selected tree isFilterExpanded; // storage expanded status in choose tree display = true; _displayFuncInput; disabled = false; _disabledFuncInput; } var DialogTypeEnum; (function (DialogTypeEnum) { DialogTypeEnum["CONFIRM"] = "CONFIRM"; DialogTypeEnum["ERROR"] = "ERROR"; DialogTypeEnum["INPUT_CONFIRM"] = "INPUT_CONFIRM"; })(DialogTypeEnum || (DialogTypeEnum = {})); class CustomDialogDataConfigModel { type = DialogTypeEnum.CONFIRM; maxLength; msg; msgDetail; errorMsg; btnOKString; btnOKClass; btnOK_IconClass; btnCancelClass; btnCancel_IconClass; btnCancelString; customClass; hideIconButton; } class Principal { username = null; firstName = null; middleName = null; lastName = null; fullName = null; gender = null; email = null; phone = null; voAuthentication = null; orgId = null; orgCode = null; orgName = null; orgType = null; orgForm = null; orgSapId = null; orgPath = null; orgIsApproveVo = null; roles = []; mustChangePassword = null; } class DialogImportFileConfigModel { downloadTemplateFunc; importFunc; downloadErrorFile; confirmMsgKey = ''; successMsgKey = ''; errorMsgKey = ''; } class PermissionModel extends BaseModel { clientId; description; id = null; url; } var ActionTypeEnum; (function (ActionTypeEnum) { ActionTypeEnum["_ADD"] = "add"; ActionTypeEnum["_EDIT"] = "edit"; ActionTypeEnum["_VIEW"] = "view"; })(ActionTypeEnum || (ActionTypeEnum = {})); var BaseStatusEnum; (function (BaseStatusEnum) { BaseStatusEnum["_"] = "base.status.all"; BaseStatusEnum["_DRAFT"] = "base.status.draft"; BaseStatusEnum["_APPROVED"] = "base.status.approved"; BaseStatusEnum["_REJECTED"] = "base.status.rejected"; })(BaseStatusEnum || (BaseStatusEnum = {})); class BaseTableComponent { activatedRoute; authoritiesService; me = null; constructor(activatedRoute, authoritiesService) { this.activatedRoute = activatedRoute; this.authoritiesService = authoritiesService; if (!this.authoritiesService.me && this.activatedRoute.snapshot.data) { this.me = this.activatedRoute.snapshot.data['me']; } if (!!this.authoritiesService.me) { this.me = this.authoritiesService.me; } if (!!this.me) { this.authoritiesService.me = this.me; this.authoritiesService.stateMe.next(this.me); } } onRowButtonClick(event) { const window = this; if (window[event.action]) { window[event.action](event.object, event.index); } } _collectParams(searchForm, map) { let params = new HttpParams(); for (const key of Object.keys(map)) { const value = map[key]; if (value) { const control = searchForm.get(value); if (control) { params = params.set(key, control.value ? control.value : ''); } } } return params; } } const InjectTokenNextSolutionsConfig = new InjectionToken('InjectTokenNextSolutionsConfig'); class CvaCustomDialogComponent { translateService; dialogRef; injector; data; config; get DialogTypeEnum() { return DialogTypeEnum; } inputText = ''; errorInputText = ''; isError = false; constructor(translateService, dialogRef, injector, ngControl, data) { this.translateService = translateService; this.dialogRef = dialogRef; this.injector = injector; this.data = data; if (ngControl) { // Hành động này thay cho provide: NG_VALUE_ACCESSOR và gắn ControlValueAccessor này vào parent FormControl ngControl.valueAccessor = this; } this.config = injector.get(InjectTokenNextSolutionsConfig); } writeValue(obj) { this.inputText = obj; } propagateChange = (_) => { /*NON-EMPTY FOR COMPILE*/ }; registerOnChange(fn) { this.propagateChange = fn; } registerOnTouched(fn) { } ngOnInit() { } onConfirm() { if (this.data && this.data.type) { if (this.data.type === DialogTypeEnum.INPUT_CONFIRM) { this.isError = !this.inputText.trim(); if (this.isError) { this.errorInputText = !!this.data?.errorMsg ? this.translateService.instant(this.data.errorMsg) : this.translateService.instant('common.required'); return; } this.dialogRef.close({ value: this.inputText }); } else { this.dialogRef.close({ value: 1 }); } } } onCancel() { this.dialogRef.close(); } onChangeInput() { this.isError = !this.inputText.trim(); if (this.isError) { this.errorInputText = !!this.data?.errorMsg ? this.translateService.instant(this.data.errorMsg) : this.translateService.instant('common.required'); } } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: CvaCustomDialogComponent, deps: [{ token: i1.TranslateService }, { token: i1$1.MatDialogRef }, { token: i0.Injector }, { token: i1$2.NgControl, optional: true, self: true }, { token: MAT_DIALOG_DATA }], target: i0.ɵɵFactoryTarget.Component }); static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.5", type: CvaCustomDialogComponent, isStandalone: false, selector: "cva-custom-dialog", ngImport: i0, template: ` <div class="cva-custom-dialog dialog-content {{data.customClass}}" *ngIf="data" style="padding-bottom: 0px !important;" fxLayout="column"> <div class="img" fxLayoutAlign="center center" fxLayout *ngIf="config && config.DIALOG_LOGO"> <img src="{{config.DIALOG_LOGO}}" alt="confirm-logo" /> </div> <div class="content" fxLayoutAlign="start stretch" fxLayout="column"> <div class="text-msg"> {{ data && data.msg ? data.msg : '' }} </div> <div class="text-msg-detail" *ngIf="data && data.msgDetail"> {{ data.msgDetail }} </div> <!-- <div class="text-error" *ngIf="data.type === DialogTypeEnum.ERROR">--> <!-- {{data && data.msg ? data.msg : ''}}--> <!-- </div>--> <!-- <div class="text-area" *ngIf="data.type === DialogTypeEnum.INPUT_CONFIRM"--> <!-- fxLayoutAlign="center center"--> <!-- fxLayout="column">--> <!-- <label fxLayoutAlign="center center"--> <!-- fxLayout>{{data && data.msg ? data.msg : ''}}</label>--> <mat-form-field appearance="outline" class="input-confirm-dialog" fxFlex="100%" fxLayout="column" *ngIf="data.type === DialogTypeEnum.INPUT_CONFIRM"> <textarea matInput [(ngModel)]="inputText" fxFlex="100%" maxlength="{{(data && !!data.maxLength) ? data.maxLength : 524288}}" (ngModelChange)="onChangeInput()"></textarea> <span *ngIf="!!data && !!data.maxLength" class="input-suffix" matSuffix>{{ (inputText?.length ? inputText.length : 0) + '/' + data.maxLength }}</span> <mat-hint style="color: red" *ngIf="isError">{{ errorInputText }}</mat-hint> </mat-form-field> <!-- </div>--> </div> </div> <hr class="display-hr-tag" *ngIf="data.type !== DialogTypeEnum.INPUT_CONFIRM"> <div class="buttonArea margin-top-10"> <button mat-button class="{{data.btnCancelClass ? data.btnCancelClass : 'primary outline'}} btn-Cancel" *ngIf="data.type !== DialogTypeEnum.ERROR" (click)="onCancel()"> <i *ngIf="!data.hideIconButton" class="{{data.btnCancel_IconClass ? data.btnCancel_IconClass : 'fa fa-times' }}"></i> {{ data && data.btnCancelString ? data.btnCancelString : ('common.Cancel' | translate) }} </button> <button mat-button class="{{data.btnOKClass ? data.btnOKClass : 'primary'}} btn-OK" (click)="onConfirm()"> <i *ngIf="!data.hideIconButton" class="{{data.btnOK_IconClass ? data.btnOK_IconClass : 'fa fa-check'}}"></i> {{ data && data.btnOKString ? data.btnOKString : ('common.OK' | translate) }} </button> </div> `, isInline: true, dependencies: [{ kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1$2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1$2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$2.MaxLengthValidator, selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]", inputs: ["maxlength"] }, { kind: "directive", type: i1$2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: i3.MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", exportAs: ["matButton"] }, { kind: "component", type: i6.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i6.MatHint, selector: "mat-hint", inputs: ["align", "id"] }, { kind: "directive", type: i6.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "directive", type: i8.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "directive", type: i8$1.DefaultLayoutDirective, selector: " [fxLayout], [fxLayout.xs], [fxLayout.sm], [fxLayout.md], [fxLayout.lg], [fxLayout.xl], [fxLayout.lt-sm], [fxLayout.lt-md], [fxLayout.lt-lg], [fxLayout.lt-xl], [fxLayout.gt-xs], [fxLayout.gt-sm], [fxLayout.gt-md], [fxLayout.gt-lg]", inputs: ["fxLayout", "fxLayout.xs", "fxLayout.sm", "fxLayout.md", "fxLayout.lg", "fxLayout.xl", "fxLayout.lt-sm", "fxLayout.lt-md", "fxLayout.lt-lg", "fxLayout.lt-xl", "fxLayout.gt-xs", "fxLayout.gt-sm", "fxLayout.gt-md", "fxLayout.gt-lg"] }, { kind: "directive", type: i8$1.DefaultLayoutAlignDirective, selector: " [fxLayoutAlign], [fxLayoutAlign.xs], [fxLayoutAlign.sm], [fxLayoutAlign.md], [fxLayoutAlign.lg], [fxLayoutAlign.xl], [fxLayoutAlign.lt-sm], [fxLayoutAlign.lt-md], [fxLayoutAlign.lt-lg], [fxLayoutAlign.lt-xl], [fxLayoutAlign.gt-xs], [fxLayoutAlign.gt-sm], [fxLayoutAlign.gt-md], [fxLayoutAlign.gt-lg]", inputs: ["fxLayoutAlign", "fxLayoutAlign.xs", "fxLayoutAlign.sm", "fxLayoutAlign.md", "fxLayoutAlign.lg", "fxLayoutAlign.xl", "fxLayoutAlign.lt-sm", "fxLayoutAlign.lt-md", "fxLayoutAlign.lt-lg", "fxLayoutAlign.lt-xl", "fxLayoutAlign.gt-xs", "fxLayoutAlign.gt-sm", "fxLayoutAlign.gt-md", "fxLayoutAlign.gt-lg"] }, { kind: "directive", type: i8$1.DefaultFlexDirective, selector: " [fxFlex], [fxFlex.xs], [fxFlex.sm], [fxFlex.md], [fxFlex.lg], [fxFlex.xl], [fxFlex.lt-sm], [fxFlex.lt-md], [fxFlex.lt-lg], [fxFlex.lt-xl], [fxFlex.gt-xs], [fxFlex.gt-sm], [fxFlex.gt-md], [fxFlex.gt-lg]", inputs: ["fxFlex", "fxFlex.xs", "fxFlex.sm", "fxFlex.md", "fxFlex.lg", "fxFlex.xl", "fxFlex.lt-sm", "fxFlex.lt-md", "fxFlex.lt-lg", "fxFlex.lt-xl", "fxFlex.gt-xs", "fxFlex.gt-sm", "fxFlex.gt-md", "fxFlex.gt-lg"] }, { kind: "pipe", type: i1.TranslatePipe, name: "translate" }] }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: CvaCustomDialogComponent, decorators: [{ type: Component, args: [{ selector: 'cva-custom-dialog', standalone: false, template: ` <div class="cva-custom-dialog dialog-content {{data.customClass}}" *ngIf="data" style="padding-bottom: 0px !important;" fxLayout="column"> <div class="img" fxLayoutAlign="center center" fxLayout *ngIf="config && config.DIALOG_LOGO"> <img src="{{config.DIALOG_LOGO}}" alt="confirm-logo" /> </div> <div class="content" fxLayoutAlign="start stretch" fxLayout="column"> <div class="text-msg"> {{ data && data.msg ? data.msg : '' }} </div> <div class="text-msg-detail" *ngIf="data && data.msgDetail"> {{ data.msgDetail }} </div> <!-- <div class="text-error" *ngIf="data.type === DialogTypeEnum.ERROR">--> <!-- {{data && data.msg ? data.msg : ''}}--> <!-- </div>--> <!-- <div class="text-area" *ngIf="data.type === DialogTypeEnum.INPUT_CONFIRM"--> <!-- fxLayoutAlign="center center"--> <!-- fxLayout="column">--> <!-- <label fxLayoutAlign="center center"--> <!-- fxLayout>{{data && data.msg ? data.msg : ''}}</label>--> <mat-form-field appearance="outline" class="input-confirm-dialog" fxFlex="100%" fxLayout="column" *ngIf="data.type === DialogTypeEnum.INPUT_CONFIRM"> <textarea matInput [(ngModel)]="inputText" fxFlex="100%" maxlength="{{(data && !!data.maxLength) ? data.maxLength : 524288}}" (ngModelChange)="onChangeInput()"></textarea> <span *ngIf="!!data && !!data.maxLength" class="input-suffix" matSuffix>{{ (inputText?.length ? inputText.length : 0) + '/' + data.maxLength }}</span> <mat-hint style="color: red" *ngIf="isError">{{ errorInputText }}</mat-hint> </mat-form-field> <!-- </div>--> </div> </div> <hr class="display-hr-tag" *ngIf="data.type !== DialogTypeEnum.INPUT_CONFIRM"> <div class="buttonArea margin-top-10"> <button mat-button class="{{data.btnCancelClass ? data.btnCancelClass : 'primary outline'}} btn-Cancel" *ngIf="data.type !== DialogTypeEnum.ERROR" (click)="onCancel()"> <i *ngIf="!data.hideIconButton" class="{{data.btnCancel_IconClass ? data.btnCancel_IconClass : 'fa fa-times' }}"></i> {{ data && data.btnCancelString ? data.btnCancelString : ('common.Cancel' | translate) }} </button> <button mat-button class="{{data.btnOKClass ? data.btnOKClass : 'primary'}} btn-OK" (click)="onConfirm()"> <i *ngIf="!data.hideIconButton" class="{{data.btnOK_IconClass ? data.btnOK_IconClass : 'fa fa-check'}}"></i> {{ data && data.btnOKString ? data.btnOKString : ('common.OK' | translate) }} </button> </div> ` }] }], ctorParameters: () => [{ type: i1.TranslateService }, { type: i1$1.MatDialogRef }, { type: i0.Injector }, { type: i1$2.NgControl, decorators: [{ type: Self }, { type: Optional }] }, { type: CustomDialogDataConfigModel, decorators: [{ type: Inject, args: [MAT_DIALOG_DATA] }] }] }); class UtilsService { dialog; transService; toastr; constructor(dialog, transService, toastr) { this.dialog = dialog; this.transService = transService; this.toastr = toastr; } static getEnumValue(o, value) { return o['_' + value]; // No type safety here unfrotunately } static calcPosition(e, results, paging) { return (paging ? ((paging.pageNumber - 1) * paging.pageSize) : 0) + (results.data.indexOf(e) + 1); } static reduceEntityAttributeForFormControl(formGroup, e, dateRangeConfigList) { return Object.keys(formGroup.controls).reduce(reduceEntityAttributeForFormControlByControlName, {}); function reduceEntityAttributeForFormControlByControlName(formControl, ctrlName) { if (e) { let includesOfDateRangeConfig = false; if (dateRangeConfigList) { for (const dateRangeConfig of dateRangeConfigList) { if (dateRangeConfig && [dateRangeConfig.dateRangeControlName, dateRangeConfig.fromDateControlName, dateRangeConfig.toDateControlName].includes(ctrlName)) { includesOfDateRangeConfig = true; switch (ctrlName) { case dateRangeConfig.dateRangeControlName: formControl[ctrlName] = { fromDate: e[dateRangeConfig.fromDateControlName] ? e[dateRangeConfig.fromDateControlName] : null, toDate: e[dateRangeConfig.toDateControlName] ? e[dateRangeConfig.toDateControlName] : null, }; break; case dateRangeConfig.fromDateControlName: formControl[ctrlName] = e[ctrlName]; if (formControl[dateRangeConfig.dateRangeControlName] && typeof (formControl[dateRangeConfig.dateRangeControlName]) === 'object') { formControl[dateRangeConfig.dateRangeControlName].fromDate = e[ctrlName]; } break; case dateRangeConfig.toDateControlName: formControl[ctrlName] = e[ctrlName]; if (formControl[dateRangeConfig.dateRangeControlName] && typeof (formControl[dateRangeConfig.dateRangeControlName]) === 'object') { formControl[dateRangeConfig.dateRangeControlName].toDate = e[ctrlName]; } break; default: break; } } } } if (!includesOfDateRangeConfig) { if (typeof (e[ctrlName]) === 'boolean') { formControl[ctrlName] = e[ctrlName] ? '1' : '0'; } else if (e[ctrlName] instanceof Array) { formControl[ctrlName] = e[ctrlName]; } else if (typeof (e[ctrlName]) === 'object') { formControl[ctrlName] = e[ctrlName] ? (e[ctrlName].id ? e[ctrlName].id : (e[ctrlName].code ? e[ctrlName].code : '')) : null; } else { formControl[ctrlName] = (e[ctrlName] != null && e[ctrlName] != undefined) ? e[ctrlName] : ''; } } } else { formControl[ctrlName] = ''; } return formControl; } } static cloneAbstractControl(control) { let newControl; if (control instanceof FormGroup) { const formGroup = new FormGroup({}, control.validator, control.asyncValidator); const controls = control.controls; if (controls) { Object.keys(controls).forEach(key => { const tempControl = UtilsService.cloneAbstractControl(controls[key]); if (tempControl) { formGroup.addControl(key, tempControl); } }); } newControl = formGroup; } else if (control instanceof FormArray) { const formArray = new FormArray([], control.validator, control.asyncValidator); const controls = control.controls; if (controls) { controls.forEach((formControl) => { const tempControl = UtilsService.cloneAbstractControl(formControl); if (tempControl) { formArray.push(tempControl); } }); } newControl = formArray; } else if (control instanceof FormControl || this.isNgControl(control)) { newControl = new FormControl(control.value, control.validator, control.asyncValidator); } else { console.error('Error: unexpected formControl value', control); } if (control.disabled && newControl) newControl.disable({ emitEvent: false }); return newControl; } static isNgControl(control) { return control && 'control' in control; } static convertTreeDataToAutocompleteData(treeFields, symbol, hasChildFn, nodes, prefixDisplayValue) { let result = []; if (treeFields) { for (const node of nodes) { const value = treeFields.value(node).toString(); const displayValue = prefixDisplayValue ? prefixDisplayValue + symbol + treeFields.display(node) : treeFields.display(node); const hasChild = hasChildFn(0, node); if (hasChild) { const childen = treeFields.children(node); result.push(...this.convertTreeDataToAutocompleteData(treeFields, symbol, hasChildFn, childen, displayValue)); } else { result.push(new SelectModel(value, displayValue, hasChild, node)); } } } return result; } strFormat(str, replacement) { let a = this.transService.instant(str); if (replacement === null || replacement === undefined || replacement.length === 0) { return a; } replacement.forEach((value, index) => { a = a.replace('{' + index + '}', this.transService.instant(value)); }); return a; } onSuccessFunc = (onSuccessMessage) => { if (onSuccessMessage) { const msg = this.transService.instant(onSuccessMessage); this.toastr.toastrConfig.positionClass = 'toast-bottom-right'; this.toastr.success(msg); } }; showWarningToarst(msgKey, replacement) { const msg = this.strFormat(msgKey, replacement); this.toastr.toastrConfig.positionClass = 'toast-bottom-right'; this.toastr.warning(msg); } showErrorToarst(msgKey, replacement) { const msg = this.strFormat(msgKey, replacement); this.toastr.toastrConfig.positionClass = 'toast-bottom-right'; this.toastr.error(msg); } showError = (err) => { let errLocale = ''; if (err !== undefined && err !== null) { errLocale = this.transService.instant(err); } this.dialog.open(CvaCustomDialogComponent, { width: '500px', data: { msg: `${errLocale}`, type: DialogTypeEnum.ERROR, }, }); }; execute3(apiCall, onSuccessFunc, onSuccessMessage, onErrorFunc) { if (!apiCall) { if (onSuccessFunc) { onSuccessFunc(null); } return; } apiCall.subscribe((data) => { if (onSuccessFunc) { if (onSuccessMessage) { onSuccessFunc(data, onSuccessMessage); } else { onSuccessFunc(data); } } else { this.onSuccessFunc(onSuccessMessage); } }, (error1) => { if (error1 !== '401') { if (!!onErrorFunc) { onErrorFunc(error1); } if (error1 === '0') { this.showErrorToarst('error.serverNotResponse'); } else { this.showError(error1); } } }); } execute(apiCall, onSuccessFunc, onSuccessMessage, confirmMsgTitle, confirmMsgTitleParamsFormat = [], confirmMsgDetail = '', confirmMsgDetailParamsFormat = [], confirmDialogConfig = undefined, confirmDialogButtonOk = 'common.OK', confirmDialogButtonCancel = 'common.Cancel') { if (confirmMsgTitle !== undefined && confirmMsgTitle !== null && confirmMsgTitle !== '') { this.showConfirmDialog(confirmMsgTitle, confirmMsgTitleParamsFormat, confirmMsgDetail, confirmMsgDetailParamsFormat, confirmDialogConfig, confirmDialogButtonOk, confirmDialogButtonCancel) .afterClosed().subscribe(result => { if (result && result.value) { this.execute3(apiCall, onSuccessFunc, onSuccessMessage); } }); } else { this.execute3(apiCall, onSuccessFunc, onSuccessMessage); } } executeWithErrorHandle(method, onSuccessFunc, onSuccessMessage, confirmMsgTitle, confirmMsgParamsFormat = [], confirmMsgDetail = '', confirmMsgDetailParamsFormat = [], onErrorFunc, dialogConfig, confirmDialogButtonOk = 'common.OK', confirmDialogButtonCancel = 'common.Cancel') { if (confirmMsgTitle !== undefined && confirmMsgTitle !== null && confirmMsgTitle !== '') { this.showConfirmDialog(confirmMsgTitle, confirmMsgParamsFormat, confirmMsgDetail, confirmMsgDetailParamsFormat, dialogConfig, confirmDialogButtonOk, confirmDialogButtonCancel) .afterClosed().subscribe((result) => { if (result && result.value) { this.execute3(method(), onSuccessFunc, onSuccessMessage, onErrorFunc); } }); } else { this.execute3(method(), onSuccessFunc, onSuccessMessage, onErrorFunc); } } showConfirmDialog(strTitle, replacementTitle, strDetailMsg = '', replacementDetail = [], confirmDialogConfig = undefined, strOkText = 'common.OK', strCancelTex = 'common.Cancel', strCustomClass) { const msgTitle = this.strFormat(strTitle, replacementTitle); const msgDetail = !!strDetailMsg ? this.strFormat(strDetailMsg, replacementDetail) : ''; const strOk = this.transService.instant(strOkText); const strCancel = this.transService.instant(strCancelTex); const re = /\./gi; const customClass = (strCustomClass ? strCustomClass : strTitle).replace(re, '-'); return this.dialog.open(CvaCustomDialogComponent, confirmDialogConfig ? confirmDialogConfig : { width: '500px', data: { customClass: customClass, msg: msgTitle, msgDetail: msgDetail, type: DialogTypeEnum.CONFIRM, btnOKString: strOk, btnCanceString: strCancel, }, }); } showConfirmInputDialog(str1, replacement, confirmInputDialogConfig = undefined, strOkText = 'common.OK', strCancelTex = 'common.Cancel', strCustomClass) { const str = this.strFormat(str1, replacement); const strOk = this.transService.instant(strOkText); const strCancel = this.transService.instant(strCancelTex); const re = /\./gi; const customClass = (strCustomClass ? strCustomClass : str1).replace(re, '-'); return this.dialog.open(CvaCustomDialogComponent, confirmInputDialogConfig ? confirmInputDialogConfig : { width: '500px', data: { customClass: customClass, msg: str, type: DialogTypeEnum.INPUT_CONFIRM, btnOKString: strOk, btnCancelString: strCancel, }, }); } getEnumValueTranslated(o, value) { const key = o['_' + value]; // No type safety here unfrotunately return this.transService.instant(key); } toBlobJon(obj) { return new Blob([JSON.stringify(obj)], { type: 'application/json', }); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: UtilsService, deps: [{ token: i1$1.MatDialog }, { token: i1.TranslateService }, { token: i3$1.ToastrService }], target: i0.ɵɵFactoryTarget.Injectable }); static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: UtilsService, providedIn: 'root' }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: UtilsService, decorators: [{ type: Injectable, args: [{ providedIn: 'root' }] }], ctorParameters: () => [{ type: i1$1.MatDialog }, { type: i1.TranslateService }, { type: i3$1.ToastrService }] }); class ApiService { http; fileSaver; injector; config; constructor(http, fileSaver, injector) { this.http = http; this.fileSaver = fileSaver; this.injector = injector; this.config = injector.get(InjectTokenNextSolutionsConfig); } getFullUrl(url) { return this.config.BASE_URL + url; } get(nativeUrl, params, baseUrl) { return this.http.get(baseUrl ? (baseUrl + nativeUrl) : this.getFullUrl(nativeUrl), { params }); } getJSON(file) { return this.http.get(file); } getBlob(nativeUrl, params, baseUrl) { const url = baseUrl ? (baseUrl + nativeUrl) : this.getFullUrl(nativeUrl); return this.http.get(url, { responseType: 'blob', // Đặt responseType thành 'blob' }); } post(nativeUrl, obj, options, baseUrl) { return this.http.post(baseUrl ? (baseUrl + nativeUrl) : this.getFullUrl(nativeUrl), obj, options ? { headers: options.headers, params: options.params, } : {}); } postBlob(nativeUrl, obj, options, baseUrl) { return this.http.post(baseUrl ? (baseUrl + nativeUrl) : this.getFullUrl(nativeUrl), obj, { headers: options.headers, params: options.params, observe: 'response', responseType: 'blob', }); } patch(nativeUrl, obj, options, baseUrl) { return this.http.patch(baseUrl ? (baseUrl + nativeUrl) : this.getFullUrl(nativeUrl), obj, options ? { headers: options.headers, params: options.params } : {}); } put(nativeUrl, obj, options, baseUrl) { return this.http.put(baseUrl ? (baseUrl + nativeUrl) : this.getFullUrl(nativeUrl), obj, options ? { headers: options.headers, params: options.params } : {}); } delete(nativeUrl, options, baseUrl) { return this.http.delete(baseUrl ? (baseUrl + nativeUrl) : this.getFullUrl(nativeUrl), options ? { headers: options.headers, params: options.params, } : {}); } saveFile(nativeUrl, obj, options, baseUrl, onErrorFunc) { this.http.post(baseUrl ? (baseUrl + nativeUrl) : this.getFullUrl(nativeUrl), obj, { headers: options.headers, params: options.params, observe: 'response', responseType: 'blob', }).subscribe((l) => { let filename = ''; const disposition = l.headers.get('Content-Disposition'); if (disposition && disposition.indexOf('attachment') !== -1) { const filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/; const matches = filenameRegex.exec(disposition); if (matches != null && matches[1]) { filename = matches[1].replace(/['"]/g, ''); } } const blobData = l.body; const contentType = l.headers.get('Content-Type'); if (blobData && contentType) { this.fileSaver.save(blobData, filename, contentType); } }, (err) => { if (onErrorFunc) { onErrorFunc(err); } }); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: ApiService, deps: [{ token: i1$3.HttpClient }, { token: i2$1.FileSaverService }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: ApiService, providedIn: 'root' }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: ApiService, decorators: [{ type: Injectable, args: [{ providedIn: 'root' }] }], ctorParameters: () => [{ type: i1$3.HttpClient }, { type: i2$1.FileSaverService }, { type: i0.Injector }] }); class FormStateService { subject = new BehaviorSubject(new Map()); uiState$ = this.subject.asObservable(); setMapState(mapState) { this.subject.next(mapState); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: FormStateService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: FormStateService, providedIn: 'root' }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: FormStateService, decorators: [{ type: Injectable, args: [{ providedIn: 'root' }] }] }); class AuthoritiesService { me = null; stateMe = new BehaviorSubject(new OAuth2AuthenticationDto()); me$ = this.stateMe.asObservable(); hasAuthorities(authorities) { if (!authorities) { return false; } let checkAuthority = false; for (const authority of authorities) { checkAuthority = checkAuthority || this.hasAuthority(authority.toLowerCase()); if (checkAuthority) { break; } } return checkAuthority; } hasAuthority(authority) { if (!authority || !this.me || !this.me.authorities) { return false; } return this.me.authorities.map(x => x.authority.toString().toLowerCase()).includes(authority.toLowerCase()); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: AuthoritiesService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: AuthoritiesService, providedIn: 'root' }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: AuthoritiesService, dec