fix: clean code

This commit is contained in:
Desy Ayurianti 2024-11-06 09:28:54 +07:00
parent cff1e79837
commit 50c3ce7497
4 changed files with 5 additions and 12 deletions

View File

@ -20,7 +20,7 @@
<div class="sensor-wrapper">
<div class="title-with-dropdown">
<div class="title">Sensor NPK 1</div>
<select class="form-select" style="margin-top: 10px" [(ngModel)]="selectedNPK1" (change)="updateCharts(); onResize()">
<select class="form-select" style="margin-top: 10px" [(ngModel)]="selectedNPK1" (change)="onResize()">
<option value="npk">NPK</option>
<option value="others">Lainnya</option>
</select>
@ -39,7 +39,7 @@
<div class="sensor-wrapper">
<div class="title-with-dropdown">
<div class="title">Sensor NPK 2</div>
<select class="form-select" style="margin-top: 10px" [(ngModel)]="selectedNPK2" (change)="updateCharts(); onResize()">
<select class="form-select" style="margin-top: 10px" [(ngModel)]="selectedNPK2" (change)=" onResize()">
<option value="npk">NPK</option>
<option value="others">Lainnya</option>
</select>

View File

@ -82,15 +82,12 @@ export class GraphComponent implements OnInit, AfterViewInit, OnDestroy, OnChang
this.updateCharts();
}
ngOnChanges(changes: SimpleChanges): void {
if (changes['interval'] && !changes['interval'].firstChange) {
if (changes['interval'] && changes['interval'].previousValue !== changes['interval'].currentValue) {
this.selectedInterval = changes['interval'].currentValue;
this.updateCharts();
}
}
ngAfterViewInit(): void {
this.onResize();
}
@ -157,7 +154,6 @@ export class GraphComponent implements OnInit, AfterViewInit, OnDestroy, OnChang
fetchNPK2Data(savedTimeRange: string): void {
const startEnd = this.getDate();
const timeRange = this.interval;
this.sensorService.getSensorData('npk2', this.selectedNPK2, startEnd, savedTimeRange).subscribe({
next: (response) => {
console.log(savedTimeRange);
@ -192,7 +188,6 @@ export class GraphComponent implements OnInit, AfterViewInit, OnDestroy, OnChang
}
createChart(canvas: HTMLCanvasElement, response: ApiResponse, sensor: string, selectedOption: string): void {
const ctx = canvas.getContext('2d');
const parameters = this.sensorParameters[sensor];

View File

@ -12,7 +12,6 @@
<button (click)="updateInterval('DAILY')" [class.active-button]="selectedButton === 'daily'">Daily</button>
</div>
<div class="graph">
<app-graph [interval]="selectedInterval"></app-graph>
</div>

View File

@ -43,7 +43,6 @@ export class HistorygraphComponent implements OnInit, OnDestroy {
}, 300);
}
ngOnDestroy(): void {
if (this.intervalId) {
clearInterval(this.intervalId);