No changes detected in diff

No code was added or removed in the provided diff; only context lines were present.
This commit is contained in:
2026-02-02 10:14:15 +01:00
parent 75846573da
commit eda30472b9
97 changed files with 7 additions and 28 deletions

View File

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

View File

@@ -0,0 +1,49 @@
import { Injectable, inject } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable, firstValueFrom, tap } from 'rxjs';
import { API_URL } from '../tokens/index';
@Injectable({
providedIn: 'root'
})
export class AuthService {
private url: string;
constructor(private http: HttpClient) {
const api_url = inject(API_URL);
this.url = `${api_url}/auth`;
}
login(credentials: { username: string; password: string }): Observable<any> {
return this.http.post(`${this.url}/login`, credentials).pipe(
tap({
next: res => this.#IsAuthenticated = true,
error: () => this.#IsAuthenticated = false
})
)
}
logout(): Observable<any> {
return this.http.post(`${this.url}/logout`, {}).pipe(
tap({
next: res => this.#IsAuthenticated = false,
error: () => this.#IsAuthenticated = true
})
);
}
async logoutAsync(): Promise<void> {
return await firstValueFrom(this.logout());
}
isAuthenticated(): Observable<boolean> {
return this.http.get<boolean>(`${this.url}/check`).pipe(
tap(isAuthenticated => this.#IsAuthenticated = isAuthenticated)
);
}
#IsAuthenticated = false;
get IsAuthenticated(): boolean {
return this.#IsAuthenticated;
}
}

View File

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

View File

@@ -0,0 +1,47 @@
import { Injectable, OnInit, 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 ConfigurationService implements OnInit {
protected url: string;
private _envelopeTypes! : any[];
private _envelopeTypeTitles! : any[];
private _referenceType!: any;
constructor(private http: HttpClient) {
const api_url = inject(API_URL);
this.url = `${api_url}`;
}
async ngOnInit(): Promise<void> {
const envelopeTypes$: Observable<any[]> = this.http.get<any[]>(`${this.url}/EnvelopeType`)
envelopeTypes$.subscribe({next: res => {
this._envelopeTypes = res;
this._envelopeTypeTitles = res.map(e => e.title);
}});
this.http.get<any>(`${this.url}/History/reference-type`).subscribe({
next: res => this._referenceType = res
})
}
public get envelopeTypes() {
return this._envelopeTypes;
}
public get envelopeTypeTitles() {
return this._envelopeTypeTitles;
}
public get referenceType() {
return this._referenceType;
}
}

View File

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

View File

@@ -0,0 +1,44 @@
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 EnvelopeReceiverService {
protected url: string;
constructor(private http: HttpClient) {
const api_url = inject(API_URL);
this.url = `${api_url}/envelopereceiver`;
}
getEnvelopeReceiver(options?: { min_status?: number; max_status?: number; ignore_status?: number[] }): Observable<any> {
let params = new HttpParams();
if (options) {
if (options.min_status)
params = params.set('min_status', options.min_status.toString());
if (options.max_status)
params = params.set('max_status', options.max_status.toString());
if (options.ignore_status)
params = params.set('ignore_status', options.ignore_status.join(','));
}
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));
}
getSecret(uuid: string): Observable<any> {
let params = new HttpParams();
params = params.set('uuid', uuid);
return this.http.get<any>(`${this.url}/secret`, { params });
}
getSecretAsync(uuid: string): Promise<any> {
return firstValueFrom(this.getSecret(uuid));
}
}

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,33 @@
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(options?: { min_status?: number; max_status?: number; ignore_status?: number[] }): Observable<any> {
let params = new HttpParams();
if (options) {
if (options.min_status)
params = params.set('min_status', options.min_status.toString());
if (options.max_status)
params = params.set('max_status', options.max_status.toString());
if (options.ignore_status)
params = params.set('ignore_status', options.ignore_status.join(','));
}
return this.http.get(this.url, { params });
}
public async getEnvelopeAsync(options?: { min_status?: number; max_status?: number; ignore_status?: number[] }): Promise<any> {
return await firstValueFrom(this.getEnvelope(options));
}
}

View File

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

View File

@@ -0,0 +1,46 @@
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 HistoryService {
protected url: string;
constructor(private http: HttpClient) {
const api_url = inject(API_URL);
this.url = `${api_url}/history`;
}
public getHistory(options?: Options): Observable<any> {
let params = new HttpParams();
if (options) {
if (options.envelopeId)
params = params.set('envelopeId', options.envelopeId);
if (options.referenceType != null)
params = params.set('referenceType', options.referenceType);
if (options.userReference)
params = params.set('userReference', options.userReference);
if (options.withReceiver)
params = params.set('withReceiver', options.withReceiver);
if (options.withSender)
params = params.set('withSender', options.withSender);
}
return this.http.get(this.url, { params });
}
public async getHistoryAsync(options?: Options): Promise<any> {
return firstValueFrom(this.getHistory(options));
}
}
class Options {
envelopeId?: number;
userReference?: string;
referenceType: number | null = null;
withSender?: boolean;
withReceiver?: boolean;
}

View File

@@ -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();
});
});

View File

@@ -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));
}
}

View File

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

View File

@@ -0,0 +1,58 @@
import { HttpClient, HttpParams } from '@angular/common/http';
import { Injectable, inject } from '@angular/core';
import { API_URL } from '../tokens';
import { Observable, firstValueFrom } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class ReceiverService {
protected url: string;
constructor(private http: HttpClient) {
const api_url = inject(API_URL);
this.url = `${api_url}/receiver`;
}
public getReceiver(options?: { emailAdress?: string; signature?: string; }): Observable<any> {
let params = new HttpParams();
if (options) {
if (options.emailAdress)
params = params.set('emailAdress', options?.emailAdress);
if (options.signature)
params = params.set('signature', options?.signature);
}
return this.http.get<any>(this.url, { params });
}
public async getReceiverAsync(options?: { emailAdress?: string; signature?: string; }): Promise<any> {
return await firstValueFrom(this.getReceiver(options));
}
public createReceiver(emailAddress: string): Observable<any> {
return this.http.post<any>(this.url, { emailAddress: emailAddress });
}
public async createReceiverAsync(emailAddress: string): Promise<any> {
return await firstValueFrom(this.createReceiver(emailAddress));
}
public deleteReceiver(options: { id: number, emailAdress?: string; signature?: string; }): Observable<any> {
let params = new HttpParams();
if (options.emailAdress)
params = params.set('emailAdress', options?.emailAdress);
if (options.signature)
params = params.set('signature', options?.signature);
if (options.id)
params = params.set('id', options?.id.toString());
return this.http.get<any>(this.url, { params });
}
public async deleteReceiverAsync(options: { id: number, emailAdress?: string; signature?: string; }): Promise<any> {
return await firstValueFrom(this.deleteReceiver(options));
}
}

View File

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

View File

@@ -0,0 +1,26 @@
import { Injectable, Inject, inject } from '@angular/core';
import { DOCUMENT } from '@angular/common';
import { Meta } from '@angular/platform-browser';
@Injectable({
providedIn: 'root'
})
export class UrlService {
document: Document;
meta: Meta;
constructor() {
this.document = inject(DOCUMENT)
this.meta = inject(Meta)
}
getBaseHref(): string {
const baseElement = this.document.querySelector('base');
return baseElement?.getAttribute('href') || '/';
}
getApiUrl(): string | null {
const apiMetaTag = this.meta.getTag('name="api-url"');
return apiMetaTag ? apiMetaTag.content : null;
}
}