Hinzugefügt Localizer Dienste für beide api und angular
This commit is contained in:
@@ -57,11 +57,8 @@ export class EnvelopeTableComponent {
|
||||
|
||||
constructor(private erService: EnvelopeReceiverService) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.erService.getEnvelopeReceiver().subscribe({
|
||||
next: res => this.source = res,
|
||||
error: console.error
|
||||
});
|
||||
async ngOnInit() {
|
||||
this.source = await this.erService.getEnvelopeReceiver();
|
||||
}
|
||||
|
||||
columns: Array<GuiColumn> = [
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
export interface EnvelopeReceiver {
|
||||
name: string | null
|
||||
privateMessage: string | null
|
||||
addedWhen: Date
|
||||
changedWhen: Date | null
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { EnvelopeTableComponent } from "../../components/envelope-table/envelope-table.component";
|
||||
import {MatTabsModule} from '@angular/material/tabs';
|
||||
import { MatTabsModule } from '@angular/material/tabs';
|
||||
import { LocalizationService } from '../../services/localization.service';
|
||||
import { firstValueFrom } from 'rxjs/internal/firstValueFrom';
|
||||
|
||||
@Component({
|
||||
selector: 'app-envelope',
|
||||
@@ -11,4 +13,12 @@ import {MatTabsModule} from '@angular/material/tabs';
|
||||
})
|
||||
export class EnvelopeComponent {
|
||||
|
||||
}
|
||||
private localizer: any = {};
|
||||
|
||||
constructor(private localizationService: LocalizationService) {
|
||||
}
|
||||
|
||||
async ngOnInit() {
|
||||
this.localizer = await this.localizationService.getLocalizer()
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Injectable, inject } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { Observable, catchError } from 'rxjs';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Observable, firstValueFrom } from 'rxjs';
|
||||
import { API_URL } from '../tokens/index';
|
||||
|
||||
@Injectable({
|
||||
@@ -14,7 +14,7 @@ export class EnvelopeReceiverService {
|
||||
this.url = `${api_url}/envelopereceiver`;
|
||||
}
|
||||
|
||||
getEnvelopeReceiver(): Observable<any> {
|
||||
return this.http.get<any>(this.url);
|
||||
getEnvelopeReceiver(): Promise<any> {
|
||||
return firstValueFrom(this.http.get<any>(this.url));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { LocalizationService } from './localization.service';
|
||||
|
||||
describe('LocalizationService', () => {
|
||||
let service: LocalizationService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(LocalizationService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,21 @@
|
||||
import { Injectable, inject } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Observable, firstValueFrom } from 'rxjs';
|
||||
import { API_URL } from '../tokens/index';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class LocalizationService {
|
||||
|
||||
private url: string;
|
||||
|
||||
constructor(private http: HttpClient) {
|
||||
const api_url = inject(API_URL);
|
||||
this.url = `${api_url}/localization`;
|
||||
}
|
||||
|
||||
getLocalizer(): Promise<any> {
|
||||
return firstValueFrom(this.http.get<any>(this.url));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user