11package io.github.inductiveautomation.kindling.zip.views.gwbk
22
33import com.formdev.flatlaf.extras.FlatSVGIcon
4+ import io.github.inductiveautomation.kindling.MainPanel
45import io.github.inductiveautomation.kindling.statistics.GatewayBackup
56import io.github.inductiveautomation.kindling.statistics.Statistic
67import io.github.inductiveautomation.kindling.statistics.StatisticCalculator
@@ -27,6 +28,7 @@ import javax.swing.JPopupMenu
2728import javax.swing.SwingConstants
2829import javax.swing.UIManager
2930import javax.swing.border.LineBorder
31+ import kotlin.io.path.exists
3032import kotlin.io.path.extension
3133
3234class GwbkStatsView(
@@ -42,6 +44,9 @@ class GwbkStatsView(
4244 private val gatewayBackup = GatewayBackup(path)
4345
4446 init {
47+ if (gatewayBackup.configDirectory.exists()) {
48+ add(eightThreeWarning(), "wrap")
49+ }
4550 add(MetaStatistics.Calculator renderedWith MetaStatisticsRenderer(), "growx, wrap")
4651 add(ProjectStatistics.Calculator renderedWith ProjectStatisticsRenderer(), "growx, sg")
4752 add(DatabaseStatistics.Calculator renderedWith DatabaseStatisticsRenderer(), "growx, sg")
@@ -64,7 +69,12 @@ class GwbkStatsView(
6469 add(throbber, "push, grow, span")
6570
6671 BACKGROUND.launch {
67- val statistic = calculate(gatewayBackup)
72+ val statistic: T? = try {
73+ calculate(gatewayBackup)
74+ } catch (e: Exception) {
75+ MainPanel.LOGGER.error("Error calculating statistic", e)
76+ null
77+ }
6878 EDT_SCOPE.launch {
6979 if (statistic == null) {
7080 this@GwbkStatsView.remove(this@apply)
@@ -84,6 +94,14 @@ class GwbkStatsView(
8494 }
8595 }
8696
97+ private fun eightThreeWarning(): JLabel = JLabel(
98+ "8.3 Backups are not yet processed correctly",
99+ FlatSVGIcon("icons/bx-error.svg"),
100+ SwingConstants.CENTER,
101+ ).apply {
102+ putClientProperty("FlatLaf.styleClass", "h2")
103+ }
104+
87105 companion object {
88106 private val BACKGROUND = CoroutineScope(SupervisorJob() + Dispatchers.IO)
89107
0 commit comments