/**
 * @fileoverview added by tsickle
 * Generated from: lib/ui-components/monitoring-actions/monitoring-actions.component.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
import { __awaiter, __generator } from "tslib";
import { Component, ContentChild, Directive, EventEmitter, Input, Output, TemplateRef } from '@angular/core';
import { CurrentDeviceService, LibError, PendingCallManager } from '@iotize/ionic';
import { AbstractVariable } from '@iotize/tap/data';
import { debug } from '../../debug';
/**
 * @record
 */
export function ActionItem() { }
if (false) {
    /** @type {?} */
    ActionItem.prototype.label;
    /** @type {?|undefined} */
    ActionItem.prototype.icon;
    /** @type {?|undefined} */
    ActionItem.prototype.disabled;
    /** @type {?} */
    ActionItem.prototype.action;
}
var ErrorContainerDirective = /** @class */ (function () {
    function ErrorContainerDirective(tpl) {
        this.tpl = tpl;
    }
    ErrorContainerDirective.decorators = [
        { type: Directive, args: [{
                    selector: '[errorContainer]'
                },] }
    ];
    /** @nocollapse */
    ErrorContainerDirective.ctorParameters = function () { return [
        { type: TemplateRef }
    ]; };
    return ErrorContainerDirective;
}());
export { ErrorContainerDirective };
if (false) {
    /** @type {?} */
    ErrorContainerDirective.prototype.tpl;
}
var MonitoringActionsComponent = /** @class */ (function () {
    function MonitoringActionsComponent(tapService) {
        this.scrollError = true;
        this.segment = true;
        this.actions = [];
        this.onError = new EventEmitter();
        this.showError = true;
        this.scrollable = false;
        this.pendingCallManager = PendingCallManager.create(tapService);
    }
    Object.defineProperty(MonitoringActionsComponent.prototype, "loading", {
        get: /**
         * @return {?}
         */
        function () {
            return this.pendingCallManager.loading;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(MonitoringActionsComponent.prototype, "pending", {
        get: /**
         * @return {?}
         */
        function () {
            return this.pendingCallManager.hasPendingCall();
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(MonitoringActionsComponent.prototype, "errorContainerTemplate", {
        get: /**
         * @return {?}
         */
        function () {
            return this.errorContainerDir && this.errorContainerDir.tpl;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(MonitoringActionsComponent.prototype, "errorContainerTemplateContext", {
        get: /**
         * @return {?}
         */
        function () {
            return { $implicit: this.error };
        },
        enumerable: true,
        configurable: true
    });
    /**
     * @return {?}
     */
    MonitoringActionsComponent.prototype.ngOnInit = /**
     * @return {?}
     */
    function () { };
    /**
     * @return {?}
     */
    MonitoringActionsComponent.prototype.ngOnDestroy = /**
     * @return {?}
     */
    function () {
        this.cancel();
    };
    /**
     * @param {?} item
     * @param {?=} index
     * @return {?}
     */
    MonitoringActionsComponent.prototype.exec = /**
     * @param {?} item
     * @param {?=} index
     * @return {?}
     */
    function (item, index) {
        var _this = this;
        if (!this.variable) {
            throw LibError.componentArgumentRequired('MonitoringActionsComponent', 'variable');
        }
        this.error = undefined;
        this.pendingCallManager
            .exec((/**
         * @return {?}
         */
        function () { return __awaiter(_this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        if (!this.variable) {
                            return [2 /*return*/];
                        }
                        return [4 /*yield*/, item.action(this.variable)];
                    case 1:
                        _a.sent();
                        if (index !== undefined) {
                            this.checkedButtonIndex = index;
                        }
                        return [2 /*return*/];
                }
            });
        }); }))
            .catch((/**
         * @param {?} err
         * @return {?}
         */
        function (err) {
            debug('MonitoringActionsComponent', 'error', err);
            _this.error = err;
            _this.onError.emit(err);
        }));
    };
    /**
     * @return {?}
     */
    MonitoringActionsComponent.prototype.cancel = /**
     * @return {?}
     */
    function () {
        this.error = undefined;
        this.pendingCallManager.cancel();
    };
    MonitoringActionsComponent.decorators = [
        { type: Component, args: [{
                    selector: 'app-monitoring-actions',
                    template: "<ion-item-sliding [disabled]=\"!error || false\">\r\n  <ion-item [ngStyle]=\"error && {'border-right': '#eb445a solid 5px'}\" [lines]=\"'none'\"  [disabled]=\"false\">\r\n  <ion-buttons *ngIf=\"!segment\" >\r\n    <ion-button *ngFor=\"let action of actions\" [disabled]=\"pending || loading || action.disabled\" (click)=\"exec(action)\" >\r\n      <ion-icon *ngIf=\"action.icon\" [name]=\"action.icon\"></ion-icon>\r\n      {{action.label}}\r\n    </ion-button>\r\n    <!-- <ion-button *ngIf=\"pending\" color=\"warning\">\r\n      <ion-icon name=\"alert\"></ion-icon>\r\n    </ion-button>-->\r\n    <ion-button *ngIf=\"pending\" color=\"warning\" (click)=\"cancel()\">\r\n        <ion-icon name=\"close\"></ion-icon>\r\n    </ion-button>\r\n    <ion-icon slot=\"end\" *ngIf=\"error\"  name=\"alert-outline\" color=\"danger\"></ion-icon>\r\n</ion-buttons> \r\n<ion-segment [value]=\"checkedButtonIndex\" [scrollable]=\"!error\" [ngStyle]=\"error ? {'overflow': 'auto'} : {'width' : '100%'}\">\r\n    <ion-segment-button *ngFor=\"let action of actions; let i = index;\" [value]=\"action.value\" [disabled]=\"pending || loading || action.disabled\" (click)=\"exec(action, i)\">\r\n      <ion-icon *ngIf=\"action.icon\" [name]=\"action.icon\"></ion-icon>\r\n      {{action.label}}\r\n    </ion-segment-button>\r\n    <!-- <ion-segment-button *ngIf=\"pending\" color=\"warning\">\r\n      <ion-icon name=\"alert\"></ion-icon>\r\n    </ion-segment-button> -->\r\n    <ion-segment-button *ngIf=\"pending\" (click)=\"cancel()\">\r\n        <ion-icon color=\"warning\" name=\"close\"></ion-icon> \r\n        <ion-text color=\"warning\">Cancel</ion-text>\r\n    </ion-segment-button>\r\n</ion-segment>\r\n<ion-icon slot=\"end\" *ngIf=\"error\"  name=\"alert-outline\" color=\"danger\" ></ion-icon>\r\n</ion-item>\r\n\r\n\r\n  <ion-item-options side=\"end\">\r\n    <ion-item-option color=\"danger\">\r\n      <ion-text *ngIf=\"error\" color=\"light\">\r\n        {{error.message}}\r\n      </ion-text>\r\n    </ion-item-option>\r\n  </ion-item-options>\r\n</ion-item-sliding>\r\n\r\n\r\n<!--\r\n<ng-template #defaultErrorContainer>\r\n    <ion-item *ngIf=\"error && showError\">\r\n        <ion-text color=\"danger\">\r\n            <ion-icon name=\"alert\"></ion-icon>\r\n            {{error.message}}\r\n        </ion-text>\r\n    </ion-item>\r\n</ng-template>\r\n-->",
                    styles: [".input-wrapper{position:relative;z-index:9999}"]
                }] }
    ];
    /** @nocollapse */
    MonitoringActionsComponent.ctorParameters = function () { return [
        { type: CurrentDeviceService }
    ]; };
    MonitoringActionsComponent.propDecorators = {
        errorContainerDir: [{ type: ContentChild, args: [ErrorContainerDirective, { static: true, read: true },] }],
        segment: [{ type: Input }],
        variable: [{ type: Input }],
        actions: [{ type: Input }],
        onError: [{ type: Output }],
        checkedButtonIndex: [{ type: Input }],
        showError: [{ type: Input }],
        error: [{ type: Input }]
    };
    return MonitoringActionsComponent;
}());
export { MonitoringActionsComponent };
if (false) {
    /** @type {?} */
    MonitoringActionsComponent.prototype.scrollError;
    /** @type {?} */
    MonitoringActionsComponent.prototype.errorContainerDir;
    /** @type {?} */
    MonitoringActionsComponent.prototype.segment;
    /** @type {?} */
    MonitoringActionsComponent.prototype.variable;
    /** @type {?} */
    MonitoringActionsComponent.prototype.actions;
    /** @type {?} */
    MonitoringActionsComponent.prototype.onError;
    /** @type {?} */
    MonitoringActionsComponent.prototype.checkedButtonIndex;
    /** @type {?} */
    MonitoringActionsComponent.prototype.showError;
    /**
     * @type {?}
     * @private
     */
    MonitoringActionsComponent.prototype.pendingCallManager;
    /** @type {?} */
    MonitoringActionsComponent.prototype.scrollable;
    /** @type {?} */
    MonitoringActionsComponent.prototype.error;
}
//# sourceMappingURL=data:application/json;base64, 