Browse Source

fix yaml guid validation (#2257)

pull/2258/head
Jason Dove 1 year ago committed by GitHub
parent
commit
11100a788b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      ErsatzTV.Application/Channels/Commands/CreateChannelHandler.cs
  2. 2
      ErsatzTV.Application/Channels/Commands/UpdateChannelHandler.cs
  3. 4
      ErsatzTV/Pages/ChannelEditor.razor
  4. 4
      ErsatzTV/Resources/yaml-playout-import.schema.json
  5. 4
      ErsatzTV/Resources/yaml-playout.schema.json
  6. 9
      ErsatzTV/Validators/ChannelEditViewModelValidator.cs

2
ErsatzTV.Application/Channels/Commands/CreateChannelHandler.cs

@ -91,7 +91,7 @@ public class CreateChannelHandler( @@ -91,7 +91,7 @@ public class CreateChannelHandler(
TranscodeMode = request.TranscodeMode,
IdleBehavior = request.IdleBehavior,
IsEnabled = request.IsEnabled,
ShowInEpg = request.ShowInEpg
ShowInEpg = request.IsEnabled && request.ShowInEpg
};
foreach (int id in watermarkId)

2
ErsatzTV.Application/Channels/Commands/UpdateChannelHandler.cs

@ -46,7 +46,7 @@ public class UpdateChannelHandler( @@ -46,7 +46,7 @@ public class UpdateChannelHandler(
c.TranscodeMode = update.TranscodeMode;
c.IdleBehavior = update.IdleBehavior;
c.IsEnabled = update.IsEnabled;
c.ShowInEpg = update.ShowInEpg;
c.ShowInEpg = update.IsEnabled && update.ShowInEpg;
c.Artwork ??= [];
if (!string.IsNullOrWhiteSpace(update.Logo?.Path))

4
ErsatzTV/Pages/ChannelEditor.razor

@ -80,13 +80,13 @@ @@ -80,13 +80,13 @@
<div class="d-flex">
<MudText>Is Enabled</MudText>
</div>
<MudCheckBox @bind-Value="_model.IsEnabled" Dense="true"/>
<MudCheckBox @bind-Value="_model.IsEnabled" For="@(() => _model.IsEnabled)" Dense="true"/>
</MudStack>
<MudStack Row="true" Breakpoint="Breakpoint.SmAndDown" Class="form-field-stack gap-md-8 mb-5">
<div class="d-flex">
<MudText>Show In EPG</MudText>
</div>
<MudCheckBox @bind-Value="_model.ShowInEpg" Dense="true"/>
<MudCheckBox @bind-Value="_model.ShowInEpg" For="@(() => _model.ShowInEpg)" Dense="true"/>
</MudStack>
<MudStack Row="true" Breakpoint="Breakpoint.SmAndDown" Class="form-field-stack gap-md-8 mb-5">
<div class="d-flex">

4
ErsatzTV/Resources/yaml-playout-import.schema.json

@ -80,7 +80,7 @@ @@ -80,7 +80,7 @@
"type": "object",
"properties": {
"source": { "type": "string" },
"value": { "type": "string" }
"value": { "type": ["integer", "string"] }
},
"required": [ "source", "value" ],
"additionalProperties": false
@ -154,7 +154,7 @@ @@ -154,7 +154,7 @@
"type": "object",
"properties": {
"source": { "type": "string" },
"value": { "type": "string" }
"value": { "type": ["integer", "string"] }
},
"required": [ "source", "value" ],
"additionalProperties": false

4
ErsatzTV/Resources/yaml-playout.schema.json

@ -124,7 +124,7 @@ @@ -124,7 +124,7 @@
"type": "object",
"properties": {
"source": { "type": "string" },
"value": { "type": "string" }
"value": { "type": ["integer", "string"] }
},
"required": [ "source", "value" ],
"additionalProperties": false
@ -198,7 +198,7 @@ @@ -198,7 +198,7 @@
"type": "object",
"properties": {
"source": { "type": "string" },
"value": { "type": "string" }
"value": { "type": ["integer", "string"] }
},
"required": [ "source", "value" ],
"additionalProperties": false

9
ErsatzTV/Validators/ChannelEditViewModelValidator.cs

@ -24,6 +24,15 @@ public class ChannelEditViewModelValidator : AbstractValidator<ChannelEditViewMo @@ -24,6 +24,15 @@ public class ChannelEditViewModelValidator : AbstractValidator<ChannelEditViewMo
.Must(Artwork.IsExternalUrl)
.WithMessage("External logo url is invalid");
});
When(
x => x.IsEnabled == false,
() =>
{
RuleFor(x => x.ShowInEpg)
.Must(x => x == false)
.WithMessage("Disabled channels cannot be shown in EPG");
});
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>

Loading…
Cancel
Save