a3366188fc
- OK reset - OK ricerca
105 lines
3.0 KiB
C#
105 lines
3.0 KiB
C#
using Microsoft.JSInterop;
|
|
using MP.MONO.Data.DbModels;
|
|
|
|
namespace MP.MONO.UI.Components
|
|
{
|
|
public partial class AlarmsSetupRawList
|
|
{
|
|
#region Protected Fields
|
|
|
|
protected List<AlarmListModel>? ListRecords = null;
|
|
|
|
#endregion Protected Fields
|
|
|
|
#region Protected Methods
|
|
|
|
protected string cssSilenced(bool isMuted)
|
|
{
|
|
string answ = isMuted ? "bg-secondary text-light" : "bg-primary text-light";
|
|
return answ;
|
|
}
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await ReloadData();
|
|
}
|
|
|
|
protected async Task ReloadData()
|
|
{
|
|
ListRecords = null;
|
|
await Task.Delay(1);
|
|
var allData = await MMDataService.getAlarmRawSetup();
|
|
// filtro...
|
|
if (string.IsNullOrEmpty(SearchVal))
|
|
{
|
|
ListRecords = allData;
|
|
}
|
|
else
|
|
{
|
|
ListRecords = allData
|
|
.Where(x => x.FullValue.ToLower().Contains(SearchVal.ToLower()))
|
|
.ToList();
|
|
}
|
|
await Task.Delay(1);
|
|
}
|
|
|
|
protected async Task resetAlarmSetup()
|
|
|
|
{
|
|
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Reset Alarm Config: you are going to reset actual alarm configuration. Are you sure to proceed?"))
|
|
return;
|
|
await Task.Delay(1);
|
|
var baseConf = await MMDataService.getAlarmRLConfig();
|
|
await MMDataService.setAlarmSetupRawList(baseConf);
|
|
await ReloadData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Inverte valore muted dell'allarme
|
|
/// </summary>
|
|
/// <param name="currAlarm"></param>
|
|
/// <returns></returns>
|
|
protected async Task toggleMute(AlarmListModel currAlarm)
|
|
{
|
|
// calcolo inverso del valore richiesto
|
|
if (ListRecords != null && ListRecords.Count > 0)
|
|
{
|
|
// sostituisco in elenco
|
|
ListRecords.Remove(currAlarm);
|
|
currAlarm.Muted = !currAlarm.Muted;
|
|
ListRecords.Add(currAlarm);
|
|
ListRecords = ListRecords.OrderBy(x => x.FullValue).ToList();
|
|
// salvo su redis...
|
|
await MMDataService.setAlarmSetupRawList(ListRecords);
|
|
}
|
|
await Task.Delay(1);
|
|
await ReloadData();
|
|
await Task.Delay(1);
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Properties
|
|
|
|
private string _searchVal { get; set; } = "";
|
|
|
|
private string SearchVal
|
|
{
|
|
get
|
|
{
|
|
return _searchVal;
|
|
}
|
|
set
|
|
{
|
|
_searchVal = value;
|
|
var pUpd = Task.Run(async () =>
|
|
{
|
|
await ReloadData();
|
|
});
|
|
pUpd.Wait();
|
|
}
|
|
}
|
|
|
|
#endregion Private Properties
|
|
}
|
|
} |