public static string CreateSensorInfoTable(SensorInfoViewModel sensorInfo) { StringBuilder result = new StringBuilder(); string encodedPath = SensorPathHelper.Encode($"{sensorInfo.ProductName}/{sensorInfo.Path}"); result.Append("<div style='margin: 10px'><div class='row justify-content-start'><div class='col-md-auto'>" + $"<h5 style='margin: 10px 20px 10px;'>{sensorInfo.ProductName}/{sensorInfo.Path}</h5><div>" + $"{CreateEditButtonForInfo(encodedPath)}{CreateSaveButtonForInfo(encodedPath)}" + $"{CreateResetButtonForInfo(encodedPath)}</div></div></div></div>"); result.Append("<table class='table table-bordered'><tbody>"); result.Append($"<tr><td>Product</td><td>{sensorInfo.ProductName}</td></tr>"); result.Append($"<tr><td>Path</td><td>{sensorInfo.Path}</td></tr>"); result.Append($"<tr><td>Sensor type</td><td>{sensorInfo.SensorType}</td></tr>"); result.Append("<tr><td>Expected update interval<i class='fas fa-question-circle' " + "title='Time format: dd.hh:mm:ss min value 00:05:00'></i></td><td><input disabled type='text' " + $"class='form-control' style='max-width:300px' id='interval_{encodedPath}' " + $"value='{sensorInfo.ExpectedUpdateInterval}'></td></tr>"); result.Append("<tr><td>Description</td><td><input disabled type='text' class='form-control' style='max-width:300px'" + $" id='description_{encodedPath}' value='{sensorInfo.Description}'></td></tr>"); result.Append("<tr><td>Unit</td><td><input disabled type='text' class='form-control' style='max-width:300px'" + $" id='unit_{encodedPath}' value='{sensorInfo.Unit}'></td></tr>"); result.Append("</div>"); return(result.ToString()); }
public SensorDataViewModel(string path, SensorViewModel sensor) { var time = (DateTime.UtcNow - sensor.Time); UpdateTime = ListHelper.GetTimeAgo(time); Status = ViewHelper.GetStatusHeaderColorClass(sensor.Status); int index = path.IndexOf('_'); var encodedPath = path.Substring(index + 1, path.Length - index - 1); var decodedPath = SensorPathHelper.Decode(encodedPath); Id = "sensor_" + SensorPathHelper.Encode($"{decodedPath}/{sensor.Name}"); Value = sensor.ShortStringValue; ValidationError = sensor.ValidationError; }
public static string CreateNotSelectedLists(string selectedPath, TreeViewModel model) { if (model == null) { return(string.Empty); } var result = new StringBuilder(1 << 8); foreach (var(_, node) in model.Nodes) { string formattedPath = SensorPathHelper.Encode(node.Path); if (!string.IsNullOrEmpty(selectedPath) && selectedPath.Equals(formattedPath)) { continue; } DFSCreateList(result, node); } return(result.ToString()); }
public static StringBuilder CreateList(StringBuilder result, NodeViewModel node) { string formattedNodePath = SensorPathHelper.Encode(node.Path); result.Append($"<div id='list_{formattedNodePath}' style='display: none;'>"); if (node.Sensors != null && !node.Sensors.IsEmpty) { foreach (var(name, sensor) in node.Sensors) { string sensorPath = $"{node.Path}/{name}"; string formattedPath = SensorPathHelper.Encode(sensorPath); result.Append($"<div id='sensorInfo_parent_{formattedPath}' style='display: none'>"); result.Append(CreateSensorInfoLink(formattedPath)); result.Append($"<div id=sensor_info_{formattedPath}></div></div>"); result.Append($"<div class='accordion' id='sensorData_{formattedPath}' style='display: none'>"); result.Append(CreateSensor(formattedPath, sensor)); result.Append("</div>"); } } result.Append("</div>"); return(result); }
public static string Recursion(NodeViewModel node) { var result = new StringBuilder(node.Nodes?.Count ?? 0 + node.Sensors?.Count ?? 0 + 8); var name = SensorPathHelper.Encode(node.Path); var shortName = node.Name.Length > NodeNameMaxLength ? $"{node.Name[..NodeNameMaxLength]}..."