mirror of
https://gitee.com/dromara/Jpom.git
synced 2024-12-02 20:08:40 +08:00
多个分组采用不同颜色来快速区分
This commit is contained in:
parent
8a90bcc5ce
commit
ae1b79023c
@ -16,6 +16,8 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@ -53,17 +55,26 @@ public class ManageControl extends BaseController {
|
||||
// 查询数据
|
||||
JSONObject json = manageService.getAllProjectInfo();
|
||||
// 转换为数据
|
||||
JSONArray array = new JSONArray();
|
||||
List<ProjectInfoModel> array = new ArrayList<>();
|
||||
Set<String> setKey = json.keySet();
|
||||
for (String asetKey : setKey) {
|
||||
ProjectInfoModel projectInfoModel = manageService.getProjectInfo(asetKey);
|
||||
String result = commandService.execCommand(CommandService.CommandOp.status, projectInfoModel);
|
||||
JSONObject jsonObject = json.getJSONObject(asetKey);
|
||||
boolean status = result.contains(CommandService.RUNING_TAG);
|
||||
jsonObject.put("status", status);
|
||||
array.add(jsonObject);
|
||||
projectInfoModel.setStatus(status);
|
||||
// jsonObject.put("status", status);
|
||||
array.add(projectInfoModel);
|
||||
}
|
||||
return PageUtil.getPaginate(200, "查询成功!", array);
|
||||
array.sort((o1, o2) -> {
|
||||
String group1 = o1.getGroup();
|
||||
String group2 = o2.getGroup();
|
||||
if (group1 == null || group2 == null) {
|
||||
return 0;
|
||||
}
|
||||
return group1.compareTo(group2);
|
||||
});
|
||||
return PageUtil.getPaginate(200, "查询成功!", (JSONArray) JSONArray.toJSON(array));
|
||||
} catch (IOException e) {
|
||||
DefaultSystemLog.ERROR().error(e.getMessage(), e);
|
||||
return JsonMessage.getString(500, e.getMessage());
|
||||
|
@ -10,11 +10,13 @@ import com.alibaba.fastjson.JSONObject;
|
||||
public class ProjectInfoModel {
|
||||
private String id;
|
||||
private String name;
|
||||
private String group;
|
||||
private String mainClass;
|
||||
private String lib;
|
||||
private String log;
|
||||
private String jvm;
|
||||
private String token;
|
||||
private boolean status;
|
||||
private String createTime;
|
||||
private String modifyTime;
|
||||
private String args;
|
||||
@ -28,6 +30,14 @@ public class ProjectInfoModel {
|
||||
*/
|
||||
private String runLibDesc;
|
||||
|
||||
public boolean isStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(boolean status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getRunLibDesc() {
|
||||
return runLibDesc;
|
||||
}
|
||||
@ -84,6 +94,14 @@ public class ProjectInfoModel {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
||||
public void setGroup(String group) {
|
||||
this.group = group;
|
||||
}
|
||||
|
||||
public String getMainClass() {
|
||||
return mainClass;
|
||||
}
|
||||
|
@ -25,18 +25,26 @@
|
||||
<label class="layui-form-label">项目名名称</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="name" placeholder="项目名称" required lay-verify="required"
|
||||
class="layui-input" value="#if($item) #if($item.name)$item.name#else$!item.id#end #end">
|
||||
class="layui-input" value="#if($item)#if($item.name)$!item.name#else$!item.id#end#end">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">Tag</label>
|
||||
<label class="layui-form-label">分组名称</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="id" placeholder="程序运行标志(设置后将不能修改)" required lay-verify="required"
|
||||
class="layui-input" value="#if($item)$!item.id#end" #if($item)readonly#end>
|
||||
<input type="text" name="group" placeholder="项目分组名称" required lay-verify="required"
|
||||
class="layui-input" value="#if($item)$!item.group#end">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">Tag</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="id" placeholder="程序运行标志(设置后将不能修改)" required lay-verify="required"
|
||||
class="layui-input #if($item)layui-disabled#end" value="#if($item)$!item.id#end"
|
||||
#if($item)readonly#end>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">MainClass</label>
|
||||
<div class="layui-input-block">
|
||||
@ -44,6 +52,9 @@
|
||||
lay-verify="required" class="layui-input" value="#if($item)$!item.mainClass#end">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">Lib</label>
|
||||
<div class="layui-input-block">
|
||||
@ -51,8 +62,6 @@
|
||||
class="layui-input" value="#if($item)$!item.lib#end">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">Log</label>
|
||||
<div class="layui-input-block">
|
||||
@ -60,13 +69,7 @@
|
||||
class="layui-input" value="#if($item)$!item.log#end">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">Token</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="token" placeholder="对应接口的token,可不填" class="layui-input"
|
||||
value="#if($item)$!item.token#end">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
@ -85,6 +88,13 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">Token</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="token" placeholder="对应接口的token,可不填" class="layui-input"
|
||||
value="#if($item)$!item.token#end">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">Build标识</label>
|
||||
<div class="layui-input-block">
|
||||
|
@ -35,8 +35,68 @@
|
||||
lay-text="运行中|未运行">
|
||||
</script>
|
||||
|
||||
<script>
|
||||
const HSL = [];
|
||||
|
||||
function randomHsl() {
|
||||
var H = Math.random();
|
||||
var S = Math.random();
|
||||
var L = Math.random();
|
||||
return [H, S, L];
|
||||
}
|
||||
|
||||
// 获取HSL数组
|
||||
function getHslArray(hslLength) {
|
||||
if (HSL.length >= hslLength) {
|
||||
return;
|
||||
}
|
||||
for (var i = 0; i < hslLength - HSL.length; i++) {
|
||||
var ret = this.randomHsl();
|
||||
|
||||
// 颜色相邻颜色差异须大于 0.25
|
||||
if (i > 0 && Math.abs(ret[0] - HSL[i - 1][0]) < 0.25) {
|
||||
i--;
|
||||
continue; // 重新获取随机色
|
||||
}
|
||||
ret[1] = 0.7 + (ret[1] * 0.2); // [0.7 - 0.9] 排除过灰颜色
|
||||
ret[2] = 0.4 + (ret[2] * 0.4); // [0.4 - 0.8] 排除过亮过暗色
|
||||
|
||||
// 数据转化到小数点后两位
|
||||
ret = ret.map(function (item) {
|
||||
return parseFloat(item.toFixed(2));
|
||||
});
|
||||
HSL.push(ret);
|
||||
}
|
||||
}
|
||||
|
||||
function hslToRgb(H, S, L) {
|
||||
var R, G, B;
|
||||
if (+S === 0) {
|
||||
R = G = B = L; // 饱和度为0 为灰色
|
||||
} else {
|
||||
var hue2Rgb = function (p, q, t) {
|
||||
if (t < 0) t += 1;
|
||||
if (t > 1) t -= 1;
|
||||
if (t < 1 / 6) return p + (q - p) * 6 * t;
|
||||
if (t < 1 / 2) return q;
|
||||
if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
|
||||
return p;
|
||||
};
|
||||
var Q = L < 0.5 ? L * (1 + S) : L + S - L * S;
|
||||
var P = 2 * L - Q;
|
||||
R = hue2Rgb(P, Q, H + 1 / 3);
|
||||
G = hue2Rgb(P, Q, H);
|
||||
B = hue2Rgb(P, Q, H - 1 / 3);
|
||||
}
|
||||
return [Math.round(R * 255), Math.round(G * 255), Math.round(B * 255)];
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
var table;
|
||||
var groupMap = new Map();
|
||||
layui.use(['layer', 'element', 'table', 'form'], function () {
|
||||
var $ = layui.$;
|
||||
table = layui.table;
|
||||
@ -53,7 +113,14 @@
|
||||
{field: 'name', title: '项目名称', width: '15%'},
|
||||
{
|
||||
title: 'lib状态', width: '10%', templet: function (d) {
|
||||
return (d.runLibDesc || "") + " / " + (d.useLibDesc || "");
|
||||
var size = groupMap.size;
|
||||
if (!groupMap.get(d.group)) {
|
||||
groupMap.set(d.group, "1");
|
||||
size += 1;
|
||||
getHslArray(size);
|
||||
}
|
||||
var rgb = hslToRgb.apply(this, HSL[size - 1]);
|
||||
return "<div title='" + d.group + "' style='background: rgb(" + rgb + ");color: #fff;margin: 0 -15px;padding: 0 15px;'>" + (d.runLibDesc || "") + " / " + (d.useLibDesc || "") + "</div>";
|
||||
}
|
||||
},
|
||||
{field: 'createTime', title: '创建时间', width: '13%'},
|
||||
@ -66,7 +133,6 @@
|
||||
statusCode: 200
|
||||
},
|
||||
done: function (data) {
|
||||
console.log(data);
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user