mirror of
https://github.com/itdoginfo/podkop.git
synced 2026-01-27 04:40:37 +03:00
feat(dashboard): add selector support to dashboard
This commit is contained in:
@@ -86,6 +86,37 @@ export async function getDashboardSections(): Promise<IGetDashboardSectionsRespo
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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') {
|
if (section.proxy_config_type === 'urltest') {
|
||||||
const selector = proxies.find(
|
const selector = proxies.find(
|
||||||
(proxy) => proxy.code === `${section['.name']}-out`,
|
(proxy) => proxy.code === `${section['.name']}-out`,
|
||||||
|
|||||||
@@ -95,6 +95,12 @@ export namespace Podkop {
|
|||||||
urltest_proxy_links: string[];
|
urltest_proxy_links: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ConfigProxySelectorSection {
|
||||||
|
connection_type: 'proxy';
|
||||||
|
proxy_config_type: 'selector';
|
||||||
|
selector_proxy_links: string[];
|
||||||
|
}
|
||||||
|
|
||||||
export interface ConfigProxyUrlSection {
|
export interface ConfigProxyUrlSection {
|
||||||
connection_type: 'proxy';
|
connection_type: 'proxy';
|
||||||
proxy_config_type: 'url';
|
proxy_config_type: 'url';
|
||||||
@@ -118,6 +124,7 @@ export namespace Podkop {
|
|||||||
|
|
||||||
export type ConfigBaseSection =
|
export type ConfigBaseSection =
|
||||||
| ConfigProxyUrlTestSection
|
| ConfigProxyUrlTestSection
|
||||||
|
| ConfigProxySelectorSection
|
||||||
| ConfigProxyUrlSection
|
| ConfigProxyUrlSection
|
||||||
| ConfigProxyOutboundSection
|
| ConfigProxyOutboundSection
|
||||||
| ConfigVpnSection
|
| ConfigVpnSection
|
||||||
|
|||||||
@@ -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") {
|
if (section.proxy_config_type === "urltest") {
|
||||||
const selector = proxies.find(
|
const selector = proxies.find(
|
||||||
(proxy) => proxy.code === `${section[".name"]}-out`
|
(proxy) => proxy.code === `${section[".name"]}-out`
|
||||||
|
|||||||
Reference in New Issue
Block a user