mirror of
https://github.com/itdoginfo/podkop.git
synced 2025-12-06 11:36:50 +03:00
fix: adapt dashboard for new sections structure
This commit is contained in:
@@ -10,6 +10,7 @@ interface IGetDashboardSectionsResponse {
|
|||||||
|
|
||||||
export async function getDashboardSections(): Promise<IGetDashboardSectionsResponse> {
|
export async function getDashboardSections(): Promise<IGetDashboardSectionsResponse> {
|
||||||
const configSections = await getConfigSections();
|
const configSections = await getConfigSections();
|
||||||
|
console.log('configSections', configSections)
|
||||||
const clashProxies = await getClashProxies();
|
const clashProxies = await getClashProxies();
|
||||||
|
|
||||||
if (!clashProxies.success) {
|
if (!clashProxies.success) {
|
||||||
@@ -27,9 +28,9 @@ export async function getDashboardSections(): Promise<IGetDashboardSectionsRespo
|
|||||||
);
|
);
|
||||||
|
|
||||||
const data = configSections
|
const data = configSections
|
||||||
.filter((section) => section.mode !== 'block')
|
.filter((section) => section.connection_type !== 'block' && section[".type"] !== 'settings')
|
||||||
.map((section) => {
|
.map((section) => {
|
||||||
if (section.mode === 'proxy') {
|
if (section.connection_type === 'proxy') {
|
||||||
if (section.proxy_config_type === 'url') {
|
if (section.proxy_config_type === 'url') {
|
||||||
const outbound = proxies.find(
|
const outbound = proxies.find(
|
||||||
(proxy) => proxy.code === `${section['.name']}-out`,
|
(proxy) => proxy.code === `${section['.name']}-out`,
|
||||||
@@ -122,7 +123,7 @@ export async function getDashboardSections(): Promise<IGetDashboardSectionsRespo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (section.mode === 'vpn') {
|
if (section.connection_type === 'vpn') {
|
||||||
const outbound = proxies.find(
|
const outbound = proxies.find(
|
||||||
(proxy) => proxy.code === `${section['.name']}-out`,
|
(proxy) => proxy.code === `${section['.name']}-out`,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -16,30 +16,30 @@ export namespace Podkop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ConfigProxyUrlTestSection {
|
export interface ConfigProxyUrlTestSection {
|
||||||
mode: 'proxy';
|
connection_type: 'proxy';
|
||||||
proxy_config_type: 'urltest';
|
proxy_config_type: 'urltest';
|
||||||
urltest_proxy_links: string[];
|
urltest_proxy_links: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ConfigProxyUrlSection {
|
export interface ConfigProxyUrlSection {
|
||||||
mode: 'proxy';
|
connection_type: 'proxy';
|
||||||
proxy_config_type: 'url';
|
proxy_config_type: 'url';
|
||||||
proxy_string: string;
|
proxy_string: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ConfigProxyOutboundSection {
|
export interface ConfigProxyOutboundSection {
|
||||||
mode: 'proxy';
|
connection_type: 'proxy';
|
||||||
proxy_config_type: 'outbound';
|
proxy_config_type: 'outbound';
|
||||||
outbound_json: string;
|
outbound_json: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ConfigVpnSection {
|
export interface ConfigVpnSection {
|
||||||
mode: 'vpn';
|
connection_type: 'vpn';
|
||||||
interface: string;
|
interface: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ConfigBlockSection {
|
export interface ConfigBlockSection {
|
||||||
mode: 'block';
|
connection_type: 'block';
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ConfigBaseSection =
|
export type ConfigBaseSection =
|
||||||
@@ -51,6 +51,6 @@ export namespace Podkop {
|
|||||||
|
|
||||||
export type ConfigSection = ConfigBaseSection & {
|
export type ConfigSection = ConfigBaseSection & {
|
||||||
'.name': string;
|
'.name': string;
|
||||||
'.type': 'main' | 'extra';
|
'.type': 'settings' | 'section';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -943,6 +943,7 @@ async function getConfigSections() {
|
|||||||
// src/podkop/methods/getDashboardSections.ts
|
// src/podkop/methods/getDashboardSections.ts
|
||||||
async function getDashboardSections() {
|
async function getDashboardSections() {
|
||||||
const configSections = await getConfigSections();
|
const configSections = await getConfigSections();
|
||||||
|
console.log("configSections", configSections);
|
||||||
const clashProxies = await getClashProxies();
|
const clashProxies = await getClashProxies();
|
||||||
if (!clashProxies.success) {
|
if (!clashProxies.success) {
|
||||||
return {
|
return {
|
||||||
@@ -956,8 +957,8 @@ async function getDashboardSections() {
|
|||||||
value
|
value
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
const data = configSections.filter((section) => section.mode !== "block").map((section) => {
|
const data = configSections.filter((section) => section.connection_type !== "block" && section[".type"] !== "settings").map((section) => {
|
||||||
if (section.mode === "proxy") {
|
if (section.connection_type === "proxy") {
|
||||||
if (section.proxy_config_type === "url") {
|
if (section.proxy_config_type === "url") {
|
||||||
const outbound = proxies.find(
|
const outbound = proxies.find(
|
||||||
(proxy) => proxy.code === `${section[".name"]}-out`
|
(proxy) => proxy.code === `${section[".name"]}-out`
|
||||||
@@ -1032,7 +1033,7 @@ async function getDashboardSections() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (section.mode === "vpn") {
|
if (section.connection_type === "vpn") {
|
||||||
const outbound = proxies.find(
|
const outbound = proxies.find(
|
||||||
(proxy) => proxy.code === `${section[".name"]}-out`
|
(proxy) => proxy.code === `${section[".name"]}-out`
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user