@@ -12,146 +12,142 @@ import { queryNodes } from '../Nodes/service';
12
12
import { queryClients , reloadClientConfigs , clientOffline } from './service' ;
13
13
const { confirm } = Modal ;
14
14
15
- const handleClientReload = async ( client :any ) => {
15
+ const handleClientReload = async ( client : any ) => {
16
16
const intl = getIntl ( getLocale ( ) ) ;
17
- const hide = message . loading ( intl . formatMessage ( { id : 'refreshing' } ) ) ;
17
+ const hide = message . loading ( intl . formatMessage ( { id : 'refreshing' } ) ) ;
18
18
try {
19
19
const result = await reloadClientConfigs ( client . address , client . id ) ;
20
20
hide ( ) ;
21
21
const success = result . success ;
22
22
if ( success ) {
23
- message . success ( intl . formatMessage ( { id : 'refresh_success' } ) ) ;
23
+ message . success ( intl . formatMessage ( { id : 'refresh_success' } ) ) ;
24
24
} else {
25
25
message . error ( result . message ) ;
26
26
}
27
27
return success ;
28
28
} catch ( error ) {
29
29
hide ( ) ;
30
- message . error ( intl . formatMessage ( { id : 'refresh_fail' } ) ) ;
30
+ message . error ( intl . formatMessage ( { id : 'refresh_fail' } ) ) ;
31
31
return false ;
32
32
}
33
- }
33
+ } ;
34
34
35
-
36
- const handleClientOffline = async ( client :any ) => {
35
+ const handleClientOffline = async ( client : any ) => {
37
36
const intl = getIntl ( getLocale ( ) ) ;
38
- const hide = message . loading ( intl . formatMessage ( { id : 'disconnecting' } ) ) ;
37
+ const hide = message . loading ( intl . formatMessage ( { id : 'disconnecting' } ) ) ;
39
38
try {
40
39
const result = await clientOffline ( client . address , client . id ) ;
41
40
hide ( ) ;
42
41
const success = result . success ;
43
42
if ( success ) {
44
- message . success ( intl . formatMessage ( { id : 'disconnect_success' } ) ) ;
43
+ message . success ( intl . formatMessage ( { id : 'disconnect_success' } ) ) ;
45
44
} else {
46
45
message . error ( result . message ) ;
47
46
}
48
47
return success ;
49
48
} catch ( error ) {
50
49
hide ( ) ;
51
- message . error ( intl . formatMessage ( { id : 'disconnect_fail' } ) ) ;
50
+ message . error ( intl . formatMessage ( { id : 'disconnect_fail' } ) ) ;
52
51
return false ;
53
52
}
54
- }
53
+ } ;
55
54
56
- const clients :React . FC = ( ) => {
55
+ const clients : React . FC = ( ) => {
57
56
const actionRef = useRef < ActionType > ( ) ;
58
57
const [ appEnums , setAppEnums ] = useState < any > ( ) ;
59
58
const intl = useIntl ( ) ;
60
59
61
- const getNodesForSelect = async ( ) =>
62
- {
63
- const result = await queryNodes ( )
64
- const arr :any [ ] = [ ] ;
65
- result . data . forEach ( ( x :{ address :string } ) => {
66
- arr . push ( {
67
- value : x . address ,
68
- label : x . address ,
69
- } ) ;
60
+ const getNodesForSelect = async ( ) => {
61
+ const result = await queryNodes ( ) ;
62
+ const arr : any [ ] = [ ] ;
63
+ result . data . forEach ( ( x : { address : string } ) => {
64
+ arr . push ( {
65
+ value : x . address ,
66
+ label : x . address ,
67
+ } ) ;
70
68
} ) ;
71
69
72
70
return arr ;
73
- }
74
- const getAppEnums = async ( ) =>
75
- {
76
- const result = await queryApps ( { } )
71
+ } ;
72
+ const getAppEnums = async ( ) => {
73
+ const result = await queryApps ( { } ) ;
77
74
const obj = { } ;
78
- result . data ?. forEach ( x => {
79
- if ( x ) {
75
+ result . data ?. forEach ( ( x ) => {
76
+ if ( x ) {
80
77
obj [ x . id ] = {
81
- text : x . name
82
- }
78
+ text : x . name ,
79
+ } ;
83
80
}
84
81
} ) ;
85
82
86
83
return obj ;
87
- }
88
- useEffect ( ( ) => {
89
- getAppEnums ( ) . then ( x => {
84
+ } ;
85
+ useEffect ( ( ) => {
86
+ getAppEnums ( ) . then ( ( x ) => {
90
87
console . log ( 'app enums ' , x ) ;
91
- setAppEnums ( { ...x } ) ;
88
+ setAppEnums ( { ...x } ) ;
92
89
} ) ;
93
90
} , [ ] ) ;
94
91
const columns : ProColumns [ ] = [
95
92
{
96
93
title : intl . formatMessage ( {
97
- id : 'pages.client.table.cols.id'
94
+ id : 'pages.client.table.cols.id' ,
98
95
} ) ,
99
96
dataIndex : 'id' ,
100
97
hideInSearch : true ,
101
- ellipsis : true
98
+ ellipsis : true ,
102
99
} ,
103
100
{
104
101
title : intl . formatMessage ( {
105
- id : 'pages.client.table.cols.node'
102
+ id : 'pages.client.table.cols.node' ,
106
103
} ) ,
107
104
dataIndex : 'address' ,
108
105
valueType : 'select' ,
109
- request : getNodesForSelect
106
+ request : getNodesForSelect ,
107
+ } ,
108
+ {
109
+ title : '环境' ,
110
+ dataIndex : 'env' ,
110
111
} ,
111
112
{
112
113
title : intl . formatMessage ( {
113
- id : 'pages.client.table.cols.appid'
114
+ id : 'pages.client.table.cols.appid' ,
114
115
} ) ,
115
116
dataIndex : 'appId' ,
116
- hideInSearch : true ,
117
- } ,
118
- {
119
- title : '环境' ,
120
- dataIndex : 'env' ,
121
- hideInSearch : true ,
122
117
} ,
123
118
{
124
119
title : intl . formatMessage ( {
125
- id : 'pages.client.table.cols.ip'
120
+ id : 'pages.client.table.cols.ip' ,
126
121
} ) ,
127
122
dataIndex : 'ip' ,
128
123
hideInSearch : true ,
129
124
} ,
130
125
{
131
126
title : intl . formatMessage ( {
132
- id : 'pages.client.table.cols.name'
127
+ id : 'pages.client.table.cols.name' ,
133
128
} ) ,
134
129
dataIndex : 'name' ,
135
130
hideInSearch : true ,
136
- } , {
131
+ } ,
132
+ {
137
133
title : intl . formatMessage ( {
138
- id : 'pages.client.table.cols.tag'
134
+ id : 'pages.client.table.cols.tag' ,
139
135
} ) ,
140
136
dataIndex : 'tag' ,
141
137
hideInSearch : true ,
142
138
} ,
143
139
{
144
140
title : intl . formatMessage ( {
145
- id : 'pages.client.table.cols.lastRefreshTime'
141
+ id : 'pages.client.table.cols.lastRefreshTime' ,
146
142
} ) ,
147
143
dataIndex : 'lastRefreshTime' ,
148
144
hideInSearch : true ,
149
145
valueType : 'dateTime' ,
150
- tip : '客户端从服务器最后一次全量拉取配置的时间'
146
+ tip : '客户端从服务器最后一次全量拉取配置的时间' ,
151
147
} ,
152
148
{
153
149
title : intl . formatMessage ( {
154
- id : 'pages.client.table.cols.action'
150
+ id : 'pages.client.table.cols.action' ,
155
151
} ) ,
156
152
valueType : 'option' ,
157
153
render : ( text , record ) => [
@@ -160,57 +156,54 @@ const clients:React.FC = () => {
160
156
handleClientReload ( record ) ;
161
157
} }
162
158
>
163
- {
164
- intl . formatMessage ( {
165
- id : 'pages.client.table.cols.action.refresh'
166
- } )
167
- }
159
+ { intl . formatMessage ( {
160
+ id : 'pages.client.table.cols.action.refresh' ,
161
+ } ) }
168
162
</ a > ,
169
163
< AuthorizedEle judgeKey = { functionKeys . Client_Disconnect } >
170
- < Button type = "link" danger onClick = {
171
- ( ) => {
172
- const msg = intl . formatMessage ( {
173
- id : 'pages.client.disconnect_message'
174
- } ) + `【${ record . id } 】` ;
175
- confirm ( {
176
- icon : < ExclamationCircleOutlined /> ,
177
- content : msg ,
178
- async onOk ( ) {
179
- console . log ( 'disconnect client ' + record . id ) ;
180
- const success = await handleClientOffline ( record ) ;
181
- if ( success ) {
182
- actionRef . current ?. reload ( ) ;
183
- }
184
- } ,
185
- onCancel ( ) {
186
- } ,
187
- } ) ;
188
- } } >
189
- {
190
- intl . formatMessage ( {
191
- id : 'pages.client.table.cols.action.disconnect'
192
- } )
193
- }
164
+ < Button
165
+ type = "link"
166
+ danger
167
+ onClick = { ( ) => {
168
+ const msg =
169
+ intl . formatMessage ( {
170
+ id : 'pages.client.disconnect_message' ,
171
+ } ) + `【${ record . id } 】` ;
172
+ confirm ( {
173
+ icon : < ExclamationCircleOutlined /> ,
174
+ content : msg ,
175
+ async onOk ( ) {
176
+ console . log ( 'disconnect client ' + record . id ) ;
177
+ const success = await handleClientOffline ( record ) ;
178
+ if ( success ) {
179
+ actionRef . current ?. reload ( ) ;
180
+ }
181
+ } ,
182
+ onCancel ( ) { } ,
183
+ } ) ;
184
+ } }
185
+ >
186
+ { intl . formatMessage ( {
187
+ id : 'pages.client.table.cols.action.disconnect' ,
188
+ } ) }
194
189
</ Button >
195
- </ AuthorizedEle >
196
- ]
197
- }
190
+ </ AuthorizedEle > ,
191
+ ] ,
192
+ } ,
198
193
] ;
199
194
return (
200
- < PageContainer header = { { title :intl . formatMessage ( { id :'pages.client.header.title' } ) } } >
201
- < ProTable
202
- search = { {
203
- labelWidth : 'auto' ,
204
- } }
205
- actionRef = { actionRef }
206
- options = {
207
- false
208
- }
195
+ < PageContainer header = { { title : intl . formatMessage ( { id : 'pages.client.header.title' } ) } } >
196
+ < ProTable
197
+ search = { {
198
+ labelWidth : 'auto' ,
199
+ } }
200
+ actionRef = { actionRef }
201
+ options = { false }
209
202
rowKey = "id"
210
- columns = { columns }
211
- request = { ( params , sorter , filter ) => queryClients ( params ) }
203
+ columns = { columns }
204
+ request = { ( params , sorter , filter ) => queryClients ( params ) }
212
205
/>
213
206
</ PageContainer >
214
207
) ;
215
- }
208
+ } ;
216
209
export default clients ;
0 commit comments