Remove old client and add new
This commit is contained in:
24
plant-browser/src/app/services/soil-data.service.ts
Normal file
24
plant-browser/src/app/services/soil-data.service.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { SoilData } from '../models/soil-data.model';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class SoilDataService {
|
||||
private apiUrl = 'http://localhost:5284/api/'; // Replace with your actual API endpoint
|
||||
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
getPlants(): Observable<SoilData[]> {
|
||||
return this.http.get<SoilData[]>(this.apiUrl + 'devices');
|
||||
}
|
||||
|
||||
// Update device nickname
|
||||
updateNickname(name: string, nickname: string): Observable<any> {
|
||||
const url = `${this.apiUrl}devices/${encodeURIComponent(name)}/nickname`;
|
||||
return this.http.put(url, { nickname: nickname });
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user