Fix link error
diff --git a/.roadhogrc.mock.js b/.roadhogrc.mock.js
index d255f73..e8f2052 100644
--- a/.roadhogrc.mock.js
+++ b/.roadhogrc.mock.js
@@ -5,7 +5,7 @@
import { TraceBrief, Trace } from './mock/trace'
import { makeExecutableSchema, addMockFunctionsToSchema } from 'graphql-tools';
import { graphql } from 'graphql';
-import { ClusterBrief, getServiceInstances, getAllServices, searchEndpoint } from './mock/metadata';
+import { ClusterBrief, getServiceInstances, getAllServices, searchEndpoint, EndpointInfo } from './mock/metadata';
import { IntValues, Thermodynamic } from './mock/metric';
import { getServiceTopN, getAllEndpointTopN, getServiceInstanceTopN, getEndpointTopN } from './mock/aggregation';
@@ -48,8 +48,9 @@
TraceBrief,
Trace,
IntValues,
+ EndpointInfo,
},
- preserveResolvers: true
+ preserveResolvers: true
});
const proxy = {
diff --git a/mock/metadata.js b/mock/metadata.js
index 4fdf8d4..999a76d 100644
--- a/mock/metadata.js
+++ b/mock/metadata.js
@@ -65,4 +65,5 @@
});
return data.endpointId;
},
+ EndpointInfo: () => mockjs.mock({ id: 5, name: 'endpoint-5', serviceId: 7, serviceName: 'service-7' }),
};
diff --git a/src/components/GlobalHeader/index.js b/src/components/GlobalHeader/index.js
index 7f931ec..115b584 100644
--- a/src/components/GlobalHeader/index.js
+++ b/src/components/GlobalHeader/index.js
@@ -81,8 +81,8 @@
onDurationToggle, onDurationReload, onRedirect: redirect,
onMenuClick,
} = this.props;
- const applications = applicationAlarmList.msgs.map(_ => ({ ..._, title: _.message, datetime: _.startTime }));
- const servers = serverAlarmList.msgs.map(_ => ({ ..._, title: _.message, datetime: _.startTime }));
+ const applications = applicationAlarmList.msgs.map(_ => ({ ..._, title: _.message, datetime: moment(_.startTime).format() }));
+ const servers = serverAlarmList.msgs.map(_ => ({ ..._, title: _.message, datetime: moment(_.startTime).format() }));
const menu = (
<Menu className={styles.menu} selectedKeys={[]} onClick={onMenuClick}>
<Menu.Item key="logout">
@@ -130,13 +130,13 @@
list={applications}
title="Service"
emptyText="No alarm"
- emptyImage="alarm-backgroud.png"
+ emptyImage="img/icon/alarm-backgroud.png"
/>
<NoticeIcon.Tab
list={servers}
title="ServiceInstance"
emptyText="No alarm"
- emptyImage="alarm-backgroud.png"
+ emptyImage="img/icon/alarm-backgroud.png"
/>
</NoticeIcon>
<Dropdown overlay={menu}>
diff --git a/src/components/Page/Search/index.js b/src/components/Page/Search/index.js
index f32da71..c47cabe 100644
--- a/src/components/Page/Search/index.js
+++ b/src/components/Page/Search/index.js
@@ -37,22 +37,21 @@
componentDidMount() {
if (this.props.variables && Object.keys(this.props.variables).length > 0) {
- this.originFetchServer('', !this.props.value.key);
+ this.originFetchServer('', this.props.value.key);
}
}
componentDidUpdate(prevProps) {
if (prevProps.variables !== this.props.variables) {
- this.originFetchServer('', true);
+ this.originFetchServer('', this.props.value.key);
}
}
- fetchServer = (value, isSelectOne) => {
+ fetchServer = (value, key) => {
if (value === undefined) {
return;
}
const { url, query, variables = {}, transform } = this.props;
- console.info(variables);
this.lastFetchId += 1;
const fetchId = this.lastFetchId;
this.setState({ data: [], fetching: true });
@@ -72,7 +71,15 @@
}
const list = body.data[Object.keys(body.data)[0]];
this.setState({ data: transform ? list.map(transform) : list, fetching: false });
- if (isSelectOne && this.state.data.length > 0) {
+ if (this.state.data.length < 1) {
+ return;
+ }
+ if (!key) {
+ this.handleSelect(this.state.data[0]);
+ return;
+ }
+ const option = this.state.data.find(_ => _.key === key);
+ if (!option) {
this.handleSelect(this.state.data[0]);
}
});
diff --git a/src/models/endpoint.js b/src/models/endpoint.js
index d4a7f20..bb617fc 100644
--- a/src/models/endpoint.js
+++ b/src/models/endpoint.js
@@ -175,6 +175,16 @@
}
`;
+const infoQuery = `
+ query Info($endpointId: ID!) {
+ endpointInfo: getEndpointInfo(endpointId: $endpointId) {
+ key: id
+ label: name
+ serviceId
+ serviceName
+ }
+ }
+`;
export default base({
namespace: 'endpoint',
state: {
@@ -219,6 +229,34 @@
dataQuery,
optionsQuery,
effects: {
+ *fetchInfo({ payload }, { call, put }) {
+ const response = yield call(exec, { query: infoQuery, variables: payload.variables });
+ const { data } = response;
+ if (!data.endpointInfo) {
+ return;
+ }
+ const { endpointInfo } = data;
+ yield put({
+ type: 'saveVariables',
+ payload: {
+ values: {
+ endpointId: endpointInfo.key,
+ serviceId: endpointInfo.serviceId,
+ },
+ labels: {
+ endpointId: endpointInfo.label,
+ serviceId: endpointInfo.serviceName,
+ },
+ },
+ });
+ yield put({
+ type: 'saveData',
+ payload: {
+ serviceInfo: { serviceId: endpointInfo.serviceId },
+ endpointInfo,
+ },
+ });
+ },
*fetchSpans({ payload }, { call, put }) {
const response = yield call(exec, { query: spanQuery, variables: payload.variables });
yield put({
@@ -294,21 +332,26 @@
payload: {
values: {
endpointId: state.key,
- serviceId: state.serviceId,
},
labels: {
endpointId: state.label,
- serviceId: state.serviceName,
},
},
});
dispatch({
type: 'saveData',
payload: {
- serviceInfo: { serviceId: state.serviceId },
endpointInfo: { key: state.key, label: state.label },
},
});
+ dispatch({
+ type: 'fetchInfo',
+ payload: {
+ variables: {
+ endpointId: state.key,
+ },
+ },
+ });
}
});
},
diff --git a/src/routes/Alarm/Alarm.js b/src/routes/Alarm/Alarm.js
index 4843954..d5c6183 100644
--- a/src/routes/Alarm/Alarm.js
+++ b/src/routes/Alarm/Alarm.js
@@ -19,6 +19,7 @@
import React, { PureComponent } from 'react';
import { connect } from 'dva';
import { Card, Input, Tabs, List, Avatar } from 'antd';
+import moment from 'moment';
import { Panel } from '../../components/Page';
import styles from './Alarm.less';
@@ -121,7 +122,7 @@
/>}
description={msg.message}
/>
- <div>{msg.startTime}</div>
+ <div>{moment(msg.startTime).format()}</div>
</List.Item>
)}
/>);
diff --git a/src/routes/Dashboard/Dashboard.js b/src/routes/Dashboard/Dashboard.js
index 8f61465..860f09e 100644
--- a/src/routes/Dashboard/Dashboard.js
+++ b/src/routes/Dashboard/Dashboard.js
@@ -51,7 +51,7 @@
}
render() {
- const { dashboard: { data }, globalVariables, duration } = this.props;
+ const { dashboard: { data }, globalVariables, duration, history } = this.props;
return (
<Panel globalVariables={globalVariables} onChange={this.handleDurationChange}>
<Row gutter={8}>
@@ -136,7 +136,7 @@
<RankList
data={data.getTopNSlowEndpoint}
renderValue={_ => `${_.value} ms`}
- onClick={(key) => redirect(history, '/monitor/endpoint', { key })}
+ onClick={(key, { label }) => redirect(history, '/monitor/endpoint', { key, label })}
/>
</Card>
</Col>
@@ -150,7 +150,7 @@
data={data.getTopNServiceThroughput}
renderValue={_ => `${_.value} cpm`}
color="#965fe466"
- onClick={(key) => redirect(history, '/monitor/service', { key })}
+ onClick={(key, { label }) => redirect(history, '/monitor/service', { key, label })}
/>
</Card>
</Col>
diff --git a/src/routes/Endpoint/Endpoint.js b/src/routes/Endpoint/Endpoint.js
index 7de5125..278b97b 100644
--- a/src/routes/Endpoint/Endpoint.js
+++ b/src/routes/Endpoint/Endpoint.js
@@ -287,7 +287,7 @@
</Select>
)}
</FormItem>
- {data.serviceInfo ? (
+ {data.serviceInfo && data.serviceInfo.serviceId ? (
<FormItem>
{getFieldDecorator('endpointId')(
<Search
diff --git a/src/routes/Topology/Topology.js b/src/routes/Topology/Topology.js
index 17c7b5c..6a42c05 100644
--- a/src/routes/Topology/Topology.js
+++ b/src/routes/Topology/Topology.js
@@ -150,12 +150,12 @@
renderActions = () => {
const { data: { appInfo } } = this.props.topology;
return [
- <Icon type="appstore" onClick={() => redirect(this.props.history, '/monitor/application', { key: appInfo.id, label: appInfo.name })} />,
+ <Icon type="appstore" onClick={() => redirect(this.props.history, '/monitor/service', { key: appInfo.id, label: appInfo.name })} />,
<Icon
type="exception"
onClick={() => redirect(this.props.history, '/trace',
{ values: {
- applicationId: appInfo.id,
+ serviceId: appInfo.id,
duration: { ...this.props.duration, input: this.props.globalVariables.duration },
},
labels: { applicationId: appInfo.name },
diff --git a/src/utils/utils.js b/src/utils/utils.js
index 130dd1c..753c166 100644
--- a/src/utils/utils.js
+++ b/src/utils/utils.js
@@ -136,7 +136,7 @@
}
export function redirect(history, pathname, param) {
- if (history.location.pathname === pathname) {
+ if (history.location && history.location.pathname === pathname) {
return;
}
history.push({ pathname, state: param });