Skip to content

Commit

Permalink
Fixes, add simple stats
Browse files Browse the repository at this point in the history
  • Loading branch information
devhyper committed May 30, 2023
1 parent eb7ba92 commit 676158a
Showing 1 changed file with 73 additions and 3 deletions.
76 changes: 73 additions & 3 deletions pages/MiningStats.qml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ import moneroComponents.P2PoolManager 1.0
Rectangle {
id: root
color: "transparent"
property alias miningStatsHeight: miningStatsView.height
property alias miningStatsHeight: miningStatsContentColumn.height
property int entryHeight: 24
property int entryPixelSize: 14
property bool showFullStats: false

Timer {
id: timer
Expand Down Expand Up @@ -69,15 +70,46 @@ Rectangle {
}
}

function updateSimpleMiningStats(statsMap)
{
var pool_statistics = statsMap["pool_statistics"];

if (pool_statistics != null)
{
var statsData = [
{"key": "Main chain height:", "value": statsMap["height"]},
{"key": "Side chain height:", "value": pool_statistics["sidechainHeight"]},
{"key": "PPLNS window:", "value": pool_statistics["pplnsWeight"] + " blocks"},
{"key": "Block reward share", "value": statsMap["block_reward_share_percent"]},
{"key": "Connections: ", "value": statsMap["connections"]},
{"key": "Peer list size: ", "value": statsMap["peer_list_size"]},
{"key": "Uptime: ", "value": statsMap["uptime"]}
];

for (var element of statsData)
{
if (element.value != null)
{
simpleMiningStatsModel.append({"key": element["key"], "value": element["value"].toString(), "depth": 0});
}
}
}
}

function updateMiningStats(statsMap)
{
simpleMiningStatsModel.clear();
updateSimpleMiningStats(statsMap);

miningStatsModel.clear();
recursivelyFindPairs(statsMap, 0);
}

ListModel { id: simpleMiningStatsModel }
ListModel { id: miningStatsModel }

Column {
id: miningStatsContentColumn
spacing: entryHeight

MoneroComponents.StandardButton {
Expand All @@ -91,9 +123,47 @@ Rectangle {
}

ListView {
visible: true
id: simpleMiningStatsView
width: root.width
height: count * entryHeight + entryHeight
model: simpleMiningStatsModel
interactive: false

delegate: Rectangle {
id: miningStatsDelegate
color: "transparent"
height: entryHeight
Layout.fillWidth: true

RowLayout {
MoneroComponents.TextBlock {
Layout.fillWidth: true
Layout.leftMargin: depth * entryPixelSize
font.pixelSize: entryPixelSize
text: key + translationManager.emptyString
}

MoneroComponents.TextBlock {
Layout.fillWidth: true
color: MoneroComponents.Style.dimmedFontColor
font.pixelSize: entryPixelSize
text: value + translationManager.emptyString
}
}
}
}

MoneroComponents.CheckBox2 {
id: showFullStatsCheckbox
checked: showFullStats
onClicked: showFullStats = !showFullStats
text: qsTr("Show full statistics") + translationManager.emptyString
}

ListView {
visible: showFullStats
id: miningStatsView
width: 1500
width: root.width
height: count * entryHeight + entryHeight
model: miningStatsModel
interactive: false
Expand Down

0 comments on commit 676158a

Please sign in to comment.