mirror of
https://gitee.com/BDWare/agent-backend
synced 2025-01-10 18:04:13 +00:00
156 lines
4.9 KiB
JavaScript
156 lines
4.9 KiB
JavaScript
|
var dtLang = {
|
||
|
"sProcessing": "处理中...",
|
||
|
"lengthMenu": '显示 <select>' + '<option value="5">5</option>' + '<option value="20">20</option>' + '<option value="100">100</option>' + '<option value="-1">全部</option>' + '</select> 项结果',
|
||
|
"sZeroRecords": "没有匹配结果",
|
||
|
"sInfo": "显示第 _START_ 至 _END_ 项结果,共 _TOTAL_ 项",
|
||
|
"sInfoEmpty": "显示第 0 至 0 项结果,共 0 项",
|
||
|
"sInfoFiltered": "(由 _MAX_ 项结果过滤)",
|
||
|
"sInfoPostFix": "",
|
||
|
"sSearch": "搜索:",
|
||
|
"sUrl": "",
|
||
|
"sEmptyTable": "表中数据为空",
|
||
|
"sLoadingRecords": "载入中...",
|
||
|
"sInfoThousands": ",",
|
||
|
"oPaginate": {
|
||
|
"sFirst": "首页",
|
||
|
"sPrevious": "上页",
|
||
|
"sNext": "下页",
|
||
|
"sLast": "末页"
|
||
|
}
|
||
|
,
|
||
|
"oAria": {
|
||
|
"sSortAscending": ": 以升序排列此列",
|
||
|
"sSortDescending": ": 以降序排列此列"
|
||
|
}
|
||
|
};
|
||
|
var tableHead = "<table id='authorizedUsersTab' class='table display row-border'><thead><tr><th>序号</th><th>PublicKey</th><th>备注</th><th>管理</th></tr></thead><tbody>";
|
||
|
var tableTail = "</tbody></table>";
|
||
|
var fillAcceptList = function(data) {
|
||
|
console.log("fillAcceptData");
|
||
|
var html = tableHead;
|
||
|
var lines = data;
|
||
|
var i = 1;
|
||
|
for (var k in data) {
|
||
|
html += "<tr><td>";
|
||
|
html += i;
|
||
|
html += "</td><td>";
|
||
|
html += k;
|
||
|
html += "</td><td>";
|
||
|
html += data[k];
|
||
|
html += "</td><td>";
|
||
|
html += "<button class='btn btn-outline-primary'>取消授权</button>";
|
||
|
html += "</td></tr>";
|
||
|
i++;
|
||
|
}
|
||
|
html += tableTail;
|
||
|
$("#authoriedDiv").html(html);
|
||
|
$("#authoriedDiv").off("click", ":button").on(
|
||
|
"click",
|
||
|
":button",
|
||
|
function(event) {
|
||
|
var pos = ($(this).closest("tr").find("td").eq(0)
|
||
|
.text() - 1) / 1;
|
||
|
var pubKey = $(this).closest("tr").find("span")[0].getAttribute("title");
|
||
|
|
||
|
executeCurrentContract("cancel",pubKey,flushAllList);
|
||
|
}
|
||
|
);
|
||
|
$("#authorizedUsersTab").DataTable({
|
||
|
"language": dtLang,
|
||
|
"rowCallback": function(row, data, displayNum, displayIndex, dataIndex) {
|
||
|
}
|
||
|
,
|
||
|
"headerCallback": function(thead, data, start, end, display) {
|
||
|
$(thead).css("background", primaryColor);
|
||
|
$(thead).css("color", "white");
|
||
|
$(thead).children().css("background", primaryColor);
|
||
|
$(thead).children().css("color", "white");
|
||
|
}
|
||
|
,
|
||
|
scrollCollapse: false,
|
||
|
paging: true,
|
||
|
pageLength: 5,
|
||
|
order: [[1, 'asc']],
|
||
|
"columnDefs": [
|
||
|
{
|
||
|
"targets": 1,
|
||
|
"render": function(data, type, row, meta) {
|
||
|
if (data.length > 15) return "<span title='" + data + "'>" + data.substring(0, 15) + " ...</span>";
|
||
|
else return data;
|
||
|
}
|
||
|
}, {
|
||
|
"targets": 2,
|
||
|
"render": function(data, type, row, meta) {
|
||
|
if (data.length > 40) return "<span title='" + data + "'>" + data.substring(0, 40) + " ...</span>";
|
||
|
else return data;
|
||
|
}
|
||
|
}
|
||
|
]
|
||
|
}
|
||
|
);
|
||
|
};
|
||
|
var tableApplyHead = "<table id='applyListTab' class='table display row-border'><thead><tr><th>序号</th><th>PublicKey</th><th>备注</th><th>管理</th></tr></thead><tbody>";
|
||
|
var tableApplyTail = "</tbody></table>";
|
||
|
var fillApplyData = function(data) {
|
||
|
console.log("fillApplyListData");
|
||
|
var html = tableApplyHead;
|
||
|
var i=1;
|
||
|
for (var k in data) {
|
||
|
html += "<tr><td>";
|
||
|
html += i;
|
||
|
html += "</td><td>";
|
||
|
html += k;
|
||
|
html += "</td><td>";
|
||
|
html += data[k];
|
||
|
html += "</td><td>";
|
||
|
html += "<button class='btn btn-outline-primary'>通过申请</button>";
|
||
|
html += "</td></tr>";
|
||
|
}
|
||
|
html += tableTail;
|
||
|
$("#unauthoriedDiv").html(html);
|
||
|
$("#unauthoriedDiv").off("click", ":button").on(
|
||
|
"click",
|
||
|
":button",
|
||
|
function(event) {
|
||
|
var pos = ($(this).closest("tr").find("td").eq(0)
|
||
|
.text() - 1) / 1;
|
||
|
var pubKey = $(this).closest("tr").find("span")[0].getAttribute("title");
|
||
|
executeCurrentContract("accept",pubKey,flushAllList);
|
||
|
}
|
||
|
);
|
||
|
console.log("tryToCall DataTable");
|
||
|
$("#applyListTab").DataTable({
|
||
|
"language": dtLang,
|
||
|
"rowCallback": function(row, data, displayNum, displayIndex, dataIndex) {
|
||
|
}
|
||
|
,
|
||
|
"headerCallback": function(thead, data, start, end, display) {
|
||
|
$(thead).css("background", primaryColor);
|
||
|
$(thead).css("color", "white");
|
||
|
$(thead).children().css("background", primaryColor);
|
||
|
$(thead).children().css("color", "white");
|
||
|
}
|
||
|
,
|
||
|
scrollCollapse: false,
|
||
|
paging: true,
|
||
|
pageLength: 10,
|
||
|
order: [[1, 'asc']],
|
||
|
"columnDefs": [
|
||
|
{
|
||
|
"targets": 1,
|
||
|
"render": function(data, type, row, meta) {
|
||
|
if (data.length > 15) return "<span title='" + data + "'>" + data.substring(0, 15) + " ...</span>";
|
||
|
else return data;
|
||
|
}
|
||
|
}, {
|
||
|
"targets": 2,
|
||
|
"render": function(data, type, row, meta) {
|
||
|
if (data.length > 40) return "<span title='" + data + "'>" + data.substring(0, 40) + " ...</span>";
|
||
|
else return data;
|
||
|
}
|
||
|
}
|
||
|
]
|
||
|
}
|
||
|
);
|
||
|
};
|