im attempting to have a grid update based on records in a DB
i have a log4net service sending messages to a DB
i keep getting an error
Uncaught (in promise) Objectmessage: "The message port closed before a response was received."[[Prototype]]: Object
BatchInsights:59 Uncaught ReferenceError: hub is not defined
at HTMLDocument.<anonymous> (BatchInsights:59:1560)
at i (jquery.min.js:2:27466)
at Object.fireWith [as resolveWith] (jquery.min.js:2:28230)
at Function.ready (jquery.min.js:2:30023)
at HTMLDocument.K (jquery.min.js:2:30385)
jquery.simulate.js:331 Uncaught ReferenceError: jQuery is not defined
at jquery.simulate.js:331:5
I followed the demo and still get this error ...here is the view
@model IEnumerable<FMM.Core.DataModel.Pharmpix.LogModel>
@using Kendo.Mvc.UI;
@using Kendo.Mvc.Extensions;
@using FMM.Core.DataModel.Pharmpix;
@{
ViewData["Title"] = $"Batch Insights Logs";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<div>
@(Html.Kendo().Notification()
.Name("notification")
.Width("100%")
.Position(position => position
.Top(50)
.Left(50))
)
@(Html.Kendo().Grid(Model)
.Name("grid")
.Columns(columns =>
{
columns.Bound(p => p.Id);
columns.Bound(p => p.Logger).Width(150);
columns.Bound(p => p.Message).Width(120).Filterable(false);
})
.ToolBar(toolbar =>
{
toolbar.Search();
})
.Groupable()
.Pageable()
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Scrollable()
.HtmlAttributes(new { style = "height:100%;" })
.DataSource(dataSource => dataSource
.SignalR()
.AutoSync(true)
.PageSize(20)
.Transport(tr => tr
.Promise("hubStart")
.Hub("hub")
.Client(c => c
.Read("read")
)
.Server(s => s
.Read("read")
))
.Schema(schema => schema
.Model(model =>
{
model.Id("Id");
model.Field("Logger", typeof(string)).Editable(false);
model.Field("Message", typeof(string));
})
)
))
</div>
<script src="https://unpkg.com/@@aspnet/signalr@1.0.0/dist/browser/signalr.js"></script>
<script>
$(document).ready(function () {
var hubUrl = "logHub";
var hub = new signalR.HubConnectionBuilder()
.withUrl(hubUrl, {
transport: signalR.HttpTransportType.LongPolling
})
.build();
var hubStart = hub.start();
});
function onPush(e) {
var notification = $("#notification").data("kendoNotification");
notification.success(e.type);
}
</script>
here is the hub
using FMM.Core.DataModel.Pharmpix;using FMM.Core.Interfaces;
using FMM.DataAccess;
using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Financial_Management_Module.Hubs
{
public class LogHub : Hub
{
private readonly PharmpixDbContext _context;
private readonly IConfiguration _configuration;
private readonly ILogging _log;
public LogHub(PharmpixDbContext context, IConfiguration configuration, ILogging log)
{
_context = context;
_configuration = configuration;
_log = log;
}
public override System.Threading.Tasks.Task OnConnectedAsync()
{
Groups.AddToGroupAsync(Context.ConnectionId, GetGroupName());
return base.OnConnectedAsync();
}
public override System.Threading.Tasks.Task OnDisconnectedAsync(Exception e)
{
Groups.RemoveFromGroupAsync(Context.ConnectionId, GetGroupName());
return base.OnDisconnectedAsync(e);
}
public IEnumerable<LogModel> Read()
{
var result = _context.LogModel.Select(i => new LogModel
{
Id = i.Id,
Logger = i.Logger,
Message = i.Message
}
).ToList();
return result;
}
public string GetGroupName()
{
return GetRemoteIpAddress();
}
public string GetRemoteIpAddress()
{
return Context.GetHttpContext()?.Connection.RemoteIpAddress.ToString();
}
}
}
here is the log hub
using FMM.Core.DataModel.Pharmpix;
using FMM.Core.Interfaces;
using FMM.DataAccess;
using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Financial_Management_Module.Hubs
{
public class LogHub : Hub
{
private readonly PharmpixDbContext _context;
private readonly IConfiguration _configuration;
private readonly ILogging _log;
public LogHub(PharmpixDbContext context, IConfiguration configuration, ILogging log)
{
_context = context;
_configuration = configuration;
_log = log;
}
public override System.Threading.Tasks.Task OnConnectedAsync()
{
Groups.AddToGroupAsync(Context.ConnectionId, GetGroupName());
return base.OnConnectedAsync();
}
public override System.Threading.Tasks.Task OnDisconnectedAsync(Exception e)
{
Groups.RemoveFromGroupAsync(Context.ConnectionId, GetGroupName());
return base.OnDisconnectedAsync(e);
}
public IEnumerable<LogModel> Read()
{
var result = _context.LogModel.Select(i => new LogModel
{
Id = i.Id,
Logger = i.Logger,
Message = i.Message
}
).ToList();
return result;
}
public string GetGroupName()
{
return GetRemoteIpAddress();
}
public string GetRemoteIpAddress()
{
return Context.GetHttpContext()?.Connection.RemoteIpAddress.ToString();
}
}
}
the code gets called if i comment out the "signal" stuff but when new entries are inserted it doesnt up date the the grid any help is appreciated!