Skip to content

Commit

Permalink
[Feature] New Home (DataLinkDC#3630)
Browse files Browse the repository at this point in the history
Co-authored-by: gaoyan1998 <gaoyan1998@users.noreply.github.com>
  • Loading branch information
gaoyan1998 and gaoyan1998 authored Jul 8, 2024
1 parent a8e4010 commit 524ffc4
Show file tree
Hide file tree
Showing 43 changed files with 801 additions and 1,250 deletions.
2 changes: 1 addition & 1 deletion dinky-admin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@
<dependency>
<groupId>com.github.jsqlparser</groupId>
<artifactId>jsqlparser</artifactId>
<version>4.4</version>
<version>4.9</version>
</dependency>
<!-- for cache-->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.dinky.data.constant.DirConstant;
import org.dinky.data.constant.PermissionConstants;
import org.dinky.data.dto.TreeNodeDTO;
import org.dinky.data.metrics.MetricsTotal;
import org.dinky.data.result.Result;
import org.dinky.service.SystemService;

Expand Down Expand Up @@ -50,6 +51,12 @@ public class SystemController {

private final SystemService systemService;

@GetMapping("/getSysInfo")
@ApiOperation("Get System Info")
public Result<MetricsTotal> getSysInfo() {
return Result.succeed(new MetricsTotal());
}

/**
* All log files for this project
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import com.fasterxml.jackson.databind.node.ObjectNode;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.lang.tree.Tree;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
Expand Down Expand Up @@ -276,4 +277,11 @@ public Result<Void> uploadTaskJson(@RequestParam("file") MultipartFile file) thr
public Result<Tree<Integer>> queryAllCatalogue() {
return taskService.queryAllCatalogue();
}

@GetMapping("/getUserTask")
@ApiOperation("Get order task")
public Result<List<TaskDTO>> getMyTask() {
int id = StpUtil.getLoginIdAsInt();
return Result.succeed(taskService.getUserTasks(id));
}
}
10 changes: 10 additions & 0 deletions dinky-admin/src/main/java/org/dinky/data/dto/TaskDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.dinky.data.typehandler.ListTypeHandler;
import org.dinky.job.JobConfig;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -234,6 +235,9 @@ public class TaskDTO extends AbstractStatementDTO {
@TableField(typeHandler = ListTypeHandler.class)
private List<Integer> secondLevelOwners;

@ApiModelProperty(value = "Update Time", dataType = "LocalDateTime", example = "2021-05-28 00:00:00")
private LocalDateTime updateTime;

public JobConfig getJobConfig() {

Map<String, String> parsedConfig =
Expand All @@ -254,4 +258,10 @@ public Task buildTask() {
BeanUtil.copyProperties(this, task);
return task;
}

public static TaskDTO fromTask(Task task) {
TaskDTO dto = new TaskDTO();
BeanUtil.copyProperties(task, dto);
return dto;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,17 @@
public class ListTypeHandler extends AbstractJsonTypeHandler<List<Object>> {
private static final Logger log = LoggerFactory.getLogger(FastjsonTypeHandler.class);

public ListTypeHandler(Class<?> type) {
super(type);
}

@Override
protected List<Object> parse(String json) {
public List<Object> parse(String json) {
return new JSONArray(json).toList(Object.class);
}

@Override
protected String toJson(List<Object> obj) {
public String toJson(List<Object> obj) {
return new JSONArray(obj).toString();
}
}
7 changes: 7 additions & 0 deletions dinky-admin/src/main/java/org/dinky/service/TaskService.java
Original file line number Diff line number Diff line change
Expand Up @@ -296,4 +296,11 @@ public interface TaskService extends ISuperService<Task> {
* @return
*/
Boolean checkTaskOperatePermission(Integer taskId);

/**
* Get user tasks
* @param userId
* @return
*/
List<TaskDTO> getUserTasks(Integer userId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
Expand Down Expand Up @@ -1020,6 +1021,37 @@ public Boolean checkTaskOperatePermission(Integer taskId) {
return null;
}

@Override
public List<TaskDTO> getUserTasks(Integer userId) {
Map<Integer, TaskDTO> tskMap = new HashMap<>();
// 流式获取数据,防止OOM
baseMapper.selectList(Wrappers.emptyWrapper(), resultContext -> {
Task task = resultContext.getResultObject();
if (hasTaskOperatePermission(task.getFirstLevelOwner(), task.getSecondLevelOwners())) {
// 去掉statement,防止OOM
task.setStatement(null);
tskMap.put(task.getJobInstanceId(), TaskDTO.fromTask(task));
if (tskMap.size() >= 1000) {
// 任务太多了,停止查询
resultContext.stop();
}
}
});

LambdaQueryWrapper<JobInstance> wrapper = new LambdaQueryWrapper<>();
wrapper.in(JobInstance::getId, tskMap.keySet());
jobInstanceService.getBaseMapper().selectList(wrapper, resultContext -> {
JobInstance jobInstance = resultContext.getResultObject();
TaskDTO taskDTO = tskMap.get(jobInstance.getId());
if (Objects.nonNull(taskDTO)) {
taskDTO.setStatus(jobInstance.getStatus());
}
});

List<TaskDTO> tasks = new ArrayList<>(tskMap.values());
return tasks;
}

private Boolean hasTaskOperatePermission(Integer firstLevelOwner, List<Integer> secondLevelOwners) {
boolean isFirstLevelOwner = firstLevelOwner != null && firstLevelOwner == StpUtil.getLoginIdAsInt();
if (TaskOwnerLockStrategyEnum.OWNER.equals(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ public class MetricsTotal implements Serializable {
private Jvm jvm = Jvm.of();
private Cpu cpu = Cpu.of();
private Mem mem = Mem.of();
private SystemInfo systemInfo = SystemInfo.of();
}
52 changes: 52 additions & 0 deletions dinky-common/src/main/java/org/dinky/data/metrics/SystemInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
*
* 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.dinky.data.metrics;

import java.util.Map;
import java.util.Properties;

import lombok.Data;

@Data
public class SystemInfo {
private String osName;
private String osArch;
private String osVersion;
private String jvmVersion;
private String jvmVendor;
private String jvmName;
private String computerName;
private String computerUser;

public static SystemInfo of() {
SystemInfo system = new SystemInfo();
Properties props = System.getProperties();
system.setOsName(props.getProperty("os.name"));
system.setOsArch(props.getProperty("os.arch"));
system.setOsVersion(props.getProperty("os.version"));
system.setJvmVersion(props.getProperty("java.vm.version"));
system.setJvmVendor(props.getProperty("java.vm.vendor"));
system.setJvmName(props.getProperty("java.vm.name"));
Map<String, String> map = System.getenv();
system.setComputerName(map.get("NAME"));
system.setComputerUser(map.get("USER"));
return system;
}
}
14 changes: 7 additions & 7 deletions dinky-web/config/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ export default [
layout: false,
hideInMenu: true
},
// {
// path: '/home',
// name: 'home',
// icon: 'HomeOutlined',
// footerRender: false,
// component: './Home'
// },
{
path: '/home',
name: 'home',
icon: 'HomeOutlined',
footerRender: false,
component: './Home'
},
{
path: '/datastudio',
name: 'datastudio',
Expand Down
20 changes: 11 additions & 9 deletions dinky-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,23 @@
"@ant-design/pro-layout": "^7.19.8",
"@ant-design/pro-table": "^3.16.1",
"@ant-design/use-emotion-css": "^1.0.4",
"@antv/g2": "^5.2.0",
"@antv/layout": "0.3.25",
"@antv/x6": "^2.18.1",
"@antv/x6-plugin-selection": "^2.2.2",
"@antv/x6-react-shape": "^2.2.3",
"@babel/runtime": "^7.24.7",
"@monaco-editor/react": "^4.6.0",
"@umijs/route-utils": "^4.0.1",
"@xterm/addon-fit": "^0.10.0",
"@xterm/xterm": "^5.5.0",
"antd": "^5.18.2",
"antd-style": "^3.6.2",
"butterfly-dag": "^4.3.28",
"classnames": "^2.5.1",
"dayjs": "^1.11.11",
"echarts": "^5.5.0",
"echarts-for-react": "^3.0.2",
"jquery": "^3.7.1",
"js-cookie": "^3.0.5",
"lodash": "^4.17.21",
Expand All @@ -66,6 +73,7 @@
"react": "^18.3.1",
"react-countup": "^6.5.3",
"react-dom": "^18.3.1",
"react-grid-layout": "^1.4.4",
"react-helmet-async": "^2.0.5",
"react-lineage-dag": "^2.0.36",
"react-markdown": "^9.0.1",
Expand All @@ -78,31 +86,25 @@
"styled-components": "^6.1.1",
"use-sse": "^2.0.1",
"uuid": "^10.0.0",
"echarts": "^5.5.0",
"echarts-for-react": "^3.0.2",
"react-grid-layout": "^1.4.4",
"@babel/runtime": "^7.24.7",
"websocket": "^1.0.35",
"@xterm/xterm": "^5.5.0",
"@xterm/addon-fit": "^0.10.0"
"websocket": "^1.0.35"
},
"devDependencies": {
"@ant-design/pro-cli": "^3.2.1",
"@types/classnames": "^2.3.1",
"@types/express": "^4.17.21",
"js-cookie": "^3.0.5",
"@types/history": "^5.0.0",
"@types/lodash": "^4.17.5",
"@types/react": "^18.2.39",
"@types/react-dom": "^18.2.17",
"@types/react-grid-layout": "^1.3.5",
"@types/react-helmet": "^6.1.9",
"@umijs/lint": "^4.2.11",
"@umijs/max": "^4.2.11",
"@types/react-grid-layout": "^1.3.5",
"cross-env": "^7.0.3",
"eslint": "^9.3.0",
"express": "^4.19.2",
"husky": "^9.0.11",
"js-cookie": "^3.0.5",
"lint-staged": "^15.2.4",
"prettier": "^3.2.5",
"react-dev-inspector": "^2.0.1",
Expand Down
2 changes: 1 addition & 1 deletion dinky-web/src/locales/en-US/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

export default {
'menu.welcome': 'Welcome',
'menu.home': 'Home',
'menu.home': 'Worker place',
'menu.exception.403': '403',
'menu.exception.404': '404',
'menu.exception.500': '500',
Expand Down
36 changes: 4 additions & 32 deletions dinky-web/src/locales/en-US/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,38 +266,10 @@ export default {
*
* */

'home.develop': 'Data Develop',
'home.develop.re': 'Resource Registration',
'home.develop.re.ag': 'Alarm Group',
'home.develop.re.ai': 'Alarm Instance',
'home.develop.re.cc': 'Cluster Configuration',
'home.develop.re.ci': 'Flink Cluster Instance',
'home.develop.re.ds': 'Data Source',
'home.develop.re.git': 'Git Project',
'home.develop.re.gv': 'Global Variables',
'home.job.batch': 'Batch Job',
'home.job.development': 'Development',
'home.job.failed': 'Failed Today',
'home.job.failed.handle': 'Handled',
'home.job.failed.name': 'Job Name',
'home.job.failed.rank': 'Rank',
'home.job.failed.time': 'Abnormal Time',
'home.job.failed.unhandle': 'Currently Unhandled Failure',
'home.job.finished': 'Completed Today',
'home.job.instance': 'Task Instance',
'home.job.metrics': 'Job Monitoring',
'home.job.online': 'Online Today',
'home.job.onlineRate': 'Number of Jobs Online Rate',
'home.job.recovery': 'Recovery Today',
'home.job.recovery.rate': 'Recovery Rate',
'home.job.running': 'Currently Running',
'home.job.running.dayonday': 'Day on Day Ratio',
'home.job.running.status': 'Current Job Running Status',
'home.job.stream': 'Streaming Job',
'home.server.load': 'Server Load',
'home.server.load.bad': 'Bad',
'home.server.load.excellent': 'Excellent',
'home.server.load.good': 'Good',
'home.fast.link': 'Quick Start / Easy Navigation',
'home.mywork': 'My Task',
'home.allwork': 'All Task',
'home.task.not.desc': 'No mission statement at this time',
/**
*
* layouts
Expand Down
2 changes: 1 addition & 1 deletion dinky-web/src/locales/zh-CN/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

export default {
'menu.welcome': '欢迎',
'menu.home': '首页',
'menu.home': '工作台',
'menu.exception.403': '403',
'menu.exception.404': '404',
'menu.exception.500': '500',
Expand Down
Loading

0 comments on commit 524ffc4

Please sign in to comment.