File tree Expand file tree Collapse file tree 4 files changed +27
-2
lines changed
resources/META-INF/resources/frontend/styles Expand file tree Collapse file tree 4 files changed +27
-2
lines changed Original file line number Diff line number Diff line change 16
16
import vpnrouter .web .model .Client ;
17
17
import vpnrouter .web .utility .UiUtility ;
18
18
19
- @ CssImport ("./styles/styles.css" )
19
+ @ CssImport (value = "./styles/styles.css" , themeFor = "vaadin-grid " )
20
20
@ Slf4j
21
21
@ Component
22
22
@ RequiredArgsConstructor
@@ -30,7 +30,7 @@ public class ClientsGridFactory {
30
30
31
31
public Grid <Client > build () {
32
32
var grid = new Grid <Client >();
33
- grid . setClassName ( "custom- grid-text" );
33
+ setStyles ( grid );
34
34
createEditor (grid );
35
35
addIpAddressField (grid );
36
36
addNameField (grid );
@@ -41,6 +41,15 @@ public Grid<Client> build() {
41
41
return grid ;
42
42
}
43
43
44
+ private void setStyles (Grid <Client > grid ) {
45
+ grid .setClassName ("custom-grid-text" );
46
+ UiUtility .getCurrentClientIpAddress ().ifPresent (currentClientIpAddress ->
47
+ grid .setClassNameGenerator (client ->
48
+ client .getIpAddress ().equals (currentClientIpAddress ) ? "highlight" : null
49
+ )
50
+ );
51
+ }
52
+
44
53
private void createEditor (Grid <Client > grid ) {
45
54
var editor = grid .getEditor ();
46
55
editor .setBinder (new Binder <>());
Original file line number Diff line number Diff line change 1
1
package vpnrouter .web .utility ;
2
2
3
3
import com .vaadin .flow .component .UI ;
4
+ import lombok .extern .slf4j .Slf4j ;
4
5
6
+ import java .util .Optional ;
7
+
8
+ @ Slf4j
5
9
public class UiUtility {
6
10
7
11
public static String getFullUiId () {
@@ -10,4 +14,12 @@ public static String getFullUiId() {
10
14
var sessionId = ui .getSession ().getSession ().getId ();
11
15
return "%s/%s" .formatted (sessionId , uiId );
12
16
}
17
+
18
+ public static Optional <String > getCurrentClientIpAddress () {
19
+ var address = Optional .ofNullable (
20
+ UI .getCurrent ().getSession ().getBrowser ().getAddress ()
21
+ );
22
+ log .info ("Current client IP address: {}" , address );
23
+ return address ;
24
+ }
13
25
}
Original file line number Diff line number Diff line change 40
40
font-size : 16px ;
41
41
font-family : Arial, sans-serif;
42
42
}
43
+
44
+ .highlight {
45
+ background-color : # cefbfb ;
46
+ }
You can’t perform that action at this time.
0 commit comments