{"version":3,"sources":["src/app/features/modals/header-filter-modal/header-filter-modal.component.ts","src/app/features/modals/header-filter-modal/header-filter-modal.component.html","node_modules/primeng/fesm2022/primeng-togglebutton.mjs","src/app/shared/toggle/toggle.component.ts","src/app/shared/toggle/toggle.component.html","src/app/shared/header/header.component.ts","src/app/shared/header/header.component.html","src/app/shared/sidebar/sidebar.service.ts","node_modules/@angular/cdk/fesm2022/coercion.mjs","node_modules/@angular/cdk/fesm2022/platform.mjs","node_modules/@angular/cdk/fesm2022/layout.mjs","node_modules/primeng/fesm2022/primeng-sidebar.mjs","src/app/services/auth.service.ts","src/app/shared/sidebar/sidebar.component.ts","src/app/shared/sidebar/sidebar.component.html"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { HttpParams } from '@angular/common/http';\nimport { Component, Input, OnDestroy, OnInit } from '@angular/core';\nimport {\n FormBuilder,\n FormGroup,\n FormsModule,\n ReactiveFormsModule,\n Validators,\n} from '@angular/forms';\nimport { NavigationEnd, Router } from '@angular/router';\nimport { TranslateModule } from '@ngx-translate/core';\nimport { DropdownModule } from 'primeng/dropdown';\nimport { DynamicDialogConfig, DynamicDialogRef } from 'primeng/dynamicdialog';\nimport { MultiSelectModule } from 'primeng/multiselect';\nimport { filter, Subscription } from 'rxjs';\nimport { API_END_POINTS } from '../../../constants/constant';\nimport { LineData } from '../../../interfaces/line.interface';\nimport { FactoryData, PlantData } from '../../../interfaces/plant.interface';\nimport { CommonService } from '../../../services/common.service';\nimport { HeaderService } from '../../../services/header.service';\nimport { HttpService } from '../../../services/http.service';\nimport { ButtonComponent } from '../../../shared/button/button.component';\nimport { get } from 'lodash';\nimport { SortByComponent } from '@shared/sort-by/sort-by.component';\n\n@Component({\n selector: 'app-header-filter-modal',\n standalone: true,\n imports: [\n DropdownModule,\n FormsModule,\n ButtonComponent,\n TranslateModule,\n CommonModule,\n ReactiveFormsModule,\n MultiSelectModule,\n SortByComponent,\n ],\n templateUrl: './header-filter-modal.component.html',\n styleUrls: ['./header-filter-modal.component.scss'],\n})\nexport class HeaderFilterModalComponent implements OnInit, OnDestroy {\n lineId: any;\n plantId!: any;\n factoryId: any;\n plantData!: PlantData[];\n cityId!: number;\n selectedLines: any;\n isSubmitted = false;\n locationForm: FormGroup;\n linesData!: LineData[];\n filteredLines!: LineData[];\n factoryData!: FactoryData[];\n lineSubscription?: Subscription;\n factorySubscription?: Subscription;\n plantName: string = 'Neemrana, Rajasthan';\n private subscriptions: Subscription = new Subscription();\n @Input() chartHeading: string = '';\n isDisabled: boolean = false;\n isAllDisabled: boolean = false;\n\n isDailyLineRoute: boolean = false;\n\n constructor(\n private fb: FormBuilder,\n private router: Router,\n private ref: DynamicDialogRef,\n private httpService: HttpService,\n public config: DynamicDialogConfig,\n private headerService: HeaderService,\n private commonService: CommonService\n ) {\n this.locationForm = this.fb.group({\n plant: [null, Validators.required],\n factory: [null],\n line: [null],\n });\n }\n\n ngOnInit(): void {\n this.checkActiveRoute(this.router.url);\n this.router.events\n .pipe(filter((event) => event instanceof NavigationEnd))\n .subscribe((event: any) => {\n this.checkActiveRoute(event.urlAfterRedirects);\n });\n this.commonService.currentChartHeading.subscribe((heading) => {\n this.chartHeading = heading;\n });\n\n this.plantId = localStorage.getItem('plantId');\n\n this.subscriptions.add(\n this.headerService.plantId.subscribe((plantId: string | null) => {\n this.plantId = plantId;\n this.updateSelectedPlant();\n })\n );\n\n this.commonService.currentChartHeading.subscribe((heading) => {\n this.chartHeading = heading;\n if (\n this.chartHeading === 'User Management' ||\n this.chartHeading === 'Alarm Code Definitions' ||\n this.chartHeading === 'Line Management' ||\n this.chartHeading === 'Production Loss Reason' ||\n this.chartHeading === 'Alerts Management'\n ) {\n this.isDisabled = true;\n this.isAllDisabled = false;\n this.headerService.removeLineId();\n this.plantId = localStorage.getItem('plantId');\n if (this.plantId) this.headerService.setPlantId(this.plantId);\n this.factoryId = localStorage.getItem('factoryId');\n if (this.factoryId) this.headerService.setFactoryId(this.factoryId);\n this.lineId = localStorage.getItem('lineId');\n if (this.lineId) this.headerService.setLineId(this.lineId);\n } else if (this.chartHeading === 'Manage Plants') {\n this.plantId = null;\n this.factoryId = null;\n this.lineId = null;\n this.isAllDisabled = true;\n this.isDisabled = false;\n } else {\n this.isAllDisabled = false;\n this.isDisabled = false;\n this.plantId = localStorage.getItem('plantId');\n if (this.plantId) this.headerService.setPlantId(this.plantId);\n this.factoryId = localStorage.getItem('factoryId');\n if (this.factoryId) this.headerService.setFactoryId(this.factoryId);\n this.lineId = localStorage.getItem('lineId');\n if (this.lineId) this.headerService.setLineId(this.lineId);\n }\n this.headerService.fetchSource.next();\n });\n\n this.factoryId = localStorage.getItem('factoryId');\n\n this.lineId = localStorage.getItem('lineId');\n\n const storedLines = localStorage.getItem('selectedLines');\n if (storedLines) {\n this.selectedLines = JSON.parse(storedLines);\n }\n\n this.subscriptions.add(\n this.headerService.lineId.subscribe((lineId: string | null) => {\n this.lineId = lineId;\n this.updateSelectedLine();\n })\n );\n\n this.subscriptions.add(\n this.headerService.factoryId.subscribe((factoryId: string | null) => {\n this.factoryId = factoryId;\n this.updateSelectedFactory();\n })\n );\n\n this.subscriptions.add(\n this.headerService.lineIds.subscribe((lineIds: string[] | null) => {\n if (lineIds) {\n this.selectedLines = lineIds;\n localStorage.setItem(\n 'selectedLines',\n JSON.stringify(this.selectedLines)\n );\n }\n })\n );\n\n this.getPlantData();\n this.getFactoryData();\n if (this.factoryId) {\n this.getLineData();\n } else if (this.plantId) {\n this.getLineDataByPlant();\n }\n }\n\n updateSelectedPlant(): void {\n const selectedPlant = this.plantData?.find(\n (plant: { id: number }) => plant.id === +this.plantId\n );\n if (selectedPlant) {\n this.locationForm\n .get('plant')\n ?.setValue(selectedPlant, { emitEvent: false });\n }\n }\n\n updateSelectedFactory(): void {\n const selectedFactory = this.factoryData?.find(\n (factory: { id: number }) => factory.id === +this.factoryId\n );\n if (selectedFactory) {\n this.locationForm\n .get('factory')\n ?.setValue(selectedFactory, { emitEvent: false });\n this.filterLines(selectedFactory);\n }\n }\n\n updateSelectedLine(): void {\n const selectedLine = this.linesData?.find(\n (line: { id: number }) => line.id === +this.lineId\n );\n if (selectedLine) {\n this.locationForm\n .get('line')\n ?.setValue(selectedLine, { emitEvent: false });\n }\n }\n\n filterLines(selectedFactory: FactoryData) {\n if (selectedFactory) {\n this.filteredLines = this.linesData?.filter(\n (line) => line.factoryId === selectedFactory?.id\n );\n } else {\n this.filteredLines = this.linesData;\n }\n }\n\n onPlantChange(event: { value: PlantData }) {\n if (event) {\n this.plantId = event.value.id;\n this.getFactoryData();\n this.getLineData();\n }\n }\n\n onFactoryChange(event: { value: FactoryData }) {\n const selectedFactory = event.value;\n this.factoryId = get(event, 'value.id');\n this.filterLines(selectedFactory);\n this.locationForm.get('line')?.setValue(null);\n this.selectedLines = [];\n this.getLineData();\n }\n\n getPlantData() {\n const url = API_END_POINTS.GET_PLANT;\n let params = new HttpParams().set('PageNumber', 0).set('PageSize', 0);\n this.httpService\n .getRequest(url, null, { params })\n .then((response) => {\n if (response) {\n this.plantData = response.data.filter(\n (plant: { isActive: boolean }) => plant.isActive\n );\n this.updateSelectedPlant();\n } else {\n console.error('No data received');\n }\n })\n .catch((error) => {\n console.error('There was an error:', error);\n });\n }\n\n getFactoryData() {\n if (!this.plantId) return;\n const url = `${API_END_POINTS.GET_FACTORY_BY_PLANTID}${this.plantId}`;\n this.httpService\n .getRequest(url)\n .then((response) => {\n if (response) {\n this.factoryData = response.data;\n this.updateSelectedFactory();\n } else {\n console.error('No data received');\n }\n })\n .catch((error) => {\n console.error('There was an error:', error);\n });\n }\n\n getLineData() {\n if (!this.factoryId) return;\n const url = `${API_END_POINTS.GET_LINE_BY_FACTORYID}${this.factoryId}`;\n this.httpService\n .getRequest(url)\n .then((response) => {\n if (response) {\n this.linesData = response;\n this.filteredLines = this.linesData;\n this.updateSelectedLine();\n } else {\n console.error('No data received');\n }\n })\n .catch((error) => {\n console.error('There was an error:', error);\n });\n }\n\n onViewLines() {\n this.isSubmitted = true;\n if (this.locationForm.valid) {\n this.ref.close({\n form: this.locationForm,\n selectedLines: this.selectedLines,\n });\n }\n }\n\n get factoryControl() {\n return this.locationForm.get('factory');\n }\n\n get isSaveViewDisabled() {\n const factorySelected = !!this.locationForm.get('factory')?.value;\n const lineSelected = !!this.locationForm.get('line')?.value;\n return !(factorySelected || lineSelected);\n }\n\n onLineChange(selectedLine: LineData) {\n this.lineId = selectedLine.id;\n localStorage.setItem('lineId', this.lineId);\n }\n\n private checkActiveRoute(url: string): void {\n if (url === '/chart/hourly-production') {\n this.isDailyLineRoute = true;\n } else {\n this.isDailyLineRoute = false;\n }\n }\n\n onClearAllClick() {\n this.ref.close(null);\n }\n\n ngOnDestroy(): void {\n if (this.factorySubscription) {\n this.factorySubscription?.unsubscribe();\n }\n if (this.lineSubscription) this.lineSubscription?.unsubscribe();\n this.subscriptions.unsubscribe();\n }\n\n getLineDataByPlant() {\n const url = `${API_END_POINTS.GET_ALL_PLANT_LINES}${this.plantId}`;\n this.httpService\n .getRequest(url)\n .then((response) => {\n if (response) {\n this.linesData = response;\n } else {\n console.error('No data received');\n }\n })\n .catch((error) => {\n console.error('There was an error:', error);\n });\n }\n}\n","
{{ chartHeading }}
\nAuto Refresh
\n{{ lastApiCallTime }}
\n{{ userName }}
\n