Added SOA editor for auth domains
This commit is contained in:
parent
1fa2cec0a6
commit
6342e48742
20
frontend/src/app/apitypes/Soa.apitype.ts
Normal file
20
frontend/src/app/apitypes/Soa.apitype.ts
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
export class SoaApitype {
|
||||||
|
|
||||||
|
public primary = '';
|
||||||
|
|
||||||
|
public email = '';
|
||||||
|
|
||||||
|
public refresh = 0;
|
||||||
|
|
||||||
|
public retry = 0;
|
||||||
|
|
||||||
|
public expire = 0;
|
||||||
|
|
||||||
|
public ttl = 0;
|
||||||
|
|
||||||
|
public serial = 0;
|
||||||
|
|
||||||
|
constructor(init: Object) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { SoaApitype } from './../apitypes/Soa.apitype';
|
||||||
import { SearchService, SearchServiceResult } from './../utils/search-service.interface';
|
import { SearchService, SearchServiceResult } from './../utils/search-service.interface';
|
||||||
import { DomainApitype } from './../apitypes/Domain.apitype';
|
import { DomainApitype } from './../apitypes/Domain.apitype';
|
||||||
import { ListApitype } from './../apitypes/List.apitype';
|
import { ListApitype } from './../apitypes/List.apitype';
|
||||||
|
@ -110,4 +111,13 @@ export class DomainsOperation implements SearchService {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async getSoa(domainId: number) {
|
||||||
|
try {
|
||||||
|
return new SoaApitype(await this.http.get(['/domains', domainId.toString(), 'soa']));
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,70 @@
|
||||||
<p>
|
<div class="row">
|
||||||
Zone type: {{ type }}
|
<div class="col-12">
|
||||||
</p>
|
<p class="font-weight-bold">Update SOA data for {{ domainName }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<form [formGroup]="soaForm" (submit)="onSubmit()">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12 col-md-4 col-lg-3">
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Primary</label>
|
||||||
|
<input type="text" class="form-control auto-invalid" formControlName="primary" />
|
||||||
|
<div class="invalid-feedback">
|
||||||
|
Primary can not be empty.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Email</label>
|
||||||
|
<input type="text" class="form-control auto-invalid" formControlName="email" />
|
||||||
|
<div class="invalid-feedback">
|
||||||
|
Must be a valid email address.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-12 col-md-3 col-lg-2 offset-lg-1">
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Refresh</label>
|
||||||
|
<input type="text" class="form-control auto-invalid" formControlName="refresh" />
|
||||||
|
<div class="invalid-feedback">
|
||||||
|
Refresh must be positive integer.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Retry</label>
|
||||||
|
<input type="text" class="form-control auto-invalid" formControlName="retry" />
|
||||||
|
<div class="invalid-feedback">
|
||||||
|
Retry must be positive integer.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-12 col-md-3 col-lg-2 offset-lg-1">
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Expire</label>
|
||||||
|
<input type="text" class="form-control auto-invalid" formControlName="expire" />
|
||||||
|
<div class="invalid-feedback">
|
||||||
|
Expire must be positive integer.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>TTL</label>
|
||||||
|
<input type="text" class="form-control auto-invalid" formControlName="ttl" />
|
||||||
|
<div class="invalid-feedback">
|
||||||
|
TTL must be positive integer.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-12 col-md-2 col-lg-2 offset-lg-1">
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Serial</label>
|
||||||
|
<input type="text" class="form-control auto-invalid" readonly formControlName="serial" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-12">
|
||||||
|
<button type="submit" class="btn btn-primary float-right float-md-left" [disabled]="!soaForm.valid || soaForm.pristine">Save</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
|
@ -1,4 +1,8 @@
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { DomainApitype } from './../../apitypes/Domain.apitype';
|
||||||
|
import { SoaApitype } from './../../apitypes/Soa.apitype';
|
||||||
|
import { DomainsOperation } from './../../operations/domains.operations';
|
||||||
|
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
|
||||||
|
import { ActivatedRoute, ParamMap } from '@angular/router';
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -7,13 +11,68 @@ import { Component, OnInit } from '@angular/core';
|
||||||
styleUrls: ['./edit-auth.component.scss']
|
styleUrls: ['./edit-auth.component.scss']
|
||||||
})
|
})
|
||||||
export class EditAuthComponent implements OnInit {
|
export class EditAuthComponent implements OnInit {
|
||||||
|
public soaForm: FormGroup;
|
||||||
|
|
||||||
public type: string;
|
public type = '';
|
||||||
|
|
||||||
constructor(private route: ActivatedRoute) { }
|
public domainName = '';
|
||||||
|
|
||||||
|
public domainId = 0;
|
||||||
|
|
||||||
|
constructor(private route: ActivatedRoute, private fb: FormBuilder, private domains: DomainsOperation) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
this.createForm();
|
||||||
|
|
||||||
this.route.data.subscribe((data) => this.type = data.type);
|
this.route.data.subscribe((data) => this.type = data.type);
|
||||||
|
|
||||||
|
this.route.paramMap.subscribe((params) => this.initControl(params));
|
||||||
|
}
|
||||||
|
|
||||||
|
private async initControl(params: ParamMap) {
|
||||||
|
this.domainId = +params.get('domainId');
|
||||||
|
|
||||||
|
this.domains.getSingle(this.domainId).then((domain: DomainApitype) => {
|
||||||
|
this.domainName = domain.name;
|
||||||
|
});
|
||||||
|
|
||||||
|
this.domains.getSoa(this.domainId).then((soa: SoaApitype) => {
|
||||||
|
this.soaForm.reset({
|
||||||
|
primary: soa.primary,
|
||||||
|
email: soa.email,
|
||||||
|
refresh: soa.refresh,
|
||||||
|
retry: soa.retry,
|
||||||
|
expire: soa.expire,
|
||||||
|
ttl: soa.ttl,
|
||||||
|
serial: soa.serial
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private async updateSerial() {
|
||||||
|
const soa = await this.domains.getSoa(this.domainId);
|
||||||
|
if (soa !== false) {
|
||||||
|
this.soaForm.controls['serial'].reset(soa.serial);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private createForm() {
|
||||||
|
this.soaForm = this.fb.group({
|
||||||
|
primary: ['', Validators.required],
|
||||||
|
email: ['', Validators.email],
|
||||||
|
refresh: ['', [Validators.required, Validators.pattern(/^[0-9]+$/)]],
|
||||||
|
retry: ['', [Validators.required, Validators.pattern(/^[0-9]+$/)]],
|
||||||
|
expire: ['', [Validators.required, Validators.pattern(/^[0-9]+$/)]],
|
||||||
|
ttl: ['', [Validators.required, Validators.pattern(/^[0-9]+$/)]],
|
||||||
|
serial: ['']
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public async onSubmit() {
|
||||||
|
const v = this.soaForm.value;
|
||||||
|
await this.domains.setSoa(this.domainId, v.primary, v.email, v.refresh, v.retry, v.expire, v.ttl);
|
||||||
|
this.soaForm.markAsPristine();
|
||||||
|
await this.updateSerial();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue