Add detail tooltips in server browser stability %

When hovering on stability percentages in the server browser, a tooltip
now shows the total downtime in the past 30 days, number of incidents,
their average length and the longest's duration.
This commit is contained in:
miruka
2021-01-11 07:50:32 -04:00
parent ae4bcffa06
commit 98b6a7b74e
3 changed files with 46 additions and 17 deletions

View File

@@ -79,6 +79,25 @@ HTile {
model.stability >= 95 ? theme.colors.positiveText :
model.stability >= 85 ? theme.colors.warningText :
theme.colors.errorText
HoverHandler { id: rightInfoHover }
HToolTip {
readonly property var times: JSON.parse(model.downtimes_ms)
readonly property real total: utils.sum(times)
visible: model.stability !== -1 && rightInfoHover.hovered
text:
total === 0 ?
qsTr("No downtimes in the last 30 days") :
qsTr(
"Last 30 days downtimes: %1, average: %2, " +
"longest: %3, total: %4"
).arg(times.length)
.arg(utils.formatRelativeTime(total / times.length))
.arg(utils.formatRelativeTime(Math.max.apply(Math,times)))
.arg(utils.formatRelativeTime(total))
}
}
HButton {