diff --git a/src/app/node/core.nim b/src/app/node/core.nim index 0700ae1e79..a7707aec20 100644 --- a/src/app/node/core.nim +++ b/src/app/node/core.nim @@ -32,4 +32,7 @@ proc init*(self: NodeController) = self.status.events.on(SignalType.DiscoverySummary.event) do(e:Args): self.status.network.peerSummaryChange(DiscoverySummarySignal(e).enodes) + self.status.events.on(SignalType.Stats.event) do (e:Args): + self.view.setStats(StatsSignal(e).stats) + self.view.init() diff --git a/src/app/node/view.nim b/src/app/node/view.nim index cea66e0e1c..195f4487e8 100644 --- a/src/app/node/view.nim +++ b/src/app/node/view.nim @@ -1,5 +1,6 @@ import NimQml, chronicles, strutils, json import ../../status/[status, node, types, settings, accounts] +import ../../status/signals/types as signal_types logScope: topics = "node-view" @@ -11,6 +12,7 @@ QtObject: lastMessage*: string wakuBloomFilterMode*: bool fullNode*: bool + stats*: Stats proc setup(self: NodeView) = self.QObject.setup @@ -122,4 +124,22 @@ QtObject: let statusGoResult = self.status.settings.setBloomLevel(BloomFilterMode, FullNode) if statusGoResult.error != "": error "Error saving updated node config", msg=statusGoResult.error - quit(QuitSuccess) # quits the app TODO: change this to logout instead when supported \ No newline at end of file + quit(QuitSuccess) # quits the app TODO: change this to logout instead when supported + + proc statsChanged*(self: NodeView) {.signal.} + + proc setStats*(self: NodeView, stats: Stats) = + self.stats = stats + self.statsChanged() + + proc uploadRate*(self: NodeView): string {.slot.} = $self.stats.uploadRate + + QtProperty[string] uploadRate: + read = uploadRate + notify = statsChanged + + proc downloadRate*(self: NodeView): string {.slot.} = $self.stats.downloadRate + + QtProperty[string] downloadRate: + read = downloadRate + notify = statsChanged \ No newline at end of file diff --git a/src/status/signals/core.nim b/src/status/signals/core.nim index 8d12c12d1c..54ee3440b9 100644 --- a/src/status/signals/core.nim +++ b/src/status/signals/core.nim @@ -1,6 +1,6 @@ import NimQml, tables, json, chronicles, strutils, json_serialization import ../types as status_types -import types, messages, discovery, whisperFilter, envelopes, expired, wallet, mailserver, communities +import types, messages, discovery, whisperFilter, envelopes, expired, wallet, mailserver, communities, stats import ../status import ../../eventemitter @@ -57,6 +57,7 @@ QtObject: of SignalType.MailserverRequestCompleted: mailserver.fromCompletedEvent(jsonSignal) of SignalType.MailserverRequestExpired: mailserver.fromExpiredEvent(jsonSignal) of SignalType.CommunityFound: communities.fromEvent(jsonSignal) + of SignalType.Stats: stats.fromEvent(jsonSignal) else: Signal() if(signalType == SignalType.NodeLogin): diff --git a/src/status/signals/stats.nim b/src/status/signals/stats.nim new file mode 100644 index 0000000000..9522651947 --- /dev/null +++ b/src/status/signals/stats.nim @@ -0,0 +1,13 @@ +import json +import types + +proc toStats(jsonMsg: JsonNode): Stats = + result = Stats( + uploadRate: uint64(jsonMsg{"uploadRate"}.getBiggestInt()), + downloadRate: uint64(jsonMsg{"downloadRate"}.getBiggestInt()) + ) + +proc fromEvent*(event: JsonNode): Signal = + var signal:StatsSignal = StatsSignal() + signal.stats = event["event"].toStats + result = signal \ No newline at end of file diff --git a/src/status/signals/types.nim b/src/status/signals/types.nim index adca67c07a..b48f13965d 100644 --- a/src/status/signals/types.nim +++ b/src/status/signals/types.nim @@ -66,3 +66,10 @@ type WhisperFilterSignal* = ref object of Signal type DiscoverySummarySignal* = ref object of Signal enodes*: seq[string] + +type Stats* = object + uploadRate*: uint64 + downloadRate*: uint64 + +type StatsSignal* = ref object of Signal + stats*: Stats \ No newline at end of file diff --git a/src/status/types.nim b/src/status/types.nim index 0dfb714dcc..84ded72147 100644 --- a/src/status/types.nim +++ b/src/status/types.nim @@ -24,6 +24,7 @@ type SignalType* {.pure.} = enum SubscriptionsError = "subscriptions.error" WhisperFilterAdded = "whisper.filter.added" CommunityFound = "community.found" + Stats = "stats" Unknown proc event*(self:SignalType):string = diff --git a/ui/app/AppLayouts/Node/NodeLayout.qml b/ui/app/AppLayouts/Node/NodeLayout.qml index d220da6747..6236a3e42d 100644 --- a/ui/app/AppLayouts/Node/NodeLayout.qml +++ b/ui/app/AppLayouts/Node/NodeLayout.qml @@ -3,6 +3,8 @@ import QtQuick.Controls 2.13 import QtQuick.Layouts 1.13 import "../../../imports" import "../../../shared" +import "../../../shared/status" + Item { id: nodeView @@ -14,6 +16,10 @@ Item { spacing: 0 anchors.fill: parent + Rate { + + } + ColumnLayout { id: messageContainer Layout.fillHeight: true diff --git a/ui/app/AppLayouts/Node/Rate.qml b/ui/app/AppLayouts/Node/Rate.qml new file mode 100644 index 0000000000..adc2297f1f --- /dev/null +++ b/ui/app/AppLayouts/Node/Rate.qml @@ -0,0 +1,78 @@ +import QtQuick 2.13 +import QtQuick.Controls 2.13 +import QtQuick.Layouts 1.13 +import "../../../imports" +import "../../../shared" +import "../../../shared/status" + + +Column { + spacing: 0 + StatusSectionHeadline { + text: qsTr("Bandwidth") + topPadding: Style.current.bigPadding + bottomPadding: Style.current.padding + } + + Row { + width: parent.width + spacing: 10 + StyledText { + text: "Upload" + width: 250 + anchors.verticalCenter: parent.verticalCenter + } + + Item { + width: 140 + height: 44 + Input { + id: uploadRate + text: Math.round(parseInt(nodeModel.uploadRate, 10) / 1024 * 100) / 100 + width: parent.width + readOnly: true + customHeight: 44 + placeholderText: "0" + anchors.top: parent.top + } + + StyledText { + color: Style.current.secondaryText + text: qsTrId("Kb/s") + anchors.verticalCenter: parent.verticalCenter + anchors.right: uploadRate.right + anchors.rightMargin: Style.current.padding + font.pixelSize: 15 + } + } + + StyledText { + text: "Download" + width: 273 + anchors.verticalCenter: parent.verticalCenter + } + + Item { + width: 140 + height: 44 + Input { + id: downloadRate + text: Math.round(parseInt(nodeModel.downloadRate, 10) / 1024 * 100) / 100 + width: parent.width + readOnly: true + customHeight: 44 + placeholderText: "0" + anchors.top: parent.top + } + + StyledText { + color: Style.current.secondaryText + text: qsTrId("Kb/s") + anchors.verticalCenter: parent.verticalCenter + anchors.right: downloadRate.right + anchors.rightMargin: Style.current.padding + font.pixelSize: 15 + } + } + } +} \ No newline at end of file diff --git a/ui/app/AppLayouts/Profile/Sections/AdvancedContainer.qml b/ui/app/AppLayouts/Profile/Sections/AdvancedContainer.qml index 9cc19a137a..22c0f8a8f7 100644 --- a/ui/app/AppLayouts/Profile/Sections/AdvancedContainer.qml +++ b/ui/app/AppLayouts/Profile/Sections/AdvancedContainer.qml @@ -125,6 +125,21 @@ Item { } } + StatusSettingsLineButton { + //% "Node Management" + text: qsTrId("node-management") + isSwitch: true + switchChecked: appSettings.nodeManagementEnabled + onClicked: { + if (!appSettings.nodeManagementEnabled) { + confirmationPopup.settingsProp = "nodeManagementEnabled" + confirmationPopup.open() + } else { + appSettings.nodeManagementEnabled = false + } + } + } + StatusSettingsLineButton { id: onlineUsers //% "Online users" @@ -153,6 +168,16 @@ Item { } } + StatusSettingsLineButton { + //% "GIF Widget" + text: qsTrId("gif-widget") + isSwitch: true + switchChecked: appSettings.isGifWidgetEnabled + onClicked: { + appSettings.isGifWidgetEnabled = !appSettings.isGifWidgetEnabled + } + } + StatusSectionHeadline { //% "Bloom filter level" text: qsTrId("bloom-filter-level") @@ -236,31 +261,6 @@ Item { } } } - - StatusSettingsLineButton { - //% "GIF Widget" - text: qsTrId("gif-widget") - isSwitch: true - switchChecked: appSettings.isGifWidgetEnabled - onClicked: { - appSettings.isGifWidgetEnabled = !appSettings.isGifWidgetEnabled - } - } - - // StatusSettingsLineButton { - // //% "Node Management" - // text: qsTrId("node-management") - // isSwitch: true - // switchChecked: appSettings.nodeManagementEnabled - // onClicked: { - // if (!appSettings.nodeManagementEnabled) { - // confirmationPopup.settingsProp = "nodeManagementEnabled" - // confirmationPopup.open() - // } else { - // appSettings.nodeManagementEnabled = false - // } - // } - // } } NetworksModal { diff --git a/ui/app/AppMain.qml b/ui/app/AppMain.qml index addca9b841..4b060f6ec8 100644 --- a/ui/app/AppMain.qml +++ b/ui/app/AppMain.qml @@ -230,6 +230,15 @@ StatusAppLayout { onClicked: appMain.changeAppSection(Constants.timeline) }, + StatusNavBarTabButton { + enabled: isExperimental === "1" || appSettings.nodeManagementEnabled + visible: enabled + tooltip.text: qsTr("Node Management") + icon.name: "node" + checked: appView.currentIndex == Utils.getAppSectionIndex(Constants.node) + onClicked: appMain.changeAppSection(Constants.node) + }, + StatusNavBarTabButton { id: profileBtn //% "Profile" diff --git a/vendor/status-go b/vendor/status-go index 151edb3607..cdc7c55030 160000 --- a/vendor/status-go +++ b/vendor/status-go @@ -1 +1 @@ -Subproject commit 151edb36077cdbb9f1f2b89f32cd939ee873ed98 +Subproject commit cdc7c5503001e2c987cf657dc707a3da81ea397e