Skip to content

Commit

Permalink
[ISSUE-alibaba#3005] fix ClusterController 403 and some display wrong (
Browse files Browse the repository at this point in the history
…alibaba#4512)

* fix 3005

* fix 3005
  • Loading branch information
wangweizZZ authored Dec 23, 2020
1 parent 638d89b commit ce57b98
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
@JsonTypeInfo(use = Id.NAME, property = "type", defaultImpl = None.class)
@JsonSubTypes({@JsonSubTypes.Type(name = Http.TYPE, value = Http.class),
@JsonSubTypes.Type(name = Mysql.TYPE, value = Mysql.class),
@JsonSubTypes.Type(name = Tcp.TYPE, value = Tcp.class)})
@JsonSubTypes.Type(name = Tcp.TYPE, value = Tcp.class),
@JsonSubTypes.Type(name = None.TYPE, value = None.class)})
public abstract class AbstractHealthChecker implements Cloneable, Serializable {

private static final long serialVersionUID = 3848305577423336421L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class EditClusterDialog extends React.Component {
name,
serviceName,
metadataText,
defaultCheckPort,
defCkport,
useIPPort4Check,
healthChecker,
} = this.state.editCluster;
Expand All @@ -74,7 +74,7 @@ class EditClusterDialog extends React.Component {
serviceName,
clusterName: name,
metadata: metadataText,
checkPort: defaultCheckPort,
checkPort: defCkport,
useInstancePort4Check: useIPPort4Check,
healthChecker: JSON.stringify(healthChecker),
},
Expand Down Expand Up @@ -106,7 +106,7 @@ class EditClusterDialog extends React.Component {
const {
healthChecker = {},
useIPPort4Check,
defaultCheckPort = '80',
defCkport = '80',
metadataText = '',
} = editCluster;
const { type, path, headers } = healthChecker;
Expand Down Expand Up @@ -139,8 +139,8 @@ class EditClusterDialog extends React.Component {
<Form.Item label={`${checkPort}:`}>
<Input
className="in-text"
value={defaultCheckPort}
onChange={defaultCheckPort => this.onChangeCluster({ defaultCheckPort })}
value={defCkport}
onChange={defCkport => this.onChangeCluster({ defCkport })}
/>
</Form.Item>
<Form.Item label={`${useIpPortCheck}:`}>
Expand Down
2 changes: 1 addition & 1 deletion console/src/main/resources/static/css/main.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion console/src/main/resources/static/js/main.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import com.alibaba.nacos.api.common.Constants;
import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.api.naming.CommonParams;
import com.alibaba.nacos.api.naming.pojo.Cluster;
import com.alibaba.nacos.api.naming.utils.NamingUtils;
import com.alibaba.nacos.auth.annotation.Secured;
import com.alibaba.nacos.auth.common.ActionTypes;
Expand Down Expand Up @@ -93,22 +92,7 @@ public ObjectNode serviceDetail(@RequestParam(defaultValue = Constants.DEFAULT_N

ObjectNode detailView = JacksonUtils.createEmptyJsonNode();
detailView.replace("service", serviceObject);

List<Cluster> clusters = new ArrayList<>();

for (com.alibaba.nacos.naming.core.Cluster cluster : detailedService.getClusterMap().values()) {
Cluster clusterView = new Cluster();
clusterView.setName(cluster.getName());
clusterView.setHealthChecker(cluster.getHealthChecker());
clusterView.setMetadata(cluster.getMetadata());
clusterView.setUseIPPort4Check(cluster.isUseIPPort4Check());
clusterView.setDefaultPort(cluster.getDefaultPort());
clusterView.setDefaultCheckPort(cluster.getDefaultCheckPort());
clusterView.setServiceName(cluster.getService().getName());
clusters.add(clusterView);
}

detailView.replace("clusters", JacksonUtils.transferToJsonNode(clusters));
detailView.replace("clusters", JacksonUtils.transferToJsonNode(detailedService.getClusterMap().values()));

return detailView;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.alibaba.nacos.naming.core.ServiceManager;
import com.alibaba.nacos.naming.misc.Loggers;
import com.alibaba.nacos.naming.misc.UtilsAndCommons;
import com.alibaba.nacos.naming.web.NamingResourceParser;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
Expand Down Expand Up @@ -59,7 +60,7 @@ public class ClusterController {
* @throws Exception if failed
*/
@PutMapping
@Secured(action = ActionTypes.WRITE)
@Secured(action = ActionTypes.WRITE, parser = NamingResourceParser.class)
public String update(HttpServletRequest request) throws Exception {

String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID, Constants.DEFAULT_NAMESPACE_ID);
Expand Down

0 comments on commit ce57b98

Please sign in to comment.