mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-09 22:06:25 +00:00
9be2a8d799
This commit includes the following changes: 1. Request from backend the messages count in a specific interval as opposed to all messages timestamps in that interval. 2. Update the chart end date before refreshing the data 3. Fix metrics type parsing in community service 4. Fix a bug where the new incoming data was not processed by ChartJs without a hover event on the chart. The fix here is to manually request paint() on model changes.d Issues found and not handled here: 1. On large communities the backend request can take 3 minutes to complete 2. CPU usage can easily go to 100% when switching chart tabs on large communities. All the requests are processed by the backend.
71 lines
1.7 KiB
QML
71 lines
1.7 KiB
QML
import QtQuick 2.15
|
|
import QtQuick.Controls 2.15
|
|
|
|
import AppLayouts.Communities.panels 1.0
|
|
import Models 1.0
|
|
|
|
import Storybook 1.0
|
|
|
|
SplitView {
|
|
id: root
|
|
|
|
orientation: Qt.Vertical
|
|
|
|
OverviewSettingsChart {
|
|
id: chart
|
|
SplitView.fillWidth: true
|
|
SplitView.fillHeight: true
|
|
onCollectCommunityMetricsMessagesCount: generateRandomModel(intervals)
|
|
}
|
|
|
|
function generateRandomModel(intervalsStr) {
|
|
if(!intervalsStr) return
|
|
|
|
var response = {
|
|
communityId: "",
|
|
metricsType: timestampMetrics.checked ? "MessagesTimestamps" : "MessagesCount",
|
|
intervals: []
|
|
}
|
|
|
|
var intervals = JSON.parse(intervalsStr)
|
|
|
|
response.intervals = intervals.map( x => {
|
|
var timestamps = generateRandomDate(x.startTimestamp, x.endTimestamp, Math.random() * 10)
|
|
|
|
return {
|
|
startTimestamp: x.startTimestamp,
|
|
endTimestamp: x.endTimestamp,
|
|
timestamps: timestamps,
|
|
count: timestamps.length
|
|
}
|
|
})
|
|
|
|
chart.model = response
|
|
}
|
|
|
|
function generateRandomDate(from, to, count) {
|
|
var newModel = []
|
|
for(var i = 0; i < count; i++) {
|
|
var date = from + Math.random() * (to - from)
|
|
newModel.push(date)
|
|
}
|
|
return newModel
|
|
}
|
|
|
|
LogsAndControlsPanel {
|
|
id: logsAndControlsPanel
|
|
|
|
SplitView.minimumHeight: 100
|
|
SplitView.preferredHeight: 150
|
|
|
|
CheckBox {
|
|
id: timestampMetrics
|
|
text: "Metrics using timestamps"
|
|
checked: false
|
|
onCheckedChanged: chart.reset()
|
|
}
|
|
}
|
|
}
|
|
|
|
// category: Panels
|