diff --git a/fe-app-podkop/src/podkop/methods/custom/getDashboardSections.ts b/fe-app-podkop/src/podkop/methods/custom/getDashboardSections.ts index 709d6a1..6696d66 100644 --- a/fe-app-podkop/src/podkop/methods/custom/getDashboardSections.ts +++ b/fe-app-podkop/src/podkop/methods/custom/getDashboardSections.ts @@ -86,6 +86,37 @@ export async function getDashboardSections(): Promise proxy.code === `${section['.name']}-out`, + ); + + const links = section.selector_proxy_links ?? []; + + const outbounds = links + .map((link, index) => ({ + link, + outbound: proxies.find( + (item) => item.code === `${section['.name']}-${index + 1}-out`, + ), + })) + .map((item) => ({ + code: item?.outbound?.code || '', + displayName: + getProxyUrlName(item.link) || item?.outbound?.value?.name || '', + latency: item?.outbound?.value?.history?.[0]?.delay || 0, + type: item?.outbound?.value?.type || '', + selected: selector?.value?.now === item?.outbound?.code, + })); + + return { + withTagSelect: true, + code: selector?.code || section['.name'], + displayName: section['.name'], + outbounds, + }; + } + if (section.proxy_config_type === 'urltest') { const selector = proxies.find( (proxy) => proxy.code === `${section['.name']}-out`, diff --git a/fe-app-podkop/src/podkop/types.ts b/fe-app-podkop/src/podkop/types.ts index 0f4ed35..672ec0c 100644 --- a/fe-app-podkop/src/podkop/types.ts +++ b/fe-app-podkop/src/podkop/types.ts @@ -95,6 +95,12 @@ export namespace Podkop { urltest_proxy_links: string[]; } + export interface ConfigProxySelectorSection { + connection_type: 'proxy'; + proxy_config_type: 'selector'; + selector_proxy_links: string[]; + } + export interface ConfigProxyUrlSection { connection_type: 'proxy'; proxy_config_type: 'url'; @@ -118,6 +124,7 @@ export namespace Podkop { export type ConfigBaseSection = | ConfigProxyUrlTestSection + | ConfigProxySelectorSection | ConfigProxyUrlSection | ConfigProxyOutboundSection | ConfigVpnSection diff --git a/luci-app-podkop/htdocs/luci-static/resources/view/podkop/main.js b/luci-app-podkop/htdocs/luci-static/resources/view/podkop/main.js index f5204dc..6bf1dfd 100644 --- a/luci-app-podkop/htdocs/luci-static/resources/view/podkop/main.js +++ b/luci-app-podkop/htdocs/luci-static/resources/view/podkop/main.js @@ -757,6 +757,30 @@ async function getDashboardSections() { ] }; } + if (section.proxy_config_type === "selector") { + const selector = proxies.find( + (proxy) => proxy.code === `${section[".name"]}-out` + ); + const links = section.selector_proxy_links ?? []; + const outbounds = links.map((link, index) => ({ + link, + outbound: proxies.find( + (item) => item.code === `${section[".name"]}-${index + 1}-out` + ) + })).map((item) => ({ + code: item?.outbound?.code || "", + displayName: getProxyUrlName(item.link) || item?.outbound?.value?.name || "", + latency: item?.outbound?.value?.history?.[0]?.delay || 0, + type: item?.outbound?.value?.type || "", + selected: selector?.value?.now === item?.outbound?.code + })); + return { + withTagSelect: true, + code: selector?.code || section[".name"], + displayName: section[".name"], + outbounds + }; + } if (section.proxy_config_type === "urltest") { const selector = proxies.find( (proxy) => proxy.code === `${section[".name"]}-out`