Merge branch 'develop' of https://github.com/alibaba/nacos into develop
This commit is contained in:
commit
2d4667a8db
@ -162,4 +162,6 @@ public class Constants {
|
||||
public static final String NULL_STRING = "null";
|
||||
|
||||
public static final String NUMBER_PATTERN = "^\\d+$";
|
||||
|
||||
public static final String ANY_PATTERN = ".*";
|
||||
}
|
||||
|
@ -97,6 +97,7 @@ const I18N_CONF = {
|
||||
pubNoData: 'No results found.',
|
||||
columnServiceName: 'Service Name',
|
||||
groupName: 'Group Name',
|
||||
groupNamePlaceholder: 'Enter Group Name',
|
||||
columnClusterCount: 'Cluster Count',
|
||||
columnIpCount: 'Instance Count',
|
||||
columnHealthyInstanceCount: 'Healthy Instance Count',
|
||||
|
@ -96,7 +96,8 @@ const I18N_CONF = {
|
||||
query: '查询',
|
||||
pubNoData: '没有数据',
|
||||
columnServiceName: '服务名',
|
||||
groupName: '分组',
|
||||
groupName: '分组名称',
|
||||
groupNamePlaceholder: '请输入分组名称',
|
||||
columnClusterCount: '集群数目',
|
||||
columnIpCount: '实例数',
|
||||
columnHealthyInstanceCount: '健康实例数',
|
||||
|
@ -56,8 +56,11 @@ class ServiceList extends React.Component {
|
||||
total: 0,
|
||||
pageSize: 10,
|
||||
currentPage: 1,
|
||||
keyword: '',
|
||||
dataSource: [],
|
||||
search: {
|
||||
serviceName: '',
|
||||
groupName: '',
|
||||
},
|
||||
hasIpCount: !(localStorage.getItem('hasIpCount') === 'false'),
|
||||
};
|
||||
this.field = new Field(this);
|
||||
@ -78,13 +81,14 @@ class ServiceList extends React.Component {
|
||||
}
|
||||
|
||||
queryServiceList() {
|
||||
const { currentPage, pageSize, keyword, withInstances = false, hasIpCount } = this.state;
|
||||
const { currentPage, pageSize, search, withInstances = false, hasIpCount } = this.state;
|
||||
const parameter = [
|
||||
`hasIpCount=${hasIpCount}`,
|
||||
`withInstances=${withInstances}`,
|
||||
`pageNo=${currentPage}`,
|
||||
`pageSize=${pageSize}`,
|
||||
`keyword=${keyword}`,
|
||||
`serviceNameParam=${search.serviceName}`,
|
||||
`groupNameParam=${search.groupName}`,
|
||||
];
|
||||
request({
|
||||
url: `v1/ns/catalog/services?${parameter.join('&')}`,
|
||||
@ -164,6 +168,8 @@ class ServiceList extends React.Component {
|
||||
serviceList,
|
||||
serviceName,
|
||||
serviceNamePlaceholder,
|
||||
groupName,
|
||||
groupNamePlaceholder,
|
||||
hiddenEmptyService,
|
||||
query,
|
||||
create,
|
||||
@ -172,7 +178,7 @@ class ServiceList extends React.Component {
|
||||
sampleCode,
|
||||
deleteAction,
|
||||
} = locale;
|
||||
const { keyword, nowNamespaceName, nowNamespaceId, hasIpCount } = this.state;
|
||||
const { search, nowNamespaceName, nowNamespaceId, hasIpCount } = this.state;
|
||||
const { init, getValue } = this.field;
|
||||
this.init = init;
|
||||
this.getValue = getValue;
|
||||
@ -214,8 +220,19 @@ class ServiceList extends React.Component {
|
||||
<Input
|
||||
placeholder={serviceNamePlaceholder}
|
||||
style={{ width: 200 }}
|
||||
value={keyword}
|
||||
onChange={keyword => this.setState({ keyword })}
|
||||
value={search.serviceName}
|
||||
onChange={serviceName => this.setState({ search: { ...search, serviceName } })}
|
||||
onPressEnter={() =>
|
||||
this.setState({ currentPage: 1 }, () => this.queryServiceList())
|
||||
}
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem label={groupName}>
|
||||
<Input
|
||||
placeholder={groupNamePlaceholder}
|
||||
style={{ width: 200 }}
|
||||
value={search.groupName}
|
||||
onChange={groupName => this.setState({ search: { ...search, groupName } })}
|
||||
onPressEnter={() =>
|
||||
this.setState({ currentPage: 1 }, () => this.queryServiceList())
|
||||
}
|
||||
|
@ -150,10 +150,13 @@ public class CatalogController {
|
||||
List<ServiceDetailInfo> serviceDetailInfoList = new ArrayList<>();
|
||||
int pageNo = Integer.parseInt(WebUtils.required(request, "pageNo"));
|
||||
int pageSize = Integer.parseInt(WebUtils.required(request, "pageSize"));
|
||||
String keyword = WebUtils.optional(request, "keyword", StringUtils.EMPTY);
|
||||
String serviceName = WebUtils.optional(request, "serviceNameParam", StringUtils.EMPTY);
|
||||
String groupName = WebUtils.optional(request, "groupNameParam", StringUtils.EMPTY);
|
||||
String param = StringUtils.isBlank(serviceName) && StringUtils.isBlank(groupName) ?
|
||||
StringUtils.EMPTY : NamingUtils.getGroupedName(serviceName, groupName);
|
||||
|
||||
List<Service> serviceList = new ArrayList<>(8);
|
||||
serviceManager.getPagedService(namespaceId, pageNo, pageSize, keyword, StringUtils.EMPTY, serviceList, false);
|
||||
serviceManager.getPagedService(namespaceId, pageNo, pageSize, param, StringUtils.EMPTY, serviceList, false);
|
||||
|
||||
for (Service service : serviceList) {
|
||||
ServiceDetailInfo serviceDetailInfo = new ServiceDetailInfo();
|
||||
@ -257,12 +260,16 @@ public class CatalogController {
|
||||
|
||||
int page = Integer.parseInt(WebUtils.required(request, "pageNo"));
|
||||
int pageSize = Integer.parseInt(WebUtils.required(request, "pageSize"));
|
||||
String keyword = WebUtils.optional(request, "keyword", StringUtils.EMPTY);
|
||||
String serviceName = WebUtils.optional(request, "serviceNameParam", StringUtils.EMPTY);
|
||||
String groupName = WebUtils.optional(request, "groupNameParam", StringUtils.EMPTY);
|
||||
String param = StringUtils.isBlank(serviceName) && StringUtils.isBlank(groupName) ?
|
||||
StringUtils.EMPTY : NamingUtils.getGroupedName(serviceName, groupName);
|
||||
|
||||
String containedInstance = WebUtils.optional(request, "instance", StringUtils.EMPTY);
|
||||
boolean hasIpCount = Boolean.parseBoolean(WebUtils.optional(request, "hasIpCount", "false"));
|
||||
|
||||
List<Service> services = new ArrayList<>();
|
||||
int total = serviceManager.getPagedService(namespaceId, page - 1, pageSize, keyword, containedInstance, services, hasIpCount);
|
||||
int total = serviceManager.getPagedService(namespaceId, page - 1, pageSize, param, containedInstance, services, hasIpCount);
|
||||
|
||||
if (CollectionUtils.isEmpty(services)) {
|
||||
result.put("serviceList", Collections.emptyList());
|
||||
|
@ -269,10 +269,10 @@ public class ServiceController {
|
||||
|
||||
Map<String, List<Service>> services = new HashMap<>(16);
|
||||
if (StringUtils.isNotBlank(namespaceId)) {
|
||||
services.put(namespaceId, serviceManager.searchServices(namespaceId, ".*" + expr + ".*"));
|
||||
services.put(namespaceId, serviceManager.searchServices(namespaceId, Constants.ANY_PATTERN + expr + Constants.ANY_PATTERN));
|
||||
} else {
|
||||
for (String namespace : serviceManager.getAllNamespaces()) {
|
||||
services.put(namespace, serviceManager.searchServices(namespace, ".*" + expr + ".*"));
|
||||
services.put(namespace, serviceManager.searchServices(namespace, Constants.ANY_PATTERN + expr + Constants.ANY_PATTERN));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -675,7 +675,7 @@ public class ServiceManager implements RecordListener<Service> {
|
||||
return serviceMap.get(namespaceId);
|
||||
}
|
||||
|
||||
public int getPagedService(String namespaceId, int startPage, int pageSize, String keyword, String containedInstance, List<Service> serviceList, boolean hasIpCount) {
|
||||
public int getPagedService(String namespaceId, int startPage, int pageSize, String param, String containedInstance, List<Service> serviceList, boolean hasIpCount) {
|
||||
|
||||
List<Service> matchList;
|
||||
|
||||
@ -683,8 +683,12 @@ public class ServiceManager implements RecordListener<Service> {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(keyword)) {
|
||||
matchList = searchServices(namespaceId, ".*" + keyword + ".*");
|
||||
if (StringUtils.isNotBlank(param)) {
|
||||
StringJoiner regex = new StringJoiner(Constants.SERVICE_INFO_SPLITER);
|
||||
for (String s : param.split(Constants.SERVICE_INFO_SPLITER)) {
|
||||
regex.add(StringUtils.isBlank(s) ? Constants.ANY_PATTERN : Constants.ANY_PATTERN + s + Constants.ANY_PATTERN);
|
||||
}
|
||||
matchList = searchServices(namespaceId, regex.toString());
|
||||
} else {
|
||||
matchList = new ArrayList<>(chooseServiceMap(namespaceId).values());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user