mirror of
https://github.com/Stefan-5422/-T5-Elektrifikatsiya.git
synced 2026-09-04 00:45:58 +02:00
red delete button settings page
This commit is contained in:
@@ -52,9 +52,14 @@
|
|||||||
</Column>
|
</Column>
|
||||||
|
|
||||||
<Column ColumnSize="ColumnSize.Is4.OnDesktop.Is7.OnMobile">
|
<Column ColumnSize="ColumnSize.Is4.OnDesktop.Is7.OnMobile">
|
||||||
<Button Position="Position.Absolute.Top.Is50.Start.Is50.Translate.Middle" Color="Color.Dark" Outline>
|
<Button class="btn1" Position="Position.Absolute.Top.Is50.Start.Is50.Translate.Middle" Color="Color.Dark" Outline>
|
||||||
<BarIcon @onclick="() => Delete(context.Item)" IconName="IconName.Delete" />
|
<BarIcon @onclick="() => Delete(context.Item)" IconName="IconName.Delete" />
|
||||||
</Button>
|
</Button>
|
||||||
|
<style>
|
||||||
|
.btn1:hover {
|
||||||
|
background: #E50000;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
</Column>
|
</Column>
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
@@ -145,6 +150,7 @@
|
|||||||
bool hideButtonSettings = true;
|
bool hideButtonSettings = true;
|
||||||
|
|
||||||
int clicks = 0;
|
int clicks = 0;
|
||||||
|
bool test = false;
|
||||||
|
|
||||||
double electricityPrice = 0;
|
double electricityPrice = 0;
|
||||||
|
|
||||||
@@ -160,11 +166,12 @@
|
|||||||
plugs = getDevicesResult.Value;
|
plugs = getDevicesResult.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
electricityPrice = MainDatabaseContext.EnergyPriceChanges.OrderByDescending(e=>e.DateTime).FirstOrDefault()?.EnergyPrice ?? 0;
|
electricityPrice = MainDatabaseContext.EnergyPriceChanges.OrderByDescending(e => e.DateTime).FirstOrDefault()?.EnergyPrice ?? 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Toggle(Device device)
|
private void Toggle(Device device)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (device == SelectedDevice || clicks == 0)
|
if (device == SelectedDevice || clicks == 0)
|
||||||
{
|
{
|
||||||
hideButtonSettings = !hideButtonSettings;
|
hideButtonSettings = !hideButtonSettings;
|
||||||
@@ -176,7 +183,9 @@
|
|||||||
{
|
{
|
||||||
SelectedDevice = device;
|
SelectedDevice = device;
|
||||||
DeviceCopy = device.CopyDevice();
|
DeviceCopy = device.CopyDevice();
|
||||||
|
clicks = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void OnSave()
|
private async void OnSave()
|
||||||
@@ -187,7 +196,7 @@
|
|||||||
MainDatabaseContext.EnergyPriceChanges.Add(new EnergyPriceChange(electricityPrice));
|
MainDatabaseContext.EnergyPriceChanges.Add(new EnergyPriceChange(electricityPrice));
|
||||||
await MainDatabaseContext.SaveChangesAsync();
|
await MainDatabaseContext.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
else if(DeviceCopy is not null && SelectedDevice is not null)
|
else if (DeviceCopy is not null && SelectedDevice is not null)
|
||||||
{
|
{
|
||||||
|
|
||||||
SelectedDevice.OverwiteDevice(DeviceCopy);
|
SelectedDevice.OverwiteDevice(DeviceCopy);
|
||||||
@@ -199,7 +208,7 @@
|
|||||||
{
|
{
|
||||||
bool succ = await MessageService.Confirm($"Do you really want to delete the device \"{contextItem.Name}\"?");
|
bool succ = await MessageService.Confirm($"Do you really want to delete the device \"{contextItem.Name}\"?");
|
||||||
|
|
||||||
if(!succ)
|
if (!succ)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -208,7 +217,7 @@
|
|||||||
|
|
||||||
int index = plugs.FindIndex(x => x.MacAddress == contextItem.MacAddress);
|
int index = plugs.FindIndex(x => x.MacAddress == contextItem.MacAddress);
|
||||||
|
|
||||||
if(index != -1)
|
if (index != -1)
|
||||||
{
|
{
|
||||||
plugs.RemoveAt(index);
|
plugs.RemoveAt(index);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user