loading state rewrite
This commit is contained in:
parent
16bb81bd2f
commit
751aab6ffa
1 changed files with 105 additions and 60 deletions
|
|
@ -85,7 +85,7 @@ PlasmoidItem {
|
|||
ListModel { id: ownedlocalipsModel }
|
||||
|
||||
// buttons blocker (antispam)
|
||||
property int isLoadingItems: 0
|
||||
property int isLoadingItems: 0 // крч на деле говно ебаное я ебал фиксить
|
||||
property bool isLoading: false // колясочные технологии, по итогу юзается токо isLoadingItems
|
||||
property bool isBlocked: false
|
||||
property bool shareBlocked: false
|
||||
|
|
@ -97,6 +97,12 @@ PlasmoidItem {
|
|||
property bool firewallBlocked: false
|
||||
property bool timeouted: false
|
||||
|
||||
property int generalLoading: (routesLoading || profileLoading || statsLoading || firewallLoading)
|
||||
property bool routesLoading: false
|
||||
property bool profileLoading: false
|
||||
property bool statsLoading: false
|
||||
property bool firewallLoading: false
|
||||
|
||||
onIsLoadingItemsChanged: {
|
||||
if (isLoadingItems > 0) {
|
||||
isLoading = true
|
||||
|
|
@ -145,7 +151,8 @@ PlasmoidItem {
|
|||
firewallBlocked = true
|
||||
Plasmoid.configuration.OnErrorRefresh ? (
|
||||
meowRelayWatchdog.start(),
|
||||
isLoadingItems += Plasmoid.configuration.BIrefresh,
|
||||
//isLoadingItems += Plasmoid.configuration.BIrefresh,
|
||||
(Plasmoid.configuration.BIrefresh ? (routesLoading = true, profileLoading = true, statsLoading = true, firewallLoading = true) : null),
|
||||
//isBlocked = true,
|
||||
superWorker.sendMessage({ "action": "fetch_routes" }),
|
||||
superWorker.sendMessage({ "action": "fetch_profile" }),
|
||||
|
|
@ -167,7 +174,7 @@ PlasmoidItem {
|
|||
refreshBlocked = false
|
||||
Plasmoid.configuration.OnErrorRefresh ? (
|
||||
meowRelayWatchdogRoutes.start(),
|
||||
isLoadingItems += Plasmoid.configuration.BIrefresh,
|
||||
//isLoadingItems += Plasmoid.configuration.BIrefresh,
|
||||
//isBlocked = true,
|
||||
superWorker.sendMessage({ "action": "fetch_routes" }),
|
||||
fetchRoutesTimer.restart()
|
||||
|
|
@ -184,7 +191,7 @@ PlasmoidItem {
|
|||
refreshBlocked = false
|
||||
Plasmoid.configuration.OnErrorRefresh ? (
|
||||
meowRelayWatchdogProfile.start(),
|
||||
isLoadingItems += Plasmoid.configuration.BIrefresh,
|
||||
//isLoadingItems += Plasmoid.configuration.BIrefresh,
|
||||
//isBlocked = true,
|
||||
superWorker.sendMessage({ "action": "fetch_profile" }),
|
||||
fetchProfileTimer.restart()
|
||||
|
|
@ -201,13 +208,27 @@ PlasmoidItem {
|
|||
refreshBlocked = false
|
||||
Plasmoid.configuration.OnErrorRefresh ? (
|
||||
meowRelayWatchdogStats.start(),
|
||||
isLoadingItems += Plasmoid.configuration.BIrefresh,
|
||||
//isLoadingItems += Plasmoid.configuration.BIrefresh,
|
||||
//isBlocked = true,
|
||||
superWorker.sendMessage({ "action": "fetch_stats" }),
|
||||
fetchStatsTimer.restart()
|
||||
) : null
|
||||
}
|
||||
}
|
||||
Timer {
|
||||
id: meowRelayWatchdogProfileAction
|
||||
interval: 10000
|
||||
repeat: false
|
||||
onTriggered: {
|
||||
console.error("MeowRelay unreachable!") //ваша няшка умерла
|
||||
timeouted = true
|
||||
refreshBlocked = false
|
||||
Plasmoid.configuration.OnErrorRefresh ? (
|
||||
meowRelayWatchdogProfileAction.start(),
|
||||
superWorker.sendMessage({ "action": "fetch_profile" })
|
||||
) : null
|
||||
}
|
||||
}
|
||||
Timer {
|
||||
id: meowRelayPing
|
||||
interval: Plasmoid.configuration.AutoPingInt * 1000
|
||||
|
|
@ -231,9 +252,10 @@ PlasmoidItem {
|
|||
for (let i = 0; i < data.length; i++) {
|
||||
routeModel.append(data[i]);
|
||||
};
|
||||
if (Plasmoid.configuration.BIrefresh || Plasmoid.configuration.BIautoupdate) {
|
||||
isLoadingItems -= 1
|
||||
};
|
||||
// if (Plasmoid.configuration.BIrefresh || Plasmoid.configuration.BIautoupdate) {
|
||||
// isLoadingItems -= 1
|
||||
// };
|
||||
routesLoading = false;
|
||||
meowRelayWatchdogRoutes.stop();
|
||||
refreshBlocked = false;
|
||||
timeouted = false;
|
||||
|
|
@ -258,9 +280,10 @@ PlasmoidItem {
|
|||
for (let i = 0; i < serverArray.length; i++) {
|
||||
statsModel.append(serverArray[i]);
|
||||
};
|
||||
if (Plasmoid.configuration.BIrefresh || Plasmoid.configuration.BIautoupdate) {
|
||||
isLoadingItems -= 1
|
||||
};
|
||||
// if (Plasmoid.configuration.BIrefresh || Plasmoid.configuration.BIautoupdate) {
|
||||
// isLoadingItems -= 1
|
||||
// };
|
||||
statsLoading = false;
|
||||
meowRelayWatchdogStats.stop();
|
||||
refreshBlocked = false;
|
||||
timeouted = false;
|
||||
|
|
@ -289,11 +312,13 @@ PlasmoidItem {
|
|||
tabs.setProperty(2, "visible", firewallEnabled)
|
||||
}
|
||||
}
|
||||
if (Plasmoid.configuration.BIrefresh || Plasmoid.configuration.BIautoupdate) {
|
||||
isLoadingItems -= 1
|
||||
}
|
||||
// if (Plasmoid.configuration.BIrefresh || Plasmoid.configuration.BIautoupdate) {
|
||||
// isLoadingItems -= 1
|
||||
// }
|
||||
profileLoading = false;
|
||||
meowRelayWatchdog.stop();
|
||||
meowRelayWatchdogProfile.stop();
|
||||
meowRelayWatchdogProfileAction.stop();
|
||||
timeouted = false;
|
||||
isBlocked = false;
|
||||
refreshBlocked = false;
|
||||
|
|
@ -330,22 +355,24 @@ PlasmoidItem {
|
|||
});
|
||||
}
|
||||
firewallBlocked = false;
|
||||
if (Plasmoid.configuration.BIpostfirewall) {
|
||||
isLoadingItems -= 1
|
||||
};
|
||||
// if (Plasmoid.configuration.BIpostfirewall) {
|
||||
// isLoadingItems -= 1
|
||||
// };
|
||||
firewallLoading = false;
|
||||
},
|
||||
"post_country": ({ status }) => {
|
||||
if (status === 200) {
|
||||
superWorker.sendMessage({ "action": "fetch_profile" })
|
||||
routesLoading = false
|
||||
//done
|
||||
}
|
||||
else {
|
||||
superWorker.sendMessage({ "actions": "fetch_routes" })
|
||||
//error
|
||||
};
|
||||
if (Plasmoid.configuration.BIpostcountry) {
|
||||
isLoadingItems -= 1
|
||||
}
|
||||
// if (Plasmoid.configuration.BIpostcountry) {
|
||||
// isLoadingItems -= 1
|
||||
// }
|
||||
},
|
||||
"post_share": ({ status }) => {
|
||||
if (status === 200) {
|
||||
|
|
@ -353,13 +380,13 @@ PlasmoidItem {
|
|||
//done
|
||||
}
|
||||
else {
|
||||
superWorker.sendMessage({ "action": "fetch_profile" })
|
||||
superWorker.sendMessage({ "action": "fetch_profile" }) // кофе
|
||||
// share = !share
|
||||
//error
|
||||
};
|
||||
if (Plasmoid.configuration.BIpostshare) {
|
||||
isLoadingItems -= 1
|
||||
}
|
||||
// if (Plasmoid.configuration.BIpostshare) {
|
||||
// isLoadingItems -= 1
|
||||
// }
|
||||
shareBlocked = false;
|
||||
},
|
||||
"post_ebalka": ({ status, ip }) => {
|
||||
|
|
@ -371,12 +398,12 @@ PlasmoidItem {
|
|||
superWorker.sendMessage({ "action": "fetch_profile" }) // кофе
|
||||
//error
|
||||
};
|
||||
if (Plasmoid.configuration.BIpostebalka) {
|
||||
isLoadingItems -= 1
|
||||
}
|
||||
if (Plasmoid.configuration.BIdevicesupdate) {
|
||||
isLoadingItems -= 1
|
||||
}
|
||||
// if (Plasmoid.configuration.BIpostebalka) {
|
||||
// isLoadingItems -= 1
|
||||
// }
|
||||
// if (Plasmoid.configuration.BIdevicesupdate) {
|
||||
// isLoadingItems -= 1
|
||||
// }
|
||||
ebalkaBlocked = false;
|
||||
devicesBlocked = false;
|
||||
},
|
||||
|
|
@ -388,36 +415,36 @@ PlasmoidItem {
|
|||
else {
|
||||
//error
|
||||
};
|
||||
if (Plasmoid.configuration.BIdevicesupdate) {
|
||||
isLoadingItems -= 1
|
||||
}
|
||||
// if (Plasmoid.configuration.BIdevicesupdate) {
|
||||
// isLoadingItems -= 1
|
||||
// }
|
||||
devicesBlocked = false;
|
||||
},
|
||||
"post_feature": ({ status }) => {
|
||||
superWorker.sendMessage({ "action": "fetch_profile" });
|
||||
if (Plasmoid.configuration.BIfeaturesupdate) {
|
||||
isLoadingItems -= 1
|
||||
}
|
||||
// if (Plasmoid.configuration.BIfeaturesupdate) {
|
||||
// isLoadingItems -= 1
|
||||
// }
|
||||
featuresBlocked = false;
|
||||
},
|
||||
"post_idconnect": ({ status }) => {
|
||||
superWorker.sendMessage({ "action": "fetch_profile" });
|
||||
superWorker.sendMessage({ "action": "fetch_routes" });
|
||||
if (Plasmoid.configuration.BIpostcountry) {
|
||||
isLoadingItems -= 1
|
||||
}
|
||||
// if (Plasmoid.configuration.BIpostcountry) {
|
||||
// isLoadingItems -= 1
|
||||
// }
|
||||
},
|
||||
"post_ruleadd": ({ status }) => {
|
||||
superWorker.sendMessage({ "action": "fetch_firewall" });
|
||||
if (Plasmoid.configuration.BIpostfirewall) {
|
||||
isLoadingItems -= 1
|
||||
}
|
||||
// if (Plasmoid.configuration.BIpostfirewall) {
|
||||
// isLoadingItems -= 1
|
||||
// }
|
||||
},
|
||||
"post_ruledrop": ({ status }) => {
|
||||
superWorker.sendMessage({ "action": "fetch_firewall" });
|
||||
if (Plasmoid.configuration.BIpostfirewall) {
|
||||
isLoadingItems -= 1
|
||||
}
|
||||
// if (Plasmoid.configuration.BIpostfirewall) {
|
||||
// isLoadingItems -= 1
|
||||
// }
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -430,7 +457,8 @@ PlasmoidItem {
|
|||
|
||||
// init fetch
|
||||
Component.onCompleted: {
|
||||
isLoadingItems += Plasmoid.configuration.BIinit
|
||||
//isLoadingItems += Plasmoid.configuration.BIinit
|
||||
Plasmoid.configuration.BIinit ? (routesLoading = true, profileLoading = true, statsLoading = true, firewallLoading = true) : null
|
||||
isBlocked = true
|
||||
meowRelayWatchdog.start()
|
||||
superWorker.sendMessage({ "action": "fetch_routes" })
|
||||
|
|
@ -452,7 +480,8 @@ PlasmoidItem {
|
|||
triggeredOnStart: false
|
||||
onTriggered: {
|
||||
//refreshBlocked = true
|
||||
isLoadingItems += Plasmoid.configuration.BIautoupdate
|
||||
//isLoadingItems += Plasmoid.configuration.BIautoupdate
|
||||
Plasmoid.configuration.BIautoupdate ? (routesLoading = true) : null
|
||||
meowRelayWatchdogRoutes.start()
|
||||
superWorker.sendMessage({ "action": "fetch_routes" })
|
||||
}
|
||||
|
|
@ -465,7 +494,8 @@ PlasmoidItem {
|
|||
triggeredOnStart: false
|
||||
onTriggered: {
|
||||
//refreshBlocked = true
|
||||
isLoadingItems += Plasmoid.configuration.BIautoupdate
|
||||
//isLoadingItems += Plasmoid.configuration.BIautoupdate
|
||||
Plasmoid.configuration.BIautoupdate ? (statsLoading = true) : null
|
||||
meowRelayWatchdogStats.start()
|
||||
superWorker.sendMessage({ "action": "fetch_stats" })
|
||||
}
|
||||
|
|
@ -478,7 +508,8 @@ PlasmoidItem {
|
|||
triggeredOnStart: false
|
||||
onTriggered: {
|
||||
//refreshBlocked = true
|
||||
isLoadingItems += Plasmoid.configuration.BIautoupdate
|
||||
//isLoadingItems += Plasmoid.configuration.BIautoupdate
|
||||
Plasmoid.configuration.BIautoupdate ? (profileLoading = true) : null
|
||||
meowRelayWatchdogProfile.start()
|
||||
superWorker.sendMessage({ "action": "fetch_profile" })
|
||||
}
|
||||
|
|
@ -610,7 +641,8 @@ PlasmoidItem {
|
|||
icon.name: "view-refresh"
|
||||
enabled: !(isBlocked)
|
||||
onClicked: {
|
||||
isLoadingItems += Plasmoid.configuration.BIpostfirewall
|
||||
//isLoadingItems += Plasmoid.configuration.BIpostfirewall
|
||||
Plasmoid.configuration.BIpostfirewall ? (firewallLoading = true) : null
|
||||
firewallBlocked = true
|
||||
superWorker.sendMessage({ "action": "fetch_firewall" })
|
||||
}
|
||||
|
|
@ -619,7 +651,8 @@ PlasmoidItem {
|
|||
text: "Add"
|
||||
enabled: !(isBlocked || firewallBlocked)
|
||||
onClicked: {
|
||||
isLoadingItems += Plasmoid.configuration.BIpostfirewall
|
||||
//isLoadingItems += Plasmoid.configuration.BIpostfirewall
|
||||
Plasmoid.configuration.BIpostfirewall ? (firewallLoading = true) : null
|
||||
firewallBlocked = true
|
||||
superWorker.sendMessage({ "action": "post_ruleadd", "dst": firewallLocalIp.currentValue, "ext": firewallIp.currentValue, "local_port": firewallLocalPortSpinner.value, "port": firewallPortSpinner.value, "proto": firewallProto.currentValue })
|
||||
}
|
||||
|
|
@ -765,8 +798,12 @@ PlasmoidItem {
|
|||
icon.name: "view-refresh"
|
||||
onClicked: {
|
||||
meowRelayWatchdog.running ? meowRelayWatchdog.stop() : null
|
||||
meowRelayWatchdogRoutes.running ? meowRelayWatchdogRoutes.stop() : null
|
||||
meowRelayWatchdogProfile.running ? meowRelayWatchdogProfile.stop() : null
|
||||
meowRelayWatchdogStats.running ? meowRelayWatchdogStats.stop() : null
|
||||
meowRelayWatchdog.start()
|
||||
isLoadingItems += Plasmoid.configuration.BIrefresh
|
||||
//isLoadingItems = (0 + (Plasmoid.configuration.BIrefresh * 4))
|
||||
Plasmoid.configuration.BIrefresh ? (routesLoading = true, profileLoading = true, statsLoading = true, firewallLoading = true) : null
|
||||
isBlocked = true
|
||||
superWorker.sendMessage({ "action": "fetch_routes" })
|
||||
superWorker.sendMessage({ "action": "fetch_profile" })
|
||||
|
|
@ -780,7 +817,7 @@ PlasmoidItem {
|
|||
Layout.fillWidth: false
|
||||
}
|
||||
PlasmaComponents.BusyIndicator {
|
||||
running: isLoadingItems //isLoading
|
||||
running: generalLoading //isLoading
|
||||
implicitWidth: 28
|
||||
implicitHeight: 28
|
||||
}
|
||||
|
|
@ -806,7 +843,8 @@ PlasmoidItem {
|
|||
checked: share
|
||||
enabled: !(isBlocked || shareBlocked)
|
||||
onClicked: {
|
||||
isLoadingItems += Plasmoid.configuration.BIpostshare
|
||||
//isLoadingItems += Plasmoid.configuration.BIpostshare
|
||||
Plasmoid.configuration.BIpostshare ? (profileLoading = true) : null
|
||||
shareBlocked = true
|
||||
superWorker.sendMessage({ "action": "post_share", "bool": !share })
|
||||
share = !share
|
||||
|
|
@ -824,7 +862,8 @@ PlasmoidItem {
|
|||
checked: ebalka
|
||||
enabled: !(isBlocked || ebalkaBlocked)
|
||||
onClicked: {
|
||||
isLoadingItems += Plasmoid.configuration.BIpostebalka
|
||||
//isLoadingItems += Plasmoid.configuration.BIpostebalka
|
||||
Plasmoid.configuration.BIpostebalka ? (profileLoading = true) : null
|
||||
ebalkaBlocked = true
|
||||
superWorker.sendMessage({ "action": "post_ebalka", "bool": !ebalka, "ip": null })
|
||||
ebalka = !ebalka
|
||||
|
|
@ -899,7 +938,8 @@ PlasmoidItem {
|
|||
}
|
||||
}
|
||||
onClicked: {
|
||||
isLoadingItems += Plasmoid.configuration.BIpostcountry
|
||||
//isLoadingItems += Plasmoid.configuration.BIpostcountry
|
||||
Plasmoid.configuration.BIpostcountry ? (routesLoading = true) : null
|
||||
superWorker.sendMessage({ "action": "post_country", "code": model.code, "provider": model.provider })
|
||||
}
|
||||
}
|
||||
|
|
@ -1016,7 +1056,8 @@ PlasmoidItem {
|
|||
checked: model.ebalka
|
||||
enabled: !(isBlocked || devicesBlocked)
|
||||
onClicked: {
|
||||
isLoadingItems += Plasmoid.configuration.BIdevicesupdate
|
||||
//isLoadingItems += Plasmoid.configuration.BIdevicesupdate
|
||||
Plasmoid.configuration.BIdevicesupdate ? (profileLoading = true) : null
|
||||
devicesBlocked = true
|
||||
superWorker.sendMessage({ "action": "post_ebalka", "bool": !model.ebalka, "ip": model.ip })
|
||||
// ebalka = !ebalka
|
||||
|
|
@ -1036,6 +1077,7 @@ PlasmoidItem {
|
|||
padding: Kirigami.Units.largeSpacing
|
||||
|
||||
function confirmAction() {
|
||||
Plasmoid.configuration.BIdevicesupdate ? (profileLoading = true) : null
|
||||
superWorker.sendMessage({ "action": "post_name", "ip": model.ip, "name": textInput.text })
|
||||
inputMenu.close();
|
||||
textInput.text = "";
|
||||
|
|
@ -1178,7 +1220,8 @@ PlasmoidItem {
|
|||
text: "Drop"
|
||||
enabled: !(isBlocked || firewallBlocked)
|
||||
onClicked: {
|
||||
isLoadingItems += Plasmoid.configuration.BIpostfirewall
|
||||
//isLoadingItems += Plasmoid.configuration.BIpostfirewall
|
||||
Plasmoid.configuration.BIpostfirewall ? (firewallLoading = true) : null
|
||||
firewallBlocked = true
|
||||
superWorker.sendMessage({ "action": "post_ruledrop", "dst": model.dst, "ext": model.ip, "local_port": model.local_port, "port": model.port, "proto": model.proto })
|
||||
}
|
||||
|
|
@ -1307,7 +1350,8 @@ PlasmoidItem {
|
|||
}
|
||||
}
|
||||
onClicked: {
|
||||
isLoadingItems += Plasmoid.configuration.BIpostcountry
|
||||
//isLoadingItems += Plasmoid.configuration.BIpostcountry
|
||||
Plasmoid.configuration.BIpostcountry ? (routesLoading = true, profileLoading = true) : null
|
||||
superWorker.sendMessage({ "action": "post_idconnect", "iface": model.name })
|
||||
}
|
||||
}
|
||||
|
|
@ -1378,7 +1422,8 @@ PlasmoidItem {
|
|||
checked: model.value
|
||||
enabled: !(isBlocked || featuresBlocked)
|
||||
onClicked: {
|
||||
isLoadingItems += Plasmoid.configuration.BIfeaturesupdate
|
||||
//isLoadingItems += Plasmoid.configuration.BIfeaturesupdate
|
||||
Plasmoid.configuration.BIfeaturesupdate ? (profileLoading = true) : null
|
||||
//featuresBlocked = true
|
||||
superWorker.sendMessage({ "action": "post_feature", "name": model.name, "value": !model.value })
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue