@stratio/egeo
Version:
1,591 lines (1,575 loc) • 640 kB
JavaScript
import { CommonModule, formatDate } from '@angular/common';
import { Injectable, EventEmitter, Component, ChangeDetectionStrategy, ComponentFactoryResolver, Input, HostBinding, Output, ViewChild, ViewContainerRef, Pipe, NgModule, ChangeDetectorRef, ElementRef, HostListener, forwardRef, ViewEncapsulation, Renderer2, Directive, ViewChildren, Injector, ANALYZE_FOR_ENTRY_COMPONENTS, ContentChildren, Optional } from '@angular/core';
import { Subject, BehaviorSubject, Observable, of } from 'rxjs';
import { trigger, state, style, transition, animate } from '@angular/animations';
import { takeRight, set, cloneDeep, keys, forEach, values, omit, has, range, flatten, get, throttle, differenceBy, includes, xorBy, clone, sortBy } from 'lodash';
import { map, catchError, zip, debounceTime } from 'rxjs/operators';
import { NG_VALUE_ACCESSOR, Validators, NG_VALIDATORS, FormControl, FormsModule, ReactiveFormsModule, NgControl, FormArray, FormGroup, NgModel } from '@angular/forms';
import { HttpClient, HttpClientModule } from '@angular/common/http';
import { __decorate, __metadata, __rest } from 'tslib';
import 'prismjs';
import 'prismjs/components/prism-typescript';
import { DomSanitizer } from '@angular/platform-browser';
import { Router, NavigationEnd, RouterModule } from '@angular/router';
import { VirtualScrollerModule } from 'ngx-virtual-scroller';
/**
* @fileoverview added by tsickle
* Generated from: lib/st-alerts/st-alerts.model.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @enum {number} */
const STALERT_SEVERITY = {
SUCCESS: 0, WARNING: 1, ERROR: 2, INFO: 3,
};
STALERT_SEVERITY[STALERT_SEVERITY.SUCCESS] = 'SUCCESS';
STALERT_SEVERITY[STALERT_SEVERITY.WARNING] = 'WARNING';
STALERT_SEVERITY[STALERT_SEVERITY.ERROR] = 'ERROR';
STALERT_SEVERITY[STALERT_SEVERITY.INFO] = 'INFO';
class StAlertLink {
}
if (false) {
/** @type {?} */
StAlertLink.prototype.title;
/** @type {?} */
StAlertLink.prototype.link;
}
class StAlert {
/**
* @param {?} id
* @param {?} title
* @param {?} message
* @param {?} severity
* @param {?} timeout
* @param {?} extendedTimeout
* @param {?} link
*/
constructor(id, title, message, severity, timeout, extendedTimeout, link) {
this.id = id;
this.title = title;
this.message = message;
this.severity = severity;
this.timeout = timeout;
this.extendedTimeout = extendedTimeout;
this.link = link;
this._readed = false;
this._opacity = 0;
this._opacityState = new Subject();
this._removeEvent = new Subject();
}
/**
* @return {?}
*/
get opacity() {
return this._opacityState.asObservable();
}
/**
* @return {?}
*/
get removeAlertEvent() {
return this._removeEvent.asObservable();
}
/**
* @return {?}
*/
notify() {
this.setVisible(true);
}
/**
* @return {?}
*/
pauseNotify() {
this._opacity = 1;
this._readed = true;
this.clearAnimation();
this.stopLife();
this._opacityState.next(this._opacity);
}
/**
* @return {?}
*/
continueNotify() {
this.startLife();
}
/**
* @return {?}
*/
cancel() {
this.setVisible(false);
}
/**
* @private
* @param {?} increase
* @return {?}
*/
setVisible(increase) {
this.clearAnimation();
this._changeVisibilityInterval = window.setInterval((/**
* @return {?}
*/
() => this.modifyVisibility(increase)), 50);
}
/**
* @private
* @param {?} increase
* @return {?}
*/
modifyVisibility(increase) {
this._opacity += increase ? 0.1 : -0.1;
if (this._opacity >= 1 || this._opacity <= 0) {
this.clearAnimation();
if (increase) {
this.startLife();
}
else {
this.notifyForRemove();
}
}
this._opacityState.next(this._opacity);
}
/**
* @private
* @return {?}
*/
notifyForRemove() {
this._opacityState.complete();
this._removeEvent.next(this);
this._removeEvent.complete();
}
/**
* @private
* @return {?}
*/
clearAnimation() {
window.clearInterval(this._changeVisibilityInterval);
}
/**
* @private
* @return {?}
*/
stopLife() {
window.clearTimeout(this._lifeTimeout);
}
/**
* @private
* @return {?}
*/
startLife() {
/** @type {?} */
let timeout = this._readed ? this.extendedTimeout : this.timeout;
this._lifeTimeout = window.setTimeout((/**
* @return {?}
*/
() => this.setVisible(false)), timeout);
}
}
if (false) {
/**
* @type {?}
* @private
*/
StAlert.prototype._changeVisibilityInterval;
/**
* @type {?}
* @private
*/
StAlert.prototype._lifeTimeout;
/**
* @type {?}
* @private
*/
StAlert.prototype._readed;
/**
* @type {?}
* @private
*/
StAlert.prototype._opacity;
/**
* @type {?}
* @private
*/
StAlert.prototype._opacityState;
/**
* @type {?}
* @private
*/
StAlert.prototype._removeEvent;
/** @type {?} */
StAlert.prototype.id;
/** @type {?} */
StAlert.prototype.title;
/** @type {?} */
StAlert.prototype.message;
/** @type {?} */
StAlert.prototype.severity;
/** @type {?} */
StAlert.prototype.timeout;
/** @type {?} */
StAlert.prototype.extendedTimeout;
/** @type {?} */
StAlert.prototype.link;
}
/**
* @fileoverview added by tsickle
* Generated from: lib/st-alerts/st-alerts.service.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class StAlertsService {
constructor() {
this._alertsList = [];
this._nextId = 0;
this._alertsStream = new BehaviorSubject([]);
}
/**
* @return {?}
*/
get alertList() {
return this._alertsStream.asObservable();
}
/**
* @param {?} title
* @param {?} message
* @param {?} severity
* @param {?=} link
* @param {?=} timeout
* @param {?=} extendedTimeout
* @return {?}
*/
notifyAlert(title, message, severity, link, timeout, extendedTimeout) {
timeout = timeout !== undefined ? timeout : 5000;
extendedTimeout = extendedTimeout !== undefined ? extendedTimeout : 4000;
/** @type {?} */
let alert = new StAlert(this._nextId, title, message, severity, timeout, extendedTimeout, link);
alert.removeAlertEvent.subscribe((/**
* @param {?} alertToRemove
* @return {?}
*/
alertToRemove => this.onNotifyRemove(alertToRemove)));
this.insertAlert(alert);
this._nextId++;
}
/**
* @private
* @param {?} alert
* @return {?}
*/
insertAlert(alert) {
this._alertsList.push(alert);
this._alertsStream.next(this._alertsList);
}
/**
* @private
* @param {?} alert
* @return {?}
*/
onNotifyRemove(alert) {
/** @type {?} */
let pos = this._alertsList.findIndex((/**
* @param {?} internalAlert
* @return {?}
*/
internalAlert => internalAlert.id === alert.id));
this._alertsList.splice(pos, 1);
this._alertsStream.next(this._alertsList);
}
}
StAlertsService.decorators = [
{ type: Injectable }
];
if (false) {
/**
* @type {?}
* @private
*/
StAlertsService.prototype._alertsList;
/**
* @type {?}
* @private
*/
StAlertsService.prototype._nextId;
/**
* @type {?}
* @private
*/
StAlertsService.prototype._alertsStream;
}
/**
* @fileoverview added by tsickle
* Generated from: lib/st-modal/st-modal.model.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @enum {number} */
const StModalResponse = {
YES: 0, NO: 1, CLOSE: 2,
};
StModalResponse[StModalResponse.YES] = 'YES';
StModalResponse[StModalResponse.NO] = 'NO';
StModalResponse[StModalResponse.CLOSE] = 'CLOSE';
/** @enum {number} */
const StModalBasicType = {
DELETE: 0, CONFIRM: 1, INFO: 2, WARNING: 3,
};
StModalBasicType[StModalBasicType.DELETE] = 'DELETE';
StModalBasicType[StModalBasicType.CONFIRM] = 'CONFIRM';
StModalBasicType[StModalBasicType.INFO] = 'INFO';
StModalBasicType[StModalBasicType.WARNING] = 'WARNING';
class StModalButton {
}
if (false) {
/** @type {?} */
StModalButton.prototype.response;
/** @type {?} */
StModalButton.prototype.responseValue;
/** @type {?} */
StModalButton.prototype.leftIcon;
/** @type {?} */
StModalButton.prototype.rightIcon;
/** @type {?} */
StModalButton.prototype.classes;
/** @type {?} */
StModalButton.prototype.closeOnClick;
/** @type {?} */
StModalButton.prototype.label;
}
class StModalConfig {
}
if (false) {
/** @type {?} */
StModalConfig.prototype.fullscreen;
/** @type {?} */
StModalConfig.prototype.modalTitle;
/** @type {?} */
StModalConfig.prototype.messageTitle;
/** @type {?} */
StModalConfig.prototype.message;
/** @type {?} */
StModalConfig.prototype.html;
/** @type {?} */
StModalConfig.prototype.inputs;
/** @type {?} */
StModalConfig.prototype.outputs;
/** @type {?} */
StModalConfig.prototype.buttons;
/** @type {?} */
StModalConfig.prototype.maxWidth;
/** @type {?} */
StModalConfig.prototype.minWidth;
/** @type {?} */
StModalConfig.prototype.empty;
/** @type {?} */
StModalConfig.prototype.showCloseBtn;
/** @type {?} */
StModalConfig.prototype.iconStatus;
}
class StModalButtonResponse {
}
if (false) {
/** @type {?} */
StModalButtonResponse.prototype.response;
/** @type {?} */
StModalButtonResponse.prototype.close;
}
/**
* @fileoverview added by tsickle
* Generated from: lib/utils/window-service.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @return {?}
*/
function getWindow() {
return window;
}
class StWindowRefService {
/**
* @return {?}
*/
get nativeWindow() {
return getWindow();
}
}
StWindowRefService.decorators = [
{ type: Injectable }
];
/**
* @fileoverview added by tsickle
* Generated from: lib/st-modal/st-modal.component.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class StModalComponent {
/**
* @param {?} cfr
* @param {?} windowRef
*/
constructor(cfr, windowRef) {
this.cfr = cfr;
this.windowRef = windowRef;
this.disabledAnimation = true;
this.click = new EventEmitter();
this.endAnimation = new EventEmitter();
this.defaultMaxWidth = 600;
this.defaultMinWidth = 400;
this.visibility = 'visible';
this._subscriptions = [];
}
/**
* @return {?}
*/
get hasIcon() {
return this.modalConfig.iconStatus;
}
/**
* @return {?}
*/
get isFullscreen() {
return this.modalConfig.fullscreen;
}
/**
* @return {?}
*/
get title() {
return this.modalConfig.modalTitle;
}
/**
* @return {?}
*/
get buttons() {
return this.modalConfig.buttons || [];
}
/**
* @return {?}
*/
get isMessageModal() {
return this.modalConfig.message && this.modalConfig.message.length > 0;
}
/**
* @return {?}
*/
get isComplexMessageModal() {
return this.modalConfig.html && this.modalConfig.html.length > 0;
}
/**
* @return {?}
*/
get html() {
return this.modalConfig.html;
}
/**
* @return {?}
*/
get message() {
return this.modalConfig.message;
}
/**
* @return {?}
*/
get messageTitle() {
return this.modalConfig.messageTitle;
}
/**
* @return {?}
*/
get modalStyles() {
/** @type {?} */
const maxWidth = this.modalConfig.maxWidth || this.defaultMaxWidth;
/** @type {?} */
const minWidth = this.modalConfig.minWidth || this.defaultMinWidth;
/** @type {?} */
const width = this.getModalActualWidth(maxWidth, minWidth);
return { 'max-width': `${maxWidth}px`, 'min-width': `${minWidth}px`, 'width': `${width}px` };
}
/**
* @return {?}
*/
get emptyModal() {
return this.modalConfig && this.modalConfig.empty;
}
/**
* @return {?}
*/
get showCloseBtn() {
return this.modalConfig.showCloseBtn;
}
/**
* @param {?} event
* @return {?}
*/
animationDone(event) {
if (event.toState === 'hidden') {
this.endAnimation.emit(true);
}
}
/**
* @param {?} event
* @return {?}
*/
onClickButtons(event) {
this.visibility = 'hidden';
this._subscriptions.push(this.endAnimation.subscribe((/**
* @param {?} data
* @return {?}
*/
(data) => {
if (data) {
this.click.emit(event);
}
})));
}
/**
* @return {?}
*/
onClose() {
this.visibility = 'hidden';
this._subscriptions.push(this.endAnimation.subscribe((/**
* @param {?} data
* @return {?}
*/
(data) => {
if (data) {
this.click.emit({
response: StModalResponse.CLOSE,
close: true
});
}
})));
}
/**
* DYNAMIC MODAL BODY COMPONENT LOAD
* @return {?}
*/
ngAfterViewInit() {
this.target = this.emptyModal ? this.targetEmpty : this.targetContent;
if (this.component && !(this.modalConfig.html || this.modalConfig.message)) {
this.loadBody();
}
this.windowRef.nativeWindow.document.body.classList.add('st-modal-overlay');
}
/**
* @return {?}
*/
ngOnDestroy() {
if (this.componentRef) {
this.componentRef.destroy();
}
this.windowRef.nativeWindow.document.body.classList.remove('st-modal-overlay');
if (this._subscriptions.length > 0) {
this._subscriptions.forEach((/**
* @param {?} subscription
* @return {?}
*/
(subscription) => {
if (subscription) {
subscription.unsubscribe();
}
}));
}
}
/**
* @private
* @param {?} maxWidth
* @param {?=} minWidth
* @return {?}
*/
getModalActualWidth(maxWidth, minWidth) {
/** @type {?} */
const screenWidth = this.windowRef.nativeWindow.screen.width;
return screenWidth > maxWidth ? maxWidth : (screenWidth < minWidth ? minWidth : screenWidth);
}
/**
* @private
* @return {?}
*/
loadBody() {
if (!this.componentRef) {
this.target.clear();
/** @type {?} */
const compFactory = this.cfr.resolveComponentFactory(this.component);
this.componentRef = this.target.createComponent(compFactory);
this.bindModalInputs();
}
}
/**
* @private
* @return {?}
*/
bindModalInputs() {
Object.keys(this.modalConfig.inputs).forEach((/**
* @param {?} key
* @return {?}
*/
(key) => {
this.componentRef.instance[key] = ((/** @type {?} */ (this.modalConfig.inputs)))[key];
}));
Object.keys(this.modalConfig.outputs).forEach((/**
* @param {?} key
* @return {?}
*/
(key) => {
this.componentRef.instance[key].subscribe(((/** @type {?} */ (this.modalConfig.outputs)))[key]);
}));
this.componentRef.changeDetectorRef.detectChanges();
}
}
StModalComponent.decorators = [
{ type: Component, args: [{
selector: 'st-modal',
template: "<!--\n\n \u00A9 2017 Stratio Big Data Inc., Sucursal en Espa\u00F1a.\n\n This software is licensed under the Apache License, Version 2.0.\n This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;\n without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n See the terms of the License for more details.\n\n SPDX-License-Identifier: Apache-2.0.\n\n-->\n<div class=\"st-modal-container\" [@state]=\"visibility\" (@state.done)=\"animationDone($event)\" [@.disabled]=\"disabledAnimation\">\n <section *ngIf=\"emptyModal\" class=\"st-modal\" [ngClass]=\"{'st-modal-fullscreen': isFullscreen}\" [ngStyle]=\"modalStyles\" [hidden]=\"emptyModal\">\n <div #stModalBodyEmpty></div>\n </section>\n <section *ngIf=\"!emptyModal\" class=\"st-modal\" [ngClass]=\"{'st-modal-fullscreen': isFullscreen}\" [ngStyle]=\"modalStyles\" [hidden]=\"!emptyModal\">\n <div class=\"st-modal-header\">\n <div class=\"container\">\n <span class=\"status-icon\" [ngClass]=\"hasIcon\" *ngIf=\"hasIcon\"></span>\n <p class=\"title\">{{title}}</p> <span class=\"close-button\" *ngIf=\"showCloseBtn\" (click)=\"onClose()\"></span>\n\n <st-modal-buttons *ngIf=\"isFullscreen\" [buttonConfig]=\"buttons\" [fullscreen]=\"isFullscreen\" (click)=\"onClickButtons($event)\"></st-modal-buttons>\n </div>\n </div>\n <div class=\"st-modal-body\">\n <div class=\"container\">\n\n <div *ngIf=\"isMessageModal\" class=\"message\">\n <h1 id=\"st-modal-message-plain-title\" class=\"st-modal-message-plain-title\">{{messageTitle}}</h1>\n <p id=\"st-modal-message-plain-message\" class=\"st-modal-message-plain-message\">{{message}}</p>\n </div>\n <div *ngIf=\"isComplexMessageModal\" [innerHTML]=\"html\" id=\"st-modal-message-html\"></div>\n <div #stModalBody id=\"st-modal-message-component\"></div>\n\n </div>\n </div>\n <footer class=\"st-modal-footer\" *ngIf=\"buttons && buttons.length > 0\">\n <div class=\"container\">\n <st-modal-buttons *ngIf=\"!isFullscreen\" [buttonConfig]=\"buttons\" (click)=\"onClickButtons($event)\"></st-modal-buttons>\n </div>\n </footer>\n </section>\n</div>\n",
changeDetection: ChangeDetectionStrategy.OnPush,
animations: [
trigger('state', [
state('void, hidden', style({ opacity: 0 })),
state('visible', style({ opacity: 1 })),
transition('* => visible', [
style({ opacity: 0 }),
animate(300)
]),
transition('* => hidden', [
style({ opacity: 1 }),
animate(300)
])
])
],
styles: ["@charset \"UTF-8\";.st-modal-container{display:flex;height:100vh;left:0;position:fixed;top:0;width:100%}.st-modal-container .st-modal{-ms-grid-row-align:center;align-self:center;display:flex;flex-direction:column;margin:auto}.st-modal-container .st-modal.st-modal-fullscreen{min-height:100vh;max-height:100vh;min-width:100%;max-width:100%}.st-modal-container .st-modal .st-modal-header{display:flex;flex-direction:row;height:70px;width:100%}.st-modal-container .st-modal .st-modal-header .container{display:flex;margin-right:auto;margin-left:auto;width:100%;align-items:center;flex-wrap:nowrap}.st-modal-container .st-modal .st-modal-header .container .status-icon{padding-right:1.05rem}.st-modal-container .st-modal .st-modal-header .container .status-icon.delete:before{content:var(--egeo-st-modal__delete-icon--content, \"\uE043\")}.st-modal-container .st-modal .st-modal-header .container .status-icon.alert:before{content:var(--egeo-st-modal__warning-icon--content, \"\uE613\")}.st-modal-container .st-modal .st-modal-header .container .close-button{font-size:var(--egeo-st-modal__close-icon--font-size,inherit);color:var(--egeo-st-modal__close-icon--color,inherit)}.st-modal-container .st-modal .st-modal-header .container .close-button:before{content:var(--egeo-st-modal__close-icon--content, \"\uE117\")}.st-modal-container .st-modal st-modal-buttons{display:flex;justify-content:flex-end;margin-left:auto}.st-modal-container .st-modal .container{min-width:auto}"]
}] }
];
/** @nocollapse */
StModalComponent.ctorParameters = () => [
{ type: ComponentFactoryResolver },
{ type: StWindowRefService }
];
StModalComponent.propDecorators = {
modalConfig: [{ type: Input }],
component: [{ type: Input }],
disabledAnimation: [{ type: HostBinding, args: ['@.disabled',] }, { type: Input }],
click: [{ type: Output }],
endAnimation: [{ type: Output }],
targetContent: [{ type: ViewChild, args: ['stModalBody', { read: ViewContainerRef, static: false },] }],
targetEmpty: [{ type: ViewChild, args: ['stModalBodyEmpty', { read: ViewContainerRef, static: false },] }]
};
if (false) {
/** @type {?} */
StModalComponent.prototype.modalConfig;
/** @type {?} */
StModalComponent.prototype.component;
/** @type {?} */
StModalComponent.prototype.disabledAnimation;
/** @type {?} */
StModalComponent.prototype.click;
/** @type {?} */
StModalComponent.prototype.endAnimation;
/** @type {?} */
StModalComponent.prototype.targetContent;
/** @type {?} */
StModalComponent.prototype.targetEmpty;
/** @type {?} */
StModalComponent.prototype.defaultMaxWidth;
/** @type {?} */
StModalComponent.prototype.defaultMinWidth;
/** @type {?} */
StModalComponent.prototype.target;
/** @type {?} */
StModalComponent.prototype.visibility;
/**
* @type {?}
* @private
*/
StModalComponent.prototype.componentRef;
/**
* @type {?}
* @private
*/
StModalComponent.prototype._subscriptions;
/**
* @type {?}
* @private
*/
StModalComponent.prototype.cfr;
/**
* @type {?}
* @private
*/
StModalComponent.prototype.windowRef;
}
/**
* @fileoverview added by tsickle
* Generated from: lib/st-modal/st-modal.service.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class StModalService {
/**
* @param {?} _cfr
*/
constructor(_cfr) {
this._cfr = _cfr;
this._containerRef = undefined;
this.dynamicModal = undefined;
}
/* External API */
/**
* @param {?} container
* @return {?}
*/
set container(container) {
this._containerRef = container;
}
// - Public methods
/**
* @param {?} config
* @param {?=} component
* @param {?=} disabledAnimation
* @return {?}
*/
show(config, component, disabledAnimation) {
/** @type {?} */
let errors = this.canCreateModal(config, component);
if (errors && errors.length > 0) {
throw new Error(errors.join(' '));
}
this.notifyButtonInteraction = new Subject();
this.createModal(this.createConfig(config), component, disabledAnimation);
return this.notifyButtonInteraction.asObservable();
}
/**
* @param {?} type
* @param {?} modalTitle
* @param {?} messageTitle
* @param {?} message
* @param {?} okButton
* @param {?=} cancelButton
* @param {?=} maxWidth
* @param {?=} minWidth
* @param {?=} icon
* @param {?=} showCloseBtn
* @return {?}
*/
showBasicModal(type, modalTitle, messageTitle, message, okButton, cancelButton = '', maxWidth = 600, minWidth = 400, icon = '', showCloseBtn = false) {
/** @type {?} */
let iconStatus;
/** @type {?} */
const buttons = [{
label: okButton,
classes: (type === StModalBasicType.DELETE) ? 'button-critical' : 'button-primary',
responseValue: StModalResponse.YES,
closeOnClick: true
}];
if (type !== StModalBasicType.INFO) {
buttons.unshift({
label: cancelButton,
classes: (type === StModalBasicType.DELETE) ? 'button-borderless' : 'button-secondary',
responseValue: StModalResponse.NO,
closeOnClick: true
});
}
switch (type) {
case StModalBasicType.DELETE:
iconStatus = 'delete';
break;
case StModalBasicType.WARNING:
iconStatus = 'alert';
break;
default:
iconStatus = icon;
break;
}
return this.show({
fullscreen: false,
message,
messageTitle,
modalTitle,
buttons,
maxWidth,
minWidth,
showCloseBtn,
iconStatus
});
}
/**
* @return {?}
*/
close() {
this.destroy();
}
/* INTERNAL METHODS FOR WORK WITH MODALS */
/**
* @private
* @param {?} modalConfig
* @param {?=} component
* @param {?=} disabledAnimation
* @return {?}
*/
createModal(modalConfig, component, disabledAnimation) {
/** @type {?} */
let stModalFactory = this._cfr.resolveComponentFactory(StModalComponent);
if (stModalFactory) {
this._containerRef.clear();
this.dynamicModal = this._containerRef.createComponent(stModalFactory);
this.bindVars(modalConfig, component, disabledAnimation);
}
}
/**
* @private
* @return {?}
*/
destroy() {
if (this.dynamicModal) {
this.dynamicModal.destroy();
this.dynamicModal = undefined;
this.notifyButtonInteraction.next(StModalResponse.CLOSE);
this.notifyButtonInteraction.complete();
}
}
/**
* @private
* @param {?} modalConfig
* @param {?} component
* @param {?} disabledAnimation
* @return {?}
*/
bindVars(modalConfig, component, disabledAnimation) {
this.dynamicModal.instance.component = component;
this.dynamicModal.instance.click.subscribe(this.notify.bind(this));
this.dynamicModal.instance.modalConfig = modalConfig;
this.dynamicModal.instance.disabledAnimation = (disabledAnimation !== null) ? disabledAnimation : true;
this.dynamicModal.changeDetectorRef.detectChanges();
}
/**
* @private
* @param {?} buttonResponse
* @return {?}
*/
notify(buttonResponse) {
this.notifyButtonInteraction.next(buttonResponse.response);
if (buttonResponse.close) {
this.close();
}
}
/**
* @private
* @param {?} config
* @param {?=} component
* @return {?}
*/
canCreateModal(config, component) {
/** @type {?} */
let errors = [];
if (!this._containerRef) {
errors.push(`[ERROR]: StModalService => Cant find container, are you sure you declarate in MAIN APP component in html and typescript?`);
}
if (this.dynamicModal !== undefined) {
errors.push(`[ERROR]: StModalService => Can't create modal beacause already exists one. Are you sure that you call close method?)`);
}
if (!component && !config.message && !config.html) {
errors.push(`[ERROR]: StModalService => Can't find message, html or component to show in modal`);
}
return errors;
}
/**
* @private
* @param {?} config
* @return {?}
*/
createConfig(config) {
/** @type {?} */
const defaultConfig = {
fullscreen: false,
inputs: {},
outputs: {},
modalTitle: 'Default title',
messageTitle: 'Default subtitle',
buttons: [],
message: undefined,
html: undefined,
maxWidth: undefined,
minWidth: undefined,
empty: false
};
/** @type {?} */
const checkedConfig = Object.assign({}, defaultConfig, config);
checkedConfig.buttons = this.checkButtons(checkedConfig.buttons);
return checkedConfig;
}
/**
* @private
* @param {?} buttons
* @return {?}
*/
checkButtons(buttons) {
return buttons.map((/**
* @param {?} button
* @return {?}
*/
button => Object.assign({}, { label: 'Button', closeOnClick: false }, button)));
}
}
StModalService.decorators = [
{ type: Injectable }
];
/** @nocollapse */
StModalService.ctorParameters = () => [
{ type: ComponentFactoryResolver }
];
if (false) {
/**
* @type {?}
* @private
*/
StModalService.prototype._containerRef;
/**
* @type {?}
* @private
*/
StModalService.prototype.dynamicModal;
/**
* @type {?}
* @private
*/
StModalService.prototype.notifyButtonInteraction;
/**
* @type {?}
* @private
*/
StModalService.prototype._cfr;
}
/**
* @fileoverview added by tsickle
* Generated from: lib/st-pagination/st-pagination.service.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class StPaginationService {
constructor() {
}
/**
* @param {?} items
* @param {?} currentPage
* @param {?} perPage
* @return {?}
*/
newPage(items, currentPage, perPage) {
if (currentPage === 1) {
this.initItem = 0;
}
else {
this.initItem = perPage * (currentPage - 1);
}
if (perPage >= items.length) {
return Object.assign([], items);
}
if (this.initItem >= items.length) {
this.initItem = items.length - (perPage + 1);
return Object.assign([], takeRight(items, perPage));
}
this.lastItem = (this.initItem + perPage);
return Object.assign([], items.slice(this.initItem, this.lastItem));
}
}
StPaginationService.decorators = [
{ type: Injectable }
];
/** @nocollapse */
StPaginationService.ctorParameters = () => [];
if (false) {
/**
* @type {?}
* @private
*/
StPaginationService.prototype.initItem;
/**
* @type {?}
* @private
*/
StPaginationService.prototype.lastItem;
}
/**
* @fileoverview added by tsickle
* Generated from: lib/utils/egeo-resolver/egeo-resolve.service.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class EgeoResolveService {
/**
* @param {?} object
* @param {?} key
* @param {?=} searchedValue
* @return {?}
*/
getKeys(object, key, searchedValue) {
return this.searchInDeep(object, key, searchedValue);
}
/**
* @param {?} object
* @param {?} resolved
* @return {?}
*/
setKeys(object, resolved) {
resolved.forEach((/**
* @param {?} element
* @return {?}
*/
(element) => set(object, element.path, element.resolved)));
}
/**
* @param {?} object
* @param {?} translateService
* @return {?}
*/
translate(object, translateService) {
/** @type {?} */
let keys = this.getKeys(object, 'translate');
// If not found translateable elements, return the same because if not, translate service broke on try to translate an empty array.
if (keys && keys.length > 0) {
/** @type {?} */
let toTranslate = this.extractTranslationKeys(keys);
return translateService.get(toTranslate).pipe(// return object translation
map((/**
* @param {?} translation
* @return {?}
*/
(translation) => this.remapObjectWithTranslations(translation, keys, object))));
}
else {
return Observable.create((/**
* @param {?} observer
* @return {?}
*/
(observer) => {
observer.next(object);
observer.complete();
}));
}
}
/**
* @param {?} keys
* @param {?} translateService
* @return {?}
*/
translateArrayOfKeys(keys, translateService) {
return translateService.get(keys).pipe(map((/**
* @param {?} translation
* @return {?}
*/
(translation) => this.remapArrayWithTranslations(translation, keys))));
}
/**
* @private
* @param {?} translations
* @param {?} originalArray
* @return {?}
*/
remapArrayWithTranslations(translations, originalArray) {
return originalArray.map((/**
* @param {?} key
* @return {?}
*/
(key) => translations[key] ? translations[key] : key));
}
/**
* @private
* @param {?} translations
* @param {?} resolverKeys
* @param {?} object
* @return {?}
*/
remapObjectWithTranslations(translations, resolverKeys, object) {
/** @type {?} */
let newObj = cloneDeep(object);
if (translations || keys(translations).length > 0) {
forEach(resolverKeys, (/**
* @param {?} resolvKey
* @return {?}
*/
(resolvKey) => {
set(newObj, resolvKey.path, this.getTranslationFromTranslatedKey(translations, resolvKey));
}));
}
return newObj;
}
/**
* @private
* @param {?} translations
* @param {?} resolverKey
* @return {?}
*/
getTranslationFromTranslatedKey(translations, resolverKey) {
/** @type {?} */
let translationElementKey = resolverKey && resolverKey.toResolve && resolverKey.toResolve.key ? resolverKey.toResolve.key : '';
return translations[translationElementKey] ? translations[translationElementKey] : translationElementKey;
}
/**
* @private
* @param {?} list
* @return {?}
*/
extractTranslationKeys(list) {
return list.map((/**
* @param {?} element
* @return {?}
*/
(element) => (/** @type {?} */ (values(omit(element.toResolve, 'translate'))[0]))));
}
/**
* @private
* @param {?} object
* @param {?} key
* @param {?} searchedValue
* @param {?=} path
* @return {?}
*/
searchInDeep(object, key, searchedValue, path = '') {
/** @type {?} */
let result = [];
if (has(object, key)) { // If we found key, return object.
if (searchedValue !== undefined) {
if (object[key] === searchedValue) {
result.push({ path, toResolve: object });
}
}
else {
result.push({ path, toResolve: object });
}
}
/** @type {?} */
let i = 0;
forEach(object, (/**
* @param {?} value
* @param {?} objKey
* @return {?}
*/
(value, objKey) => {
if (typeof value === 'object') {
result = [...result, ...this.searchInDeep(value, key, searchedValue, this.getPath(path, object, i, objKey))];
}
i++;
}));
return result;
}
// Build path for future replace
/**
* @private
* @param {?} actualPath
* @param {?} obj
* @param {?} pos
* @param {?} key
* @return {?}
*/
getPath(actualPath, obj, pos, key) {
if (this.isArray(obj)) {
actualPath = `${actualPath}[${pos}]`;
}
else {
actualPath = actualPath === '' ? key : `${actualPath}.${key}`;
}
return actualPath;
}
/**
* @private
* @param {?} value
* @return {?}
*/
isArray(value) {
return Object.prototype.toString.call(value) === '[object Array]';
}
}
EgeoResolveService.decorators = [
{ type: Injectable }
];
/**
* @fileoverview added by tsickle
* Generated from: lib/utils/unique-dispatcher.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class SelectOneDispatcher {
constructor() {
this.listeners = [];
}
/**
* @param {?} id
* @param {?} name
* @return {?}
*/
notify(id, name) {
for (let listener of this.listeners) {
listener(id, name);
}
}
/**
* @param {?} listener
* @return {?}
*/
listen(listener) {
this.listeners.push(listener);
}
}
SelectOneDispatcher.decorators = [
{ type: Injectable }
];
if (false) {
/**
* @type {?}
* @private
*/
SelectOneDispatcher.prototype.listeners;
}
/**
* @fileoverview added by tsickle
* Generated from: lib/pipes/search-filter/search-filter.pipe.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class StFilterList {
/**
* @param {?} list
* @param {?} field
* @param {?} search
* @return {?}
*/
transform(list, field, search) {
this.checkParams(field);
if (!search) {
return list;
}
if (list && list.length > 0 && field) {
return list.filter((/**
* @param {?} element
* @return {?}
*/
(element) => this.contains(element, field, search)));
}
else {
return [];
}
}
/**
* @private
* @param {?} element
* @param {?} field
* @param {?} search
* @return {?}
*/
contains(element, field, search) {
if (this.isDefined(element) && this.isString(field) && this.isString(search) && this.isString(element[field])) {
return element[field].toUpperCase().search(search.toUpperCase()) > -1;
}
return false;
}
/**
* @private
* @param {?} value
* @return {?}
*/
isDefined(value) {
return value !== undefined && value !== null;
}
/**
* @private
* @param {?} value
* @return {?}
*/
isString(value) {
return this.isDefined(value) && typeof value === 'string';
}
/**
* @private
* @param {?} field
* @return {?}
*/
checkParams(field) {
if (!this.isString(field)) {
throw new Error('PIPE: stFilterList: "field" is a required and string parameter');
}
}
}
StFilterList.decorators = [
{ type: Pipe, args: [{
name: 'stFilterList'
},] }
];
/**
* @fileoverview added by tsickle
* Generated from: lib/pipes/st-object-to-array/st-object-to-array.pipe.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class StObjectToArrayPipe {
/**
* @param {?} obj
* @return {?}
*/
transform(obj) {
return obj ? Object.keys(obj).map((/**
* @param {?} key
* @return {?}
*/
key => ({ key, value: obj[key] }))) : [];
}
}
StObjectToArrayPipe.decorators = [
{ type: Pipe, args: [{ 'name': 'stObjectToArray' },] }
];
/**
* @fileoverview added by tsickle
* Generated from: lib/pipes/pipes.module.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class PipesModule {
}
PipesModule.decorators = [
{ type: NgModule, args: [{
imports: [CommonModule],
declarations: [StFilterList, StObjectToArrayPipe],
exports: [StFilterList, StObjectToArrayPipe]
},] }
];
/**
* @fileoverview added by tsickle
* Generated from: lib/st-alerts/st-alerts.component.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @description {Component} [Alerts]
*
* Alerts are made to let the user know errors or information about he is trying to do.
*
* @model
*
* [Alert] {./st-alerts.model.ts#StAlert}
*
* @example
*
* {html}
*
* ```
* <st-alerts [showInConsole]="true"></st-alerts>
*
* ```
*/
class StAlertsComponent {
/**
* @param {?} alertService
*/
constructor(alertService) {
this.alertService = alertService;
/**
* \@Input {boolean} [showInConsole=false] Display logs in console
*/
this.showInConsole = false;
/**
* \@Input {string} [qaTag=] Component qa tag
*/
this.qaTag = 'st-alert-manager';
}
}
StAlertsComponent.decorators = [
{ type: Component, args: [{
selector: 'st-alerts',
template: "<!--\n\n \u00A9 2017 Stratio Big Data Inc., Sucursal en Espa\u00F1a.\n\n This software is licensed under the Apache License, Version 2.0.\n This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;\n without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n See the terms of the License for more details.\n\n SPDX-License-Identifier: Apache-2.0.\n\n-->\n<div [attr.id]='qaTag' class=\"st-alerts sth-alerts\">\n <st-alert-box class=\"st-alert-box\" *ngFor=\"let alert of (alertService.alertList | async)\" [alert]=\"alert\" [showInConsole]=\"showInConsole\"></st-alert-box>\n</div>\n",
changeDetection: ChangeDetectionStrategy.OnPush,
styles: ["@charset \"UTF-8\";.st-alert-box{margin-top:15px;display:block}.st-alerts{width:288px;position:fixed;right:15px;top:0}"]
}] }
];
/** @nocollapse */
StAlertsComponent.ctorParameters = () => [
{ type: StAlertsService }
];
StAlertsComponent.propDecorators = {
showInConsole: [{ type: Input }],
qaTag: [{ type: Input }]
};
if (false) {
/**
* \@Input {boolean} [showInConsole=false] Display logs in console
* @type {?}
*/
StAlertsComponent.prototype.showInConsole;
/**
* \@Input {string} [qaTag=] Component qa tag
* @type {?}
*/
StAlertsComponent.prototype.qaTag;
/** @type {?} */
StAlertsComponent.prototype.alertService;
}
/**
* @fileoverview added by tsickle
* Generated from: lib/st-alerts/alert-box/st-alert-box.component.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @description {Component} [Alert Box]
*
* Alert box is made to let the user know errors or information about he is trying to do.
*
* @example
*
* {html}
*
* ```
* <st-alert-box [alert]="alert" [showInConsole]="showInConsole"></st-alert-box>
*
* ```
*/
class StAlertBoxComponent {
/**
* @param {?} _cd
*/
constructor(_cd) {
this._cd = _cd;
/**
* \@Input {boolean} [showInConsole=false] Display logs in console
*/
this.showInConsole = false;
/**
* \@Output {StAlertLink} [clickLink=] Event emitted when link is clicked
*/
this.clickLink = new EventEmitter();
/**
* \@Output {boolean} [close=] Event emitted when alert is closed
*/
this.close = new EventEmitter();
this.opacity = 0;
}
/**
* @return {?}
*/
ngOnInit() {
this.alert.opacity.subscribe((/**
* @param {?} opacity
* @return {?}
*/
opacity => this.changeOpacity(opacity)));
this.alert.notify();
if (this.showInConsole) {
this.notifyConsole();
}
this.severityColorValue = this.getSeverityColor();
this.iconValue = this.getIcon();
}
/**
* @return {?}
*/
closeAlert() {
this.alert.cancel();
this.close.emit(true);
}
/**
* @return {?}
*/
getIcon() {
switch (this.alert.severity) {
case STALERT_SEVERITY.ERROR: return 'icon-circle-alert';
case STALERT_SEVERITY.WARNING: return 'icon-alert';
case STALERT_SEVERITY.SUCCESS: return 'icon-circle-check';
case STALERT_SEVERITY.INFO: return 'icon-info';
default: return '';
}
}
/**
* @return {?}
*/
getSeverityColor() {
switch (this.alert.severity) {
case STALERT_SEVERITY.ERROR: return 'sth-alert-box-error';
case STALERT_SEVERITY.WARNING: return 'sth-alert-box-warning';
case STALERT_SEVERITY.SUCCESS: return 'sth-alert-box-success';
case STALERT_SEVERITY.INFO: return 'sth-alert-box-info';
default: return '';
}
}
/**
* @return {?}
*/
goTo() {
this.clickLink.emit(this.alert.link);
}
/**
* @param {?} opacity
* @return {?}
*/
changeOpacity(opacity) {
this.opacity = opacity;
this._cd.markForCheck();
}
/**
* @private
* @return {?}
*/
notifyConsole() {
switch (this.alert.severity) {
case STALERT_SEVERITY.ERROR:
console.error(`ERROR-${this.alert.title}: ${this.alert.message}`);
break;
case STALERT_SEVERITY.WARNING:
console.warn(`WARNING-${this.alert.title}: ${this.alert.message}`);
break;
case STALERT_SEVERITY.SUCCESS:
console.log(`SUCCESS-${this.alert.title}: ${this.alert.message}`);
break;
default:
console.error(`ERROR: severity not found for ${this.alert.title}: ${this.alert.message}`);
break;
}
}
}
StAlertBoxComponent.decorators = [
{ type: Component, args: [{
selector: 'st-alert-box',
template: "<!--\n\n \u00A9 2017 Stratio Big Data Inc., Sucursal en Espa\u00F1a.\n\n This software is licensed under the Apache License, Version 2.0.\n This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;\n without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n See the terms of the License for more details.\n\n SPDX-License-Identifier: Apache-2.0.\n\n-->\n<div class=\"sth-alert-box\" [ngClass]=\"severityColorValue\" [ngStyle]=\"{opacity: opacity}\">\n <div class=\"sth-alert-box-content\">\n <div class=\"sth-alert-box-close-button\">\n <i (click)=\"closeAlert()\" class=\"icon-cross\"></i>\n </div>\n <header class=\"sth-alert-box-header\">\n <i class=\"status-icon\" [ngClass]=\"iconValue\"></i>\n <span>{{alert.title}}</span>\n </header>\n <div class=\"sth-alert-box-body\">\n <p>{{alert.message}}</p>\n </div>\n </div>\n <footer *ngIf=\"alert.link\" class=\"sth-alert-box-footer\">\n <a (click)=\"goTo()\">{{alert.link.title}}</a>\n </footer>\n</div>\n",
changeDetection: ChangeDetectionStrategy.OnPush
}] }
];
/** @nocollapse */
StAlertBoxComponent.ctorParameters = () => [
{ type: ChangeDetectorRef }
];
StAlertBoxComponent.propDecorators = {
alert: [{ type: Input }],
showInConsole: [{ type: Input }],
clickLink: [{ type: Output }],
close: [{ type: Output }]
};
if (false) {
/**
* \@Input {StAlert} [alert=] Data of the alert
* @type {?}
*/
StAlertBoxComponent.prototype.alert;
/**
* \@Input {boolean} [showInConsole=false] Display logs in console
* @type {?}
*/
StAlertBoxComponent.prototype.showInConsole;
/**
* \@Output {StAlertLink} [clickLink=] Event emitted when link is clicked
* @type {?}
*/
StAlertBoxComponent.prototype.clickLink;
/**
* \@Output {boolean} [close=] Event emitted when alert is closed
* @type {?}
*/
StAlertBoxComponent.prototype.close;
/** @type {?} */
StAlertBoxComponent.prototype.iconValue;
/** @type {?} */
StAlertBoxComponent.prototype.opacity;
/** @type {?} */
StAlertBoxComponent.prototype.severityColorValue;
/**
* @type {?}
* @private
*/
StAlertBoxComponent.prototype._cd;
}
/**
* @fileoverview added by tsickle
* Generated from: lib/st-alerts/alert-box/st-alert-box.module.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class StAlertBoxModule {
}
StAlertBoxModule.decorators = [
{ type: NgModule, args: [{
imports: [CommonModule],
declarations: [StAlertBoxComponent],
exports: [StAlertBoxComponent]
},] }
];
/**
* @fileoverview added by tsickle
* Generated from: lib/st-alerts/st-alerts.module.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRe