Skip to content

Commit

Permalink
fix for grpc
Browse files Browse the repository at this point in the history
  • Loading branch information
michielpost committed Nov 15, 2023
1 parent 5333f5f commit 2e80200
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
10 changes: 5 additions & 5 deletions HueLightDJ.Blazor.Controls/Pages/LightDJ.razor
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<MudText Typo="Typo.h3">@config?.Name</MudText>

<MudPaper Class="d-flex flex-row flex-grow-1 gap-4" Elevation="0">
<MudText>Log msg:</MudText>
<MudText>@lastMsg</MudText>
<MudText>Log msg:</MudText>
<MudText>@lastMsg</MudText>
</MudPaper>


Expand Down Expand Up @@ -55,9 +55,9 @@
@foreach (var effectGroup in effectsVM.BaseEffects)
{
<MudPaper>
<MudText Typo="Typo.h6">@effectGroup.Key</MudText>
<MudText Typo="Typo.h6">@effectGroup.Title</MudText>

@foreach (var effect in effectGroup.Value)
@foreach (var effect in effectGroup.Effects)
{
<MudPaper Class="d-flex flex-row flex-grow-1 gap-4" Elevation="0">
<MudButton Variant="Variant.Text" Color="Color.Primary" OnClick="@(() => LightDJService.StartEffect(new StartEffectRequest { TypeName = effect.TypeName, ColorHex = effect.IsRandom ? null : effect.Color}))">@effect.Name</MudButton>
Expand All @@ -75,7 +75,7 @@
}

</MudPaper>
<br />
<br />
}

<MudText Typo="Typo.h5">Short Effects</MudText>
Expand Down
11 changes: 9 additions & 2 deletions HueLightDJ.Services.Interfaces/Models/EffectViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,21 @@ namespace HueLightDJ.Services.Interfaces.Models
[ProtoContract(ImplicitFields = ImplicitFields.AllPublic)]
public class EffectsVM
{
public Dictionary<string, List<EffectViewModel>> BaseEffects { get; set; } = new();
public List<EffectList> BaseEffects { get; set; } = new();
public List<EffectViewModel> ShortEffects { get; set; } = new();
public List<EffectViewModel> GroupEffects { get; set; } = new();
public List<string> IteratorModes { get; set; } = new();
public List<string> SecondaryIteratorModes { get; set; } = new();

}

[ProtoContract(ImplicitFields = ImplicitFields.AllPublic)]
public class EffectList
{
public required string Title { get; set; }
public List<EffectViewModel> Effects { get; set; } = new();
}

[ProtoContract(ImplicitFields = ImplicitFields.AllPublic)]
public class EffectViewModel
{
Expand All @@ -27,7 +34,7 @@ public class EffectViewModel


//VueJS properties:
public string Color { get; set; } = default!;
public string? Color { get; set; }

public bool IsRandom { get; set; } = true;

Expand Down
9 changes: 5 additions & 4 deletions HueLightDJ.Services/Internal/EffectService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static EffectsVM GetEffectViewModels()



Dictionary<string, List<EffectViewModel>> baseEffects = new Dictionary<string, List<EffectViewModel>>();
List<EffectList> baseEffects = new();
List<EffectViewModel> shortEffects = new List<EffectViewModel>();
List<EffectViewModel> groupEffects = new List<EffectViewModel>();
foreach (var type in all)
Expand All @@ -96,10 +96,11 @@ public static EffectsVM GetEffectViewModels()

if (hueEffectAtt.IsBaseEffect)
{
if (!baseEffects.ContainsKey(hueEffectAtt.Group))
baseEffects.Add(hueEffectAtt.Group, new List<EffectViewModel>());
if (!baseEffects.Where(x => x.Title == hueEffectAtt.Group).Any())
baseEffects.Add(new EffectList { Title = hueEffectAtt.Group });

baseEffects[hueEffectAtt.Group].Add(effect);
var current = baseEffects.Where(x => x.Title == hueEffectAtt.Group).Select(x => x).Single();
current.Effects.Add(effect);
}
else
shortEffects.Add(effect);
Expand Down

0 comments on commit 2e80200

Please sign in to comment.