feat(services): Hinzufügen des EnvelopeService zur Verarbeitung von API-Anfragen

This commit is contained in:
Developer 02
2024-09-05 11:53:22 +02:00
parent b8b09ded5d
commit 3692aa80a4
6 changed files with 47 additions and 6 deletions

View File

@@ -1,5 +1,6 @@
import { AfterViewInit, Component, Input, ViewChild, inject, viewChild } from '@angular/core';
import { EnvelopeReceiverService } from '../../../services/envelope-receiver.service';
import { EnvelopeService } from '../../../services/envelope.service';
import { animate, state, style, transition, trigger } from '@angular/animations';
import { ConfigurationService } from '../../../services/configuration.service';
import { DDTable } from "../dd-table/dd-table.component";
@@ -60,9 +61,12 @@ export class EnvelopeTableComponent implements AfterViewInit {
private erService: EnvelopeReceiverService = inject(EnvelopeReceiverService);
private envService: EnvelopeService = inject(EnvelopeService);
private config: ConfigurationService = inject(ConfigurationService);
async ngAfterViewInit() {
this.data = await this.erService.getEnvelopeReceiverAsync(this.options);
await this.envService.getEnvelopeAsync().then(console.log)
}
}

View File

@@ -27,7 +27,6 @@ export class EnvelopeReceiverService {
return this.http.get<any>(this.url, { params });
}
getEnvelopeReceiverAsync(options?: { min_status?: number; max_status?: number; ignore_status?: number[] }): Promise<any> {
return firstValueFrom(this.getEnvelopeReceiver(options));
}

View File

@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { EnvelopeService } from './envelope.service';
describe('EnvelopeService', () => {
let service: EnvelopeService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(EnvelopeService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

View File

@@ -0,0 +1,24 @@
import { Injectable, inject } from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http';
import { Observable, firstValueFrom } from 'rxjs';
import { API_URL } from '../tokens/index';
@Injectable({
providedIn: 'root'
})
export class EnvelopeService {
protected url: string;
constructor(private http: HttpClient) {
const api_url = inject(API_URL);
this.url = `${api_url}/envelope`;
}
public getEnvelope(): Observable<any> {
return this.http.get(this.url);
}
public async getEnvelopeAsync(): Promise<any> {
return await firstValueFrom(this.getEnvelope());
}
}