mirror of
https://github.com/itdoginfo/podkop.git
synced 2025-12-06 11:36:50 +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) {
|
||||
await triggerProxySelector(selector, tag);
|
||||
@@ -83,6 +83,18 @@ async function handleTestProxyLatency(tag: string) {
|
||||
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() {
|
||||
const sections = store.get().sections;
|
||||
console.log('render dashboard sections group');
|
||||
@@ -91,6 +103,8 @@ async function renderDashboardSections() {
|
||||
renderOutboundGroup({
|
||||
section,
|
||||
onTestLatency: (tag) => {
|
||||
replaceTestLatencyButtonsWithSkeleton();
|
||||
|
||||
if (section.withTagSelect) {
|
||||
return handleTestGroupLatency(tag);
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ export function renderOutboundGroup({
|
||||
},
|
||||
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(
|
||||
'div',
|
||||
|
||||
@@ -1164,7 +1164,7 @@ function renderOutboundGroup({
|
||||
},
|
||||
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(
|
||||
"div",
|
||||
@@ -1398,6 +1398,15 @@ async function handleTestProxyLatency(tag) {
|
||||
await triggerLatencyProxyTest(tag);
|
||||
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() {
|
||||
const sections = store.get().sections;
|
||||
console.log("render dashboard sections group");
|
||||
@@ -1406,6 +1415,7 @@ async function renderDashboardSections() {
|
||||
(section) => renderOutboundGroup({
|
||||
section,
|
||||
onTestLatency: (tag) => {
|
||||
replaceTestLatencyButtonsWithSkeleton();
|
||||
if (section.withTagSelect) {
|
||||
return handleTestGroupLatency(tag);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user