Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
PowerPanel-Frontend/src/app/statistics/statistics.component.ts
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
194 lines (147 sloc)
3.72 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Component, OnInit} from '@angular/core'; | |
import {MetricsService} from '../services/metrics.service'; | |
import {HttpClient, HttpHeaders} from '@angular/common/http'; | |
import { Router } from '@angular/router'; | |
@Component({ | |
selector: 'app-statistics', | |
templateUrl: './statistics.component.html', | |
styleUrls: ['./statistics.component.css'] | |
}) | |
export class StatisticsComponent implements OnInit { | |
constructor(public data: MetricsService, private http: HttpClient, private router: Router) { | |
} | |
public fuelTemp: any; | |
public oilTemp: any; | |
public pACurrent: any; | |
public pBCurrent: any; | |
public pCCurrent: any; | |
public engineSpeed: any; | |
public fuelLevel: any; | |
public pAVoltage: any; | |
public pBVoltage: any; | |
public pCVoltage: any; | |
public coolantTemp: any; | |
public oilPressure: any; | |
public metric: any; | |
public metricYearAvg: any; | |
public fuelTempYearAvg: any; | |
public isRecent: boolean = true; | |
public isHour: boolean = false; | |
public isDay: boolean = false; | |
public isWeek: boolean = false; | |
public isMonth: boolean = false; | |
public isYear: boolean = false; | |
viewRecent() { | |
this.isRecent = true; | |
this.isHour = false; | |
this.isDay = false; | |
this.isWeek = false; | |
this.isMonth = false; | |
this.isYear = false; | |
} | |
viewHour() { | |
this.isRecent = false; | |
this.isHour = true; | |
this.isDay = false; | |
this.isWeek = false; | |
this.isMonth = false; | |
this.isYear = false; | |
} | |
viewDay() { | |
this.isRecent = false; | |
this.isHour = false; | |
this.isDay = true; | |
this.isWeek = false; | |
this.isMonth = false; | |
this.isYear = false; | |
} | |
viewWeek() { | |
this.isRecent = false; | |
this.isHour = false; | |
this.isDay = false; | |
this.isWeek = true; | |
this.isMonth = false; | |
this.isYear = false; | |
} | |
viewMonth() { | |
this.isRecent = false; | |
this.isHour = false; | |
this.isDay = false; | |
this.isWeek = false; | |
this.isMonth = true; | |
this.isYear = false; | |
} | |
viewYear() { | |
this.isRecent = false; | |
this.isHour = false; | |
this.isDay = false; | |
this.isWeek = false; | |
this.isMonth = false; | |
this.isYear = true; | |
} | |
setDial(dialValue, metricName) { | |
console.log(dialValue); | |
var returnVal = { | |
'chart': { | |
'caption': metricName, | |
'lowerLimit': '0', | |
'upperLimit': '200', | |
'showValue': '1', | |
'theme': 'fusion', | |
'showToolTip': '0' | |
}, | |
'colorRange': { | |
'color': [{ | |
'minValue': '0', | |
'maxValue': '50', | |
'code': '#F2726F' | |
}, { | |
'minValue': '50', | |
'maxValue': '75', | |
'code': '#FFC533' | |
}, { | |
'minValue': '75', | |
'maxValue': '200', | |
'code': '#62B58F' | |
}] | |
}, | |
'dials': { | |
'dial': [{ | |
'value': dialValue | |
}] | |
} | |
}; | |
return returnVal; | |
} | |
goToGraphGen() | |
{ | |
this.router.navigateByUrl('/visualize-one'); | |
} | |
goToGraphSpec(dataType) | |
{ | |
this.router.navigateByUrl('/visualize-one'); | |
localStorage.setItem('data_type', dataType); | |
} | |
ngOnInit() { | |
const jsonToken = localStorage.getItem('auth_token'); | |
try { | |
this.data.getDevMetrics(jsonToken).subscribe((data) => { | |
//console.log(data.outputs[1].dps[0][1]); | |
this.metric = data; | |
this.fuelTemp = Math.round(this.metric.outputs[0].dps[0][1]); | |
this.oilTemp = this.metric.outputs[1].dps[0][1]; | |
this.pACurrent = this.metric.outputs[2].dps[0][1]; | |
}); | |
} catch (err) { | |
return err; | |
} | |
try { | |
this.data.getYearMetrics(jsonToken).subscribe((data) => { | |
this.metricYearAvg = data; | |
this.fuelTempYearAvg = this.metricYearAvg.outputs[0].dps[0][1]; | |
}); | |
} catch (err) { | |
return err; | |
} | |
} | |
} |