Data2025/src/main/angular/src/app/location/location-service.ts

74 lines
2.4 KiB
TypeScript

import {Injectable} from '@angular/core';
import {ApiService, CrudService, Next, WebsocketService} from '../common';
import {Location} from './Location'
@Injectable({
providedIn: 'root'
})
export class LocationService extends CrudService<Location> {
constructor(
api: ApiService,
ws: WebsocketService,
) {
super(api, ws, ['Location'], Location.fromJson);
}
findAll(next: Next<Location[]>) {
this.getList(['findAll'], next);
}
getById(id: number, next: Next<Location>) {
this.getSingle([id, 'byId'], next);
}
name(location: Location, name: string, next?: Next<Location>) {
this.postSingle([location.id, 'name'], name, next);
}
latitude(location: Location, latitude: number, next?: Next<Location>) {
this.postSingle([location.id, 'latitude'], latitude, next);
}
longitude(location: Location, longitude: number, next?: Next<Location>) {
this.postSingle([location.id, 'longitude'], longitude, next);
}
energyPurchase(location: Location, seriesId: number | null, next?: Next<Location>) {
this.postSingle([location.id, 'energyPurchase'], seriesId, next);
}
energyDeliver(location: Location, seriesId: number | null, next?: Next<Location>) {
this.postSingle([location.id, 'energyDeliver'], seriesId, next);
}
energyProduce(location: Location, seriesId: number | null, next?: Next<Location>) {
this.postSingle([location.id, 'energyProduce'], seriesId, next);
}
powerPurchase(location: Location, seriesId: number | null, next?: Next<Location>) {
this.postSingle([location.id, 'powerPurchase'], seriesId, next);
}
powerDeliver(location: Location, seriesId: number | null, next?: Next<Location>) {
this.postSingle([location.id, 'powerDeliver'], seriesId, next);
}
powerProduce(location: Location, seriesId: number | null, next?: Next<Location>) {
this.postSingle([location.id, 'powerProduce'], seriesId, next);
}
outsideTemperature(location: Location, seriesId: number | null, next?: Next<Location>) {
this.postSingle([location.id, 'outsideTemperature'], seriesId, next);
}
outsideHumidityRelative(location: Location, seriesId: number | null, next?: Next<Location>) {
this.postSingle([location.id, 'outsideHumidityRelative'], seriesId, next);
}
outsideHumidityAbsolute(location: Location, seriesId: number | null, next?: Next<Location>) {
this.postSingle([location.id, 'outsideHumidityAbsolute'], seriesId, next);
}
}