tree显示设备状态:停止、连接成功、连接断开

This commit is contained in:
iioter 2022-08-08 15:16:42 +08:00
parent 2633fbe886
commit 0265a53207
8 changed files with 20 additions and 9 deletions

View File

@ -34,13 +34,19 @@ namespace IoTGateway.ViewModel.BasicData.DeviceConfigVMs
.OrderBy(x => x.Parent.Index).ThenBy(x => x.Parent.DeviceName)
.OrderBy(x => x.Index).ThenBy(x => x.DeviceName)
.GetTreeSelectListItems(Wtm, x => x.DeviceName);
var deviceService = Wtm.ServiceProvider.GetService(typeof(DeviceService)) as DeviceService;
foreach (var device in AllDevices)
{
foreach (var item in device.Children)
{
item.Text = item.Text;
item.Icon = "layui-icon layui-icon-link";
var deviceThread = deviceService.DeviceThreads.Where(x => x._device.ID.ToString() == (string)item.Value).FirstOrDefault();
if (deviceThread != null)
item.Icon = deviceThread._device.AutoStart ? (deviceThread._driver.IsConnected ? "layui-icon layui-icon-link" : "layui-icon layui-icon-unlink") : "layui-icon layui-icon-pause";
item.Text = " "+item.Text;
item.Expended = true;
item.Selected =item.Value.ToString() == IoTBackgroundService.ConfigSelectDeviceId.ToString();
}
}
base.InitListVM();

View File

@ -31,7 +31,7 @@ namespace IoTGateway.ViewModel.BasicData.DeviceConfigVMs
.GetSelectListItems(Wtm, y => y.DeviceName);
if (Entity.DeviceId != null)
{
if (Entity.EnumInfo != null)
if (!string.IsNullOrEmpty(Entity.EnumInfo))
{
AllTypes = new List<ComboSelectListItem>();
var EnumInfos = JsonSerializer.Deserialize<Dictionary<string, int>>(Entity.EnumInfo);

View File

@ -47,10 +47,11 @@ namespace IoTGateway.ViewModel.BasicData.DeviceVariableVMs
{
var deviceThread = deviceService.DeviceThreads.Where(x => x._device.ID.ToString() == (string)item.Value).FirstOrDefault();
if (deviceThread != null)
item.Icon = deviceThread._device.AutoStart ? (deviceThread._driver.IsConnected ? "layui-icon-link" : "layui-icon-unlink") : "layui-icon-pause";
item.Icon = deviceThread._device.AutoStart ? (deviceThread._driver.IsConnected ? "layui-icon layui-icon-link" : "layui-icon layui-icon-unlink") : "layui-icon layui-icon-pause";
item.Text = item.Text;
item.Text = " " + item.Text;
item.Expended = true;
item.Selected = item.Value.ToString() == IoTBackgroundService.VariableSelectDeviceId.ToString();
}
}

View File

@ -5,7 +5,7 @@
<wt:row items-per-row="ItemsPerRowEnum.Two">
@*<wt:textbox field="Entity.DeviceConfigName" />*@
@{
if (Model.Entity.EnumInfo != null)
if (!string.IsNullOrEmpty(Model.Entity.EnumInfo))
{
<wt:combobox field="Entity.Value" items="AllTypes" />
}

View File

@ -2,7 +2,7 @@
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
internalLogLevel="Info"
internalLogLevel="Error"
internalLogFile="./logs/internal-nlog-AspNetCore.txt">
<!-- enable asp.net core layout renderers -->

View File

@ -201,8 +201,8 @@ layui.define('form', function(exports){
if(options.isJump && item.href){
return '<a href="'+ item.href +'" target="_blank" class="'+ ELEM_TEXT +'">'+ (item.title || item.label || options.text.defaultNodeName) +'</a>';
} else {
return '<span class="' + ELEM_TEXT + (item.disabled ? ' ' + DISABLED : '') + '"><i class="layui-icon ' + (item.icon || '') + '"></i>' + (item.title || item.label || options.text.defaultNodeName) + '</span>';
//return '<span class="' + ELEM_TEXT + (item.disabled ? ' ' + DISABLED : '') + '">' + (item.title || item.label || options.text.defaultNodeName) + '</span>';
return '<span class="' + ELEM_TEXT + (item.disabled ? ' ' + DISABLED : '') + '"><i class="iconfont ' + (item.icon || '') + '"></i>' + (item.title || item.label || options.text.defaultNodeName) + '</span>';
}
}()
,'</div>'

View File

@ -10,6 +10,9 @@ namespace WalkingTec.Mvvm.TagHelpers.LayUI
[JsonPropertyName("title")]
public string Title { get; set; }
[JsonPropertyName("icon")]
public string Icon { get; set; }
[JsonPropertyName("id")]
public string Id { get; set; }

View File

@ -176,6 +176,7 @@ layui.use(['tree'],function(){{
{
Id = s.Value.ToString(),
Title = s.Text,
Icon = s.Icon,
Url = s.Url,
Expand = s.Expended,
Level = level,