mirror of
https://github.com/itdoginfo/podkop.git
synced 2026-01-27 04:40:37 +03:00
feat: add loaders to test latency buttons
This commit is contained in:
@@ -66,7 +66,7 @@ async function connectToClashSockets() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Renderer
|
// Handlers
|
||||||
|
|
||||||
async function handleChooseOutbound(selector: string, tag: string) {
|
async function handleChooseOutbound(selector: string, tag: string) {
|
||||||
await triggerProxySelector(selector, tag);
|
await triggerProxySelector(selector, tag);
|
||||||
@@ -83,6 +83,18 @@ async function handleTestProxyLatency(tag: string) {
|
|||||||
await fetchDashboardSections();
|
await fetchDashboardSections();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function replaceTestLatencyButtonsWithSkeleton () {
|
||||||
|
document.querySelectorAll('.dashboard-sections-grid-item-test-latency').forEach(el => {
|
||||||
|
const newDiv = document.createElement('div');
|
||||||
|
newDiv.className = 'skeleton';
|
||||||
|
newDiv.style.width = '99px';
|
||||||
|
newDiv.style.height = '28px';
|
||||||
|
el.replaceWith(newDiv);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Renderer
|
||||||
|
|
||||||
async function renderDashboardSections() {
|
async function renderDashboardSections() {
|
||||||
const sections = store.get().sections;
|
const sections = store.get().sections;
|
||||||
console.log('render dashboard sections group');
|
console.log('render dashboard sections group');
|
||||||
@@ -91,6 +103,8 @@ async function renderDashboardSections() {
|
|||||||
renderOutboundGroup({
|
renderOutboundGroup({
|
||||||
section,
|
section,
|
||||||
onTestLatency: (tag) => {
|
onTestLatency: (tag) => {
|
||||||
|
replaceTestLatencyButtonsWithSkeleton();
|
||||||
|
|
||||||
if (section.withTagSelect) {
|
if (section.withTagSelect) {
|
||||||
return handleTestGroupLatency(tag);
|
return handleTestGroupLatency(tag);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ export function renderOutboundGroup({
|
|||||||
},
|
},
|
||||||
section.displayName,
|
section.displayName,
|
||||||
),
|
),
|
||||||
E('button', { class: 'btn', click: () => testLatency() }, 'Test latency'),
|
E('button', { class: 'btn dashboard-sections-grid-item-test-latency', click: () => testLatency() }, 'Test latency'),
|
||||||
]),
|
]),
|
||||||
E(
|
E(
|
||||||
'div',
|
'div',
|
||||||
|
|||||||
@@ -1164,7 +1164,7 @@ function renderOutboundGroup({
|
|||||||
},
|
},
|
||||||
section.displayName
|
section.displayName
|
||||||
),
|
),
|
||||||
E("button", { class: "btn", click: () => testLatency() }, "Test latency")
|
E("button", { class: "btn dashboard-sections-grid-item-test-latency", click: () => testLatency() }, "Test latency")
|
||||||
]),
|
]),
|
||||||
E(
|
E(
|
||||||
"div",
|
"div",
|
||||||
@@ -1398,6 +1398,15 @@ async function handleTestProxyLatency(tag) {
|
|||||||
await triggerLatencyProxyTest(tag);
|
await triggerLatencyProxyTest(tag);
|
||||||
await fetchDashboardSections();
|
await fetchDashboardSections();
|
||||||
}
|
}
|
||||||
|
function replaceTestLatencyButtonsWithSkeleton() {
|
||||||
|
document.querySelectorAll(".dashboard-sections-grid-item-test-latency").forEach((el) => {
|
||||||
|
const newDiv = document.createElement("div");
|
||||||
|
newDiv.className = "skeleton";
|
||||||
|
newDiv.style.width = "99px";
|
||||||
|
newDiv.style.height = "28px";
|
||||||
|
el.replaceWith(newDiv);
|
||||||
|
});
|
||||||
|
}
|
||||||
async function renderDashboardSections() {
|
async function renderDashboardSections() {
|
||||||
const sections = store.get().sections;
|
const sections = store.get().sections;
|
||||||
console.log("render dashboard sections group");
|
console.log("render dashboard sections group");
|
||||||
@@ -1406,6 +1415,7 @@ async function renderDashboardSections() {
|
|||||||
(section) => renderOutboundGroup({
|
(section) => renderOutboundGroup({
|
||||||
section,
|
section,
|
||||||
onTestLatency: (tag) => {
|
onTestLatency: (tag) => {
|
||||||
|
replaceTestLatencyButtonsWithSkeleton();
|
||||||
if (section.withTagSelect) {
|
if (section.withTagSelect) {
|
||||||
return handleTestGroupLatency(tag);
|
return handleTestGroupLatency(tag);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user