|
1 | 1 | <script lang="ts"> |
2 | 2 | import type { GwNode } from "$lib/types/gwnode"; |
3 | 3 | import { proxies } from "$lib/stores/proxyStore"; |
4 | | - import { Edit, Trash2 } from 'lucide-svelte'; |
| 4 | + import Button from "../common/Button.svelte"; |
| 5 | + import { Edit, Trash2, ShipWheel } from "lucide-svelte"; |
5 | 6 |
|
6 | 7 | // Props for the component |
7 | 8 | export let gwnode: GwNode; |
|
16 | 17 |
|
17 | 18 | // Get proxy details if proxy_id exists |
18 | 19 | $: if (gwnode.proxy_id && $proxies) { |
19 | | - const selectedProxy = $proxies.find((p) => p.proxy.id === gwnode.proxy_id); |
| 20 | + const selectedProxy = $proxies.find( |
| 21 | + (p) => p.proxy.id === gwnode.proxy_id, |
| 22 | + ); |
20 | 23 | if (selectedProxy) { |
21 | 24 | proxyListen = selectedProxy.proxy.addr_listen || ""; |
22 | | - |
| 25 | +
|
23 | 26 | // If gwnode has a domain_id, find the matching domain |
24 | 27 | if (gwnode.domain_id && selectedProxy.domains) { |
25 | | - const domain = selectedProxy.domains.find(d => d.id === gwnode.domain_id); |
| 28 | + const domain = selectedProxy.domains.find( |
| 29 | + (d) => d.id === gwnode.domain_id, |
| 30 | + ); |
26 | 31 | if (domain) { |
27 | 32 | proxyTls = domain.tls || false; |
28 | 33 | proxyDomain = domain.sni || ""; |
|
34 | 39 | proxyTls = false; |
35 | 40 | proxyDomain = ""; |
36 | 41 | } |
37 | | - |
| 42 | +
|
38 | 43 | proxyTitle = selectedProxy.proxy.title || ""; |
39 | 44 | } |
40 | 45 | } |
41 | 46 | </script> |
42 | 47 |
|
43 | | -<a href={`/gwnode/${gwnode.id}`} class="block relative"> |
44 | | - <div |
45 | | - class="border border-gray-200 dark:border-gray-700 hover:bg-white/40 hover:dark:bg-gray-800/40 hover:border-gray-300 dark:hover:border-gray-600 duration-200 p-4 relative" |
46 | | - > |
47 | | - <!-- Action buttons (positioned absolute top right) --> |
48 | | - <div class="absolute top-5 right-2 flex space-x-2"> |
49 | | - <button |
50 | | - on:click|stopPropagation|preventDefault={() => onEdit(gwnode)} |
51 | | - class="p-1 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200" |
52 | | - aria-label="Edit" |
| 48 | +<div |
| 49 | + class="border border-gray-200 dark:border-gray-700 hover:bg-white/40 hover:dark:bg-gray-800/40 hover:border-gray-300 dark:hover:border-gray-600 duration-200 p-4 relative" |
| 50 | +> |
| 51 | + <!-- Action buttons (positioned absolute top right) --> |
| 52 | + <div class="absolute top-2 right-2 flex space-x-2"> |
| 53 | + <a |
| 54 | + href={`/gwnode/${gwnode.id}`} |
| 55 | + class="flex flex-row gap-1 items-center text-sm font-medium bg-blue-600 text-white hover:bg-blue-700 px-2" |
53 | 56 | > |
54 | | - <Edit size={16} /> |
55 | | - </button> |
56 | | - <button |
57 | | - on:click|stopPropagation|preventDefault={() => |
58 | | - onDelete(gwnode.id)} |
59 | | - class="p-1 text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300" |
60 | | - aria-label="Delete" |
61 | | - > |
62 | | - <Trash2 size={16} /> |
63 | | - </button> |
64 | | - </div> |
| 57 | + <ShipWheel size={16} class="mr-1" /> |
| 58 | + Route |
| 59 | + </a> |
| 60 | + <Button variant="secondary" size="sm" onClick={() => onEdit(gwnode)}> |
| 61 | + <Edit size={16} /> |
| 62 | + Modify |
| 63 | + </Button> |
| 64 | + <Button variant="danger" size="sm" onClick={() => onDelete(gwnode.id)}> |
| 65 | + <Trash2 size={16} /> |
| 66 | + Delete |
| 67 | + </Button> |
| 68 | + </div> |
65 | 69 |
|
66 | | - <!-- Title --> |
67 | | - <h3 |
68 | | - class="text-lg font-bold text-gray-900 dark:text-gray-100 mb-2 pr-16" |
69 | | - > |
70 | | - {gwnode.title} |
71 | | - </h3> |
| 70 | + <!-- Title --> |
| 71 | + <h3 |
| 72 | + class="text-lg font-bold text-gray-900 dark:text-gray-100 mb-2 pt-5 pr-16" |
| 73 | + > |
| 74 | + {gwnode.title} |
| 75 | + </h3> |
72 | 76 |
|
73 | | - <!-- Proxy information --> |
74 | | - <div class="mb-2"> |
75 | | - <h4 class="text-sm font-medium text-gray-700 dark:text-gray-300"> |
76 | | - Proxy Bind |
77 | | - </h4> |
78 | | - <table |
79 | | - class="w-full text-sm text-left text-gray-700 dark:text-gray-300 mt-1" |
80 | | - > |
81 | | - <tbody> |
| 77 | + <!-- Proxy information --> |
| 78 | + <div class="mb-2"> |
| 79 | + <h4 class="text-sm font-medium text-gray-700 dark:text-gray-300"> |
| 80 | + Proxy Bind |
| 81 | + </h4> |
| 82 | + <table |
| 83 | + class="w-full text-sm text-left text-gray-700 dark:text-gray-300 mt-1" |
| 84 | + > |
| 85 | + <tbody> |
| 86 | + <tr> |
| 87 | + <td class="py-1 pr-2 italic w-20">Name:</td> |
| 88 | + <td class="py-1">{proxyTitle || "Not specified"}</td> |
| 89 | + </tr> |
| 90 | + {#if proxyListen} |
82 | 91 | <tr> |
83 | | - <td class="py-1 pr-2 italic w-20">Name:</td> |
84 | | - <td class="py-1">{proxyTitle || "Not specified"}</td> |
| 92 | + <td class="py-1 pr-2 italic w-20">Listen:</td> |
| 93 | + <td |
| 94 | + class="py-1 font-mono text-xs text-gray-500 dark:text-gray-400" |
| 95 | + >{proxyListen}</td |
| 96 | + > |
85 | 97 | </tr> |
86 | | - {#if proxyListen} |
87 | | - <tr> |
88 | | - <td class="py-1 pr-2 italic w-20">Listen:</td> |
89 | | - <td |
90 | | - class="py-1 font-mono text-xs text-gray-500 dark:text-gray-400" |
91 | | - >{proxyListen}</td |
92 | | - > |
93 | | - </tr> |
94 | | - {:else} |
95 | | - <tr> |
96 | | - <td class="py-1 pr-2 italic w-20">Listen:</td> |
97 | | - <td |
98 | | - class="py-1 font-mono text-xs text-gray-500 dark:text-gray-400" |
99 | | - >Not specified</td |
100 | | - > |
101 | | - </tr> |
102 | | - {/if} |
103 | | - {#if proxyDomain} |
104 | | - <tr> |
105 | | - <td class="py-1 pr-2 italic w-20">Domain:</td> |
106 | | - <td |
107 | | - class="py-1 font-mono text-xs text-gray-500 dark:text-gray-400" |
108 | | - >{proxyDomain}</td |
109 | | - > |
110 | | - </tr> |
111 | | - {:else} |
112 | | - <tr> |
113 | | - <td class="py-1 pr-2 italic w-20">Domain:</td> |
114 | | - <td |
115 | | - class="py-1 font-mono text-xs text-gray-500 dark:text-gray-400" |
116 | | - >-</td |
117 | | - > |
118 | | - </tr> |
119 | | - {/if} |
120 | | - {#if proxyTls} |
121 | | - <tr> |
122 | | - <td class="py-1 pr-2 italic w-20">Security:</td |
123 | | - > |
124 | | - <td |
125 | | - class="py-1 text-xs text-green-600 dark:text-green-400" |
126 | | - >TLS Enabled</td |
127 | | - > |
128 | | - </tr> |
129 | | - {:else} |
130 | | - <tr> |
131 | | - <td class="py-1 pr-2 italic w-20">Security:</td |
132 | | - > |
133 | | - <td |
134 | | - class="py-1 text-xs text-red-600 dark:text-red-400" |
135 | | - >Disabled</td |
136 | | - > |
137 | | - </tr> |
138 | | - {/if} |
139 | | - </tbody> |
140 | | - </table> |
141 | | - </div> |
142 | | - <hr class="my-2 border-gray-300 dark:border-gray-600" /> |
143 | | - <!-- Target --> |
144 | | - <div class="mt-2"> |
145 | | - <h4 class="text-sm font-medium text-gray-700 dark:text-gray-300"> |
146 | | - Proxy Target |
147 | | - </h4> |
148 | | - <table |
149 | | - class="w-full text-sm text-left text-gray-700 dark:text-gray-300 mt-1" |
150 | | - > |
151 | | - <tbody> |
| 98 | + {:else} |
152 | 99 | <tr> |
153 | | - <td class="py-1 pr-2 italic w-20">Address:</td> |
154 | | - <td class="py-1"> |
155 | | - <span |
156 | | - class="font-mono bg-gray-100 dark:bg-gray-800 px-2 py-1 rounded" |
157 | | - >{gwnode.alt_target}</span |
158 | | - > |
159 | | - </td> |
| 100 | + <td class="py-1 pr-2 italic w-20">Listen:</td> |
| 101 | + <td |
| 102 | + class="py-1 font-mono text-xs text-gray-500 dark:text-gray-400" |
| 103 | + >Not specified</td |
| 104 | + > |
160 | 105 | </tr> |
161 | | - </tbody> |
162 | | - </table> |
163 | | - </div> |
| 106 | + {/if} |
| 107 | + {#if proxyDomain} |
| 108 | + <tr> |
| 109 | + <td class="py-1 pr-2 italic w-20">Domain:</td> |
| 110 | + <td |
| 111 | + class="py-1 font-mono text-xs text-gray-500 dark:text-gray-400" |
| 112 | + >{proxyDomain}</td |
| 113 | + > |
| 114 | + </tr> |
| 115 | + {:else} |
| 116 | + <tr> |
| 117 | + <td class="py-1 pr-2 italic w-20">Domain:</td> |
| 118 | + <td |
| 119 | + class="py-1 font-mono text-xs text-gray-500 dark:text-gray-400" |
| 120 | + >-</td |
| 121 | + > |
| 122 | + </tr> |
| 123 | + {/if} |
| 124 | + {#if proxyTls} |
| 125 | + <tr> |
| 126 | + <td class="py-1 pr-2 italic w-20">Security:</td> |
| 127 | + <td |
| 128 | + class="py-1 text-xs text-green-600 dark:text-green-400" |
| 129 | + >TLS Enabled</td |
| 130 | + > |
| 131 | + </tr> |
| 132 | + {:else} |
| 133 | + <tr> |
| 134 | + <td class="py-1 pr-2 italic w-20">Security:</td> |
| 135 | + <td class="py-1 text-xs text-red-600 dark:text-red-400" |
| 136 | + >Disabled</td |
| 137 | + > |
| 138 | + </tr> |
| 139 | + {/if} |
| 140 | + </tbody> |
| 141 | + </table> |
| 142 | + </div> |
| 143 | + <hr class="my-2 border-gray-300 dark:border-gray-600" /> |
| 144 | + <!-- Target --> |
| 145 | + <div class="mt-2"> |
| 146 | + <h4 class="text-sm font-medium text-gray-700 dark:text-gray-300"> |
| 147 | + Proxy Target |
| 148 | + </h4> |
| 149 | + <table |
| 150 | + class="w-full text-sm text-left text-gray-700 dark:text-gray-300 mt-1" |
| 151 | + > |
| 152 | + <tbody> |
| 153 | + <tr> |
| 154 | + <td class="py-1 pr-2 italic w-20">Address:</td> |
| 155 | + <td class="py-1"> |
| 156 | + <span |
| 157 | + class="font-mono bg-gray-100 dark:bg-gray-800 px-2 py-1 rounded" |
| 158 | + >{gwnode.alt_target}</span |
| 159 | + > |
| 160 | + </td> |
| 161 | + </tr> |
| 162 | + </tbody> |
| 163 | + </table> |
164 | 164 | </div> |
165 | | -</a> |
| 165 | +</div> |
0 commit comments