UNPKG

wlpacks-ontimize-web-ngx

Version:
1,398 lines (1,385 loc) 4.44 MB
import { InjectionToken, Directive, ElementRef, EventEmitter, HostListener, Input, Renderer2, Output, Component, ViewEncapsulation, Injectable, Injector, Host, Optional, forwardRef, Inject, ChangeDetectionStrategy, TemplateRef, ViewChild, ViewChildren, Pipe, CUSTOM_ELEMENTS_SCHEMA, NgModule, ChangeDetectorRef, ViewContainerRef, ComponentFactoryResolver, ContentChildren, ContentChild, NgZone, APP_INITIALIZER, HostBinding, ApplicationRef, ɵɵdefineInjectable, ɵɵinject, INJECTOR, SkipSelf, KeyValueDiffers } from '@angular/core'; import { Observable, BehaviorSubject, ReplaySubject, Subscription, Subject, combineLatest, merge, fromEvent, of, timer } from 'rxjs'; export { Observable, Subject } from 'rxjs'; import { ActivatedRoute, Router, NavigationStart, NavigationEnd, RouterModule } from '@angular/router'; import { MatDialogRef, MatDialog, MatSnackBarRef, MatSnackBar, MatSuffix, MatIconRegistry, MAT_DATE_FORMATS, MatAutocompleteModule, MatButtonModule, MatButtonToggleModule, MatCardModule, MatCheckboxModule, MatChipsModule, MatDatepickerModule, MatDialogModule, MatExpansionModule, MatFormFieldModule, MatGridListModule, MatIconModule, MatInputModule, MatListModule, MatMenuModule, MatPaginatorModule, MatProgressBarModule, MatProgressSpinnerModule, MatRadioModule, MatRippleModule, MatSelectModule, MatSidenavModule, MatSliderModule, MatSlideToggleModule, MatSnackBarModule, MatSortModule, MatTableModule, MatTabsModule, MatToolbarModule, MatTooltipModule, MatButtonToggleGroup, MAT_FORM_FIELD_DEFAULT_OPTIONS, MatMenuTrigger, MAT_DIALOG_DATA, MatPaginator, MatSelect, MAT_DATE_LOCALE, DateAdapter, MatDatepickerInput, MatTab, MatTabGroup, MatLine, MatListAvatarCssMatStyler, MatCheckbox, MatSelectionList, MatSort, matSortAnimations, MatSortHeader, MatSortHeaderIntl, MatPaginatorIntl, MAT_SORT_HEADER_INTL_PROVIDER, GestureConfig, MatSidenav, MAT_RIPPLE_GLOBAL_OPTIONS } from '@angular/material'; import { HttpClient, HttpHeaders, HttpEventType, HttpRequest, HttpErrorResponse, HttpClientModule } from '@angular/common/http'; import { map, share, filter, debounceTime, distinctUntilChanged, take, takeUntil, catchError } from 'rxjs/operators'; import { FormControl, FormGroup, Validators, FormsModule, ReactiveFormsModule, NG_VALUE_ACCESSOR } from '@angular/forms'; import * as moment from 'moment'; import moment__default, { } from 'moment'; import { TranslateService, TranslateDefaultParser, TranslateLoader, TranslateModule, TranslateParser } from '@ngx-translate/core'; import { __decorate, __metadata } from 'tslib'; import { Location, CommonModule, LOCATION_INITIALIZED } from '@angular/common'; import { DomSanitizer, HAMMER_GESTURE_CONFIG, BrowserModule } from '@angular/platform-browser'; import { OverlayModule, Overlay, ScrollStrategyOptions, OverlayConfig } from '@angular/cdk/overlay'; import { ScrollingModule } from '@angular/cdk/scrolling'; import { MatMomentDateModule, MomentDateAdapter } from '@angular/material-moment-adapter'; import { FlexLayoutModule, MediaObserver } from '@angular/flex-layout'; import '@angular/material/menu'; import { ComponentPortal, DomPortalOutlet, TemplatePortal, PortalModule } from '@angular/cdk/portal'; import { SelectionModel, DataSource } from '@angular/cdk/collections'; import { ESCAPE, UP_ARROW } from '@angular/cdk/keycodes'; import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout'; import { NgxMaterialTimepickerModule } from 'ngx-material-timepicker'; import { animate, state, style, transition, trigger } from '@angular/animations'; import { CdkColumnDef, CdkTableModule } from '@angular/cdk/table'; import { moveItemInArray, transferArrayItem, DragDropModule } from '@angular/cdk/drag-drop'; import { ObserversModule } from '@angular/cdk/observers'; import 'reflect-metadata'; import { TranslateHttpLoader } from '@ngx-translate/http-loader'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; 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)); } } Codes.PAGINATED_QUERY_METHOD = 'advancedQuery'; Codes.DELETE_METHOD = 'delete'; Codes.INSERT_METHOD = 'insert'; Codes.UPDATE_METHOD = 'update'; Codes.QUERY_METHOD = 'query'; Codes.DEFAULT_QUERY_ROWS = 10; 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.EDITION_MODE_NONE = 'none'; Codes.EDITION_MODE_CLICK = 'click'; Codes.EDITION_MODE_DBLCLICK_VALUES = ['dblclick', 'doubleclick']; 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.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'; 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 (array && array.length === 0) { return true; } return false; } 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 normalizeString(value, toLowerCase = true) { if (value && value.length) { let result = value.normalize('NFD').replace(/[\u0300-\u036f]/g, ''); if (toLowerCase) { result = result.toLowerCase(); } return result; } return ''; } static flatten(array) { return [].concat(...array); } 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 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; } } 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; } } function noop() { } class ObservableWrapper { static subscribe(emitter, onNext, onError, onComplete = () => { }) { onError = (typeof onError === 'function') && onError || noop; onComplete = (typeof onComplete === 'function') && onComplete || noop; return emitter.subscribe({ next: onNext, error: onError, complete: onComplete }); } static isObservable(obs) { return !!obs.subscribe; } static hasSubscribers(obs) { return obs.observers.length > 0; } static dispose(subscription) { subscription.unsubscribe(); } static callNext(emitter, value) { emitter.emit(value); } static callEmit(emitter, value) { emitter.emit(value); } static callError(emitter, error) { emitter.error(error); } static callComplete(emitter) { emitter.complete(); } } class OListItemDirective { constructor(_el, renderer, actRoute) { this._el = _el; this.renderer = renderer; this.actRoute = actRoute; this.mdClick = new EventEmitter(); this.mdDoubleClick = new EventEmitter(); this.selectable = false; } ngOnInit() { this.subcription = this.actRoute.params.subscribe(params => this.updateActiveState(params)); } ngOnDestroy() { if (this.subcription) { this.subcription.unsubscribe(); } } onMouseEnter() { if (!this.selectable && 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) { ObservableWrapper.callEmit(this.mdClick, this); } } onClick(onNext) { return ObservableWrapper.subscribe(this.mdClick, onNext); } onItemDoubleClicked(e) { if (!this.selectable) { ObservableWrapper.callEmit(this.mdDoubleClick, this); } } onDoubleClick(onNext) { return ObservableWrapper.subscribe(this.mdDoubleClick, onNext); } isSelected() { return this._list.isItemSelected(this.modelData); } onSelect() { this._list.setSelected(this.modelData); } setListComponent(list) { this._list = list; } setItemData(data) { if (!this.modelData) { this.modelData = data; } } getItemData() { return this.modelData; } } 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)' } },] } ]; OListItemDirective.ctorParameters = () => [ { type: ElementRef }, { type: Renderer2 }, { type: ActivatedRoute } ]; OListItemDirective.propDecorators = { modelData: [{ type: Input, args: ['o-list-item',] }], selectable: [{ type: Input }], onMouseEnter: [{ type: HostListener, args: ['mouseenter',] }] }; 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$$1 = true; this.keyboardNumberKeysArray.forEach(key => { trigger$$1 = trigger$$1 && this.activeKeys[key]; }); if (trigger$$1) { e.preventDefault(); e.stopPropagation(); this.onKeysPressed.emit(); } } } OKeyboardListenerDirective.decorators = [ { type: Directive, args: [{ selector: '[oKeyboardListener]' },] } ]; OKeyboardListenerDirective.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) { if (value == null || typeof value === 'number') { return value; } return parseFloat(value.toString()); } function createConverterIfNeeded(metadata, converter) { if (converter != null) { return converter; } switch (metadata.name) { case 'String': converter = StringConverter; break; case 'Boolean': converter = BooleanConverter; break; case 'Number': converter = NumberConverter; break; } return converter; } function InputConverter(converter) { return (target, key) => { const metadata = Reflect.getMetadata('design:type', target, key); if (metadata == null) { throw new Error('The reflection metadata could not be found.'); } converter = createConverterIfNeeded(metadata, converter); if (converter == null) { throw new Error('There is no converter for the given property type "' + metadata.name + '".'); } const stringKey = typeof key === 'string' ? key : key.toString(); const definition = Object.getOwnPropertyDescriptor(target, key); Object.defineProperty(target, key, { get: definition != null ? definition.get : function () { return this['__' + stringKey]; }, set: definition != null ? (newValue) => { definition.set(converter(newValue)); } : function (newValue) { this['__' + stringKey] = converter(newValue); }, enumerable: true, configurable: true }); }; } class ODialogComponent { constructor(dialogRef) { this.dialogRef = dialogRef; } onOkClick() { if (this.dialogRef) { this.dialogRef.close(true); } } alert(title, message, config) { config = this.ensureConfig(config); this.configureDefaultAlert(title, message, config); } info(title, message, config) { config = this.ensureConfig(config); config.alertType = 'info'; if (typeof (config.icon) === 'undefined') { config.icon = 'info'; } this.configureDefaultAlert(title, message, config); } warn(title, message, config) { config = this.ensureConfig(config); config.alertType = 'warn'; if (typeof (config.icon) === 'undefined') { config.icon = 'warning'; } this.configureDefaultAlert(title, message, config); } error(title, message, config) { config = this.ensureConfig(config); config.alertType = 'error'; if (typeof (config.icon) === 'undefined') { config.icon = 'error'; } this.configureDefaultAlert(title, message, config); } confirm(title, message, config) { config = this.ensureConfig(config); this.configureDefaultAlert(title, message, config); this.twoOptions = true; } ensureConfig(config) { if (!config) { config = {}; } return config; } configureDefaultAlert(title, message, config) { this.twoOptions = false; this.title = title; this.message = message; this.icon = (typeof (config.icon) !== 'undefined') ? config.icon : undefined; if (this.icon !== undefined) { this.useIcon = true; } this.alertType = config.alertType; this.okButtonText = (typeof (config.okButtonText) !== 'undefined') ? config.okButtonText : ODialogComponent.DEFAULT_OK_BUTTON_TEXT; this.cancelButtonText = (typeof (config.cancelButtonText) !== 'undefined') ? config.cancelButtonText : ODialogComponent.DEFAULT_CANCEL_BUTTON_TEXT; } get isInfo() { return this.alertType === 'info'; } get isWarn() { return this.alertType === 'warn'; } get isError() { return this.alertType === 'error'; } get title() { return this._title; } set title(val) { this._title = val; } get message() { return this._message; } set message(val) { this._message = val; } get okButtonText() { return this._okButtonText; } set okButtonText(val) { this._okButtonText = val; } get cancelButtonText() { return this._cancelButtonText; } set cancelButtonText(val) { this._cancelButtonText = val; } get icon() { return this._icon; } set icon(val) { this._icon = val; } get alertType() { return this._alertType; } set alertType(val) { this._alertType = val; } get twoOptions() { return this._twoOptions; } set twoOptions(val) { this._twoOptions = val; } get useIcon() { return this._useIcon; } set useIcon(val) { this._useIcon = val; } } ODialogComponent.DEFAULT_OK_BUTTON_TEXT = 'OK'; ODialogComponent.DEFAULT_CANCEL_BUTTON_TEXT = 'CANCEL'; ODialogComponent.decorators = [ { type: Component, args: [{ selector: 'o-dialog', template: "<div *ngIf=\"title && title.length > 0\" mat-dialog-title>{{ title | oTranslate }}</div>\n<div mat-dialog-content>\n <div fxLayout=\"row\" class=\"alert-content\" [class.alert-content-icon]=\"useIcon\" fxLayoutAlign=\"space-between center\">\n <mat-icon *ngIf=\"useIcon\" class=\"alert-icon\" [class.info]=\"isInfo\" [class.warn]=\"isWarn\" [class.error]=\"isError\">\n {{ icon }}\n </mat-icon>\n <span [innerHTML]=\"message | oTranslate\"></span>\n </div>\n</div>\n<mat-dialog-actions align=\"end\">\n <span fxFlex></span>\n <button type=\"button\" *ngIf=\"twoOptions\" mat-stroked-button mat-dialog-close class=\"o-button-default\">\n {{ cancelButtonText | oTranslate | uppercase }}\n </button>\n <button type=\"button\" mat-stroked-button class=\"o-button-primary\" (click)=\"onOkClick()\">{{ okButtonText | oTranslate | uppercase }}</button>\n</mat-dialog-actions>\n", encapsulation: ViewEncapsulation.None, host: { '[class.o-dialog]': 'true' }, styles: [".o-dialog{cursor:default}.o-dialog .alert-content{box-sizing:border-box;flex:1 1 100%;display:flex;flex-direction:row;place-content:center space-between;align-items:center;padding:12px 0}.o-dialog .alert-content-icon{min-height:70px}.o-dialog .alert-icon{font-size:50px;margin-right:16px;min-height:50px;min-width:50px}"] }] } ]; ODialogComponent.ctorParameters = () => [ { type: MatDialogRef } ]; class DialogService { constructor(injector) { this.injector = injector; this.ng2Dialog = this.injector.get(MatDialog); } get dialog() { if (this.dialogRef) { return this.dialogRef.componentInstance; } return undefined; } alert(title, message, config) { const self = this; const observable = new Observable(observer => { self.openDialog(observer); self.dialogRef.componentInstance.alert(title, message, config); }); return observable.toPromise(); } info(title, message, config) { const self = this; const observable = new Observable(observer => { self.openDialog(observer); self.dialogRef.componentInstance.info(title, message, config); }); return observable.toPromise(); } warn(title, message, config) { const self = this; const observable = new Observable(observer => { self.openDialog(observer); self.dialogRef.componentInstance.warn(title, message, config); }); return observable.toPromise(); } error(title, message, config) { const self = this; const observable = new Observable(observer => { self.openDialog(observer); self.dialogRef.componentInstance.error(title, message, config); }); return observable.toPromise(); } confirm(title, message, config) { const self = this; const observable = new Observable(observer => { self.openDialog(observer); self.dialogRef.componentInstance.confirm(title, message, config); }); return observable.toPromise(); } openDialog(observer) { const cfg = { role: 'alertdialog', disableClose: true, panelClass: ['o-dialog-class', 'o-dialog-service'] }; this.dialogRef = this.ng2Dialog.open(ODialogComponent, cfg); this.dialogRef.afterClosed().subscribe(result => { result = result === undefined ? false : result; observer.next(result); observer.complete(); this.dialogRef = null; }); } } DialogService.decorators = [ { type: Injectable, args: [{ providedIn: 'root' },] } ]; DialogService.ctorParameters = () => [ { type: Injector } ]; DialogService.ngInjectableDef = ɵɵdefineInjectable({ factory: function DialogService_Factory() { return new DialogService(ɵɵinject(INJECTOR)); }, token: DialogService, providedIn: "root" }); class OFormValue { constructor(value) { this.value = value; } } class SQLTypes { static getSQLTypeValue(type) { let value; type = type ? type.toUpperCase() : ''; switch (type) { case 'BIT': value = SQLTypes.BIT; break; case 'TINYINT': value = SQLTypes.TINYINT; break; case 'SMALLINT': value = SQLTypes.SMALLINT; break; case 'INTEGER': value = SQLTypes.INTEGER; break; case 'BIGINT': value = SQLTypes.BIGINT; break; case 'FLOAT': value = SQLTypes.FLOAT; break; case 'REAL': value = SQLTypes.REAL; break; case 'DOUBLE': value = SQLTypes.DOUBLE; break; case 'NUMERIC': value = SQLTypes.NUMERIC; break; case 'DECIMAL': value = SQLTypes.DECIMAL; break; case 'CHAR': value = SQLTypes.CHAR; break; case 'VARCHAR': value = SQLTypes.VARCHAR; break; case 'LONGVARCHAR': value = SQLTypes.LONGVARCHAR; break; case 'DATE': value = SQLTypes.DATE; break; case 'TIME': value = SQLTypes.TIME; break; case 'TIMESTAMP': value = SQLTypes.TIMESTAMP; break; case 'BINARY': value = SQLTypes.BINARY; break; case 'VARBINARY': value = SQLTypes.VARBINARY; break; case 'LONGVARBINARY': value = SQLTypes.LONGVARBINARY; break; case 'NULL': value = SQLTypes.NULL; break; case 'OTHER': value = SQLTypes.OTHER; break; case 'JAVA_OBJECT': value = SQLTypes.JAVA_OBJECT; break; case 'DISTINCT': value = SQLTypes.DISTINCT; break; case 'STRUCT': value = SQLTypes.STRUCT; break; case 'ARRAY': value = SQLTypes.ARRAY; break; case 'BLOB': value = SQLTypes.BLOB; break; case 'CLOB': value = SQLTypes.CLOB; break; case 'REF': value = SQLTypes.REF; break; case 'DATALINK': value = SQLTypes.DATALINK; break; case 'BOOLEAN': value = SQLTypes.BOOLEAN; break; case 'ROWID': value = SQLTypes.ROWID; break; case 'NCHAR': value = SQLTypes.NCHAR; break; case 'NVARCHAR': value = SQLTypes.NVARCHAR; break; case 'LONGNVARCHAR': value = SQLTypes.LONGNVARCHAR; break; case 'NCLOB': value = SQLTypes.NCLOB; break; case 'SQLXML': value = SQLTypes.SQLXML; break; case 'BASE64': value = SQLTypes.BASE64; break; default: value = SQLTypes.OTHER; break; } return value; } static getSQLTypeKey(type) { let value; switch (type) { case SQLTypes.BIT: value = 'BIT'; break; case SQLTypes.TINYINT: value = 'TINYINT'; break; case SQLTypes.SMALLINT: value = 'SMALLINT'; break; case SQLTypes.INTEGER: value = 'INTEGER'; break; case SQLTypes.BIGINT: value = 'BIGINT'; break; case SQLTypes.FLOAT: value = 'FLOAT'; break; case SQLTypes.REAL: value = 'REAL'; break; case SQLTypes.DOUBLE: value = 'DOUBLE'; break; case SQLTypes.NUMERIC: value = 'NUMERIC'; break; case SQLTypes.DECIMAL: value = 'DECIMAL'; break; case SQLTypes.CHAR: value = 'CHAR'; break; case SQLTypes.VARCHAR: value = 'VARCHAR'; break; case SQLTypes.LONGVARCHAR: value = 'LONGVARCHAR'; break; case SQLTypes.DATE: value = 'DATE'; break; case SQLTypes.TIME: value = 'TIME'; break; case SQLTypes.TIMESTAMP: value = 'TIMESTAMP'; break; case SQLTypes.BINARY: value = 'BINARY'; break; case SQLTypes.VARBINARY: value = 'VARBINARY'; break; case SQLTypes.LONGVARBINARY: value = 'LONGVARBINARY'; break; case SQLTypes.NULL: value = 'NULL'; break; case SQLTypes.OTHER: value = 'OTHER'; break; case SQLTypes.JAVA_OBJECT: value = 'JAVA_OBJECT'; break; case SQLTypes.DISTINCT: value = 'DISTINCT'; break; case SQLTypes.STRUCT: value = 'STRUCT'; break; case SQLTypes.ARRAY: value = 'ARRAY'; break; case SQLTypes.BLOB: value = 'BLOB'; break; case SQLTypes.CLOB: value = 'CLOB'; break; case SQLTypes.REF: value = 'REF'; break; case SQLTypes.DATALINK: value = 'DATALINK'; break; case SQLTypes.BOOLEAN: value = 'BOOLEAN'; break; case SQLTypes.ROWID: value = 'ROWID'; break; case SQLTypes.NCHAR: value = 'NCHAR'; break; case SQLTypes.NVARCHAR: value = 'NVARCHAR'; break; case SQLTypes.LONGNVARCHAR: value = 'LONGNVARCHAR'; break; case SQLTypes.NCLOB: value = 'NCLOB'; break; case SQLTypes.SQLXML: value = 'SQLXML'; break; case SQLTypes.BASE64: value = 'BASE64'; break; default: value = 'OTHER'; break; } return value; } static parseUsingSQLType(arg, type) { let value = arg; type = type ? type.toUpperCase() : ''; try { switch (type) { case 'TINYINT': case 'SMALLINT': case 'INTEGER': case 'BIGINT': value = Number(arg); break; case 'FLOAT': case 'REAL': case 'DOUBLE': case 'NUMERIC': case 'DECIMAL': value = parseFloat(arg); break; default: break; } } catch (err) { console.error('SQLTypes.parseUsingSQLType error'); } return value; } static isNumericSQLType(arg) { return [ SQLTypes.TINYINT, SQLTypes.SMALLINT, SQLTypes.INTEGER, SQLTypes.BIGINT, SQLTypes.FLOAT, SQLTypes.REAL, SQLTypes.DOUBLE, SQLTypes.NUMERIC, SQLTypes.DECIMAL ].indexOf(arg) !== -1; } } SQLTypes.BIT = -7; SQLTypes.TINYINT = -6; SQLTypes.SMALLINT = 5; SQLTypes.INTEGER = 4; SQLTypes.BIGINT = -5; SQLTypes.FLOAT = 6; SQLTypes.REAL = 7; SQLTypes.DOUBLE = 8; SQLTypes.NUMERIC = 2; SQLTypes.DECIMAL = 3; SQLTypes.CHAR = 1; SQLTypes.VARCHAR = 12; SQLTypes.LONGVARCHAR = -1; SQLTypes.DATE = 91; SQLTypes.TIME = 92; SQLTypes.TIMESTAMP = 93; SQLTypes.BINARY = -2; SQLTypes.VARBINARY = -3; SQLTypes.LONGVARBINARY = -4; SQLTypes.NULL = 0; SQLTypes.OTHER = 1111; SQLTypes.JAVA_OBJECT = 2000; SQLTypes.DISTINCT = 2001; SQLTypes.STRUCT = 2002; SQLTypes.ARRAY = 2003; SQLTypes.BLOB = 2004; SQLTypes.CLOB = 2005; SQLTypes.REF = 2006; SQLTypes.DATALINK = 70; SQLTypes.BOOLEAN = 16; SQLTypes.ROWID = -8; SQLTypes.NCHAR = -15; SQLTypes.NVARCHAR = -9; SQLTypes.LONGNVARCHAR = -16; SQLTypes.NCLOB = 2011; SQLTypes.BASE64 = 6464; SQLTypes.SQLXML = 2009; class ServiceUtils { static getParentKeysFromExpandableContainer(parentKeysObject, expandableContainer) { const result = {}; const ownKeys = Object.keys(parentKeysObject || {}); const dataComponent = expandableContainer ? expandableContainer.data : {}; const existsData = Object.keys(dataComponent).length > 0; if (existsData) { ownKeys.forEach(ownKey => { const keyValue = parentKeysObject[ownKey]; if (dataComponent.hasOwnProperty(keyValue)) { const value = dataComponent[keyValue]; if (Util.isDefined(value)) { switch (typeof (value)) { case 'string': if (value.trim().length > 0) { result[ownKey] = value.trim(); } break; case 'number': if (!isNaN(value)) { result[ownKey] = value; } break; } } } }); } return result; } static getParentKeysFromForm(parentKeysObject, form) { const result = {}; const ownKeys = Object.keys(parentKeysObject || {}); const formComponents = form ? form.getComponents() : {}; const existsComponents = Object.keys(formComponents).length > 0; const formDataProperties = form ? form.getDataValues() : {}; const existsProperties = Object.keys(formDataProperties).length > 0; const urlData = form ? form.getFormNavigation().getFilterFromUrlParams() : {}; const existsUrlData = Object.keys(urlData).length > 0; if (existsUrlData) { form.keysArray.forEach((key, i) => { if (urlData.hasOwnProperty(key)) { urlData[key] = SQLTypes.parseUsingSQLType(urlData[key], form.keysSqlTypesArray[i]); } }); } if (existsComponents || existsProperties || existsUrlData) { ownKeys.forEach(ownKey => { const keyValue = parentKeysObject[ownKey]; const isEquivObject = Util.isObject(keyValue); const formFieldAttr = isEquivObject ? Object.keys(keyValue)[0] : keyValue; let currentData; if (formComponents.hasOwnProperty(formFieldAttr)) { co