mirror of
https://github.com/MizuchiLabs/mantrae.git
synced 2025-12-16 20:05:17 -06:00
fix dns provider display
This commit is contained in:
@@ -68,8 +68,16 @@ func (s *HTTPRouterOps) Get(
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dnsProvider, err := s.app.Conn.GetQuery().GetDnsProvidersByHttpRouter(ctx, result.ID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
router := result.ToProto()
|
||||
for _, p := range dnsProvider {
|
||||
router.DnsProviders = append(router.DnsProviders, p.ToProto())
|
||||
}
|
||||
return &mantraev1.GetRouterResponse{
|
||||
Router: result.ToProto(),
|
||||
Router: router,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -261,7 +269,15 @@ func (s *HTTPRouterOps) List(
|
||||
|
||||
routers := make([]*mantraev1.Router, 0, len(result))
|
||||
for _, r := range result {
|
||||
routers = append(routers, r.ToProto())
|
||||
dnsProvider, err := s.app.Conn.GetQuery().GetDnsProvidersByHttpRouter(ctx, r.ID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
router := r.ToProto()
|
||||
for _, p := range dnsProvider {
|
||||
router.DnsProviders = append(router.DnsProviders, p.ToProto())
|
||||
}
|
||||
routers = append(routers, router)
|
||||
}
|
||||
return &mantraev1.ListRoutersResponse{
|
||||
Routers: routers,
|
||||
@@ -279,6 +295,14 @@ func (s *TCPRouterOps) Get(
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dnsProvider, err := s.app.Conn.GetQuery().GetDnsProvidersByHttpRouter(ctx, result.ID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
router := result.ToProto()
|
||||
for _, p := range dnsProvider {
|
||||
router.DnsProviders = append(router.DnsProviders, p.ToProto())
|
||||
}
|
||||
return &mantraev1.GetRouterResponse{
|
||||
Router: result.ToProto(),
|
||||
}, nil
|
||||
@@ -451,7 +475,15 @@ func (s *TCPRouterOps) List(
|
||||
|
||||
routers := make([]*mantraev1.Router, 0, len(result))
|
||||
for _, r := range result {
|
||||
routers = append(routers, r.ToProto())
|
||||
dnsProvider, err := s.app.Conn.GetQuery().GetDnsProvidersByTcpRouter(ctx, r.ID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
router := r.ToProto()
|
||||
for _, p := range dnsProvider {
|
||||
router.DnsProviders = append(router.DnsProviders, p.ToProto())
|
||||
}
|
||||
routers = append(routers, router)
|
||||
}
|
||||
return &mantraev1.ListRoutersResponse{
|
||||
Routers: routers,
|
||||
|
||||
@@ -1,24 +1,25 @@
|
||||
<script lang="ts">
|
||||
import * as Select from '$lib/components/ui/select/index.js';
|
||||
import * as Alert from '$lib/components/ui/alert/index.js';
|
||||
import RuleEditor from '../utils/ruleEditor.svelte';
|
||||
import { Badge } from '$lib/components/ui/badge/index.js';
|
||||
import { Button } from '$lib/components/ui/button/index.js';
|
||||
import { Input } from '$lib/components/ui/input/index.js';
|
||||
import { Label } from '$lib/components/ui/label/index.js';
|
||||
import * as Select from '$lib/components/ui/select/index.js';
|
||||
import { ProtocolType } from '$lib/gen/mantrae/v1/protocol_pb';
|
||||
import { type Router } from '$lib/gen/mantrae/v1/router_pb';
|
||||
import type { Router as HTTPRouter, RouterTLSConfig } from '$lib/gen/zen/traefik-schemas';
|
||||
import { CircleAlert, ExternalLink, Plus, Star } from '@lucide/svelte';
|
||||
import { unmarshalConfig, marshalConfig } from '$lib/types';
|
||||
import { formatArrayDisplay } from '$lib/utils';
|
||||
import { onMount } from 'svelte';
|
||||
import { ProtocolType } from '$lib/gen/mantrae/v1/protocol_pb';
|
||||
import { entryPoints, middlewares, routers } from '$lib/stores/realtime';
|
||||
import { marshalConfig, unmarshalConfig } from '$lib/types';
|
||||
import { formatArrayDisplay } from '$lib/utils';
|
||||
import { CircleAlert, ExternalLink, Plus, Star } from '@lucide/svelte';
|
||||
import { onMount } from 'svelte';
|
||||
import { SvelteSet } from 'svelte/reactivity';
|
||||
import RuleEditor from '../utils/ruleEditor.svelte';
|
||||
|
||||
let { router = $bindable() }: { router: Router } = $props();
|
||||
|
||||
let certResolvers: string[] = $state([]);
|
||||
let config = $state<HTTPRouter>(unmarshalConfig(router.config) as HTTPRouter);
|
||||
let certResolvers = new SvelteSet();
|
||||
|
||||
$effect(() => {
|
||||
if (config) router.config = marshalConfig(config);
|
||||
@@ -28,7 +29,7 @@
|
||||
$routers.forEach((r) => {
|
||||
if (r.type === router.type) {
|
||||
let tmp = unmarshalConfig(r.config) as HTTPRouter;
|
||||
if (tmp?.tls?.certResolver) certResolvers.push(tmp.tls?.certResolver);
|
||||
if (tmp?.tls?.certResolver) certResolvers.add(tmp.tls?.certResolver);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -152,7 +153,7 @@
|
||||
<Badge
|
||||
onclick={() => {
|
||||
if (!config.tls) config.tls = {} as RouterTLSConfig;
|
||||
config.tls.certResolver = resolver;
|
||||
if (resolver) config.tls.certResolver = resolver.toString();
|
||||
}}
|
||||
class="mt-1 cursor-pointer"
|
||||
>
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
<script lang="ts">
|
||||
import * as Select from '$lib/components/ui/select/index.js';
|
||||
import RuleEditor from '../utils/ruleEditor.svelte';
|
||||
import { Badge } from '$lib/components/ui/badge/index.js';
|
||||
import { Input } from '$lib/components/ui/input/index.js';
|
||||
import { Label } from '$lib/components/ui/label/index.js';
|
||||
import * as Select from '$lib/components/ui/select/index.js';
|
||||
import { ProtocolType } from '$lib/gen/mantrae/v1/protocol_pb';
|
||||
import { type Router } from '$lib/gen/mantrae/v1/router_pb';
|
||||
import type { RouterTCPTLSConfig, TCPRouter } from '$lib/gen/zen/traefik-schemas';
|
||||
import { Star } from '@lucide/svelte';
|
||||
import { unmarshalConfig, marshalConfig } from '$lib/types';
|
||||
import { onMount } from 'svelte';
|
||||
import { ProtocolType } from '$lib/gen/mantrae/v1/protocol_pb';
|
||||
import { entryPoints, middlewares, routers } from '$lib/stores/realtime';
|
||||
import { marshalConfig, unmarshalConfig } from '$lib/types';
|
||||
import { Star } from '@lucide/svelte';
|
||||
import { onMount } from 'svelte';
|
||||
import { SvelteSet } from 'svelte/reactivity';
|
||||
import RuleEditor from '../utils/ruleEditor.svelte';
|
||||
|
||||
let { router = $bindable() }: { router: Router } = $props();
|
||||
|
||||
let config = $state(unmarshalConfig(router.config) as TCPRouter);
|
||||
let certResolvers: string[] = $state([]);
|
||||
let certResolvers = new SvelteSet();
|
||||
|
||||
$effect(() => {
|
||||
if (config) router.config = marshalConfig(config);
|
||||
@@ -25,7 +26,7 @@
|
||||
$routers.forEach((r) => {
|
||||
if (r.type === router.type) {
|
||||
let tmp = unmarshalConfig(r.config) as TCPRouter;
|
||||
if (tmp?.tls?.certResolver) certResolvers.push(tmp.tls?.certResolver);
|
||||
if (tmp?.tls?.certResolver) certResolvers.add(tmp.tls?.certResolver);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -105,7 +106,7 @@
|
||||
<Badge
|
||||
onclick={() => {
|
||||
if (!config.tls) config.tls = {} as RouterTCPTLSConfig;
|
||||
config.tls.certResolver = resolver;
|
||||
if (resolver) config.tls.certResolver = resolver.toString();
|
||||
}}
|
||||
class="mt-1 cursor-pointer"
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user