Skip to content

Commit

Permalink
[Improve] Refactor the menus (#3225)
Browse files Browse the repository at this point in the history
* [WIP][Improve] reorganize the menus

* icon style improvement

* menu icon style improvement

* FE components path bug fixed.

* [Improve] menu icon improvement

* menu improvement

* FE component bug fixed.

* menu path improvement

* menu improvement

* menu ddl improve

* mysql ddl improvement

* FE page path improvement

* logo style improvement

* FE vue components path improvement

* Transactional bug fixed.

* application services improvement

* [Bug] application mybatis Mapper bug fixed

* FE build failed bug fixed

* minor improvement

* LinkBadge component improvement

* FE api minor improvement

* [Improve] upgrade ddl improvement

---------

Co-authored-by: benjobs <[email protected]>
  • Loading branch information
wolfboys and benjobs authored Oct 15, 2023
1 parent 5879aec commit 6072491
Show file tree
Hide file tree
Showing 143 changed files with 1,027 additions and 1,179 deletions.
6 changes: 6 additions & 0 deletions streampark-console/streampark-console-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,12 @@
<optional>true</optional>
</dependency>

<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public RestResponse list(Application app, RestRequest request) {
@PostMapping("mapping")
@RequiresPermissions("app:mapping")
public RestResponse mapping(Application app) {
boolean flag = applicationInfoService.mapping(app);
boolean flag = applicationManageService.mapping(app);
return RestResponse.success(flag);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
@Slf4j
@Validated
@RestController
@RequestMapping("flink/project")
@RequestMapping("project")
public class ProjectController {

@Autowired private ProjectService projectService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.Getter;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;

Expand Down Expand Up @@ -112,7 +113,7 @@ public class Application implements Serializable {
private String k8sJmPodTemplate;
private String k8sTmPodTemplate;

private String ingressTemplate;
@Getter private String ingressTemplate;
private String defaultModeIngress;

/** flink-hadoop integration on flink-k8s mode */
Expand Down Expand Up @@ -252,10 +253,6 @@ public class Application implements Serializable {

private transient AppControl appControl;

public String getIngressTemplate() {
return ingressTemplate;
}

public void setDefaultModeIngress(String defaultModeIngress) {
this.defaultModeIngress = defaultModeIngress;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public class ApplicationBackUp {

private transient boolean backup;

public ApplicationBackUp() {}

public ApplicationBackUp(Application application) {
this.appId = application.getId();
this.sqlId = application.getSqlId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@

public interface ApplicationMapper extends BaseMapper<Application> {

IPage<Application> page(Page<Application> page, @Param("application") Application application);
IPage<Application> page(Page<Application> page, @Param("app") Application application);

Application getApp(@Param("application") Application application);
Application getApp(@Param("app") Application application);

void persistMetrics(@Param("application") Application application);
void persistMetrics(@Param("app") Application application);

List<Application> getByTeamId(@Param("teamId") Long teamId);

List<Application> getProbeApps();

boolean mapping(@Param("application") Application appParam);
boolean mapping(@Param("app") Application appParam);

List<String> getRecentK8sNamespace(@Param("limitSize") Integer limit);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,6 @@
*/
public interface ApplicationInfoService extends IService<Application> {

/**
* Maps the given application.
*
* @param appParam The application to be mapped.
* @return True if the mapping was successful, false otherwise.
*/
boolean mapping(Application appParam);

/**
* Checks the environment for the given application.
*
Expand Down Expand Up @@ -142,13 +134,6 @@ public interface ApplicationInfoService extends IService<Application> {
*/
AppExistsStateEnum checkExists(Application appParam);

/**
* Persists the metrics of the given application.
*
* @param appParam The application which metrics need to be persisted.
*/
void persistMetrics(Application appParam);

/**
* Reads the configuration for the given application and returns it as a String.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,21 @@ public interface ApplicationManageService extends IService<Application> {
*/
void toEffective(Application appParam);

/**
* Persists the metrics of the given application.
*
* @param appParam The application which metrics need to be persisted.
*/
void persistMetrics(Application appParam);

/**
* Maps the given application.
*
* @param appParam The application to be mapped.
* @return True if the mapping was successful, false otherwise.
*/
boolean mapping(Application appParam);

/**
* Checks if the given application is ready to build and update.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
import org.apache.streampark.console.core.service.SettingService;
import org.apache.streampark.console.core.service.VariableService;
import org.apache.streampark.console.core.service.application.ApplicationActionService;
import org.apache.streampark.console.core.service.application.ApplicationInfoService;
import org.apache.streampark.console.core.service.application.ApplicationManageService;
import org.apache.streampark.console.core.utils.FlinkK8sDataTypeConverterStub;
import org.apache.streampark.console.core.watcher.FlinkAppHttpWatcher;
Expand Down Expand Up @@ -133,9 +132,8 @@ public class ApplicationActionServiceImpl extends ServiceImpl<ApplicationMapper,
new ThreadPoolExecutor.AbortPolicy());

@Autowired private ApplicationBackUpService backUpService;
@Autowired private ApplicationManageService applicationManageService;

@Autowired private ApplicationInfoService applicationInfoService;
@Autowired private ApplicationManageService applicationManageService;

@Autowired private ApplicationConfigService configService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@

import static org.apache.streampark.common.enums.StorageType.LFS;
import static org.apache.streampark.console.core.watcher.FlinkK8sWatcherWrapper.Bridge.toTrackId;
import static org.apache.streampark.console.core.watcher.FlinkK8sWatcherWrapper.isKubernetesApp;

@Slf4j
@Service
Expand Down Expand Up @@ -455,22 +454,6 @@ public String getMain(Application appParam) {
return manifest.getMainAttributes().getValue("Main-Class");
}

@Override
public boolean mapping(Application appParam) {
boolean mapping = this.baseMapper.mapping(appParam);
Application application = getById(appParam.getId());
if (isKubernetesApp(application)) {
// todo mark
k8SFlinkTrackMonitor.doWatching(toTrackId(application));
if (K8sFlinkConfig.isV2Enabled()) {
flinkK8sObserver.watchApplication(application);
}
} else {
FlinkAppHttpWatcher.doWatching(application);
}
return mapping;
}

@Override
public String checkSavepointPath(Application appParam) throws Exception {
String savepointPath = appParam.getSavePoint();
Expand Down Expand Up @@ -505,11 +488,6 @@ public String checkSavepointPath(Application appParam) throws Exception {
}
}

@Override
public void persistMetrics(Application appParam) {
this.baseMapper.persistMetrics(appParam);
}

private Boolean checkJobName(String jobName) {
if (!StringUtils.isBlank(jobName.trim())) {
return JOB_NAME_PATTERN.matcher(jobName).matches()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,27 @@ public void toEffective(Application appParam) {
}
}

@Override
public void persistMetrics(Application appParam) {
this.baseMapper.persistMetrics(appParam);
}

@Override
public boolean mapping(Application appParam) {
boolean mapping = this.baseMapper.mapping(appParam);
Application application = getById(appParam.getId());
if (isKubernetesApp(application)) {
// todo mark
k8SFlinkTrackMonitor.doWatching(toTrackId(application));
if (K8sFlinkConfig.isV2Enabled()) {
flinkK8sObserver.watchApplication(application);
}
} else {
FlinkAppHttpWatcher.doWatching(application);
}
return mapping;
}

@Override
public Boolean delete(Application appParam) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public void init() {
public void doStop() {
log.info(
"FlinkAppHttpWatcher StreamPark Console will be shutdown,persistent application to database.");
WATCHING_APPS.forEach((k, v) -> applicationInfoService.persistMetrics(v));
WATCHING_APPS.forEach((k, v) -> applicationManageService.persistMetrics(v));
}

/**
Expand Down Expand Up @@ -529,7 +529,7 @@ private void doPersistMetrics(Application application, boolean stopWatch) {
} else {
WATCHING_APPS.put(application.getId(), application);
}
applicationInfoService.persistMetrics(application);
applicationManageService.persistMetrics(application);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void subscribeJobStatusChange(FlinkJobStatusChangeEvent event) {
}
// update application record
setByJobStatusCV(app, jobStatus);
applicationInfoService.persistMetrics(app);
applicationManageService.persistMetrics(app);

// email alerts when necessary
FlinkAppStateEnum state = app.getStateEnum();
Expand Down Expand Up @@ -148,7 +148,7 @@ public void subscribeMetricsChange(FlinkClusterMetricChangeEvent event) {
app.setTotalSlot(metrics.totalSlot());
app.setAvailableSlot(metrics.availableSlot());

applicationInfoService.persistMetrics(app);
applicationManageService.persistMetrics(app);
}

@SuppressWarnings("UnstableApiUsage")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,9 @@
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.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

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

Expand Down Expand Up @@ -67,19 +64,4 @@ public RestResponse menuList(Menu menu) {
Map<String, Object> maps = this.menuService.findMenus(menu);
return RestResponse.success(maps);
}

@Operation(summary = "Create menu")
@PostMapping("post")
@RequiresPermissions("menu:add")
public RestResponse addMenu(@Valid Menu menu) {
this.menuService.createMenu(menu);
return RestResponse.success();
}

@PutMapping("update")
@RequiresPermissions("menu:update")
public RestResponse updateMenu(@Valid Menu menu) throws Exception {
this.menuService.updateMenu(menu);
return RestResponse.success();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,5 @@ public interface MenuService extends IService<Menu> {

Map<String, Object> findMenus(Menu menu);

void createMenu(Menu menu);

void updateMenu(Menu menu) throws Exception;

/**
* Recursively delete menu buttons
*
* @param menuIds menuIds
*/
void deleteMenus(String[] menuIds) throws Exception;

List<VueRouter<Menu>> getUserRouters(Long userId, Long teamId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -125,28 +123,6 @@ public Map<String, Object> findMenus(Menu menu) {
return result;
}

@Override
public void createMenu(Menu menu) {
menu.setCreateTime(new Date());
setMenu(menu);
this.save(menu);
}

@Override
public void updateMenu(Menu menu) throws Exception {
menu.setModifyTime(new Date());
setMenu(menu);
baseMapper.updateById(menu);
}

@Override
public void deleteMenus(String[] menuIds) throws Exception {
// Find users associated with these menus/buttons
this.roleMenuServie.deleteByMenuId(menuIds);
// Recursively delete these menus/buttons
this.removeByIds(Arrays.asList(menuIds));
}

@Override
public List<VueRouter<Menu>> getUserRouters(Long userId, Long teamId) {
List<VueRouter<Menu>> routes = new ArrayList<>();
Expand All @@ -165,15 +141,4 @@ public List<VueRouter<Menu>> getUserRouters(Long userId, Long teamId) {
});
return VueRouterUtils.buildVueRouter(routes);
}

private void setMenu(Menu menu) {
if (menu.getParentId() == null) {
menu.setParentId(0L);
}
if (Menu.TYPE_BUTTON.equals(menu.getType())) {
menu.setPath(null);
menu.setIcon(null);
menu.setComponent(null);
}
}
}
Loading

0 comments on commit 6072491

Please sign in to comment.