Files
Extrudex/frontend/src/app/services/filament.service.ts
dex-bot f5ca20307e
Some checks failed
Dev Build / build-test (pull_request) Failing after 53s
Dev Build / deploy-dev (pull_request) Has been skipped
Dev Build / notify-success (pull_request) Has been skipped
Dev Build / notify-failure (pull_request) Successful in 3s
CUB-36: add delete confirmation dialog for filament spool removal
2026-04-27 18:12:58 +00:00

37 lines
1.0 KiB
TypeScript

import { Injectable, inject } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { Filament } from '../models/filament.model';
/**
* API base URL — matches the Extrudex backend default.
* TODO: Move to environment config when multi-environment support is added.
*/
const API_BASE_URL = '/api';
/**
* Service for CRUD operations on filament spools.
* Communicates with the Extrudex backend SpoolsController.
*/
@Injectable({ providedIn: 'root' })
export class FilamentService {
private readonly http = inject(HttpClient);
/**
* Fetch all filament spools from the backend.
* GET /api/spools
*/
getFilaments(): Observable<Filament[]> {
return this.http.get<Filament[]>(`${API_BASE_URL}/spools`);
}
/**
* Soft-delete a filament spool by ID.
* DELETE /api/spools/{id}
* Returns 204 No Content on success.
*/
deleteFilament(id: string): Observable<void> {
return this.http.delete<void>(`${API_BASE_URL}/spools/${id}`);
}
}