This commit is contained in:
Lurkars
2020-11-02 08:29:52 +01:00
commit b7b4e2d032
126 changed files with 18263 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
<div [innerHTML]="htmlTemplate"></div>
+25
View File
@@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { HtmlComponent } from './html.component';
describe('HtmlComponent', () => {
let component: HtmlComponent;
let fixture: ComponentFixture<HtmlComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ HtmlComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(HtmlComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
+32
View File
@@ -0,0 +1,32 @@
import { Component, OnInit, Input } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { I18nService } from './../../services/i18n.service';
@Component({
selector: 'app-html',
templateUrl: './html.component.html',
styleUrls: ['./html.component.scss']
})
export class HtmlComponent implements OnInit {
htmlTemplate: any;
locale: String;
@Input() template;
constructor(private i18n: I18nService, private httpClient: HttpClient) {
this.locale = this.i18n.getLocale();
}
ngOnInit(): void {
const headers = new HttpHeaders()
.set('content-type', 'text/html');
this.httpClient.get(
'./assets/templates/' + this.template + (this.locale ? "." + this.locale : "") + ".html",
{
headers: headers,
responseType: 'text'
}).subscribe(response => this.htmlTemplate = response);
}
}
+18
View File
@@ -0,0 +1,18 @@
import { Pipe, PipeTransform } from '@angular/core';
import { I18nService } from './../services/i18n.service';
@Pipe({
name: 'i18n'
})
export class I18nPipe implements PipeTransform {
constructor(private i18n: I18nService) {
}
transform(value: String, ...args: any[]): String {
return this.i18n.get(value, args);
}
}
+22
View File
@@ -0,0 +1,22 @@
import { FormGroup } from '@angular/forms';
export function MatchingValidator(passwordName: string, password2Name: string) {
return (formGroup: FormGroup) => {
const password = formGroup.controls[passwordName];
const password2 = formGroup.controls[password2Name];
if (password2.errors && !password2.errors.matchingValidator) {
return;
}
if (password.value !== password2.value) {
password2.setErrors({ matchingValidator: true });
} else {
password2.setErrors(null);
}
}
}