var token = localStorage.getItem("token");
if(token){
token = token.substr(1,token.length-2);
}
var init = function () {
http.get('/api/tx-manager/admin/modelList?access_token='+token, '加载数据...', function (res) {
var list = $("#list");
list.empty();
for (var p in res) {
var v = res[p];
var name = v['name'];
var tr = '
';
list.append(tr);
}
});
};
init();
$(document).on("click", ".model-name", function () {
var model = $(this).text();
$('#model').attr("data-model", model);
http.get('/api/tx-manager/admin/modelTimes?model=' + model+'&access_token='+token, '加载数据...', function (res) {
var list = $("#logs");
list.empty();
for (var p in res) {
var data = res[p];
var name = data.split(":")[0];
var tr = '
';
list.append(tr);
}
});
return false;
});
$(document).on("click", ".model-time", function () {
var file = $(this).attr("data-data");
var path = $('#model').attr("data-model") + ":" + file;
http.get('/api/tx-manager/admin/modelInfos?path=' + path+'&access_token='+token, '加载数据...', function (res) {
var list = $("#compensate");
list.empty();
for (var p in res) {
var param = res[p];
var tr =
'
' +
'
' + param.time + '
' +
'
' + param.method + '
' +
'
' + param.executeTime + '
' +
'
' +
' ' +
'' +
' ' +
'
' +
'
';
list.append(tr);
}
});
return false;
});
var confim = function(title,callback){
var button = $('#show-alert').find("button[data-event=button]");
button.unbind();
$("#content").text(title);
button.click(function(){
if(callback!=null){
callback();
reloadPage();
}
return true;
})
$('#show-alert').modal();
}
$(document).on("click", ".delete", function () {
var path = $(this).attr("data-data");
var tag = $(this).parent().parent();
confim("确认要删除吗?",function(){
http.get('/api/tx-manager/admin/delCompensate?path=' + path+'&access_token='+token, '加载数据...', function (res) {
if (res) {
hint('删除成功.');
tag.remove();
} else {
hint('删除失败.');
}
});
});
return false;
});
var reloadPage = function(){
var compensate = $("#compensate");
var lg = compensate.find("tr").length;
if(lg==1){
location.reload();
}
}
$(document).on("click", ".compensate", function () {
var path = $(this).attr("data-data");
var tag = $(this).parent().parent();
confim("确认要补偿吗?",function(){
http.get('/api/tx-manager/admin/compensate?path=' + path+'&access_token='+token, '加载数据...', function (res) {
if (res) {
hint('补偿成功.');
tag.remove();
} else {
hint('补偿失败.');
}
});
});
return false;
});
$(document).on("click", ".detail", function () {
var base64 = $(this).attr("data-data");
var unicode = BASE64.decoder(base64);
var str = '';
for (var i = 0, len = unicode.length; i < len; ++i) {
str += String.fromCharCode(unicode[i]);
}
var obj = JSON.parse(str);
$("#body").empty();
$('#body').append('
\n' +
'
\n' +
' 发起方模块\n' +
'
\n' +
'
\n' +
' \n' +
'
\n' +
'\n' +
'
\n' +
' 发起方地址\n' +
'
\n' +
'
\n' +
' \n' +
'
\n' +
'
\n' +
'
\n' +
'
\n' +
' 发起方标示\n' +
'
\n' +
'
\n' +
' \n' +
'
\n' +
'
\n' +
'
\n' +
'
\n' +
' 记录时间\n' +
'
\n' +
'
\n' +
' \n' +
'
\n' +
'\n' +
'
\n' +
' 执行时间(毫秒)\n' +
'
\n' +
'
\n' +
' \n' +
'
\n' +
'
\n' +
'
\n' +
'
\n' +
' 发起方执行方法\n' +
'
\n' +
'
\n' +
' \n' +
'
\n' +
'
\n' +
'
\n' +
'
\n' +
' 事务组Id\n' +
'
\n' +
'
\n' +
' \n' +
'
\n' +
'
\n' +
' 完成状态(1:已结束 0:未结束)\n' +
'
\n' +
'
\n' +
' \n' +
'
\n' +
'
');
$("#data-address").text(obj["address"]);
var currentTime = obj["currentTime"];
var date = new Date(currentTime);
$("#data-currentTime").text(date.format('yyyy-MM-dd h:m:s'));
$("#data-model").text(obj["model"]);
$("#data-model").text(obj["model"]);
$("#data-time").text(obj["time"]);
$("#data-methodStr").text(obj["methodStr"]);
$("#data-uniqueKey").text(obj["uniqueKey"]);
$("#data-hasOver").text(obj["txGroup"]["hasOver"]);
$("#data-groupId").text(obj["txGroup"]["groupId"]);
$("#data-startTime").text(obj["txGroup"]["startTime"]);
$("#data-state").text(obj["txGroup"]["state"]);
var list = obj["txGroup"]["list"];
for (var index in list) {
var p = list[index];
var notify = p["notify"];
var model = p["model"];
var modelIpAddress = p["modelIpAddress"];
var methodStr = p["methodStr"];
var uniqueKey = p["uniqueKey"];
var tr1 =
'