10
10
body {
11
11
padding : 0 20px ;
12
12
}
13
+ li {
14
+ margin : 3px ;
15
+ }
13
16
</ style >
14
17
</ head >
15
18
@@ -21,7 +24,7 @@ <h5>Last UncaughtException: {{ last_bug }}</h5>
21
24
< h2 class ="mt-4 "> Connections (total: {{ count }}) :</ h2 >
22
25
< ul >
23
26
< li v-for ="connection in connections " :key ="connection.id ">
24
- Key: {{ connection.key }} - Nick: {{ connection.nick }} - Number of channels: {{ connection.channelCount }} - < button class ="kill " :data-key =" connection.key "> Kill</ button >
27
+ Key: {{ connection.key }} - Nick: {{ connection.nick }} - User: {{ connection.user }} - Host: {{ connection.host }} - Number of channels: {{ connection.channelCount }} - < button class ="kill btn btn-primary " @click =" removeConnection( connection.key, $event) "> Kill</ button >
25
28
</ li >
26
29
</ ul >
27
30
</ div >
@@ -54,22 +57,11 @@ <h2 class="mt-4">Connections (total: {{ count }}) :</h2>
54
57
. catch ( error => {
55
58
console . error ( 'Error while retrieving data:' , error ) ;
56
59
} ) ;
57
- }
58
- } ,
59
- mounted ( ) {
60
- this . fetchData ( ) ;
61
- setInterval ( ( ) => {
62
- this . fetchData ( ) ;
63
- } , 5000 ) ;
64
- }
65
- } ) ;
66
-
67
- document . addEventListener ( "DOMContentLoaded" , function ( ) {
68
- document . addEventListener ( "click" , function ( event ) {
69
- if ( event . target . classList . contains ( 'kill' ) ) {
60
+ } ,
61
+ removeConnection ( key , event ) {
70
62
var data = {
71
63
command : "kill" ,
72
- key : event . target . getAttribute ( 'data- key' )
64
+ key : key
73
65
} ;
74
66
75
67
var url = new URL ( "/send" , window . location . origin ) ;
@@ -83,10 +75,14 @@ <h2 class="mt-4">Connections (total: {{ count }}) :</h2>
83
75
throw new Error ( 'Error fetching data' ) ;
84
76
}
85
77
} )
86
- . then ( function ( data ) {
78
+ . then ( ( data ) => {
87
79
if ( data == "disconnected" ) {
88
80
event . target . innerText = "disconnected !" ;
89
- event . target . disabled = true ;
81
+ const index = this . connections . findIndex ( connection => connection . key === key ) ;
82
+ if ( index !== - 1 ) {
83
+ this . connections . splice ( index , 1 ) ;
84
+ this . count -- ;
85
+ }
90
86
}
91
87
else
92
88
console . log ( "Error !" ) ;
@@ -95,11 +91,15 @@ <h2 class="mt-4">Connections (total: {{ count }}) :</h2>
95
91
console . error ( "Error sending request:" , error ) ;
96
92
} ) ;
97
93
}
98
- } ) ;
94
+ } ,
95
+ mounted ( ) {
96
+ this . fetchData ( ) ;
97
+ setInterval ( ( ) => {
98
+ this . fetchData ( ) ;
99
+ } , 5000 ) ;
100
+ }
99
101
} ) ;
100
102
101
-
102
-
103
103
</ script >
104
104
</ body >
105
105
</ html >
0 commit comments