Skip to content

Commit

Permalink
tree显示设备状态:停止、连接成功、连接断开
Browse files Browse the repository at this point in the history
  • Loading branch information
iioter committed Aug 8, 2022
1 parent 2633fbe commit 0265a53
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,19 @@ protected override void InitListVM()
.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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected override void InitVM()
.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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ protected override void InitListVM()
{
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();

}
}
Expand Down
2 changes: 1 addition & 1 deletion IoTGateway/Areas/BasicData/Views/DeviceConfig/Edit.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
}
Expand Down
2 changes: 1 addition & 1 deletion IoTGateway/nlog.config
Original file line number Diff line number Diff line change
Expand Up @@ -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 -->
Expand Down
4 changes: 2 additions & 2 deletions IoTGateway/wwwroot/layui/lay/modules/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -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>'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ public class LayuiTreeItem
[JsonPropertyName("title")]
public string Title { get; set; }

[JsonPropertyName("icon")]
public string Icon { get; set; }

[JsonPropertyName("id")]
public string Id { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ private List<LayuiTreeItem> GetLayuiTree(IEnumerable<TreeSelectListItem> tree, i
{
Id = s.Value.ToString(),
Title = s.Text,
Icon = s.Icon,
Url = s.Url,
Expand = s.Expended,
Level = level,
Expand Down

0 comments on commit 0265a53

Please sign in to comment.