From 5ba7a5c492571d6672d2224956196eeb1f91c198 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BD=A6=E6=B0=91?= Date: Fri, 12 Oct 2018 23:43:58 +0800 Subject: [PATCH] fix: Fix Instance list display --- .../pages/ServiceDetail/EditInstanceDialog.js | 12 +++--- .../src/pages/ServiceDetail/InstanceTable.js | 41 +++++++++++++++---- 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/console/src/main/resources/static/src/pages/ServiceDetail/EditInstanceDialog.js b/console/src/main/resources/static/src/pages/ServiceDetail/EditInstanceDialog.js index 6c7566b2e..3dbe9a764 100644 --- a/console/src/main/resources/static/src/pages/ServiceDetail/EditInstanceDialog.js +++ b/console/src/main/resources/static/src/pages/ServiceDetail/EditInstanceDialog.js @@ -51,20 +51,22 @@ class EditInstanceDialog extends React.Component { >
-

1.1.1.1

+

{editInstance.ip}

-

8080

+

{editInstance.port}

this.onChangeCluster({healthy})} + value={editInstance.weight} + onChange={weight => this.onChangeCluster({weight})} /> - f}/> + this.onChangeCluster({enabled})}/> this.setState({loading: true}), - success: res => this.setState({instance: res}), + success: instance => this.setState({instance}), complete: () => this.setState({loading: false}) }) } @@ -42,20 +42,41 @@ class InstanceTable extends React.Component { this.refs.editInstanceDialog.show(instance) } - switchState() { + switchState(index, record) { + const {instance} = this.state + const {ip, port, weight, enabled} = record + const {clusterName, serviceName} = this.props + const newVal = Object.assign({}, instance) + newVal.list[index]['enabled'] = !enabled + window.request({ + method: 'POST', + url: '/nacos/v1/ns/instance/update', + data: {serviceName, clusterName, ip, port, weight, enable: !enabled}, + dataType: 'text', + beforeSend: () => this.setState({loading: true}), + success: () => this.setState({instance: newVal}), + complete: () => this.setState({loading: false}) + }) + } + + onChangePage(pageNum) { + this.setState({pageNum}, () => this.getInstanceList()) } render() { - const {clusterName} = this.props - const {instance = {}, pageSize, loading} = this.state + const {instance, pageSize, loading} = this.state return instance.count ? (
- - + `${val}`}/> + Object.keys(metadata).map(k => `${k}=${metadata[k]}`).join(',')} + /> this.openInstanceDialog(record)} >{I18N.EDITOR} + >{I18N[record.enabled ? 'OFFLINE' : 'ONLINE']} )}/>
@@ -78,7 +99,9 @@ class InstanceTable extends React.Component { ? ( this.onChange(clusterName, currentPage)} + total={instance.count} + pageSize={pageSize} + onChange={currentPage => this.onChangePage(currentPage)} /> ) : null