feat: 任务日志点击默认显示上一条执行结果
This commit is contained in:
parent
481310ca29
commit
7b3526d9c2
|
@ -14,7 +14,7 @@ namespace Bootstrap.Admin.Controllers.Api
|
|||
public class TasksLogController : ControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// 任务管理页面日志按钮调用此方法
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="hub"></param>
|
||||
|
@ -23,12 +23,16 @@ namespace Bootstrap.Admin.Controllers.Api
|
|||
public bool Get([FromQuery]string name, [FromServices]IHubContext<SignalRHub> hub)
|
||||
{
|
||||
var sche = TaskServicesManager.GetOrAdd(name);
|
||||
sche.Triggers.First().PulseCallback = async t =>
|
||||
{
|
||||
var result = $"{{\"name\": \"{name}\", \"msg\": \"{sche.LastRuntime}: Trigger({t.GetType().Name}) Run({t.LastResult}) NextRuntime: {sche.NextRuntime} Elapsed: {t.LastRunElapsedTime.Seconds}s\"}}";
|
||||
await SignalRManager.SendTaskLog(hub.Clients.All, result);
|
||||
};
|
||||
sche.Triggers.First().PulseCallback = t => SendTaskLog(sche, name, hub);
|
||||
SendTaskLog(sche, name, hub);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void SendTaskLog(IScheduler sche, string name, IHubContext<SignalRHub> hub)
|
||||
{
|
||||
var t = sche.Triggers.First();
|
||||
var result = $"{{\"name\": \"{name}\", \"msg\": \"{sche.LastRuntime}: Trigger({t.GetType().Name}) Run({t.LastResult}) NextRuntime: {sche.NextRuntime} Elapsed: {t.LastRunElapsedTime.Seconds}s\"}}";
|
||||
SignalRManager.SendTaskLog(hub.Clients.All, result).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
else if (value === "Timeout") {
|
||||
content = $.format(template, 'warning', '超时');
|
||||
}
|
||||
return content;
|
||||
return content;
|
||||
};
|
||||
|
||||
$('.card-body table').lgbTable({
|
||||
|
@ -59,16 +59,12 @@
|
|||
events: {
|
||||
'click .info': function (e, value, row, index) {
|
||||
$taskLogModelTitle.html(row.Name + ' - 任务日志窗口(最新50条)');
|
||||
$.bc({
|
||||
url: 'api/TasksLog?name=' + row.Name
|
||||
});
|
||||
$('#dialogLog').modal('show').on('hide.bs.modal', function () {
|
||||
// close hub
|
||||
if ($taskMsg.hub) $taskMsg.hub.stop();
|
||||
$taskMsg.html('<div></div>');
|
||||
});
|
||||
|
||||
// var lastMsg = "";
|
||||
// open hub
|
||||
$taskMsg.notifi({
|
||||
url: 'NotiHub',
|
||||
|
@ -82,13 +78,20 @@
|
|||
if (data.name !== row.Name) return;
|
||||
|
||||
result = data.msg;
|
||||
result = result.replace("Run(Cancelled)", "<span class='text-danger'>Run(Cancelled)</span>");
|
||||
result = result.replace("Run(Cancelled)", "<span class='text-info'>Run(Cancelled)</span>");
|
||||
result = result.replace("Run(Success)", "<span class='text-success'>Run(Success)</span>");
|
||||
result = result.replace("Run(Error)", "<span class='text-danger'>Run(Error)</span>");
|
||||
result = result.replace("Run(Timeout)", "<span class='text-warning'>Run(Timeout)</span>");
|
||||
content.append('<div>' + result + '</div>');
|
||||
|
||||
// auto scroll
|
||||
if ($autoScroll.find('i').hasClass(check[0])) this.scrollTop(content.height());
|
||||
},
|
||||
invoke: function () {
|
||||
$.bc({
|
||||
url: 'api/TasksLog?name=' + row.Name
|
||||
});
|
||||
},
|
||||
onclose: function (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
|
|
@ -461,7 +461,9 @@
|
|||
// 连接成功
|
||||
// invoke 为 调用服务端方法
|
||||
// invoke: function (connection) { return connection.invoke('RetrieveDashboard'); }
|
||||
if (op.invoke) op.invoke(connection).then(function (result) { console.log(result); }).catch(function (err) { console.error(err.toString()); });
|
||||
if (!op.invoke) return;
|
||||
var executor = op.invoke(connection);
|
||||
if (typeof executor === "object" && $.isFunction(executor.then)) executor.then(function (result) { console.log(result); }).catch(function (err) { console.error(err.toString()); });
|
||||
});
|
||||
this.hub = connection;
|
||||
return this;
|
||||
|
|
Loading…
Reference in New Issue