Added timestamps

This commit is contained in:
Zakary Timson 2019-06-16 16:09:09 -04:00
parent 7545dd8069
commit cd122610c2
3 changed files with 14 additions and 5 deletions

View File

@ -19,10 +19,16 @@
<h5 class="mb-0">{{battery.name}}</h5> <h5 class="mb-0">{{battery.name}}</h5>
</div> </div>
<div class="d-flex flex-grow-1 align-items-center justify-content-center"> <div class="d-flex flex-grow-1 align-items-center justify-content-center">
<button mat-button (click)="selected = i" [ngClass]="{'text-success': batteryService.charging, 'text-danger': !batteryService.charging}">{{battery.charge | number : '1.1-1'}} V</button> <button mat-button (click)="selected = i"
[ngClass]="{'selected': selected == i, 'text-success': batteryService.charging, 'text-danger': !batteryService.charging}">
{{battery.charge | number : '1.1-1'}} V
</button>
</div> </div>
<div class="d-flex flex-grow-1 align-items-center justify-content-end text-muted"> <div class="d-flex flex-grow-1 align-items-center justify-content-end text-muted">
<button mat-button (click)="selected = batteryService.batteries.length + i">{{battery.temp | number : '1.1-1'}} °C</button> <button mat-button (click)="selected = batteryService.batteries.length + i"
[ngClass]="{'selected': selected == batteryService.batteries.length + i}">
{{battery.temp | number : '1.1-1'}} °C
</button>
</div> </div>
</div> </div>
<div *ngIf="selected == i" class="w-100" style="height: 200px"> <div *ngIf="selected == i" class="w-100" style="height: 200px">
@ -46,6 +52,8 @@
[yScaleMin]="0" [yScaleMin]="0"
[yScaleMax]="50" [yScaleMax]="50"
[yAxisTickFormatting]="tempFormat" [yAxisTickFormatting]="tempFormat"
[xAxis]="true"
[xAxisTickFormatting]="dateFormat"
[roundDomains]="true" [roundDomains]="true"
></ngx-charts-area-chart> ></ngx-charts-area-chart>
</div> </div>

View File

@ -4,7 +4,8 @@ import {AppComponent} from '../app.component';
@Component({ @Component({
selector: 'app-batterys', selector: 'app-batterys',
templateUrl: './battery.component.html' templateUrl: './battery.component.html',
styles: [`.selected { background-color: rgba(0, 0, 0, 0.1); }`]
}) })
export class BatteryComponent implements OnInit { export class BatteryComponent implements OnInit {
@ -15,7 +16,7 @@ export class BatteryComponent implements OnInit {
group: 'Ordinal', group: 'Ordinal',
domain: ['#2830a8'] domain: ['#2830a8']
}; };
selected; selected = 0;
constructor(public app: AppComponent, public batteryService: BatteryService) { } constructor(public app: AppComponent, public batteryService: BatteryService) { }

View File

@ -54,7 +54,7 @@ export class BatteryService {
chargeHistory: data.modules[key].map((val, i) => ({name: val.timestamp.toDate(), value: val.charge})), chargeHistory: data.modules[key].map((val, i) => ({name: val.timestamp.toDate(), value: val.charge})),
name: key, name: key,
temp: data.modules[key][last].temp, temp: data.modules[key][last].temp,
tempHistory: data.modules[key].map((val, i) => ({name: i, value: val.temp})) tempHistory: data.modules[key].map((val, i) => ({name: val.timestamp.toDate(), value: val.temp}))
} }
}); });
this.lastCharge = this.charge; this.lastCharge = this.charge;