{"ast":null,"code":"import { __decorate } from \"tslib\";\nimport { Component } from '@angular/core';\nimport { FormGroup, FormControl, Validators } from '@angular/forms';\nimport { SuccessModalComponent } from 'src/app/shared/modals/success-modal/success-modal.component';\nlet UpdateNetworkDeviceComponent = class UpdateNetworkDeviceComponent {\n  constructor(repository, errorHandler, router, route, modal) {\n    this.repository = repository;\n    this.errorHandler = errorHandler;\n    this.router = router;\n    this.route = route;\n    this.modal = modal;\n    this.errorMessage = '';\n    this.loadDevice = () => {\n      this.repository.getData(`api/network-devices/${this.deviceId}`).subscribe({\n        next: device => {\n          this.deviceForm.patchValue(device);\n        },\n        error: err => {\n          this.errorHandler.handleError(err);\n          this.errorMessage = this.errorHandler.errorMessage;\n        }\n      });\n    };\n    this.updateDevice = deviceFormValue => {\n      if (this.deviceForm.valid) {\n        this.repository.update(`api/network-devices/${this.deviceId}`, deviceFormValue).subscribe({\n          next: () => {\n            const config = {\n              initialState: {\n                modalHeaderText: 'Başarılı',\n                modalBodyText: 'Network cihazı başarıyla güncellendi',\n                okButtonText: 'Tamam'\n              }\n            };\n            this.bsModalRef = this.modal.show(SuccessModalComponent, config);\n            this.bsModalRef.content.redirectOnOk.subscribe(() => this.redirectToDeviceList());\n          },\n          error: err => {\n            this.errorHandler.handleError(err);\n            this.errorMessage = this.errorHandler.errorMessage;\n          }\n        });\n      }\n    };\n    this.redirectToDeviceList = () => {\n      this.router.navigate(['/ui-components/network']);\n    };\n  }\n  ngOnInit() {\n    this.deviceId = this.route.snapshot.paramMap.get('id');\n    this.loadDevice();\n    this.deviceForm = new FormGroup({\n      model: new FormControl('', [Validators.required]),\n      type: new FormControl('', [Validators.required]),\n      ipAddress: new FormControl('', [Validators.required]),\n      macAddress: new FormControl('', [Validators.required]),\n      location: new FormControl('', [Validators.required]),\n      serialNumber: new FormControl('', [Validators.required]),\n      notes: new FormControl('')\n    });\n  }\n};\nUpdateNetworkDeviceComponent = __decorate([Component({\n  selector: 'app-update-network-device',\n  templateUrl: './update-network-device.component.html',\n  styleUrls: ['./update-network-device.component.css']\n})], UpdateNetworkDeviceComponent);\nexport { UpdateNetworkDeviceComponent };","map":{"version":3,"names":["Component","FormGroup","FormControl","Validators","SuccessModalComponent","UpdateNetworkDeviceComponent","constructor","repository","errorHandler","router","route","modal","errorMessage","loadDevice","getData","deviceId","subscribe","next","device","deviceForm","patchValue","error","err","handleError","updateDevice","deviceFormValue","valid","update","config","initialState","modalHeaderText","modalBodyText","okButtonText","bsModalRef","show","content","redirectOnOk","redirectToDeviceList","navigate","ngOnInit","snapshot","paramMap","get","model","required","type","ipAddress","macAddress","location","serialNumber","notes","__decorate","selector","templateUrl","styleUrls"],"sources":["C:\\Users\\Cem\\Desktop\\InventryUI-Client\\src\\app\\pages\\ui-components\\network\\update-network\\update-network.component.ts"],"sourcesContent":["import { HttpErrorResponse } from '@angular/common/http';\r\nimport { Component, OnInit } from '@angular/core';\r\nimport { FormGroup, FormControl, Validators } from '@angular/forms';\r\nimport { Router, ActivatedRoute } from '@angular/router';\r\nimport { BsModalRef, BsModalService, ModalOptions } from 'ngx-bootstrap/modal';\r\nimport { SuccessModalComponent } from 'src/app/shared/modals/success-modal/success-modal.component';\r\nimport { RepositoryErrorHandlerService } from 'src/app/shared/services/repository-error-handler.service';\r\nimport { RepositoryService } from 'src/app/shared/services/repository.service';\r\n\r\n@Component({\r\n  selector: 'app-update-network-device',\r\n  templateUrl: './update-network-device.component.html',\r\n  styleUrls: ['./update-network-device.component.css']\r\n})\r\nexport class UpdateNetworkDeviceComponent implements OnInit {\r\n  public deviceForm: FormGroup;\r\n  public errorMessage: string = '';\r\n  public bsModalRef?: BsModalRef;\r\n  private deviceId: string;\r\n\r\n  constructor(\r\n    private repository: RepositoryService,\r\n    private errorHandler: RepositoryErrorHandlerService,\r\n    private router: Router,\r\n    private route: ActivatedRoute,\r\n    private modal: BsModalService\r\n  ) { }\r\n\r\n  ngOnInit(): void {\r\n    this.deviceId = this.route.snapshot.paramMap.get('id')!;\r\n    this.loadDevice();\r\n    this.deviceForm = new FormGroup({\r\n      model: new FormControl('', [Validators.required]),\r\n      type: new FormControl('', [Validators.required]),\r\n      ipAddress: new FormControl('', [Validators.required]),\r\n      macAddress: new FormControl('', [Validators.required]),\r\n      location: new FormControl('', [Validators.required]),\r\n      serialNumber: new FormControl('', [Validators.required]),\r\n      notes: new FormControl('')\r\n    });\r\n  }\r\n\r\n  private loadDevice = () => {\r\n    this.repository.getData(`api/network-devices/${this.deviceId}`)\r\n      .subscribe({\r\n        next: (device: any) => {\r\n          this.deviceForm.patchValue(device);\r\n        },\r\n        error: (err: HttpErrorResponse) => {\r\n          this.errorHandler.handleError(err);\r\n          this.errorMessage = this.errorHandler.errorMessage;\r\n        }\r\n      });\r\n  }\r\n\r\n  updateDevice = (deviceFormValue: any) => {\r\n    if (this.deviceForm.valid) {\r\n      this.repository.update(`api/network-devices/${this.deviceId}`, deviceFormValue)\r\n        .subscribe({\r\n          next: () => {\r\n            const config: ModalOptions = {\r\n              initialState: {\r\n                modalHeaderText: 'Başarılı',\r\n                modalBodyText: 'Network cihazı başarıyla güncellendi',\r\n                okButtonText: 'Tamam'\r\n              }\r\n            };\r\n            this.bsModalRef = this.modal.show(SuccessModalComponent, config);\r\n            this.bsModalRef.content.redirectOnOk.subscribe(() => this.redirectToDeviceList());\r\n          },\r\n          error: (err: HttpErrorResponse) => {\r\n            this.errorHandler.handleError(err);\r\n            this.errorMessage = this.errorHandler.errorMessage;\r\n          }\r\n        });\r\n    }\r\n  }\r\n\r\n  redirectToDeviceList = () => {\r\n    this.router.navigate(['/ui-components/network']);\r\n  }\r\n}\r\n"],"mappings":";AACA,SAASA,SAAS,QAAgB,eAAe;AACjD,SAASC,SAAS,EAAEC,WAAW,EAAEC,UAAU,QAAQ,gBAAgB;AAGnE,SAASC,qBAAqB,QAAQ,6DAA6D;AAS5F,IAAMC,4BAA4B,GAAlC,MAAMA,4BAA4B;EAMvCC,YACUC,UAA6B,EAC7BC,YAA2C,EAC3CC,MAAc,E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