var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { Component } from '@angular/core';
import { MDBModalRef } from 'angular-bootstrap-md';
import { Subject } from 'rxjs';
import { ScenariosService } from '../services/scenarios.service';
var VmTypeModalComponent = /** @class */ (function () {
    function VmTypeModalComponent(modalRef, _scenariosService) {
        this.modalRef = modalRef;
        this._scenariosService = _scenariosService;
        this.action = new Subject();
        this.sendData = {};
    }
    VmTypeModalComponent.prototype.ngOnInit = function () {
        if (this.item) {
            this.sendData = JSON.parse(JSON.stringify(this.item));
        }
    };
    VmTypeModalComponent.prototype.ngOnDestroy = function () {
    };
    VmTypeModalComponent.prototype.confirm = function () {
        var _this = this;
        console.log("sendData", this.sendData);
        if (this.sendData._id) {
            this._scenariosService.updateScenarioVmtype(this.sendData._id, this.sendData).subscribe(function (res) {
                console.log("done", res);
                _this.action.next("DONE!!!");
                _this.modalRef.hide();
            });
        }
        else {
            this._scenariosService.createScenarioVmtype(this.sendData).subscribe(function (res) {
                console.log("done", res);
                _this.action.next("DONE!!!");
                _this.modalRef.hide();
            });
        }
    };
    VmTypeModalComponent.prototype.delete = function () {
        var _this = this;
        this._scenariosService.deleteScenarioVmtype(this.sendData._id).subscribe(function (res) {
            console.log("done", res);
            _this.action.next("DONE!!!");
            _this.modalRef.hide();
        });
    };
    VmTypeModalComponent.prototype.checkOnchange = function ($event, field) {
        this.sendData[field] = $event.checked;
    };
    VmTypeModalComponent = __decorate([
        Component({
            selector: 'qmi-new-vmtype',
            templateUrl: './edit-vmtype.component.html',
            styleUrls: []
        }),
        __metadata("design:paramtypes", [MDBModalRef, ScenariosService])
    ], VmTypeModalComponent);
    return VmTypeModalComponent;
}());
export { VmTypeModalComponent };
//# sourceMappingURL=edit-vmtype.component.js.map