mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 10:21:52 +00:00
fix dns form
This commit is contained in:
@@ -63,7 +63,7 @@ import { Authority, AuthorityService } from './authority.service'
|
||||
iconStart="@tui.download"
|
||||
href="/static/local-root-ca.crt"
|
||||
>
|
||||
{{ 'Download your Root CA' | i18n }}
|
||||
{{ 'Download' | i18n }}
|
||||
</a>
|
||||
</tui-opt-group>
|
||||
}
|
||||
|
||||
@@ -115,29 +115,27 @@ export default class SystemDnsComponent {
|
||||
|
||||
private readonly dnsSpec = ISB.InputSpec.of({
|
||||
strategy: ISB.Value.union({
|
||||
name: 'DNS Servers',
|
||||
default: 'defaults',
|
||||
name: 'strategy',
|
||||
default: 'dhcp',
|
||||
variants: ISB.Variants.of({
|
||||
defaults: {
|
||||
name: 'Default',
|
||||
dhcp: {
|
||||
name: 'DHCP',
|
||||
spec: ISB.InputSpec.of({
|
||||
servers: ISB.Value.list(
|
||||
ISB.List.text(
|
||||
{
|
||||
name: 'Default DNS Servers',
|
||||
},
|
||||
{},
|
||||
),
|
||||
),
|
||||
servers: ISB.Value.dynamicText(() => ({
|
||||
name: 'DHCP Servers',
|
||||
default: null,
|
||||
required: true,
|
||||
disabled: 'Cannot edit DHCP servers',
|
||||
})),
|
||||
}),
|
||||
},
|
||||
custom: {
|
||||
name: 'Custom',
|
||||
static: {
|
||||
name: 'Static',
|
||||
spec: ISB.InputSpec.of({
|
||||
servers: ISB.Value.list(
|
||||
ISB.List.text(
|
||||
{
|
||||
name: 'DNS Servers',
|
||||
name: 'Static Servers',
|
||||
minLength: 1,
|
||||
maxLength: 3,
|
||||
},
|
||||
@@ -158,14 +156,24 @@ export default class SystemDnsComponent {
|
||||
switchMap(async ([pkgs, { gateways, dns }]) => {
|
||||
const spec = await configBuilderToSpec(this.dnsSpec)
|
||||
|
||||
const current = dns.staticServers
|
||||
? {
|
||||
selection: 'custom',
|
||||
value: dns.staticServers,
|
||||
}
|
||||
: { selection: 'defaults', value: dns.dhcpServers }
|
||||
const dhcpServers = { servers: dns.dhcpServers.join(', ') }
|
||||
const staticServers = { servers: dns.staticServers || [] }
|
||||
|
||||
const form = this.formService.createForm(spec, current)
|
||||
const current: (typeof this.dnsSpec._TYPE)['strategy'] =
|
||||
dns.staticServers
|
||||
? {
|
||||
selection: 'static',
|
||||
value: staticServers,
|
||||
other: {
|
||||
dhcp: dhcpServers,
|
||||
},
|
||||
}
|
||||
: {
|
||||
selection: 'dhcp',
|
||||
value: dhcpServers,
|
||||
}
|
||||
|
||||
const form = this.formService.createForm(spec, { strategy: current })
|
||||
|
||||
return {
|
||||
spec,
|
||||
@@ -190,8 +198,10 @@ export default class SystemDnsComponent {
|
||||
|
||||
try {
|
||||
await this.api.setDns({
|
||||
servers: value.strategy.value.servers,
|
||||
static: value.strategy.selection === 'custom',
|
||||
servers:
|
||||
value.strategy.selection === 'dhcp'
|
||||
? null
|
||||
: value.strategy.value.servers,
|
||||
})
|
||||
} catch (e: any) {
|
||||
this.errorService.handleError(e)
|
||||
|
||||
@@ -105,9 +105,8 @@ export namespace RR {
|
||||
export type DiskRepairRes = null
|
||||
|
||||
export type SetDnsReq = {
|
||||
servers: string[]
|
||||
static: boolean
|
||||
} // net.dns.set
|
||||
servers: string[] | null
|
||||
} // net.dns.set-static
|
||||
export type SetDnsRes = null
|
||||
|
||||
export type QueryDnsReq = {
|
||||
|
||||
@@ -269,7 +269,7 @@ export class LiveApiService extends ApiService {
|
||||
|
||||
async setDns(params: RR.SetDnsReq): Promise<RR.SetDnsRes> {
|
||||
return this.rpcRequest({
|
||||
method: 'net.dns.set',
|
||||
method: 'net.dns.set-static',
|
||||
params,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -465,11 +465,11 @@ export class MockApiService extends ApiService {
|
||||
async setDns(params: RR.SetDnsReq): Promise<RR.SetDnsRes> {
|
||||
await pauseFor(2000)
|
||||
|
||||
const patch: ReplaceOperation<RR.SetDnsReq>[] = [
|
||||
const patch: ReplaceOperation<T.DnsSettings['staticServers']>[] = [
|
||||
{
|
||||
op: PatchOp.REPLACE,
|
||||
path: '/serverInfo/network/dns',
|
||||
value: params,
|
||||
path: '/serverInfo/network/dns/staticServers',
|
||||
value: params.servers,
|
||||
},
|
||||
]
|
||||
this.mockRevision(patch)
|
||||
|
||||
Reference in New Issue
Block a user