Skip to content

Commit

Permalink
feat: add image create component service
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdeDevs committed Dec 15, 2024
1 parent af2c0d8 commit 01ca273
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/app/image/image.component.spec.ts
Original file line number Diff line number Diff line change
@@ -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<ImageComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [ImageComponent]
})
.compileComponents();

fixture = TestBed.createComponent(ImageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
32 changes: 32 additions & 0 deletions src/app/image/image.service.ts
Original file line number Diff line number Diff line change
@@ -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<Image> {

constructor() {
super(Image);
}

public findById(id: number): Observable<Image> {
return this.getResource(id);
}


public findByApartment(apartment: Apartment): Observable<ResourceCollection<Image>> {
return this.searchCollection('findByApartment', { params: { apartment: apartment } });
}


public findByFilename(filename: string): Observable<ResourceCollection<Image>> {
return this.searchCollection('findByFilename', { params: { filename: filename } });
}

public findByContent(content: string): Observable<ResourceCollection<Image>> {
return this.searchCollection('findByContent', { params: { content: content } });
}

}

0 comments on commit 01ca273

Please sign in to comment.