From 01ca2736cc3db9616f2a5140d86936353a9b14ca Mon Sep 17 00:00:00 2001 From: Abdellah Lamrabat Date: Sun, 15 Dec 2024 13:58:14 +0100 Subject: [PATCH] feat: add image create component service --- src/app/image/image.component.spec.ts | 23 +++++++++++++++++++ src/app/image/image.service.ts | 32 +++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 src/app/image/image.component.spec.ts create mode 100644 src/app/image/image.service.ts diff --git a/src/app/image/image.component.spec.ts b/src/app/image/image.component.spec.ts new file mode 100644 index 0000000..263123f --- /dev/null +++ b/src/app/image/image.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ImageComponent } from './image-create/image.component'; + +describe('ImageComponent', () => { + let component: ImageComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [ImageComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(ImageComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/image/image.service.ts b/src/app/image/image.service.ts new file mode 100644 index 0000000..aa8f0d1 --- /dev/null +++ b/src/app/image/image.service.ts @@ -0,0 +1,32 @@ +import { Injectable } from '@angular/core'; +import { HateoasResourceOperation, ResourceCollection } from '@lagoshny/ngx-hateoas-client'; +import { Observable } from 'rxjs'; +import { Image } from './image'; +import { Apartment } from '../apartment/apartment'; + +@Injectable({ providedIn: 'root' }) +export class ImageService extends HateoasResourceOperation { + + constructor() { + super(Image); + } + + public findById(id: number): Observable { + return this.getResource(id); + } + + + public findByApartment(apartment: Apartment): Observable> { + return this.searchCollection('findByApartment', { params: { apartment: apartment } }); + } + + + public findByFilename(filename: string): Observable> { + return this.searchCollection('findByFilename', { params: { filename: filename } }); + } + + public findByContent(content: string): Observable> { + return this.searchCollection('findByContent', { params: { content: content } }); + } + +}