penambahan UI pada setiap inputan monitoring list
This commit is contained in:
		
							parent
							
								
									9b4ac3b992
								
							
						
					
					
						commit
						124f3eef4c
					
				@ -1,4 +1,4 @@
 | 
				
			|||||||
<div class="app-content content" style="background-color: #FBFBFB !important">
 | 
					<div class="app-content content" style="background-color: #fbfbfb !important">
 | 
				
			||||||
  <div class="content-wrapper">
 | 
					  <div class="content-wrapper">
 | 
				
			||||||
    <div class="content-header row mb-1">
 | 
					    <div class="content-header row mb-1">
 | 
				
			||||||
      <app-breadcrumb class="col-12" [breadcrumb]="breadcrumb"></app-breadcrumb>
 | 
					      <app-breadcrumb class="col-12" [breadcrumb]="breadcrumb"></app-breadcrumb>
 | 
				
			||||||
@ -7,11 +7,11 @@
 | 
				
			|||||||
      <section id="basic-form-layouts">
 | 
					      <section id="basic-form-layouts">
 | 
				
			||||||
        <div class="row">
 | 
					        <div class="row">
 | 
				
			||||||
          <div class="col-12" *blockUI="'projectInfo'; message: 'Loading'">
 | 
					          <div class="col-12" *blockUI="'projectInfo'; message: 'Loading'">
 | 
				
			||||||
            <div class="card" style="background-color: #FBFBFB !important">
 | 
					            <div class="card" style="background-color: #fbfbfb !important">
 | 
				
			||||||
              <div class="card-content">
 | 
					              <div class="card-content">
 | 
				
			||||||
                <div
 | 
					                <div
 | 
				
			||||||
                  class="card-header"
 | 
					                  class="card-header"
 | 
				
			||||||
                  style="background-color: #FBFBFB !important"
 | 
					                  style="background-color: #fbfbfb !important"
 | 
				
			||||||
                >
 | 
					                >
 | 
				
			||||||
                  <h2 style="color: #242222">
 | 
					                  <h2 style="color: #242222">
 | 
				
			||||||
                    {{
 | 
					                    {{
 | 
				
			||||||
@ -55,6 +55,18 @@
 | 
				
			|||||||
                                  {{ data.name }}
 | 
					                                  {{ data.name }}
 | 
				
			||||||
                                </option>
 | 
					                                </option>
 | 
				
			||||||
                              </select>
 | 
					                              </select>
 | 
				
			||||||
 | 
					                              <button
 | 
				
			||||||
 | 
					                                class="btn btn-danger ml-2"
 | 
				
			||||||
 | 
					                                type="button"
 | 
				
			||||||
 | 
					                                style="
 | 
				
			||||||
 | 
					                                  color: #ffffff !important;
 | 
				
			||||||
 | 
					                                  border-color: #37a647 !important;
 | 
				
			||||||
 | 
					                                  background-color: #37a647 !important;
 | 
				
			||||||
 | 
					                                "
 | 
				
			||||||
 | 
					                                (click)="modalAddBuilding()"
 | 
				
			||||||
 | 
					                              >
 | 
				
			||||||
 | 
					                                <i class="feather ft-plus"> New Building</i>
 | 
				
			||||||
 | 
					                              </button>
 | 
				
			||||||
                            </div>
 | 
					                            </div>
 | 
				
			||||||
                            <small
 | 
					                            <small
 | 
				
			||||||
                              class="form-text text-muted danger"
 | 
					                              class="form-text text-muted danger"
 | 
				
			||||||
@ -86,6 +98,18 @@
 | 
				
			|||||||
                                  {{ data.name }}
 | 
					                                  {{ data.name }}
 | 
				
			||||||
                                </option>
 | 
					                                </option>
 | 
				
			||||||
                              </select>
 | 
					                              </select>
 | 
				
			||||||
 | 
					                              <button
 | 
				
			||||||
 | 
					                                class="btn btn-danger ml-2"
 | 
				
			||||||
 | 
					                                type="button"
 | 
				
			||||||
 | 
					                                style="
 | 
				
			||||||
 | 
					                                  color: #ffffff !important;
 | 
				
			||||||
 | 
					                                  border-color: #37a647 !important;
 | 
				
			||||||
 | 
					                                  background-color: #37a647 !important;
 | 
				
			||||||
 | 
					                                "
 | 
				
			||||||
 | 
					                                (click)="modalAddFloor()"
 | 
				
			||||||
 | 
					                              >
 | 
				
			||||||
 | 
					                                <i class="feather ft-plus"> New Floor</i>
 | 
				
			||||||
 | 
					                              </button>
 | 
				
			||||||
                            </div>
 | 
					                            </div>
 | 
				
			||||||
                            <small
 | 
					                            <small
 | 
				
			||||||
                              class="form-text text-muted danger"
 | 
					                              class="form-text text-muted danger"
 | 
				
			||||||
@ -134,8 +158,8 @@
 | 
				
			|||||||
                                      type="button"
 | 
					                                      type="button"
 | 
				
			||||||
                                      style="
 | 
					                                      style="
 | 
				
			||||||
                                        color: #ffffff !important;
 | 
					                                        color: #ffffff !important;
 | 
				
			||||||
                                        border-color: #37A647 !important;
 | 
					                                        border-color: #a64f37 !important;
 | 
				
			||||||
                                        background-color: #37A647 !important;
 | 
					                                        background-color: #a64f37 !important;
 | 
				
			||||||
                                      "
 | 
					                                      "
 | 
				
			||||||
                                      (click)="removePhone(i)"
 | 
					                                      (click)="removePhone(i)"
 | 
				
			||||||
                                    >
 | 
					                                    >
 | 
				
			||||||
@ -151,13 +175,25 @@
 | 
				
			|||||||
                              [disabled]="disableButton"
 | 
					                              [disabled]="disableButton"
 | 
				
			||||||
                              style="
 | 
					                              style="
 | 
				
			||||||
                                color: #ffffff !important;
 | 
					                                color: #ffffff !important;
 | 
				
			||||||
                                border-color: #37A647 !important;
 | 
					                                border-color: #37a647 !important;
 | 
				
			||||||
                                background-color: #37A647 !important;
 | 
					                                background-color: #37a647 !important;
 | 
				
			||||||
                              "
 | 
					                              "
 | 
				
			||||||
                              (click)="addPhone()"
 | 
					                              (click)="addPhone()"
 | 
				
			||||||
                            >
 | 
					                            >
 | 
				
			||||||
                              <i class="feather ft-plus"></i> Add Room
 | 
					                              <i class="feather ft-plus"></i> Add Room
 | 
				
			||||||
                            </button>
 | 
					                            </button>
 | 
				
			||||||
 | 
					                            <button
 | 
				
			||||||
 | 
					                              type="button"
 | 
				
			||||||
 | 
					                              class="btn btn-primary ml-2"
 | 
				
			||||||
 | 
					                              style="
 | 
				
			||||||
 | 
					                                color: #ffffff !important;
 | 
				
			||||||
 | 
					                                border-color: #37a647 !important;
 | 
				
			||||||
 | 
					                                background-color: #37a647 !important;
 | 
				
			||||||
 | 
					                              "
 | 
				
			||||||
 | 
					                              (click)="modalAddNewRoom()"
 | 
				
			||||||
 | 
					                            >
 | 
				
			||||||
 | 
					                              New Room
 | 
				
			||||||
 | 
					                            </button>
 | 
				
			||||||
                          </div>
 | 
					                          </div>
 | 
				
			||||||
                          <div class="form-group" *ngIf="mode !== 'add'">
 | 
					                          <div class="form-group" *ngIf="mode !== 'add'">
 | 
				
			||||||
                            <label for="roomId">Room *</label>
 | 
					                            <label for="roomId">Room *</label>
 | 
				
			||||||
@ -230,7 +266,7 @@
 | 
				
			|||||||
                        style="
 | 
					                        style="
 | 
				
			||||||
                          color: #242222 !important;
 | 
					                          color: #242222 !important;
 | 
				
			||||||
                          border-color: #242222 !important;
 | 
					                          border-color: #242222 !important;
 | 
				
			||||||
                          background-color: #FBFBFB !important;
 | 
					                          background-color: #fbfbfb !important;
 | 
				
			||||||
                        "
 | 
					                        "
 | 
				
			||||||
                        (click)="cancel()"
 | 
					                        (click)="cancel()"
 | 
				
			||||||
                      >
 | 
					                      >
 | 
				
			||||||
@ -242,8 +278,8 @@
 | 
				
			|||||||
                        [disabled]="disableButton"
 | 
					                        [disabled]="disableButton"
 | 
				
			||||||
                        style="
 | 
					                        style="
 | 
				
			||||||
                          color: #ffffff !important;
 | 
					                          color: #ffffff !important;
 | 
				
			||||||
                          border-color: #37A647 !important;
 | 
					                          border-color: #37a647 !important;
 | 
				
			||||||
                          background-color: #37A647 !important;
 | 
					                          background-color: #37a647 !important;
 | 
				
			||||||
                        "
 | 
					                        "
 | 
				
			||||||
                        (click)="save()"
 | 
					                        (click)="save()"
 | 
				
			||||||
                      >
 | 
					                      >
 | 
				
			||||||
 | 
				
			|||||||
@ -1,15 +1,25 @@
 | 
				
			|||||||
import { Component, ViewChild } from '@angular/core';
 | 
					import { Component, ViewChild } from "@angular/core";
 | 
				
			||||||
import { FormArray, FormBuilder, FormGroup, NgForm, Validators } from '@angular/forms';
 | 
					import {
 | 
				
			||||||
import { ActivatedRoute, Router } from '@angular/router';
 | 
					  FormArray,
 | 
				
			||||||
import { BlockUI, NgBlockUI } from 'ng-block-ui';
 | 
					  FormBuilder,
 | 
				
			||||||
import { BuildingService } from '../../service/monitoring-api.service';
 | 
					  FormGroup,
 | 
				
			||||||
import { LoginService } from '../../service/login.service';
 | 
					  NgForm,
 | 
				
			||||||
import { ToastrService } from 'ngx-toastr';
 | 
					  Validators,
 | 
				
			||||||
 | 
					} from "@angular/forms";
 | 
				
			||||||
 | 
					import { ActivatedRoute, Router } from "@angular/router";
 | 
				
			||||||
 | 
					import { BlockUI, NgBlockUI } from "ng-block-ui";
 | 
				
			||||||
 | 
					import { BuildingService } from "../../service/monitoring-api.service";
 | 
				
			||||||
 | 
					import { LoginService } from "../../service/login.service";
 | 
				
			||||||
 | 
					import { ToastrService } from "ngx-toastr";
 | 
				
			||||||
 | 
					import { NgbModal } from "@ng-bootstrap/ng-bootstrap";
 | 
				
			||||||
 | 
					import { AddEditMasterBuildingComponent } from "../../master/master-building/add-edit-master-building/add-edit-master-building.component";
 | 
				
			||||||
 | 
					import { AddEditMasterComponent } from "../../master/add-edit-master/add-edit-master.component";
 | 
				
			||||||
 | 
					import { AddEditMasterRoomComponent } from "../../master/master-room/add-edit-master-room/add-edit-master-room.component";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@Component({
 | 
					@Component({
 | 
				
			||||||
  selector: 'app-add-edit-list',
 | 
					  selector: "app-add-edit-list",
 | 
				
			||||||
  templateUrl: './add-edit-list.component.html',
 | 
					  templateUrl: "./add-edit-list.component.html",
 | 
				
			||||||
  styleUrls: ['./add-edit-list.component.css']
 | 
					  styleUrls: ["./add-edit-list.component.css"],
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
export class AddEditListComponent {
 | 
					export class AddEditListComponent {
 | 
				
			||||||
  // @ViewChild("f", { read: true }) userProfileForm: NgForm;
 | 
					  // @ViewChild("f", { read: true }) userProfileForm: NgForm;
 | 
				
			||||||
@ -22,17 +32,19 @@ export class AddEditListComponent {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  dataBuildingList: any;
 | 
					  dataBuildingList: any;
 | 
				
			||||||
  dataRoomList: any;
 | 
					  dataRoomList: any;
 | 
				
			||||||
 | 
					  dataRoomListSementara: any;
 | 
				
			||||||
  dataFloorList: any;
 | 
					  dataFloorList: any;
 | 
				
			||||||
  dataMasterStatus: any;
 | 
					  dataMasterStatus: any;
 | 
				
			||||||
  roombuildingId: any;
 | 
					  roombuildingId: any;
 | 
				
			||||||
  dataRoomBuilding: any;
 | 
					  dataRoomBuilding: any;
 | 
				
			||||||
  disableButton: boolean = true;
 | 
					  disableButton: boolean = true;
 | 
				
			||||||
 | 
					  lewatModal: boolean = false;
 | 
				
			||||||
  // userProfileForm: FormGroup;
 | 
					  // userProfileForm: FormGroup;
 | 
				
			||||||
  public userList: FormArray;
 | 
					  public userList: FormArray;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @BlockUI("projectInfo") blockUIProjectInfo: NgBlockUI;
 | 
					  @BlockUI("projectInfo") blockUIProjectInfo: NgBlockUI;
 | 
				
			||||||
  get userFormGroup() {
 | 
					  get userFormGroup() {
 | 
				
			||||||
    return this.projectInfo.get('userArray') as FormArray;
 | 
					    return this.projectInfo.get("userArray") as FormArray;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  constructor(
 | 
					  constructor(
 | 
				
			||||||
@ -42,6 +54,7 @@ export class AddEditListComponent {
 | 
				
			|||||||
    private monitoringApiService: BuildingService,
 | 
					    private monitoringApiService: BuildingService,
 | 
				
			||||||
    private authService: LoginService,
 | 
					    private authService: LoginService,
 | 
				
			||||||
    private toastr: ToastrService,
 | 
					    private toastr: ToastrService,
 | 
				
			||||||
 | 
					    private modalService: NgbModal
 | 
				
			||||||
  ) {}
 | 
					  ) {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ngOnInit() {
 | 
					  ngOnInit() {
 | 
				
			||||||
@ -50,18 +63,15 @@ export class AddEditListComponent {
 | 
				
			|||||||
    this.route.data.subscribe((data) => {
 | 
					    this.route.data.subscribe((data) => {
 | 
				
			||||||
      this.mode = data.mode;
 | 
					      this.mode = data.mode;
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    this.route.params.subscribe(params => {
 | 
					    this.route.params.subscribe((params) => {
 | 
				
			||||||
      const id = params['id'];
 | 
					      const id = params["id"];
 | 
				
			||||||
      this.roombuildingId = id;
 | 
					      this.roombuildingId = id;
 | 
				
			||||||
      if (id) {
 | 
					      if (id) {
 | 
				
			||||||
        this.loadRoomBuilding(id);
 | 
					        this.loadRoomBuilding(id);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    this.setBreadcrumb();
 | 
					    this.setBreadcrumb();
 | 
				
			||||||
    this.dataListBuilding();
 | 
					    
 | 
				
			||||||
    this.dataListRoom();
 | 
					 | 
				
			||||||
    this.dataListMaster();
 | 
					 | 
				
			||||||
    this.dataListFloor();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    this.projectInfo = this.formBuilder.group({
 | 
					    this.projectInfo = this.formBuilder.group({
 | 
				
			||||||
      buildingId: ["", Validators.required],
 | 
					      buildingId: ["", Validators.required],
 | 
				
			||||||
@ -70,44 +80,54 @@ export class AddEditListComponent {
 | 
				
			|||||||
      floorId: ["", Validators.required],
 | 
					      floorId: ["", Validators.required],
 | 
				
			||||||
      userArray: this.formBuilder.array([this.createRoom()]),
 | 
					      userArray: this.formBuilder.array([this.createRoom()]),
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    this.userList = this.projectInfo.get('userArray') as FormArray;
 | 
					    this.userList = this.projectInfo.get("userArray") as FormArray;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    this.dataListBuilding();
 | 
				
			||||||
 | 
					    this.dataListRoom();
 | 
				
			||||||
 | 
					    this.dataListMaster();
 | 
				
			||||||
 | 
					    this.dataListFloor();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  createRoom(): FormGroup {
 | 
					  createRoom(): FormGroup {
 | 
				
			||||||
    return this.formBuilder.group({
 | 
					    return this.formBuilder.group({
 | 
				
			||||||
      roomId: ['', Validators.required]
 | 
					      roomId: ["", Validators.required],
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  addPhone() {
 | 
					  addPhone() {
 | 
				
			||||||
    this.userList.push(this.createRoom());
 | 
					    this.userList.push(this.createRoom());
 | 
				
			||||||
    this.disableButton = true
 | 
					    this.disableButton = true;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  removePhone(index) {
 | 
					  removePhone(index) {
 | 
				
			||||||
    this.userList.removeAt(index);
 | 
					    this.userList.removeAt(index);
 | 
				
			||||||
    this.isRoomDuplicate(index)
 | 
					    this.isRoomDuplicate(index);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  validateDouble(event: any, index: number) {
 | 
					  validateDouble(event: any, index: number) {
 | 
				
			||||||
 | 
					    console.log(event);
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    const selectedRoomId = (event.target as HTMLSelectElement).value;
 | 
					    const selectedRoomId = (event.target as HTMLSelectElement).value;
 | 
				
			||||||
    if (this.isRoomDuplicate(index)) {
 | 
					    if (this.isRoomDuplicate(index)) {
 | 
				
			||||||
      this.disableButton = true
 | 
					      this.disableButton = true;
 | 
				
			||||||
      this.toastr.error("Room", "Data yang ada masukan double!", {
 | 
					      this.toastr.error("Room", "Data yang ada masukan double!", {
 | 
				
			||||||
        timeOut: 2000,
 | 
					        timeOut: 2000,
 | 
				
			||||||
        closeButton: true,
 | 
					        closeButton: true,
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      this.disableButton = false
 | 
					      this.disableButton = false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  isRoomDuplicate(index: number): boolean {
 | 
					  isRoomDuplicate(index: number): boolean {
 | 
				
			||||||
    const selectedRooms = this.userFormGroup.value.map((room) => room.roomId);
 | 
					    const selectedRooms = this.userFormGroup.value.map((room) => room.roomId);
 | 
				
			||||||
    const currentRoomId = selectedRooms[index];
 | 
					    const currentRoomId = selectedRooms[index];
 | 
				
			||||||
    const roomOccurrences = selectedRooms.filter(roomId => roomId === currentRoomId).length;
 | 
					    const roomOccurrences = selectedRooms.filter(
 | 
				
			||||||
 | 
					      (roomId) => roomId === currentRoomId
 | 
				
			||||||
 | 
					    ).length;
 | 
				
			||||||
    if (roomOccurrences === 0) {
 | 
					    if (roomOccurrences === 0) {
 | 
				
			||||||
      this.disableButton = false
 | 
					      this.disableButton = false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return roomOccurrences > 1;
 | 
					    return roomOccurrences > 1;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@ -153,28 +173,31 @@ export class AddEditListComponent {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  loadRoomBuilding(deviceId: string) {
 | 
					  loadRoomBuilding(deviceId: string) {
 | 
				
			||||||
    this.monitoringApiService.getRoomBuildingById(deviceId).subscribe(data => {
 | 
					    this.monitoringApiService
 | 
				
			||||||
 | 
					      .getRoomBuildingById(deviceId)
 | 
				
			||||||
 | 
					      .subscribe((data) => {
 | 
				
			||||||
        this.dataRoomBuilding = data;
 | 
					        this.dataRoomBuilding = data;
 | 
				
			||||||
      this.formGetDevice(data)
 | 
					        this.formGetDevice(data);
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  formGetDevice(data){
 | 
					  formGetDevice(data) {
 | 
				
			||||||
    this.projectInfo.patchValue({
 | 
					    this.projectInfo.patchValue({
 | 
				
			||||||
      buildingId: data.data.buildingId,
 | 
					      buildingId: data.data.buildingId,
 | 
				
			||||||
      roomId: data.data.roomId,
 | 
					      roomId: data.data.roomId,
 | 
				
			||||||
 | 
					      floorId: data.data.floorId,
 | 
				
			||||||
      statusId: data.data.statusId,
 | 
					      statusId: data.data.statusId,
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (this.mode === 'view') {
 | 
					    if (this.mode === "view") {
 | 
				
			||||||
      this.formDisable();
 | 
					      this.formDisable();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  formDisable(){
 | 
					  formDisable() {
 | 
				
			||||||
    this.projectInfo.get('buildingId').disable()
 | 
					    this.projectInfo.get("buildingId").disable();
 | 
				
			||||||
    this.projectInfo.get('roomId').disable()
 | 
					    this.projectInfo.get("roomId").disable();
 | 
				
			||||||
    this.projectInfo.get('statusId').disable()
 | 
					    this.projectInfo.get("statusId").disable();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  isEditMode() {
 | 
					  isEditMode() {
 | 
				
			||||||
@ -209,60 +232,87 @@ export class AddEditListComponent {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  dataListBuilding() {
 | 
					  dataListBuilding() {
 | 
				
			||||||
    this.monitoringApiService.getBuildingList().subscribe(data => {
 | 
					    this.monitoringApiService.getBuildingList().subscribe((data) => {
 | 
				
			||||||
      this.dataBuildingList = data.data.filter(item => item.statusName.toLowerCase() === "aktif" || item.status_id === 71)
 | 
					      this.dataBuildingList = data.data
 | 
				
			||||||
 | 
					        .filter(
 | 
				
			||||||
 | 
					          (item) =>
 | 
				
			||||||
 | 
					            item.statusName.toLowerCase() === "aktif" || item.status_id === 71
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
 | 
					        .sort((a, b) => b.id - a.id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      if (this.lewatModal) {
 | 
				
			||||||
 | 
					        this.projectInfo.patchValue({
 | 
				
			||||||
 | 
					          buildingId: this.dataBuildingList[0],
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					        this.lewatModal = false;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  dataListRoom() {
 | 
					  dataListRoom() {
 | 
				
			||||||
    this.monitoringApiService.getListRoomDataUnmap().subscribe(data => {
 | 
					    this.monitoringApiService.getListRoomDataUnmap().subscribe((data) => {
 | 
				
			||||||
      const newArray = data.data.map(item => ({
 | 
					      console.log(data);
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      const newArray = data.data.map((item) => ({
 | 
				
			||||||
        id: item.id,
 | 
					        id: item.id,
 | 
				
			||||||
        name: `${item.name} (${item.code})`
 | 
					        name: `${item.name} (${item.code})`,
 | 
				
			||||||
      }));
 | 
					      })).sort((a, b) => b.id - a.id);
 | 
				
			||||||
      this.dataRoomList = newArray
 | 
					      this.dataRoomList = newArray;
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  dataListFloor() {
 | 
					  dataListFloor() {
 | 
				
			||||||
    this.monitoringApiService.getListFloorDataUnmap(6).subscribe(data => {
 | 
					    this.monitoringApiService.getListFloorDataUnmap(6).subscribe((data) => {
 | 
				
			||||||
      console.log(data);
 | 
					      const newArray = data.data.map((item) => ({
 | 
				
			||||||
      
 | 
					 | 
				
			||||||
      const newArray = data.data.map(item => ({
 | 
					 | 
				
			||||||
        id: item.id,
 | 
					        id: item.id,
 | 
				
			||||||
        name: `${item.name} (${item.code})`
 | 
					        name: `${item.name} (${item.code})`,
 | 
				
			||||||
      }));
 | 
					      })).sort((a, b) => b.id - a.id);
 | 
				
			||||||
      this.dataFloorList = newArray
 | 
					      this.dataFloorList = newArray;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      if (this.lewatModal) {
 | 
				
			||||||
 | 
					        this.projectInfo.patchValue({
 | 
				
			||||||
 | 
					          floorId: this.dataFloorList[0],
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					        this.lewatModal = false;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  dataListMaster() {
 | 
					  dataListMaster() {
 | 
				
			||||||
    this.monitoringApiService.getMasterListData().subscribe(data => {
 | 
					    this.monitoringApiService.getMasterListData().subscribe((data) => {
 | 
				
			||||||
      const dataStatus = data.data.find(
 | 
					      const dataStatus = data.data.find(
 | 
				
			||||||
        (item) => item.name === "master_status"
 | 
					        (item) => item.name === "master_status"
 | 
				
			||||||
      ).headerDetailParam;
 | 
					      ).headerDetailParam;
 | 
				
			||||||
      this.dataMasterStatus = dataStatus.filter(item => item.statusName.toLowerCase() === "aktif" || item.status.toLowerCase() === "71")
 | 
					      this.dataMasterStatus = dataStatus.filter(
 | 
				
			||||||
 | 
					        (item) =>
 | 
				
			||||||
 | 
					          item.statusName.toLowerCase() === "aktif" ||
 | 
				
			||||||
 | 
					          item.status.toLowerCase() === "71"
 | 
				
			||||||
 | 
					      );
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  save() {
 | 
					  save() {
 | 
				
			||||||
    if (this.mode === 'add') {
 | 
					    if (this.mode === "add") {
 | 
				
			||||||
      if (this.projectInfo.invalid) {
 | 
					      if (this.projectInfo.invalid) {
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      const formData = this.projectInfo.value;
 | 
					      const formData = this.projectInfo.value;
 | 
				
			||||||
      const transformedData = {
 | 
					      const transformedData = {
 | 
				
			||||||
        buildingId: formData.buildingId,
 | 
					        buildingId: formData.buildingId,
 | 
				
			||||||
        roomId: formData.userArray.map(room => room.roomId),
 | 
					        roomId: formData.userArray.map((room) => room.roomId),
 | 
				
			||||||
        statusId: formData.statusId,
 | 
					        statusId: formData.statusId,
 | 
				
			||||||
        floorId: formData.floorId
 | 
					        floorId: formData.floorId,
 | 
				
			||||||
      };
 | 
					      };
 | 
				
			||||||
      this.monitoringApiService.postBatchBuilding(transformedData).subscribe((res) => {
 | 
					      this.monitoringApiService
 | 
				
			||||||
 | 
					        .postBatchBuilding(transformedData)
 | 
				
			||||||
 | 
					        .subscribe((res) => {
 | 
				
			||||||
          this.router.navigate(["/list-monitoring"]);
 | 
					          this.router.navigate(["/list-monitoring"]);
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      delete this.projectInfo.value.userArray;
 | 
					      delete this.projectInfo.value.userArray;
 | 
				
			||||||
      this.monitoringApiService.puttBuildingRoom(this.projectInfo.value, this.roombuildingId).subscribe(data => {
 | 
					      this.monitoringApiService
 | 
				
			||||||
 | 
					        .puttBuildingRoom(this.projectInfo.value, this.roombuildingId)
 | 
				
			||||||
 | 
					        .subscribe((data) => {
 | 
				
			||||||
          this.router.navigate(["/list-monitoring"]);
 | 
					          this.router.navigate(["/list-monitoring"]);
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -271,4 +321,109 @@ export class AddEditListComponent {
 | 
				
			|||||||
  cancel() {
 | 
					  cancel() {
 | 
				
			||||||
    this.router.navigate(["/list-monitoring"]);
 | 
					    this.router.navigate(["/list-monitoring"]);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  modalAddBuilding() {
 | 
				
			||||||
 | 
					    const modalRef = this.modalService.open(AddEditMasterBuildingComponent, {
 | 
				
			||||||
 | 
					      size: "lg",
 | 
				
			||||||
 | 
					      backdrop: "static",
 | 
				
			||||||
 | 
					      keyboard: false,
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    modalRef.componentInstance.mode = "add";
 | 
				
			||||||
 | 
					    modalRef.result.then(
 | 
				
			||||||
 | 
					      (result) => {
 | 
				
			||||||
 | 
					        if (result) {
 | 
				
			||||||
 | 
					          if (
 | 
				
			||||||
 | 
					            this.dataBuildingList.some(
 | 
				
			||||||
 | 
					              (value) =>
 | 
				
			||||||
 | 
					                value.name.trim().toLowerCase() ===
 | 
				
			||||||
 | 
					                result.name.trim().toLowerCase()
 | 
				
			||||||
 | 
					            )
 | 
				
			||||||
 | 
					          ) {
 | 
				
			||||||
 | 
					            this.toastr.error("Warning", "Data yang anda masukan double.", {
 | 
				
			||||||
 | 
					              timeOut: 5000,
 | 
				
			||||||
 | 
					              closeButton: true,
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					          } else {
 | 
				
			||||||
 | 
					            this.monitoringApiService
 | 
				
			||||||
 | 
					              .postMasterBuildingParam(result)
 | 
				
			||||||
 | 
					              .subscribe((res) => {
 | 
				
			||||||
 | 
					                this.dataListBuilding();
 | 
				
			||||||
 | 
					                this.lewatModal = true;
 | 
				
			||||||
 | 
					              });
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
 | 
					      (reason) => {
 | 
				
			||||||
 | 
					        console.log(`Dismissed: ${reason}`);
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  modalAddFloor() {
 | 
				
			||||||
 | 
					    const modalRef = this.modalService.open(AddEditMasterComponent, {
 | 
				
			||||||
 | 
					      size: "lg",
 | 
				
			||||||
 | 
					      backdrop: "static", 
 | 
				
			||||||
 | 
					      keyboard: false, 
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    modalRef.componentInstance.headerId = 6;
 | 
				
			||||||
 | 
					    modalRef.componentInstance.mode = "add";
 | 
				
			||||||
 | 
					    modalRef.componentInstance.floor = true;
 | 
				
			||||||
 | 
					    modalRef.result.then(
 | 
				
			||||||
 | 
					      (result) => {
 | 
				
			||||||
 | 
					        if (result) {
 | 
				
			||||||
 | 
					          this.monitoringApiService
 | 
				
			||||||
 | 
					            .postHeaderDetailParam(result)
 | 
				
			||||||
 | 
					            .subscribe((res) => {
 | 
				
			||||||
 | 
					              this.dataListFloor();
 | 
				
			||||||
 | 
					              this.lewatModal = true;
 | 
				
			||||||
 | 
					              if (res.status === 400) {
 | 
				
			||||||
 | 
					                this.toastr.error("Warning", "Data yang anda masukan double.", {
 | 
				
			||||||
 | 
					                  timeOut: 5000,
 | 
				
			||||||
 | 
					                  closeButton: true,
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					              }
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
 | 
					      (reason) => {
 | 
				
			||||||
 | 
					        console.log(`Dismissed: ${reason}`);
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  modalAddNewRoom(){
 | 
				
			||||||
 | 
					    const modalRef = this.modalService.open(AddEditMasterRoomComponent, {
 | 
				
			||||||
 | 
					      size: "lg",
 | 
				
			||||||
 | 
					      backdrop: "static",
 | 
				
			||||||
 | 
					      keyboard: false,
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    modalRef.componentInstance.mode = "add";
 | 
				
			||||||
 | 
					    modalRef.result.then(
 | 
				
			||||||
 | 
					      (result) => {
 | 
				
			||||||
 | 
					        if (result) {
 | 
				
			||||||
 | 
					          const filteredData = {
 | 
				
			||||||
 | 
					            name: result.name,
 | 
				
			||||||
 | 
					            code: result.code.trim(),
 | 
				
			||||||
 | 
					            description: result.description,
 | 
				
			||||||
 | 
					          };
 | 
				
			||||||
 | 
					          this.monitoringApiService
 | 
				
			||||||
 | 
					            .postMasterRoomParam(filteredData)
 | 
				
			||||||
 | 
					            .subscribe((res) => {
 | 
				
			||||||
 | 
					              this.dataListRoom();
 | 
				
			||||||
 | 
					            }, (error) => {
 | 
				
			||||||
 | 
					              this.toastr.error("Error", error.error.message, {
 | 
				
			||||||
 | 
					                timeOut: 2000,
 | 
				
			||||||
 | 
					                closeButton: true,
 | 
				
			||||||
 | 
					              });
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
 | 
					      (reason) => {
 | 
				
			||||||
 | 
					        console.log(`Dismissed: ${reason}`);
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -1,16 +1,16 @@
 | 
				
			|||||||
import { Component } from '@angular/core';
 | 
					import { Component } from "@angular/core";
 | 
				
			||||||
import { AddEditMasterComponent } from '../add-edit-master/add-edit-master.component';
 | 
					import { AddEditMasterComponent } from "../add-edit-master/add-edit-master.component";
 | 
				
			||||||
import { TableApiService } from 'src/app/_services/table-api.service';
 | 
					import { TableApiService } from "src/app/_services/table-api.service";
 | 
				
			||||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
 | 
					import { NgbModal } from "@ng-bootstrap/ng-bootstrap";
 | 
				
			||||||
import { Router } from '@angular/router';
 | 
					import { Router } from "@angular/router";
 | 
				
			||||||
import { BuildingService } from '../../service/monitoring-api.service';
 | 
					import { BuildingService } from "../../service/monitoring-api.service";
 | 
				
			||||||
import { LoginService } from '../../service/login.service';
 | 
					import { LoginService } from "../../service/login.service";
 | 
				
			||||||
import { ToastrService } from 'ngx-toastr';
 | 
					import { ToastrService } from "ngx-toastr";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@Component({
 | 
					@Component({
 | 
				
			||||||
  selector: 'app-master-floor',
 | 
					  selector: "app-master-floor",
 | 
				
			||||||
  templateUrl: './master-floor.component.html',
 | 
					  templateUrl: "./master-floor.component.html",
 | 
				
			||||||
  styleUrls: ['./master-floor.component.css']
 | 
					  styleUrls: ["./master-floor.component.css"],
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
export class MasterFloorComponent {
 | 
					export class MasterFloorComponent {
 | 
				
			||||||
  data: any;
 | 
					  data: any;
 | 
				
			||||||
@ -26,7 +26,7 @@ export class MasterFloorComponent {
 | 
				
			|||||||
    private router: Router,
 | 
					    private router: Router,
 | 
				
			||||||
    private monitoringApiService: BuildingService,
 | 
					    private monitoringApiService: BuildingService,
 | 
				
			||||||
    private authService: LoginService,
 | 
					    private authService: LoginService,
 | 
				
			||||||
    private toastr: ToastrService,
 | 
					    private toastr: ToastrService
 | 
				
			||||||
  ) {}
 | 
					  ) {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ngOnInit() {
 | 
					  ngOnInit() {
 | 
				
			||||||
@ -55,7 +55,9 @@ export class MasterFloorComponent {
 | 
				
			|||||||
        (item) => item.name === "master_floor"
 | 
					        (item) => item.name === "master_floor"
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
      // this.filteredRows = this.dataMasterCategori.headerDetailParam;
 | 
					      // this.filteredRows = this.dataMasterCategori.headerDetailParam;
 | 
				
			||||||
      this.filteredRows = this.dataMasterCategori.headerDetailParam.sort((a, b) => b.id - a.id);
 | 
					      this.filteredRows = this.dataMasterCategori.headerDetailParam.sort(
 | 
				
			||||||
 | 
					        (a, b) => b.id - a.id
 | 
				
			||||||
 | 
					      );
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -83,8 +85,8 @@ export class MasterFloorComponent {
 | 
				
			|||||||
  openAddMasterModal() {
 | 
					  openAddMasterModal() {
 | 
				
			||||||
    const modalRef = this.modalService.open(AddEditMasterComponent, {
 | 
					    const modalRef = this.modalService.open(AddEditMasterComponent, {
 | 
				
			||||||
      size: "lg",
 | 
					      size: "lg",
 | 
				
			||||||
      backdrop: 'static',  // Add this line
 | 
					      backdrop: "static", // Add this line
 | 
				
			||||||
      keyboard: false  // Add this line
 | 
					      keyboard: false, // Add this line
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    modalRef.componentInstance.headerId = this.dataMasterCategori.id;
 | 
					    modalRef.componentInstance.headerId = this.dataMasterCategori.id;
 | 
				
			||||||
@ -94,16 +96,9 @@ export class MasterFloorComponent {
 | 
				
			|||||||
      (result) => {
 | 
					      (result) => {
 | 
				
			||||||
        console.log(result);
 | 
					        console.log(result);
 | 
				
			||||||
        if (result) {
 | 
					        if (result) {
 | 
				
			||||||
          if (this.filteredRows.some(value => value.name.trim().toLowerCase() === result.name.trim().toLowerCase())) {
 | 
					 | 
				
			||||||
            this.toastr.error("Warning", "Data yang anda masukan double.", {
 | 
					 | 
				
			||||||
              timeOut: 5000,
 | 
					 | 
				
			||||||
              closeButton: true,
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
          } else {
 | 
					 | 
				
			||||||
          this.monitoringApiService
 | 
					          this.monitoringApiService
 | 
				
			||||||
            .postHeaderDetailParam(result)
 | 
					            .postHeaderDetailParam(result)
 | 
				
			||||||
            .subscribe((res) => {
 | 
					            .subscribe((res) => {
 | 
				
			||||||
              console.log(res);
 | 
					 | 
				
			||||||
              this.fetchData();
 | 
					              this.fetchData();
 | 
				
			||||||
              if (res.status === 400) {
 | 
					              if (res.status === 400) {
 | 
				
			||||||
                this.toastr.error("Warning", "Data yang anda masukan double.", {
 | 
					                this.toastr.error("Warning", "Data yang anda masukan double.", {
 | 
				
			||||||
@ -113,7 +108,6 @@ export class MasterFloorComponent {
 | 
				
			|||||||
              }
 | 
					              }
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        // if (result) {
 | 
					        // if (result) {
 | 
				
			||||||
        //   this.monitoringApiService
 | 
					        //   this.monitoringApiService
 | 
				
			||||||
        //     .postHeaderDetailParam(result)
 | 
					        //     .postHeaderDetailParam(result)
 | 
				
			||||||
@ -132,8 +126,8 @@ export class MasterFloorComponent {
 | 
				
			|||||||
  editRow(row) {
 | 
					  editRow(row) {
 | 
				
			||||||
    const modalRef = this.modalService.open(AddEditMasterComponent, {
 | 
					    const modalRef = this.modalService.open(AddEditMasterComponent, {
 | 
				
			||||||
      size: "lg",
 | 
					      size: "lg",
 | 
				
			||||||
      backdrop: 'static',  // Add this line
 | 
					      backdrop: "static", // Add this line
 | 
				
			||||||
      keyboard: false  // Add this line
 | 
					      keyboard: false, // Add this line
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    modalRef.componentInstance.headerId = this.dataMasterCategori.id;
 | 
					    modalRef.componentInstance.headerId = this.dataMasterCategori.id;
 | 
				
			||||||
@ -145,10 +139,14 @@ export class MasterFloorComponent {
 | 
				
			|||||||
        if (result) {
 | 
					        if (result) {
 | 
				
			||||||
          if (
 | 
					          if (
 | 
				
			||||||
            this.filteredRows.some(
 | 
					            this.filteredRows.some(
 | 
				
			||||||
              (value) => value.name.trim().toLowerCase() === result.name.trim().toLowerCase()
 | 
					              (value) =>
 | 
				
			||||||
 | 
					                value.name.trim().toLowerCase() ===
 | 
				
			||||||
 | 
					                result.name.trim().toLowerCase()
 | 
				
			||||||
            )
 | 
					            )
 | 
				
			||||||
          ) {
 | 
					          ) {
 | 
				
			||||||
            if (row.name.trim().toLowerCase() === result.name.trim().toLowerCase()) {
 | 
					            if (
 | 
				
			||||||
 | 
					              row.name.trim().toLowerCase() === result.name.trim().toLowerCase()
 | 
				
			||||||
 | 
					            ) {
 | 
				
			||||||
              this.monitoringApiService
 | 
					              this.monitoringApiService
 | 
				
			||||||
                .putHeaderDetailParam(result, row.id)
 | 
					                .putHeaderDetailParam(result, row.id)
 | 
				
			||||||
                .subscribe((res) => {
 | 
					                .subscribe((res) => {
 | 
				
			||||||
@ -156,17 +154,22 @@ export class MasterFloorComponent {
 | 
				
			|||||||
                  console.log(res);
 | 
					                  console.log(res);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                  if (res.status === 400) {
 | 
					                  if (res.status === 400) {
 | 
				
			||||||
                    this.toastr.error("Warning", "Data yang anda masukan double.", {
 | 
					                    this.toastr.error(
 | 
				
			||||||
 | 
					                      "Warning",
 | 
				
			||||||
 | 
					                      "Data yang anda masukan double.",
 | 
				
			||||||
 | 
					                      {
 | 
				
			||||||
                        timeOut: 5000,
 | 
					                        timeOut: 5000,
 | 
				
			||||||
                        closeButton: true,
 | 
					                        closeButton: true,
 | 
				
			||||||
                    });
 | 
					                      }
 | 
				
			||||||
 | 
					                    );
 | 
				
			||||||
                  }
 | 
					                  }
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
              if (
 | 
					              if (
 | 
				
			||||||
                this.filteredRows.some(
 | 
					                this.filteredRows.some(
 | 
				
			||||||
                  (value) =>
 | 
					                  (value) =>
 | 
				
			||||||
                    value.name.trim().toLowerCase() === result.name.trim().toLowerCase()
 | 
					                    value.name.trim().toLowerCase() ===
 | 
				
			||||||
 | 
					                    result.name.trim().toLowerCase()
 | 
				
			||||||
                )
 | 
					                )
 | 
				
			||||||
              ) {
 | 
					              ) {
 | 
				
			||||||
                this.toastr.error("Warning", "Data yang anda masukan double.", {
 | 
					                this.toastr.error("Warning", "Data yang anda masukan double.", {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user