All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
static.console-fe.src.pages.ServiceManagement.ServiceDetail.ServiceDetail.js Maven / Gradle / Ivy
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import React from 'react';
import PropTypes from 'prop-types';
import { request } from '@/globalLib';
import { Input, Button, Card, ConfigProvider, Form, Loading, Message } from '@alifd/next';
import EditServiceDialog from './EditServiceDialog';
import EditClusterDialog from './EditClusterDialog';
import InstanceTable from './InstanceTable';
import { getParameter } from 'utils/nacosutil';
import MonacoEditor from 'components/MonacoEditor';
import { MONACO_READONLY_OPTIONS, METADATA_ENTER } from './constant';
import './ServiceDetail.scss';
const FormItem = Form.Item;
const pageFormLayout = {
labelCol: { fixedSpan: 10 },
wrapperCol: { span: 14 },
};
@ConfigProvider.config
class ServiceDetail extends React.Component {
static displayName = 'ServiceDetail';
static propTypes = {
locale: PropTypes.object,
history: PropTypes.object,
location: PropTypes.object,
};
constructor(props) {
super(props);
this.editServiceDialog = React.createRef();
this.editClusterDialog = React.createRef();
this.state = {
serviceName: getParameter(props.location.search, 'name'),
groupName: getParameter(props.location.search, 'groupName'),
loading: false,
currentPage: 1,
clusters: [],
instances: {},
service: {},
pageSize: 10,
pageNum: {},
};
}
componentDidMount() {
if (!this.state.serviceName) {
this.props.history.goBack();
return;
}
this.getServiceDetail();
}
getServiceDetail() {
const { serviceName, groupName } = this.state;
request({
url: `v1/ns/catalog/service?serviceName=${serviceName}&groupName=${groupName}`,
beforeSend: () => this.openLoading(),
success: ({ clusters = [], service = {} }) => this.setState({ service, clusters }),
error: e => Message.error(e.responseText || 'error'),
complete: () => this.closeLoading(),
});
}
openLoading() {
this.setState({ loading: true });
}
closeLoading() {
this.setState({ loading: false });
}
openEditServiceDialog() {
this.editServiceDialog.current.getInstance().show(this.state.service);
}
openClusterDialog(cluster) {
this.editClusterDialog.current.getInstance().show(cluster);
}
render() {
const { locale = {} } = this.props;
const { serviceName, groupName, loading, service = {}, clusters } = this.state;
const { metadata = {}, selector = {} } = service;
let metadataText = '';
if (Object.keys(metadata).length) {
metadataText = JSON.stringify(metadata, null, '\t');
}
return (
{locale.serviceDetails}
this.props.history.goBack()}
>
{locale.back}
this.openEditServiceDialog()}
>
{locale.editService}
{clusters.map(cluster => (
this.openClusterDialog(cluster)}>
{locale.editCluster}
}
>
))}
this.openLoading()}
closeLoading={() => this.closeLoading()}
getServiceDetail={() => this.getServiceDetail()}
/>
this.openLoading()}
closeLoading={() => this.closeLoading()}
getServiceDetail={() => this.getServiceDetail()}
/>
);
}
}
export default ServiceDetail;