diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts index f94587d..dff0d7c 100644 --- a/frontend/src/app/app.module.ts +++ b/frontend/src/app/app.module.ts @@ -1,3 +1,4 @@ +import { EditAuthAddComponent } from './pages/edit-auth/edit-auth-add.component'; import { EditAuthLineComponent } from './pages/edit-auth/edit-auth-line.component'; import { RecordsOperation } from './operations/records.operations'; import { LoggedOutGuard } from './services/logged-out-guard.service'; @@ -67,7 +68,8 @@ import { UsersComponent } from './pages/users/users.component'; EditUserComponent, CreateUserComponent, SearchComponent, - EditAuthLineComponent + EditAuthLineComponent, + EditAuthAddComponent ], imports: [ BrowserModule, diff --git a/frontend/src/app/pages/edit-auth/edit-auth-add.component.html b/frontend/src/app/pages/edit-auth/edit-auth-add.component.html new file mode 100644 index 0000000..4bb3e4a --- /dev/null +++ b/frontend/src/app/pages/edit-auth/edit-auth-add.component.html @@ -0,0 +1,36 @@ +Add + +
+ +
+ .{{ domain.name }} +
+
+ + + + + + + + +
+ +
+ Must be positive integer. +
+
+ + +
+ +
+ Must be positive integer. +
+
+ + + + + + \ No newline at end of file diff --git a/frontend/src/app/pages/edit-auth/edit-auth-add.component.ts b/frontend/src/app/pages/edit-auth/edit-auth-add.component.ts new file mode 100644 index 0000000..3d066fe --- /dev/null +++ b/frontend/src/app/pages/edit-auth/edit-auth-add.component.ts @@ -0,0 +1,54 @@ +import { RecordsOperation } from './../../operations/records.operations'; +import { StateService } from './../../services/state.service'; +import { DomainApitype } from './../../apitypes/Domain.apitype'; +import { FormControl, FormBuilder, Validators } from '@angular/forms'; +import { RecordApitype } from './../../apitypes/Record.apitype'; +import { Component, OnInit, Input, SimpleChanges, EventEmitter, Output } from '@angular/core'; + +@Component({ + // tslint:disable-next-line:component-selector + selector: '[app-edit-auth-add]', + templateUrl: './edit-auth-add.component.html' +}) +export class EditAuthAddComponent implements OnInit { + + @Input() domain: DomainApitype; + + @Output() recordAdded = new EventEmitter(); + + public inputName: FormControl; + public inputType: FormControl; + public inputContent: FormControl; + public inputPriority: FormControl; + public inputTtl: FormControl; + + constructor(private fb: FormBuilder, public gs: StateService, private records: RecordsOperation) { + this.setupFormControls(); + } + + ngOnInit(): void { + } + + public async setupFormControls() { + this.inputName = this.fb.control(''); + this.inputType = this.fb.control('A'); + this.inputContent = this.fb.control(''); + this.inputPriority = this.fb.control('0', [Validators.required, Validators.pattern(/^[0-9]+$/)]); + this.inputTtl = this.fb.control('86400', [Validators.required, Validators.pattern(/^[0-9]+$/)]); + } + + public fullName(): string { + if (this.inputName.value !== '') { + return this.inputName.value + '.' + this.domain.name; + } else { + return this.domain.name; + } + } + + public async onSave() { + await this.records.create(this.domain.id, this.fullName(), this.inputType.value, + this.inputContent.value, this.inputPriority.value, this.inputTtl.value); + + this.recordAdded.emit(); + } +} diff --git a/frontend/src/app/pages/edit-auth/edit-auth.component.html b/frontend/src/app/pages/edit-auth/edit-auth.component.html index 330e604..65cca2f 100644 --- a/frontend/src/app/pages/edit-auth/edit-auth.component.html +++ b/frontend/src/app/pages/edit-auth/edit-auth.component.html @@ -118,6 +118,9 @@ + + + diff --git a/frontend/src/app/pages/edit-auth/edit-auth.component.ts b/frontend/src/app/pages/edit-auth/edit-auth.component.ts index 75b5c09..11cda5c 100644 --- a/frontend/src/app/pages/edit-auth/edit-auth.component.ts +++ b/frontend/src/app/pages/edit-auth/edit-auth.component.ts @@ -75,7 +75,7 @@ export class EditAuthComponent implements OnInit { this.typeFilter.reset(); } - private async updateSerial() { + public async updateSerial() { const soa = await this.domains.getSoa(this.domainId); if (soa !== false) { this.soaForm.controls['serial'].reset(soa.serial);