Skip to content

Commit

Permalink
[ISSUE apache#86] Add view controllers to console (apache#88)
Browse files Browse the repository at this point in the history
* Add view controller

* Some fixes to the position of the dynamic properties in the request, changes to the controller, and added comments to the config table

* improve somme method name

* Sync the modification of apache#85

* Sync the modification of apache#85

* Removed the use of delete annotations

---------

Co-authored-by: 周倬贤 <14100340+zhou-zhuoxian@user.noreply.gitee.com>
  • Loading branch information
zzxxiansheng and 周倬贤 committed Apr 7, 2024
1 parent 6f268a0 commit b65a406
Show file tree
Hide file tree
Showing 84 changed files with 2,176 additions and 266 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@SpringBootApplication
@EnableTransactionManagement
@EnableAspectJAutoProxy(exposeProxy = true)
public class EventMeshDashboardApplication {

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/

package org.apache.eventmesh.dashboard.console.controller;


import org.apache.eventmesh.dashboard.console.modle.vo.cluster.GetClusterBaseMessageVO;
import org.apache.eventmesh.dashboard.console.modle.vo.cluster.ResourceNumVO;
import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController

public class ClusterController {

@Autowired
ClusterService clusterService;

@GetMapping("/cluster/getResourceNum")
public ResourceNumVO getResourceNumByClusterId(Long clusterId) {
return clusterService.getResourceNumByCluster(clusterId);
}


@GetMapping("/cluster/getBaseMessage")
public GetClusterBaseMessageVO getClusterBaseMessage(Long clusterId) {
return clusterService.getClusterBaseMessage(clusterId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/

package org.apache.eventmesh.dashboard.console.controller;

import org.apache.eventmesh.dashboard.console.entity.config.ConfigEntity;
import org.apache.eventmesh.dashboard.console.modle.dto.config.DetailConfigsVO;
import org.apache.eventmesh.dashboard.console.modle.dto.config.GetConfigsListDTO;
import org.apache.eventmesh.dashboard.console.modle.dto.config.UpdateConfigDTO;
import org.apache.eventmesh.dashboard.console.service.config.ConfigService;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ConfigController {

@Autowired
private ConfigService configService;

@PostMapping("/cluster/config/updateConfigs")
public String updateConfigsByTypeAndId(@Validated @RequestBody UpdateConfigDTO updateConfigDTO) {
try {
configService.updateConfigsByInstanceId(updateConfigDTO.getUsername(), updateConfigDTO.getClusterId(), updateConfigDTO.getInstanceType(),
updateConfigDTO.getInstanceId(), updateConfigDTO.getChangeConfigDTOS());
} catch (Exception e) {
return e.getMessage();
}
return "success";
}


@PostMapping("/cluster/config/getInstanceDetailConfigs")
public List<DetailConfigsVO> getInstanceDetailConfigs(@Validated @RequestBody GetConfigsListDTO getConfigsListDTO) {
List<ConfigEntity> configEntityList = configService.selectToFront(getConfigsListDTO.getInstanceId(),
getConfigsListDTO.getInstanceType(), getConfigsListDTO);
Map<String, String> stringStringConcurrentHashMap = configService.selectDefaultConfig(getConfigsListDTO.getBusinessType(),
getConfigsListDTO.getInstanceId(), getConfigsListDTO.getInstanceType());
ArrayList<DetailConfigsVO> showDetailConfigsVOS = new ArrayList<>();
configEntityList.forEach(n -> {
DetailConfigsVO showDetailConfigsVO = new DetailConfigsVO();
showDetailConfigsVO.setDefaultValue(stringStringConcurrentHashMap.get(n.getConfigName()));
showDetailConfigsVO.setIsModify(n.getIsModify());
showDetailConfigsVO.setConfigName(n.getConfigName());
showDetailConfigsVO.setConfigValue(n.getConfigValue());
showDetailConfigsVO.setAlreadyUpdate(n.getAlreadyUpdate());
showDetailConfigsVOS.add(showDetailConfigsVO);
});
return showDetailConfigsVOS;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,73 @@

package org.apache.eventmesh.dashboard.console.controller;

import org.apache.eventmesh.dashboard.service.meta.ConnectionCore;
import org.apache.eventmesh.dashboard.console.entity.config.ConfigEntity;
import org.apache.eventmesh.dashboard.console.entity.connector.ConnectorEntity;
import org.apache.eventmesh.dashboard.console.modle.dto.connection.AddConnectionDTO;
import org.apache.eventmesh.dashboard.console.modle.dto.connection.CreateConnectionDTO;
import org.apache.eventmesh.dashboard.console.modle.dto.connection.GetConnectionListDTO;
import org.apache.eventmesh.dashboard.console.modle.vo.connection.ConnectionListVO;
import org.apache.eventmesh.dashboard.console.service.connection.ConnectionDataService;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@RestController
public class ConnectionController {

/**
* TODO expose implement by FunctionManager
*/
ConnectionCore connectionCore;
@Autowired
private ConnectionDataService connectionDataService;

/**
* Query Connection List
* <p>
* The subscription information of SourceConnector and SinkConnector reported by EventMesh Runtime to the meta,
* containing the configuration of each connection.
* 'type' only can be Sink or Source
*
* @param page the page number
* @param size the page size
* @return A paged list of connection configuration and total number of pages
* @param type
* @return
*/
@GetMapping("/connection")
public String listConnections(@RequestParam("page") Integer page, @RequestParam("size") String size) {
return null;
@GetMapping("/cluster/connection/getConnectorBusinessType")
public List<String> getConnectorBusinessType(String type) {
return connectionDataService.getConnectorBusinessType(type);
}

@GetMapping("/cluster/connection/getConnectorConfigs")
public List<ConfigEntity> getConnectorConfigsByClassAndVersion(String version, String classType) {
return connectionDataService.getConnectorConfigsByClassAndVersion(classType, version);
}


@GetMapping("/cluster/connection/showCreateConnectionMessage")
public AddConnectionDTO showCreateConnectionMessage() {
return new AddConnectionDTO();
}


@PostMapping("/cluster/connection/createConnection")
public String createConnection(@Validated @RequestBody CreateConnectionDTO createConnectionDTO) {
try {
connectionDataService.createConnection(createConnectionDTO);

} catch (Exception e) {
return e.getMessage();
}
return "success";
}


@PostMapping("/cluster/connection/getConnectionList")
public List<ConnectionListVO> getConnectionList(@Validated @RequestBody GetConnectionListDTO getConnectionListDTO) {
return connectionDataService.getConnectionToFrontByCluster(getConnectionListDTO.getClusterId(), getConnectionListDTO);
}

@GetMapping("/cluster/connection/getConnectorDetail")
public ConnectorEntity getConnectorDetail(Long connectorId) {
return connectionDataService.getConnectorById(connectorId);
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/

package org.apache.eventmesh.dashboard.console.controller;

import org.apache.eventmesh.dashboard.console.entity.health.HealthCheckResultEntity;
import org.apache.eventmesh.dashboard.console.modle.vo.health.InstanceLiveProportionVo;
import org.apache.eventmesh.dashboard.console.service.health.HealthDataService;

import java.sql.Timestamp;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HealthController {

@Autowired
HealthDataService healthDataService;

@GetMapping("/cluster/health/getHistoryLiveStatus")
public List<HealthCheckResultEntity> getHistoryLiveStatusById(Integer type, Long instanceId, String startTime) {
Timestamp timestamp = Timestamp.valueOf(startTime);
return healthDataService.getInstanceLiveStatusHistory(type, instanceId, timestamp);
}

@GetMapping("/cluster/health/getInstanceLiveProportion")
public InstanceLiveProportionVo getInstanceLiveProportion(Integer instanceType, Long theClusterId) {
return healthDataService.getInstanceLiveProportion(theClusterId, instanceType);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/

package org.apache.eventmesh.dashboard.console.controller;

import org.apache.eventmesh.dashboard.console.entity.log.LogEntity;
import org.apache.eventmesh.dashboard.console.modle.dto.log.GetLogListDTO;
import org.apache.eventmesh.dashboard.console.service.log.LogService;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class LogController {

@Autowired
private LogService logService;

@PostMapping("/cluster/log/getList")
public List<LogEntity> getLogLIstToFront(@Validated @RequestBody GetLogListDTO getLogListDTO) {
return logService.getLogListByCluster(getLogListDTO);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/

package org.apache.eventmesh.dashboard.console.controller;

import org.apache.eventmesh.dashboard.console.entity.runtime.RuntimeEntity;
import org.apache.eventmesh.dashboard.console.modle.dto.runtime.GetRuntimeListDTO;
import org.apache.eventmesh.dashboard.console.service.runtime.RuntimeService;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class RuntimeController {

@Autowired
private RuntimeService runtimeService;

@PostMapping("/clusterId/runtime/getList")
public List<RuntimeEntity> getRuntimeList(@Validated @RequestBody GetRuntimeListDTO getRuntimeListDTO) {
return runtimeService.getRuntimeToFrontByClusterId(getRuntimeListDTO.getClusterId(), getRuntimeListDTO);
}


}
Loading

0 comments on commit b65a406

Please sign in to comment.