UNPKG

ontimize-web-ngx

Version:
1,277 lines (1,266 loc) 2.82 MB
import * as i0 from '@angular/core'; import { InjectionToken, Pipe, EventEmitter, Directive, Host, Self, Optional, Input, HostListener, forwardRef, Output, Injectable, Injector, Component, ContentChildren, ChangeDetectorRef, NgModule, ViewChild, ElementRef, ViewEncapsulation, ViewContainerRef, Inject, NgZone, HostBinding, ViewChildren, ChangeDetectionStrategy, inject, CUSTOM_ELEMENTS_SCHEMA, TemplateRef, SkipSelf, isDevMode, ContentChild, Renderer2, APP_INITIALIZER } from '@angular/core'; import moment from 'moment'; import { isObservable, from, of, Subscription, Observable, Subject, share as share$1, timer, combineLatest, BehaviorSubject, ReplaySubject, concatMap, delay, merge, takeUntil as takeUntil$1, take as take$1, asyncScheduler, EMPTY, fromEvent, distinctUntilChanged as distinctUntilChanged$1, map as map$1, shareReplay, tap, filter as filter$1 } from 'rxjs'; export { Observable, Subject } from 'rxjs'; import * as i1$7 from '@angular/common/http'; import { HttpClient, HttpHeaders, HttpRequest, HttpEventType, HttpErrorResponse, HttpClientModule } from '@angular/common/http'; import { DomSanitizer, BrowserModule } from '@angular/platform-browser'; import { BrowserAnimationsModule, NoopAnimationsModule } from '@angular/platform-browser/animations'; import * as i2$2 from '@ngx-translate/core'; import { TranslateService, TranslateDefaultParser, TranslateModule, TranslateLoader, TranslateParser } from '@ngx-translate/core'; import * as i10 from 'ngx-material-timepicker'; import { TimepickerDirective, NgxMaterialTimepickerModule } from 'ngx-material-timepicker'; import * as i1$2 from '@angular/common'; import { Location, CommonModule, DOCUMENT, LOCATION_INITIALIZED } from '@angular/common'; import * as i1 from '@angular/router'; import { Router, NavigationStart, NavigationEnd, RouterModule, ActivatedRoute } from '@angular/router'; import * as i2$1 from '@angular/flex-layout'; import { FlexLayoutModule, MediaObserver } from '@angular/flex-layout'; import * as i3$3 from '@angular/forms'; import { NG_VALUE_ACCESSOR, UntypedFormControl, UntypedFormGroup, Validators, FormsModule, ReactiveFormsModule, FormGroup } from '@angular/forms'; import { __decorate, __metadata } from 'tslib'; import { coerceNumberProperty } from '@angular/cdk/coercion'; import * as i1$1 from '@angular/material/dialog'; import { MatDialog, MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog'; import { MatSnackBar, MatSnackBarRef, MatSnackBarModule } from '@angular/material/snack-bar'; import * as i2 from '@angular/flex-layout/flex'; import * as i3 from '@angular/material/button'; import { MatButtonModule } from '@angular/material/button'; import * as i5 from '@angular/material/icon'; import { MatIconModule } from '@angular/material/icon'; import { map, share, filter, catchError, debounceTime, distinctUntilChanged, takeUntil, take, observeOn, switchMap, delay as delay$1 } from 'rxjs/operators'; import * as i1$3 from '@angular/cdk/overlay'; import { OverlayModule, OverlayConfig } from '@angular/cdk/overlay'; import { ComponentPortal, DomPortalOutlet, TemplatePortal, PortalModule } from '@angular/cdk/portal'; import * as i4 from '@angular/material/menu'; import { MatMenuTrigger, MatMenuModule } from '@angular/material/menu'; import * as i3$1 from '@angular/material/divider'; import * as i3$2 from '@angular/material/toolbar'; import { MatToolbarModule } from '@angular/material/toolbar'; import * as i7 from '@angular/material/progress-bar'; import { MatProgressBarModule } from '@angular/material/progress-bar'; import * as i8 from '@angular/material/form-field'; import { MatError, MatSuffix, MatFormFieldModule, MAT_FORM_FIELD_DEFAULT_OPTIONS } from '@angular/material/form-field'; import { SelectionModel, DataSource } from '@angular/cdk/collections'; import * as i5$1 from '@angular/material/list'; import { MatSelectionList, MatListModule, MatListItemLine, MatListItemTitle } from '@angular/material/list'; import * as i7$1 from '@angular/material/input'; import { MatInputModule } from '@angular/material/input'; import * as i9 from '@angular/material/tooltip'; import { MatTooltipModule, MatTooltip } from '@angular/material/tooltip'; import * as i7$4 from '@angular/cdk/scrolling'; import { ScrollingModule, VIRTUAL_SCROLL_STRATEGY } from '@angular/cdk/scrolling'; import { MatAutocompleteModule } from '@angular/material/autocomplete'; import * as i11 from '@angular/material/badge'; import { MatBadgeModule } from '@angular/material/badge'; import * as i6 from '@angular/material/button-toggle'; import { MatButtonToggleModule, MatButtonToggleGroup } from '@angular/material/button-toggle'; import * as i4$4 from '@angular/material/card'; import { MatCardModule } from '@angular/material/card'; import * as i5$2 from '@angular/material/checkbox'; import { MatCheckboxModule } from '@angular/material/checkbox'; import { MatChipsModule } from '@angular/material/chips'; import * as i1$4 from '@angular/material/core'; import { MatRippleModule, MAT_DATE_FORMATS, MAT_DATE_LOCALE, DateAdapter, AnimationDurations, MAT_RIPPLE_GLOBAL_OPTIONS } from '@angular/material/core'; import * as i8$1 from '@angular/material/datepicker'; import { MatDatepickerModule, MatDatepickerInput } from '@angular/material/datepicker'; import * as i3$4 from '@angular/material/expansion'; import { MatExpansionModule } from '@angular/material/expansion'; import * as i7$3 from '@angular/material/grid-list'; import { MatGridListModule } from '@angular/material/grid-list'; import * as i11$1 from '@angular/material/paginator'; import { MatPaginatorModule, MatPaginator, MatPaginatorIntl } from '@angular/material/paginator'; import * as i5$3 from '@angular/material/progress-spinner'; import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; import * as i7$5 from '@angular/material/radio'; import { MatRadioModule, MatRadioGroup } from '@angular/material/radio'; import * as i3$5 from '@angular/material/select'; import { MatSelectModule, MatSelect } from '@angular/material/select'; import * as i3$6 from '@angular/material/sidenav'; import { MatSidenavModule, MatSidenav } from '@angular/material/sidenav'; import * as i6$2 from '@angular/material/slide-toggle'; import { MatSlideToggleModule } from '@angular/material/slide-toggle'; import * as i4$3 from '@angular/material/slider'; import { MatSliderModule } from '@angular/material/slider'; import * as i1$6 from '@angular/material/sort'; import { MatSortModule, MatSort, MatSortHeader, matSortAnimations, MAT_SORT_HEADER_INTL_PROVIDER } from '@angular/material/sort'; import * as i14 from '@angular/material/table'; import { MatTableModule, MatTable, MatRow } from '@angular/material/table'; import * as i6$1 from '@angular/material/tabs'; import { MatTabsModule, MatTabGroup, MatTab } from '@angular/material/tabs'; import { MatMomentDateModule, MomentDateAdapter } from '@angular/material-moment-adapter'; import * as i4$1 from '@angular/flex-layout/extended'; import { TranslateHttpLoader } from '@ngx-translate/http-loader'; import * as i7$2 from '@angular/cdk/drag-drop'; import { moveItemInArray, transferArrayItem, DragDropModule } from '@angular/cdk/drag-drop'; import * as i4$2 from 'angular-resizable-element'; import { ResizableModule } from 'angular-resizable-element'; import * as i3$7 from 'ngx-skeleton-loader'; import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; import * as i1$5 from '@angular/cdk/layout'; import { Breakpoints } from '@angular/cdk/layout'; import { ESCAPE, UP_ARROW } from '@angular/cdk/keycodes'; import * as lpn from 'google-libphonenumber'; import { trigger, state, style, transition, animate } from '@angular/animations'; import * as i18 from '@angular/cdk/observers'; import { ObserversModule } from '@angular/cdk/observers'; import * as i5$4 from '@angular/cdk/table'; import { CdkTableModule } from '@angular/cdk/table'; import * as i3$8 from '@angular/cdk/a11y'; import { FlatTreeControl, CdkTreeModule } from '@angular/cdk/tree'; import * as i11$2 from '@angular/material/tree'; import { MatTreeModule } from '@angular/material/tree'; class Base64 { static decode(s) { let pads = 0, i, b10, imax = s.length, x = []; s = String(s); if (imax === 0) { return s; } if (s.charAt(imax - 1) === this.PADCHAR) { pads = 1; if (s.charAt(imax - 2) === this.PADCHAR) { pads = 2; } imax -= 4; } for (i = 0; i < imax; i += 4) { b10 = (this.getByte64(s, i) << 18) | (this.getByte64(s, i + 1) << 12) | (this.getByte64(s, i + 2) << 6) | this.getByte64(s, i + 3); x.push(String.fromCharCode(b10 >> 16, (b10 >> 8) & 255, b10 & 255)); } switch (pads) { case 1: b10 = (this.getByte64(s, i) << 18) | (this.getByte64(s, i + 1) << 12) | (this.getByte64(s, i + 2) << 6); x.push(String.fromCharCode(b10 >> 16, (b10 >> 8) & 255)); break; case 2: b10 = (this.getByte64(s, i) << 18) | (this.getByte64(s, i + 1) << 12); x.push(String.fromCharCode(b10 >> 16)); break; } return x.join(''); } static encode(s) { s = String(s); let i, b10, x = [], imax = s.length - s.length % 3; if (s.length === 0) { return s; } for (i = 0; i < imax; i += 3) { b10 = (this.getByte(s, i) << 16) | (this.getByte(s, i + 1) << 8) | this.getByte(s, i + 2); x.push(this.ALPHA.charAt(b10 >> 18)); x.push(this.ALPHA.charAt((b10 >> 12) & 63)); x.push(this.ALPHA.charAt((b10 >> 6) & 63)); x.push(this.ALPHA.charAt(b10 & 63)); } switch (s.length - imax) { case 1: b10 = this.getByte(s, i) << 16; x.push(this.ALPHA.charAt(b10 >> 18) + this.ALPHA.charAt((b10 >> 12) & 63) + this.PADCHAR + this.PADCHAR); break; case 2: b10 = (this.getByte(s, i) << 16) | (this.getByte(s, i + 1) << 8); x.push(this.ALPHA.charAt(b10 >> 18) + this.ALPHA.charAt((b10 >> 12) & 63) + this.ALPHA.charAt((b10 >> 6) & 63) + this.PADCHAR); break; } return x.join(''); } static getByte(s, i) { const x = s.charCodeAt(i); return x; } static getByte64(s, i) { const idx = this.ALPHA.indexOf(s.charAt(i)); return idx; } } Base64.PADCHAR = '='; Base64.ALPHA = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; class Codes { static isDoubleClickMode(value) { return Codes.DETAIL_MODE_DBLCLICK_VALUES.indexOf(value) !== -1; } static isValidRowHeight(value) { return Codes.AVAILABLE_ROW_HEIGHTS_VALUES.indexOf(value) !== -1; } static getIsDetailObject() { const res = {}; res[Codes.IS_DETAIL] = 'true'; return res; } static formatString(format) { return (format === Codes.TWENTY_FOUR_HOUR_FORMAT ? Codes.HourFormat.TWENTY_FOUR : Codes.HourFormat.TWELVE); } static isHourInputAllowed(e) { if ([46, 8, 9, 27, 13].some(n => n === e.keyCode) || (e.key === ':') || (e.keyCode === 65 && (e.ctrlKey === true || e.metaKey === true)) || (e.keyCode === 67 && (e.ctrlKey === true || e.metaKey === true)) || (e.keyCode === 88 && (e.ctrlKey === true || e.metaKey === true)) || (e.keyCode >= 35 && e.keyCode <= 40)) { return true; } return !((e.keyCode < 48 || e.keyCode > 57) && (e.keyCode < 96 || e.keyCode > 105)); } static isValidEditionMode(editionMode) { return Codes.AVAILABLE_MODES.indexOf(editionMode) !== -1; } static isValidDetailMode(detailMode) { return Codes.AVAILABLE_DETAIL_MODES.indexOf(detailMode) !== -1; } } Codes.PAGINATED_QUERY_METHOD = 'advancedQuery'; Codes.DELETE_METHOD = 'delete'; Codes.INSERT_METHOD = 'insert'; Codes.UPDATE_METHOD = 'update'; Codes.QUERY_METHOD = 'query'; Codes.QUERYBYID_METHOD = 'queryById'; Codes.DEFAULT_QUERY_ROWS = 10; Codes.PAGE_SIZE_OPTIONS = [10, 25, 50, 100]; Codes.DETAIL_ICON = 'chevron_right'; Codes.EDIT_ICON = 'mode_edit'; Codes.DEFAULT_ROW_HEIGHT = 'medium'; Codes.AVAILABLE_ROW_HEIGHTS_VALUES = ['small', 'medium', 'large']; Codes.DETAIL_MODE_NONE = 'none'; Codes.DETAIL_MODE_CLICK = 'click'; Codes.DETAIL_MODE_DBLCLICK_VALUES = ['dblclick', 'doubleclick']; Codes.AVAILABLE_DETAIL_MODES = [Codes.DETAIL_MODE_NONE, Codes.DETAIL_MODE_CLICK, ...Codes.DETAIL_MODE_DBLCLICK_VALUES]; Codes.EDITION_MODE_NONE = 'none'; Codes.EDITION_MODE_CLICK = 'click'; Codes.EDITION_MODE_DBLCLICK_VALUES = ['dblclick', 'doubleclick']; Codes.AVAILABLE_MODES = [Codes.EDITION_MODE_NONE, Codes.EDITION_MODE_CLICK, ...Codes.EDITION_MODE_DBLCLICK_VALUES]; Codes.SELECTION_MODE_NONE = 'none'; Codes.SELECTION_MODE_SINGLE = 'single'; Codes.SELECTION_MODE_MULTIPLE = 'multiple'; Codes.EXPORT_MODE_VISIBLE = 'visible'; Codes.EXPORT_MODE_LOCAL = 'local'; Codes.EXPORT_MODE_ALL = 'all'; Codes.HYPHEN_SEPARATOR = '-'; Codes.SPACE_SEPARATOR = ' '; Codes.COLUMNS_ALIAS_SEPARATOR = ':'; Codes.ARRAY_INPUT_SEPARATOR = ';'; Codes.TYPE_SEPARATOR = ':'; Codes.VALUES_SEPARATOR = '='; Codes.ASC_SORT = 'asc'; Codes.DESC_SORT = 'desc'; Codes.TYPE_INT = 'int'; Codes.ROUTE_SEPARATOR = '/'; Codes.ROUTE_VARIABLE_CHAR = ':'; Codes.PARENT_KEYS_KEY = 'pk'; Codes.QUERY_PARAMS = 'queryParams'; Codes.IS_DETAIL = 'isdetail'; Codes.LANGUAGE_KEY = 'lang'; Codes.SESSION_KEY = 'session'; Codes.SESSION_EXPIRED_KEY = 'session-expired'; Codes.LOGIN_ROUTE = '/login'; Codes.FORBIDDEN_ROUTE = '403'; Codes.DEFAULT_EDIT_ROUTE = 'edit'; Codes.DEFAULT_DETAIL_ROUTE = undefined; Codes.DEFAULT_INSERT_ROUTE = 'new'; Codes.IGNORE_CAN_DEACTIVATE = 'ignore_can_deactivate'; Codes.INSERTION_MODE = 'insertionMode'; Codes.ONTIMIZE_SUCCESSFUL_CODE = 0; Codes.ONTIMIZE_FAILED_CODE = 1; Codes.ONTIMIZE_UNAUTHORIZED_CODE = 3; Codes.ICON_POSITION_LEFT = 'left'; Codes.ICON_POSITION_RIGHT = 'right'; Codes.COLUMN_TITLE_ALIGN_START = 'start'; Codes.COLUMN_TITLE_ALIGN_CENTER = 'center'; Codes.COLUMN_TITLE_ALIGN_END = 'end'; Codes.COLUMN_TITLE_ALIGN_AUTO = 'auto'; Codes.AVAILABLE_COLUMN_TITLE_ALIGNS = [Codes.COLUMN_TITLE_ALIGN_START, Codes.COLUMN_TITLE_ALIGN_CENTER, Codes.COLUMN_TITLE_ALIGN_END, Codes.COLUMN_TITLE_ALIGN_AUTO]; Codes.O_MAT_ERROR_STANDARD = 'standard'; Codes.O_MAT_ERROR_LITE = 'lite'; Codes.O_INPUTS_OPTIONS_COLOR_ACCENT = 'accent'; Codes.HourFormat = { TWELVE: 'hh:mm a', TWENTY_FOUR: 'HH:mm a', }; Codes.CLOSE_DETAIL_ACTION = 'CLOSE'; Codes.BACK_ACTION = 'BACK'; Codes.RELOAD_ACTION = 'RELOAD'; Codes.GO_EDIT_ACTION = 'GO_EDIT'; Codes.EDIT_ACTION = 'EDIT'; Codes.INSERT_ACTION = 'INSERT'; Codes.GO_INSERT_ACTION = 'GO_INSERT'; Codes.DELETE_ACTION = 'DELETE'; Codes.UNDO_LAST_CHANGE_ACTION = 'UNDO_LAST_CHANGE'; Codes.DEFAULT_COLUMN_MIN_WIDTH = 80; Codes.NAME_COLUMN_SELECT = 'select'; Codes.NAME_COLUMN_EXPANDABLE = 'expandable'; Codes.SUFFIX_COLUMN_INSERTABLE = '_insertable'; Codes.LIMIT_SCROLLVIRTUAL = 50; Codes.TWENTY_FOUR_HOUR_FORMAT = 24; Codes.TWELVE_FOUR_HOUR_FORMAT = 12; Codes.OAppLayoutModes = ['mobile', 'desktop']; Codes.OSidenavModes = ['over', 'push', 'side']; Codes.OAppLayoutMode = ['mobile', 'desktop']; Codes.OSidenavMode = ['over', 'push', 'side']; Codes.APP_LAYOUT_MODE_DESKTOP = 'desktop'; Codes.APP_LAYOUT_MODE_MOBILE = 'mobile'; Codes.VISIBLE_EXPORT_BUTTONS = ['xlsx', 'pdf', 'html']; Codes.VISIBLE_EXPORT_BUTTONS3X = ['xlsx', 'pdf', 'csv']; Codes.DEFAULT_CHANGE_EVENT = 'onValueChange'; Codes.TYPES_DATE_GROUPS = ["YEAR", "MONTH", "YEAR_MONTH", "YEAR_MONTH_DAY"]; Codes.TOOLTIP_DISPLAY_MODE = ['always', 'never', 'only-collapsed', 'only-expanded']; Codes.TOOLTIP_DISPLAY_COLLAPSED = 'only-collapsed'; class Util { static isObject(val) { const valType = typeof val; return valType === 'object'; } static isArray(val) { return val instanceof Array; } static parseBoolean(value, defaultValue) { if ((typeof value === 'string') && (value.toUpperCase() === 'TRUE' || value.toUpperCase() === 'YES')) { return true; } else if ((typeof value === 'string') && (value.toUpperCase() === 'FALSE' || value.toUpperCase() === 'NO')) { return false; } else if (Util.isDefined(defaultValue)) { return defaultValue; } return false; } static parseArray(value, excludeRepeated = false) { let result = []; if (value) { result = value.split(Codes.ARRAY_INPUT_SEPARATOR); } if (excludeRepeated && result.length > 0) { result = Array.from(new Set(result)); } return result; } static parseParentKeysEquivalences(pKeysArray, separator = ':') { const equivalences = {}; if (pKeysArray && pKeysArray.length > 0) { pKeysArray.forEach(item => { const aux = item.split(separator); if (aux && aux.length === 2) { if (/.+\[.+\]/.test(aux[1])) { const equivKey = aux[1].substring(0, aux[1].indexOf('[')); const equivValue = aux[1].substring(aux[1].indexOf('[') + 1, aux[1].indexOf(']')); const equiv = {}; equiv[equivKey] = equivValue; equivalences[aux[0]] = equiv; } else { equivalences[aux[0]] = aux[1]; } } else if (aux && aux.length === 1) { equivalences[item] = item; } }); } return equivalences; } static encodeParentKeys(parentKeys) { let encoded = ''; if (parentKeys) { encoded = Base64.encode(JSON.stringify(parentKeys)); } return encoded; } static decodeParentKeys(parentKeys) { let decoded = {}; if (parentKeys && parentKeys.length > 0) { const d = Base64.decode(parentKeys); decoded = JSON.parse(d); } return decoded; } static isArrayEmpty(array) { if (!Util.isDefined(array) || array.length === 0) { return true; } return false; } static isObjectEmpty(obj) { return typeof obj === 'object' && Object.keys(obj).length === 0; } static isDataService(arg) { if (arg === undefined || arg === null) { return false; } return (arg.getDefaultServiceConfiguration !== undefined && arg.configureService !== undefined); } static isPermissionsService(arg) { if (arg === undefined || arg === null) { return false; } return (arg.loadPermissions !== undefined); } static isFormDataComponent(arg) { if (arg === undefined || arg === null) { return false; } return (arg.isAutomaticBinding !== undefined); } static isEquivalent(a, b) { const aProps = Object.getOwnPropertyNames(a); const bProps = Object.getOwnPropertyNames(b); if (aProps.length !== bProps.length) { return false; } for (let i = 0; i < aProps.length; i++) { const propName = aProps[i]; let bValue = b[propName]; if (typeof a[propName] === 'number') { const intB = parseInt(bValue, 10); bValue = isNaN(intB) ? bValue : intB; } if (a[propName] !== bValue) { return false; } } return true; } static equals(o1, o2) { if (o1 === o2) { return true; } if (o1 === null || o2 === null) { return false; } if (o1 !== o1 && o2 !== o2) { return true; } const t1 = typeof o1; const t2 = typeof o2; let length; let key; let keySet; if (t1 === t2 && t1 === 'object') { if (Array.isArray(o1)) { if (!Array.isArray(o2)) { return false; } length = o1.length; if (length === o2.length) { for (key = 0; key < length; key++) { if (!Util.equals(o1[key], o2[key])) { return false; } } return true; } } else { if (Array.isArray(o2)) { return false; } keySet = Object.create(null); for (key in o1) { if (!Util.equals(o1[key], o2[key])) { return false; } keySet[key] = true; } for (key in o2) { if (!(key in keySet) && typeof o2[key] !== 'undefined') { return false; } } return true; } } return false; } static isDefined(value) { return typeof value !== 'undefined' && value !== null; } static randomNumber() { const randomArray = new Uint32Array(1); window.crypto.getRandomValues(randomArray); return randomArray[0]; } static normalizeString(value, toLowerCase = true) { if (typeof value === 'string') { if (value && value.length) { let result = value.normalize('NFD').replace(/[\u0300-\u036f]/g, ''); if (toLowerCase) { result = result.toLowerCase(); } return result; } return ''; } return value; } static flatten(array) { let flattened = []; for (const current of array) { if (!Array.isArray(current)) { flattened.push(current); continue; } for (const childCurrent of current) { flattened.push(childCurrent); } } return flattened; } static getValuesFromObject(obj = {}) { const array = []; Object.keys(obj).forEach(key => { if (typeof obj[key] === 'object') { array.push(Util.getValuesFromObject(obj[key])); } array.push(obj[key]); }); return Util.flatten(array); } static parseIconPosition(value, defaultValue) { let result = defaultValue || Codes.ICON_POSITION_LEFT; const availablePositions = [Codes.ICON_POSITION_LEFT, Codes.ICON_POSITION_RIGHT]; if (value && value.length) { result = value.toLowerCase(); } if (availablePositions.indexOf(result) === -1) { result = defaultValue || Codes.ICON_POSITION_LEFT; } return result; } static copyToClipboard(data) { document.addEventListener('copy', (e) => { e.clipboardData.setData('text/plain', data); e.preventDefault(); document.removeEventListener('copy', null); }); document.execCommand('copy'); } static checkPixelsValueString(value) { return typeof value === 'string' ? value.toLowerCase().endsWith('px') : false; } static extractPixelsValue(value, defaultValue) { let result = typeof value === 'number' ? value : undefined; if (Util.checkPixelsValueString(value)) { const parsed = parseFloat(value.substr(0, value.length - 'px'.length)); result = isNaN(parsed) ? defaultValue : parsed; } return Util.isDefined(result) ? result : defaultValue; } static parseOInputsOptions(elRef, oInputsOptions) { if (oInputsOptions.iconColor === Codes.O_INPUTS_OPTIONS_COLOR_ACCENT) { const matFormFieldEL = elRef.nativeElement.getElementsByTagName('mat-form-field')[0]; if (Util.isDefined(matFormFieldEL)) { matFormFieldEL.classList.add('accent'); } } } static escapeSpecialCharacter(S) { const str = String(S); const cpList = Array.from(str[Symbol.iterator]()); const cuList = []; for (const c of cpList) { if ('^$\\.*+?()[]{}|'.indexOf(c) !== -1) { cuList.push('\\'); } cuList.push(c); } const L = cuList.join(''); return L; } static isArrayEqual(array1, array2) { return array1.length === array2.length && array1.every((v, i) => v === array2[i]); } ; static differenceArrays(array1, array2) { const difference = array1.filter(obj => { return !array2.some(obj2 => { return this.equals(obj, obj2); }); }); return difference; } static convertToODateValueType(val) { let result = 'timestamp'; const lowerVal = (val || '').toLowerCase(); if (lowerVal === 'string' || lowerVal === 'date' || lowerVal === 'timestamp' || lowerVal === 'iso-8601') { result = lowerVal; } return result; } static uniqueBy(a, key) { const seen = {}; return a.filter((item) => { const k = key(item); return seen.hasOwnProperty(k) ? false : (seen[k] = true); }); } static compare(a, b) { if (a < b) { return -1; } if (a > b) { return 1; } return 0; } static parseByValueType(value, valueType, format) { if (!Util.isDefined(value)) { return void 0; } let result = value; const m = moment(value); if (!m.isValid()) { return void 0; } switch (valueType) { case 'string': result = m.format(format); break; case 'date': result = m.toDate(); break; case 'iso-8601': result = m.toISOString(); break; case 'timestamp': result = m.valueOf(); break; default: result = void 0; break; } return result; } static wrapIntoObservable(value) { if (isObservable(value)) { return value; } if (Util.isPromise(value)) { return from(Promise.resolve(value)); } return of(value); } static isPromise(obj) { return !!obj && typeof obj.then === 'function'; } static createServiceInstance(clazz, injector) { if (!Util.isDefined(clazz)) { return; } const newInstance = new clazz(injector); return newInstance; } static configureMessageService(configureServiceArgs) { let messageService = configureServiceArgs.baseService; const serviceType = configureServiceArgs.serviceType; const injector = configureServiceArgs.injector; if (serviceType) { messageService = serviceType; } try { messageService = injector.get(messageService); if (serviceType) { messageService = Util.createServiceInstance(messageService, injector); } } catch (e) { console.error(e); } return messageService; } static isBase64(file) { const pattern = new RegExp(/^([A-Za-z0-9+\/]{4})*([A-Za-z0-9+\/]{4}|[A-Za-z0-9+\/]{3}=|[A-Za-z0-9+\/]{2}==)$/g); if (file.substring(0, 4) === 'data') { file = file.substring(file.indexOf('base64') + 7); } return pattern.test(file.replace(/\s+/g, '')); } static stringify(obj) { let cache = []; let str = JSON.stringify(obj, function (key, value) { if (typeof value === "object" && value !== null) { if (cache.indexOf(value) !== -1) { return; } cache.push(value); } return value; }); cache = null; return str; } static toLowerCase(value) { if (typeof value === 'string') { return value.toLocaleLowerCase(); } else { return value; } } static toUpperCase(value) { if (typeof value === 'string') { return value.toUpperCase(); } else { return value; } } static parseToLowerCase(value) { if (Util.isArray(value)) { return value.map((x) => x.toLocaleLowerCase()); } else if (typeof value === 'string') { return value.toLocaleLowerCase(); } else if (typeof value === 'object') { return Util.mapKeys(value, Util.toLowerCase); } return value; } static parseToUpperCase(value) { if (Util.isArray(value)) { return value.map((x) => x.toLocaleUpperCase()); } else if (typeof value === 'string') { return value.toLocaleUpperCase(); } else if (typeof value === 'object') { return Util.mapKeys(value, Util.toUpperCase); } return value; } static sortFunction(propertyA, propertyB, activeSortDirection) { let valueA = ''; let valueB = ''; if (Util.isDefined(propertyA)) { valueA = isNaN(+propertyA) ? propertyA.toString().trim().toLowerCase() : +propertyA; } if (Util.isDefined(propertyB)) { valueB = isNaN(+propertyB) ? propertyB.toString().trim().toLowerCase() : +propertyB; } return (valueA <= valueB ? -1 : 1) * (activeSortDirection === 'asc' ? 1 : -1); } static cloneArray(arr) { const clonedArray = arr.map((x) => Object.assign({}, x)); return clonedArray; } static getLastActivateRoute(routeSnapshot) { let child = routeSnapshot; while (child.firstChild) { child = child.firstChild; } return child; } static getValueFromPath(obj, path) { if (!obj || !path) return undefined; return path.split('.').reduce((acc, key) => { if (acc && typeof acc === 'object') { return acc[key]; } return undefined; }, obj); } } Util.columnAggregates = ['sum', 'count', 'avg', 'min', 'max']; Util.objectToQueryString = (initialObj) => { const reducer = (obj, parentPrefix = null) => (prev, key) => { const val = obj[key]; key = encodeURIComponent(key); let prefix; if (key === 'filterParentKeys') { prefix = parentPrefix; } else { prefix = parentPrefix ? `${parentPrefix}[${key}]` : key; } if (key === 'filter' && !Util.isObjectEmpty(obj[key])) { prev.push(Object.keys(val).map(itemfilter => { const filterKey = `filter[${itemfilter}]`; if (Util.isObject(val[itemfilter])) { return `${encodeURIComponent(filterKey)}=${encodeURIComponent(JSON.stringify(val[itemfilter]))}`; } else { return `${encodeURIComponent(filterKey)}=${encodeURIComponent(val[itemfilter])}`; } }).join('&')); return prev; } if (val == null || typeof val === 'function') { prev.push(`${encodeURIComponent(prefix)}=`); return prev; } if (['number', 'boolean', 'string'].includes(typeof val)) { prev.push(`${encodeURIComponent(prefix)}=${encodeURIComponent(val)}`); return prev; } prev.push(Object.keys(val).reduce(reducer(val, prefix), []).join('&')); return prev; }; return Object.keys(initialObj).reduce(reducer(initialObj), []).join('&'); }; Util.mapKeys = (obj, fn) => Object.keys(obj).reduce((acc, k) => { acc[fn(obj[k], k, obj)] = obj[k]; return acc; }, {}); Util.mapValues = (obj, fn) => Object.keys(obj).reduce((acc, k) => ({ ...acc, [k]: fn(obj[k]) }), {}); const DEFAULT_LOCAL_STORAGE_KEY = undefined; const DEFAULT_CONFIG = { uuid: DEFAULT_LOCAL_STORAGE_KEY, title: 'Ontimize Web App' }; const O_INPUTS_OPTIONS = new InjectionToken('o-inputs-options'); const APP_CONFIG = new InjectionToken('app.config'); class AppConfig { constructor(config) { this._config = (config && Util.isObject(config) && !Array.isArray(config)) ? config : {}; } getConfiguration() { return Object.assign(DEFAULT_CONFIG, this._config); } getServiceConfiguration() { return this._config.servicesConfiguration || {}; } getMenuConfiguration() { return this._config.appMenuConfiguration || []; } useRemoteBundle() { return Util.isDefined(this._config.bundle); } getBundleEndpoint() { let result; const existsBundleConf = this.useRemoteBundle(); if (existsBundleConf && Util.isDefined(this._config.bundle.endpoint)) { result = this._config.bundle.endpoint; } else if (existsBundleConf && Util.isDefined(this._config.bundle.path)) { result = this._config.apiEndpoint + '/' + this._config.bundle.path; } return result; } getI18nAssetsConfiguration() { if (Util.isDefined(this._config.assets) && Util.isDefined(this._config.assets.i18n)) { return this._config.assets.i18n; } return undefined; } getCssAssetsConfiguration() { if (Util.isDefined(this._config.assets) && Util.isDefined(this._config.assets.css)) { return this._config.assets.css; } return undefined; } getImagesAssetsConfiguration() { if (Util.isDefined(this._config.assets) && Util.isDefined(this._config.assets.images)) { return this._config.assets.images; } return undefined; } getJsAssetsConfiguration() { if (Util.isDefined(this._config.assets) && Util.isDefined(this._config.assets.js)) { return this._config.assets.js; } return undefined; } getRemoteConfigurationConfig() { return this._config.remoteConfig; } useRemoteConfiguration() { return Util.isDefined(this._config.remoteConfig); } getRemoteConfigurationEndpoint() { let result; const existsRemoteConf = this.useRemoteConfiguration(); if (existsRemoteConf && Util.isDefined(this._config.remoteConfig.endpoint)) { result = this._config.remoteConfig.endpoint; } else if (existsRemoteConf && Util.isDefined(this._config.remoteConfig.path)) { result = this._config.apiEndpoint + '/' + this._config.remoteConfig.path; } return result; } useExportConfiguration() { return Util.isDefined(this._config.exportConfiguration); } getExportPath() { let result; const existsRemoteConf = this.useExportConfiguration(); if (existsRemoteConf && Util.isDefined(this._config.exportConfiguration.path)) { result = this._config.exportConfiguration.path; } else { result = this._config.apiEndpoint + '/export'; } return result; } getNameConvention() { return this._config.nameConvention || 'database'; } } class IsEmptyValuePipe { transform(value) { return value === null || value === undefined || value === ''; } } IsEmptyValuePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: IsEmptyValuePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); IsEmptyValuePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.10", ngImport: i0, type: IsEmptyValuePipe, name: "isEmptyValue" }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: IsEmptyValuePipe, decorators: [{ type: Pipe, args: [{ name: 'isEmptyValue', pure: true }] }] }); class ListItem { } class OListItemDirective { constructor(listItem, _el, renderer, actRoute) { this.listItem = listItem; this._el = _el; this.renderer = renderer; this.actRoute = actRoute; this.onClick = new EventEmitter(); this.onDoubleClick = new EventEmitter(); this.selectable = false; this.subscription = new Subscription(); } ngOnInit() { this.subscription.add(this.actRoute.params.subscribe(params => this.updateActiveState(params))); } ngOnDestroy() { this.subscription.unsubscribe(); } onMouseEnter() { if (!this.selectable && this._list && this._list.detailMode !== Codes.DETAIL_MODE_NONE) { this.renderer.setStyle(this._el.nativeElement, 'cursor', 'pointer'); } } updateActiveState(params) { if (this._list) { const aKeys = this._list.getKeys(); if (this.modelData) { let _act = false; if (aKeys.length > 0) { for (let k = 0; k < aKeys.length; ++k) { const key = aKeys[k]; const id = params[key]; _act = (this.modelData[key] === id); if (_act === false) { break; } } } if (_act) { this._el.nativeElement.classList.add('mat-active'); } else { this._el.nativeElement.classList.remove('mat-active'); } } else { this._el.nativeElement.classList.remove('mat-active'); } } } onItemClicked(e) { if (!this.selectable && this._list) { this._list.onItemDetailClick(this); this.onClick.emit(this.getItemData()); } } onItemDoubleClicked(e) { if (!this.selectable && this._list) { this._list.onItemDetailDoubleClick(this); this.onDoubleClick.emit(this.getItemData()); } } isSelected() { return this._list && this._list.isItemSelected(this.modelData); } setListComponent(list) { this._list = list; } setItemData(data) { if (!Util.isDefined(this.modelData) || this.modelData !== 'object') { this.modelData = data; } if (Util.isDefined(this.listItem)) { this.listItem.setItemData(this.modelData); } } getItemData() { return this.modelData; } } OListItemDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: OListItemDirective, deps: [{ token: ListItem, host: true, optional: true, self: true }, { token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i1.ActivatedRoute }], target: i0.ɵɵFactoryTarget.Directive }); OListItemDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.10", type: OListItemDirective, selector: "o-list-item, mat-list-item[o-list-item], mat-card[o-list-item]", inputs: { modelData: ["o-list-item", "modelData"], selectable: "selectable" }, host: { listeners: { "click": "onItemClicked($event)", "dblclick": "onItemDoubleClicked($event)", "mouseenter": "onMouseEnter()" }, properties: { "class.o-list-item": "true" } }, exportAs: ["olistitem"], ngImport: i0 }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: OListItemDirective, decorators: [{ type: Directive, args: [{ selector: 'o-list-item, mat-list-item[o-list-item], mat-card[o-list-item]', exportAs: 'olistitem', host: { '[class.o-list-item]': 'true', '(click)': 'onItemClicked($event)', '(dblclick)': 'onItemDoubleClicked($event)' } }] }], ctorParameters: function () { return [{ type: ListItem, decorators: [{ type: Host }, { type: Self }, { type: Optional }] }, { type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i1.ActivatedRoute }]; }, propDecorators: { modelData: [{ type: Input, args: ['o-list-item'] }], selectable: [{ type: Input }], onMouseEnter: [{ type: HostListener, args: ['mouseenter'] }] } }); class InputRegulateDirective { constructor(elementRef, renderer) { this.elementRef = elementRef; this.renderer = renderer; } ngOnInit() { if (Util.isDefined(this.oInputRegulatePattern)) { this.regExpattern = new RegExp(this.oInputRegulatePattern); } } onInputChange(value) { if (Util.isDefined(this.regExpattern)) { const filterValue = this.regExpattern.test(value) ? value : this.value; this.updateTextInput(filterValue, filterValue !== this.value); } } onBlur() { this.onTouched(); } updateTextInput(value, propagateChange) { this.renderer.setProperty(this.elementRef.nativeElement, 'value', value); if (propagateChange) { this.onChange(value); } this.value = value; } registerOnChange(fn) { this.onChange = fn; } registerOnTouched(fn) { this.onTouched = fn; } setDisabledState(isDisabled) { this.renderer.setProperty(this.elementRef.nativeElement, 'disabled', isDisabled); } writeValue(value) { value = value ? String(value) : ''; this.updateTextInput(value, false); } } InputRegulateDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: InputRegulateDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive }); InputRegulateDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.10", type: InputRegulateDirective, selector: "[oInputRegulate]", inputs: { oInputRegulatePattern: "oInputRegulatePattern" }, host: { listeners: { "input": "onInputChange($event.target.value)", "blur": "onBlur()" } }, providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => InputRegulateDirective), multi: true }], ngImport: i0 }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: InputRegulateDirective, decorators: [{ type: Directive, args: [{ selector: '[oInputRegulate]', providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => InputRegulateDirective), multi: true }] }] }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.Renderer2 }]; }, propDecorators: { oInputRegulatePattern: [{ type: Input }], onInputChange: [{ type: HostListener, args: ['input', ['$event.target.value']] }], onBlur: [{ type: HostListener, args: ['blur'] }] } }); class OKeyboardListenerDirective { constructor() { this.onKeysPressed = new EventEmitter(); this.keyboardNumberKeysArray = []; this.activeKeys = {}; } keyDown(e) { const pressedCode = e.keyCode; if (this.keyboardNumberKeysArray.indexOf(pressedCode) !== -1) { this.activeKeys[pressedCode] = true; this.checkNeededKeys(e); } } keyUp(e) { const pressedCode = e.keyCode; if (this.keyboardNumberKeysArray.indexOf(pressedCode) !== -1) { this.activeKeys[pressedCode] = false; } } ngOnInit() { this.parseKeyboardKeys(); } parseKeyboardKeys() { const keysAsStringArray = Util.parseArray(this.keyboardKeys); keysAsStringArray.forEach(key => { try { this.keyboardNumberKeysArray.push(parseInt(key, 10)); } catch (e) { console.error(e); } }); } checkNeededKeys(e) { let trigger = true; this.keyboardNumberKeysArray.forEach(key => { trigger = trigger && this.activeKeys[key]; }); if (trigger) { e.preventDefault(); e.stopPropagation(); this.onKeysPressed.emit(); } } } OKeyboardListenerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: OKeyboardListenerDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); OKeyboardListenerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.10", type: OKeyboardListenerDirective, selector: "[oKeyboardListener]", inputs: { keyboardKeys: "keyboardKeys" }, outputs: { onKeysPressed: "onKeysPressed" }, host: { listeners: { "keydown": "keyDown($event)", "keyup": "keyUp($event)" } }, ngImport: i0 }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: OKeyboardListenerDirective, decorators: [{ type: Directive, args: [{ selector: '[oKeyboardListener]' }] }], propDecorators: { keyboardKeys: [{ type: Input }], onKeysPressed: [{ type: Output }], keyDown: [{ type: HostListener, args: ['keydown', ['$event']] }], keyUp: [{ type: HostListener, args: ['keyup', ['$event']] }] } }); function StringConverter(value) { if (value == null || typeof value === 'string') { return value; } return value.toString(); } function BooleanConverter(value) { if (value == null || typeof value === 'boolean') { return value; } return value.toString() === 'true' || value.toString() === 'yes'; } function NumberConverter(value) { return coerceNumberProperty(value); } function BooleanInputConverter() { return function decorator(target, propertyKey) { const privateFieldName = `_${String(propertyKey)}`; Object.defineProperty(target, privateFieldName, { configurable: true, writable: true, }); return { get() { return this[privateFieldName]; }, set(value) { this[privateFieldName] = BooleanConverter(value); }, }; }; } function NumberInputConverter() { return function decorator(target, propertyKey) { const privateFieldName = `_${String(propertyKey)}`; Object.defineProperty(target, privateFieldName, { configurable: true, writable: true, }); return { get() { return this[privateFieldName]; }, set(value) { this[privateFieldName] = NumberConverter(value); }, }; }; } const MAP = { en: { 'LANGUAGE': 'Language', 'LOCALE_en': 'EN', 'LOCALE_es': 'ES', 'LOCALE_pt': 'PT', 'USERNAME': 'Username', 'PASSWORD': 'Password', 'LOGIN': 'Login', 'LOGOUT': 'Logout', 'OK': 'Ok', 'ACCEPT': 'Accept', 'CANCEL': 'Cancel', 'CLOSE': 'Close', 'YES': 'Yes', 'NO': 'No', 'RESET': 'Reset', 'CONFIRM': 'Confirm', 'NEXT': 'Next', 'PREVIOUS': 'Previous', 'FINISH': 'Finish', 'SAVE': 'Save', 'INSERT': 'Ok', 'REFRESH': 'Refresh', 'SEARCH': 'Search', 'FILTER': 'Filter', 'DELETE': 'Delete', 'ADD': 'New', 'SELECT': 'Select', 'SELECT_ALL': 'Select all', 'INFO': 'Information', 'ERROR': 'Error', 'FOUND': 'Found', 'RESULTS': 'Results', 'TOTAL': 'Total', 'MONEY': 'Money', 'HOME': 'Home', 'SHOW_CONSOLE': 'Show console', 'FILE': 'File', 'OPTIONS': 'Options', 'EDIT': 'Edit', 'UNDO': 'Undo', 'REDO': 'Redo', 'COPY': 'Copy', 'PASTE': 'Paste', 'LOCK': 'Lock', 'EXIT': 'Exit', 'SETTINGS': 'Settings', 'FORM': 'Form', 'LIST': 'List', 'LIST.EMPTY': 'No results found', 'LIST.EMPTY_USING_FILTER': ' using filter "{0}"', 'TABLE': 'Table', 'DETAIL': 'Detail', 'PAGE': 'Page', 'FIRST_PAGE': 'First', 'LAST_PAGE': 'Last', 'PREVIOUS_PAGE': 'Previous', 'NEXT_PAGE': 'Next', 'PHOTO': 'Picture', 'CHOOSE_FILE': 'Choose file', 'FORM_VALIDATION.REQUIRED': 'Required', 'FORM_VALIDATION.LENGTH': 'Invalid length', 'FORM_VALIDATION.MIN_LENGTH': 'Minimum length', 'FORM_VALIDATION.MAX_LENGTH': 'Maximum length', 'FORM_VALIDATION.MIN_DECIMAL_DIGITS': 'Minimum number of decimal digits', 'FORM_VALIDATION.MAX_DEC