Commit aef9242c by 黄明步

服务器预警与接口预警合并

parent 98d67d16
...@@ -427,6 +427,11 @@ public class ViewController { ...@@ -427,6 +427,11 @@ public class ViewController {
@RequestMapping("/monitoring") @RequestMapping("/monitoring")
public String monitoring(ModelMap modelMap) { public String monitoring(ModelMap modelMap) {
modelMap.put("gatewayUrl", gatewayUrl); modelMap.put("gatewayUrl", gatewayUrl);
try {
modelMap.put("youxiang", UserUtil.getCurrentUser().getYouxiang());
} catch (Exception e) {
log.error("获取登录账户信息失败");
}
return "monitoring/index"; return "monitoring/index";
} }
} }
...@@ -39,9 +39,11 @@ ...@@ -39,9 +39,11 @@
</fieldset> </fieldset>
<table id="interfaceTable" lay-filter="interfaceTable"></table> <table id="interfaceTable" lay-filter="interfaceTable"></table>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;"> <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
<legend style="color: red;font-weight: bold;">接口异常信</legend> <legend style="color: red;font-weight: bold;">我的异常消</legend>
</fieldset> </fieldset>
<table id="errorInfo" lay-filter="errorInfo"></table> <!--<table id="errorInfo" lay-filter="errorInfo"></table>-->
<table id="messageList" lay-filter="messageList"></table>
</body> </body>
<script type="text/html" id="status"> <script type="text/html" id="status">
<div class="status-container"> <div class="status-container">
...@@ -59,6 +61,12 @@ ...@@ -59,6 +61,12 @@
<span style="color: red"></span> <span style="color: red"></span>
{{# } }} {{# } }}
</script> </script>
<script type="text/html" id="bar">
<button class="layui-btn layui-btn-xs" lay-event="look">查阅</button>
{{# if(!d.read){ }}
<button class="layui-btn layui-btn-xs layui-btn-normal" lay-event="read">标记已读</button>
{{# }}}
</script>
<script src="layui/layui.all.js"></script> <script src="layui/layui.all.js"></script>
<script src="js/jquery.min.js"></script> <script src="js/jquery.min.js"></script>
<script src="layui/xmSelect/xm-select.js"></script> <script src="layui/xmSelect/xm-select.js"></script>
...@@ -67,6 +75,7 @@ ...@@ -67,6 +75,7 @@
let youxiang = [[${youxiang}]]; let youxiang = [[${youxiang}]];
</script> </script>
<script> <script>
console.log("username:"+youxiang + gatewayUrl)
var list, table, form, condition = {}; var list, table, form, condition = {};
layui.use(['laydate', "table", "form"], function () { layui.use(['laydate', "table", "form"], function () {
var laydate = layui.laydate var laydate = layui.laydate
...@@ -98,14 +107,6 @@ ...@@ -98,14 +107,6 @@
before: function (e) { before: function (e) {
condition = e.where; condition = e.where;
}, },
// parseData: function (res) {
// return {
// code: res.code,
// msg: res.msg,
// count: res.data.total,
// data: res.data.records
// }
// }
}); });
table.render({ table.render({
elem: "#errorInfo", elem: "#errorInfo",
...@@ -133,6 +134,104 @@ ...@@ -133,6 +134,104 @@
}, },
}); });
console.log(youxiang)
const messageList = table.render({
elem: "#messageList",
url: gatewayUrl + "/getMyMessageList",
where: {username: youxiang},
page: true,
cols: [
[
{field: "title", title: "标题", align: "center", minWidth: 250},
{field: "body", title: "内容", align: "center", minWidth: 150},
{
field: "read", title: "是否已读", align: "center", minWidth: 150, templet: function (data) {
if (data.read) {
return "<span style='color: #CCCCCC;'>已读</span>"
} else {
return "<span style='color: #FF5722;'>未读</span>"
}
}
},
{field: "createDateTime", title: "创建时间", align: "center", minWidth: 150},
{fixed: "right", width: 140, align: "center", toolbar: "#bar"}
]
],
response: {
statusCode: 200,
},
parseData: function (res) {
return {
code: res.code,
msg: res.msg,
count: res.data.total,
data: res.data.list
}
},
toolbar: true,
defaultToolbar: ['filter', 'print', {title: "导出数据表格", layEvent: "exports", icon: "layui-icon-export"}],
});
table.on("toolbar(messageList)", function (obj) {
if (obj.event === "exports") {
$.ajax({
url: gatewayUrl + "/exportMyMessageList",
data: {username: youxiang},
type: "get",
xhrFields: {
responseType: 'blob' // 设置响应类型为二进制流
},
success: function (data) {
// 创建 Blob 对象
var blob = new Blob([data], {type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'});
saveAs(blob, '告警消息日志导出.xlsx');
},
error: function () {
layer.msg("导出数据失败!", {icon: 2});
}
})
}
});
table.on('tool(messageList)', function (obj) {
let data = obj.data;
let layEvent = obj.event;
if (layEvent === "look") {
form.val("lookForm", data);
layer.open({
type: 1,
title: ['消息内容', 'font-size:18px;text-align:center;background-color:#3b749e;'],
id: "look",
content: $("#lookForm"),
area: ["600px", "625px"],
success: function (layero, index) {
layer.full(index);
}
})
} else if (layEvent === "read") {
let sendData = {
userMessageId: data.userMessageId,
read: true
}
$.ajax({
type: "put",
url: gatewayUrl + "/updateUserMessage",
contentType: "application/json;charset=utf-8",
data: JSON.stringify(sendData),
success: function (res) {
if (res.code === 200) {
layer.msg("已标记为已读");
messageList.reload();
parent.loadUnreadMessageCount();
} else {
layer.msg(res.msg);
}
}, error: function () {
layer.msg("无法连接");
}
});
}
});
}); });
</script> </script>
</html> </html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment