@@ -7,20 +7,62 @@ package io.gitpod.jetbrains.remote
7
7
import com.jetbrains.ide.model.uiautomation.BeControl
8
8
import com.jetbrains.rd.ui.bedsl.dsl.VerticalGridBuilder
9
9
import com.jetbrains.rd.ui.bedsl.dsl.verticalGrid
10
+ import com.jetbrains.rd.ui.bedsl.dsl.*
10
11
import com.jetbrains.rd.util.lifetime.Lifetime
11
- import com.jetbrains.rd.util.reactive.Property
12
12
import com.jetbrains.rdserver.diagnostics.BackendDiagnosticsService
13
13
import com.jetbrains.rdserver.unattendedHost.customization.controlCenter.performance.MetricControlProvider
14
14
import com.jetbrains.rdserver.unattendedHost.customization.controlCenter.performance.createProgressBar
15
15
import com.jetbrains.rdserver.unattendedHost.customization.controlCenter.performance.createProgressRow
16
+ import com.jetbrains.rd.util.reactive.Property
16
17
17
18
class GitpodMetricControlProvider : MetricControlProvider {
18
19
override val id: String = " gitpodMetricsControl"
19
20
override fun getControl (lifetime : Lifetime ): BeControl {
21
+ val backendDiagnosticsService = BackendDiagnosticsService .Companion .getInstance()
22
+
20
23
return verticalGrid {
21
- val backendDiagnosticsService = BackendDiagnosticsService .Companion .getInstance()
22
- createCpuControl(this , backendDiagnosticsService, lifetime)
23
- createMemoryControl(this , backendDiagnosticsService, lifetime)
24
+ createWorkspaceHeaderRow(this , backendDiagnosticsService, lifetime)
25
+ row {
26
+ verticalGrid {
27
+ createCpuControl(this , backendDiagnosticsService, lifetime)
28
+ createMemoryControl(this , backendDiagnosticsService, lifetime)
29
+ }.withMargin { margin(0 , 0 , 0 , 10 ) }
30
+ }
31
+ row {
32
+ horizontalGrid {
33
+ column {
34
+ label(" Node" )
35
+ }
36
+ }.withMargin { margin(0 , 0 , 0 , 10 ) }
37
+ }
38
+ }
39
+ }
40
+
41
+ private fun createWorkspaceHeaderRow (ctx : VerticalGridBuilder , backendDiagnosticsService : BackendDiagnosticsService , lifetime : Lifetime ) {
42
+ val labelProperty = Property (" " )
43
+
44
+ val workspaceClassMetric = backendDiagnosticsService.getMetric(" gitpod_workspace_class" )
45
+ val workspaceClass = workspaceClassMetric.toString()
46
+
47
+ fun updateLabel () {
48
+ if (workspaceClass == " " ) {
49
+ labelProperty.set(" Workspace" )
50
+ } else {
51
+ labelProperty.set(" Workspace ($workspaceClass )" )
52
+ }
53
+ }
54
+ updateLabel()
55
+
56
+ workspaceClassMetric.valueProperty.change.advise(lifetime) {
57
+ updateLabel()
58
+ }
59
+
60
+ return ctx.row {
61
+ horizontalGrid {
62
+ column {
63
+ label(" Workspace $workspaceClass " )
64
+ }
65
+ }.withMargin { margin(0 , 0 , 0 , 10 ) }
24
66
}
25
67
}
26
68
@@ -29,7 +71,7 @@ class GitpodMetricControlProvider : MetricControlProvider {
29
71
val cpuTotal = backendDiagnosticsService.getMetric(" gitpod_workspace_cpu_total" )
30
72
val cpuPercentage = backendDiagnosticsService.getMetric(" gitpod_workspace_cpu_percentage" )
31
73
val cpuPercentageProperty = Property (" $cpuPercentage %" )
32
- val label = " Workspace CPU"
74
+ val label = " CPU"
33
75
val progressBar = createProgressBar(lifetime, cpuPercentage.valueProperty, cpuPercentageProperty)
34
76
val labelProperty = Property (" " )
35
77
@@ -51,7 +93,7 @@ class GitpodMetricControlProvider : MetricControlProvider {
51
93
val memoryTotal = backendDiagnosticsService.getMetric(" gitpod_workspace_memory_total" )
52
94
val memoryPercentage = backendDiagnosticsService.getMetric(" gitpod_workspace_memory_percentage" )
53
95
val memoryPercentageProperty = Property (" $memoryPercentage %" )
54
- val label = " Workspace Memory"
96
+ val label = " Memory"
55
97
val progressBar = createProgressBar(lifetime, memoryPercentage.valueProperty, memoryPercentageProperty)
56
98
val labelProperty = Property (" " )
57
99
0 commit comments