import { Component, Input } from '@angular/core';
import { FormBuilder } from '@angular/forms';
import { MonitoringSettingsService } from './monitoring-settings.service';
import { ModalController } from '@ionic/angular';
import { getFormFieldOrError } from '@iotize/ionic';
import * as i0 from "@angular/core";
import * as i1 from "@angular/forms";
import * as i2 from "./monitoring-settings.service";
import * as i3 from "@ionic/angular";
import * as i4 from "@angular/common";
export class TapMonitoringSettingsComponent {
    constructor(formBuilder, monitoringSettingsService, modalController) {
        this.formBuilder = formBuilder;
        this.monitoringSettingsService = monitoringSettingsService;
        this.modalController = modalController;
        this.showDataSource = false;
        this.form = this.formBuilder.group({
            period: [this.monitoringSettingsService.settings.period],
            dataSource: ['live'],
        });
    }
    get period() {
        return getFormFieldOrError(this.form, 'period');
    }
    get dataSource() {
        return getFormFieldOrError(this.form, 'dataSource');
    }
    ngOnInit() {
        this.form.valueChanges.subscribe(() => {
            this.monitoringSettingsService.settings = {
                period: this.period.value,
            };
        });
    }
    async dismiss() {
        const topOverlay = await this.modalController.getTop();
        if (topOverlay) {
            await this.modalController.dismiss(topOverlay.id);
        }
    }
}
/** @nocollapse */ TapMonitoringSettingsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TapMonitoringSettingsComponent, deps: [{ token: i1.FormBuilder }, { token: i2.MonitoringSettingsService }, { token: i3.ModalController }], target: i0.ɵɵFactoryTarget.Component });
/** @nocollapse */ TapMonitoringSettingsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: TapMonitoringSettingsComponent, selector: "tap-monitoring-settings", inputs: { showDataSource: "showDataSource" }, ngImport: i0, template: "<ion-header>\n  <ion-toolbar color=\"primary\">\n    <ion-buttons slot=\"start\">\n      <ion-button (click)=\"dismiss()\">\n        <ion-icon name=\"arrow-back\"></ion-icon>\n      </ion-button>\n    </ion-buttons>\n    <ion-title class=\"text-center\">\n      Monitoring Settings\n    </ion-title>\n  </ion-toolbar>\n</ion-header>\n<ion-content>\n  <form [formGroup]=\"form\">\n    <ion-list>\n      <ion-item>\n        <ion-label>Frequency (in milliseconds)</ion-label>\n        <ion-input\n          [formControlName]=\"'period'\"\n          slot=\"end\"\n          text-right\n          type=\"number\"\n        ></ion-input>\n      </ion-item>\n      <ion-item *ngIf=\"showDataSource\">\n        <ion-label>Data source</ion-label>\n        <ion-select [formControlName]=\"'dataSource'\" slot=\"end\">\n          <ion-select-option value=\"live\">Live data</ion-select-option>\n          <ion-select-option value=\"datalog\">Data log</ion-select-option>\n        </ion-select>\n      </ion-item>\n    </ion-list>\n  </form>\n</ion-content>\n<ion-footer>\n  <ion-toolbar>\n    <ion-buttons slot=\"end\">\n      <ion-button (click)=\"dismiss()\">Ok</ion-button>\n    </ion-buttons>\n  </ion-toolbar>\n</ion-footer>\n", styles: [""], dependencies: [{ kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i3.IonButton, selector: "ion-button", inputs: ["buttonType", "color", "disabled", "download", "expand", "fill", "form", "href", "mode", "rel", "routerAnimation", "routerDirection", "shape", "size", "strong", "target", "type"] }, { kind: "component", type: i3.IonButtons, selector: "ion-buttons", inputs: ["collapse"] }, { kind: "component", type: i3.IonContent, selector: "ion-content", inputs: ["color", "forceOverscroll", "fullscreen", "scrollEvents", "scrollX", "scrollY"] }, { kind: "component", type: i3.IonFooter, selector: "ion-footer", inputs: ["collapse", "mode", "translucent"] }, { kind: "component", type: i3.IonHeader, selector: "ion-header", inputs: ["collapse", "mode", "translucent"] }, { kind: "component", type: i3.IonIcon, selector: "ion-icon", inputs: ["color", "flipRtl", "icon", "ios", "lazy", "md", "mode", "name", "sanitize", "size", "src"] }, { kind: "component", type: i3.IonInput, selector: "ion-input", inputs: ["accept", "autocapitalize", "autocomplete", "autocorrect", "autofocus", "clearInput", "clearOnEdit", "color", "debounce", "disabled", "enterkeyhint", "inputmode", "max", "maxlength", "min", "minlength", "mode", "multiple", "name", "pattern", "placeholder", "readonly", "required", "size", "spellcheck", "step", "type", "value"] }, { kind: "component", type: i3.IonItem, selector: "ion-item", inputs: ["button", "color", "counter", "counterFormatter", "detail", "detailIcon", "disabled", "download", "fill", "href", "lines", "mode", "rel", "routerAnimation", "routerDirection", "shape", "target", "type"] }, { kind: "component", type: i3.IonLabel, selector: "ion-label", inputs: ["color", "mode", "position"] }, { kind: "component", type: i3.IonList, selector: "ion-list", inputs: ["inset", "lines", "mode"] }, { kind: "component", type: i3.IonSelect, selector: "ion-select", inputs: ["cancelText", "compareWith", "disabled", "interface", "interfaceOptions", "mode", "multiple", "name", "okText", "placeholder", "selectedText", "value"] }, { kind: "component", type: i3.IonSelectOption, selector: "ion-select-option", inputs: ["disabled", "value"] }, { kind: "component", type: i3.IonTitle, selector: "ion-title", inputs: ["color", "size"] }, { kind: "component", type: i3.IonToolbar, selector: "ion-toolbar", inputs: ["color", "mode"] }, { kind: "directive", type: i3.NumericValueAccessor, selector: "ion-input[type=number]" }, { kind: "directive", type: i3.SelectValueAccessor, selector: "ion-range, ion-select, ion-radio-group, ion-segment, ion-datetime" }, { kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TapMonitoringSettingsComponent, decorators: [{
            type: Component,
            args: [{ selector: 'tap-monitoring-settings', template: "<ion-header>\n  <ion-toolbar color=\"primary\">\n    <ion-buttons slot=\"start\">\n      <ion-button (click)=\"dismiss()\">\n        <ion-icon name=\"arrow-back\"></ion-icon>\n      </ion-button>\n    </ion-buttons>\n    <ion-title class=\"text-center\">\n      Monitoring Settings\n    </ion-title>\n  </ion-toolbar>\n</ion-header>\n<ion-content>\n  <form [formGroup]=\"form\">\n    <ion-list>\n      <ion-item>\n        <ion-label>Frequency (in milliseconds)</ion-label>\n        <ion-input\n          [formControlName]=\"'period'\"\n          slot=\"end\"\n          text-right\n          type=\"number\"\n        ></ion-input>\n      </ion-item>\n      <ion-item *ngIf=\"showDataSource\">\n        <ion-label>Data source</ion-label>\n        <ion-select [formControlName]=\"'dataSource'\" slot=\"end\">\n          <ion-select-option value=\"live\">Live data</ion-select-option>\n          <ion-select-option value=\"datalog\">Data log</ion-select-option>\n        </ion-select>\n      </ion-item>\n    </ion-list>\n  </form>\n</ion-content>\n<ion-footer>\n  <ion-toolbar>\n    <ion-buttons slot=\"end\">\n      <ion-button (click)=\"dismiss()\">Ok</ion-button>\n    </ion-buttons>\n  </ion-toolbar>\n</ion-footer>\n" }]
        }], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: i2.MonitoringSettingsService }, { type: i3.ModalController }]; }, propDecorators: { showDataSource: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64, 