feat: console add instance ephemeral

This commit is contained in:
LoadChange 2019-03-15 14:58:40 +08:00
parent 7bf60c18e7
commit feb466864e
3 changed files with 18 additions and 12 deletions

View File

@ -56,7 +56,7 @@ class EditInstanceDialog extends React.Component {
onConfirm() { onConfirm() {
const { serviceName, clusterName, getInstanceList, openLoading, closeLoading } = this.props; const { serviceName, clusterName, getInstanceList, openLoading, closeLoading } = this.props;
const { ip, port, weight, enabled, metadataText } = this.state.editInstance; const { ip, port, ephemeral, weight, enabled, metadataText } = this.state.editInstance;
request({ request({
method: 'PUT', method: 'PUT',
url: 'v1/ns/instance', url: 'v1/ns/instance',
@ -65,6 +65,7 @@ class EditInstanceDialog extends React.Component {
clusterName, clusterName,
ip, ip,
port, port,
ephemeral,
weight, weight,
enable: enabled, enable: enabled,
metadata: replaceEnter(METADATA_SEPARATOR)(metadataText), metadata: replaceEnter(METADATA_SEPARATOR)(metadataText),
@ -79,6 +80,7 @@ class EditInstanceDialog extends React.Component {
this.hide(); this.hide();
getInstanceList(); getInstanceList();
}, },
error: e => Message.error(e.responseText || 'error'),
complete: () => closeLoading(), complete: () => closeLoading(),
}); });
} }

View File

@ -14,7 +14,7 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { request } from '../../../globalLib'; import { request } from '../../../globalLib';
import { Button, ConfigProvider, Pagination, Table } from '@alifd/next'; import { Button, ConfigProvider, Message, Pagination, Table } from '@alifd/next';
import { HEALTHY_COLOR_MAPPING } from './constant'; import { HEALTHY_COLOR_MAPPING } from './constant';
import EditInstanceDialog from './EditInstanceDialog'; import EditInstanceDialog from './EditInstanceDialog';
@ -75,10 +75,8 @@ class InstanceTable extends React.Component {
switchState(index, record) { switchState(index, record) {
const { instance } = this.state; const { instance } = this.state;
const { ip, port, weight, enabled, metadata } = record; const { ip, port, ephemeral, weight, enabled, metadata } = record;
const { clusterName, serviceName } = this.props; const { clusterName, serviceName } = this.props;
const newVal = Object.assign({}, instance);
newVal.list[index].enabled = !enabled;
request({ request({
method: 'PUT', method: 'PUT',
url: 'v1/ns/instance', url: 'v1/ns/instance',
@ -87,13 +85,19 @@ class InstanceTable extends React.Component {
clusterName, clusterName,
ip, ip,
port, port,
ephemeral,
weight, weight,
enable: !enabled, enable: !enabled,
metadata: JSON.stringify(metadata), metadata: JSON.stringify(metadata),
}, },
dataType: 'text', dataType: 'text',
beforeSend: () => this.openLoading(), beforeSend: () => this.openLoading(),
success: () => this.setState({ instance: newVal }), success: () => {
const newVal = Object.assign({}, instance);
newVal.list[index].enabled = !enabled;
this.setState({ instance: newVal });
},
error: e => Message.error(e.responseText || 'error'),
complete: () => this.closeLoading(), complete: () => this.closeLoading(),
}); });
} }

File diff suppressed because one or more lines are too long