changed the way to trigger a playlist sync
This commit is contained in:
@@ -14,11 +14,13 @@ namespace Tv7Playlist.Controllers
|
|||||||
{
|
{
|
||||||
private readonly PlaylistContext _playlistContext;
|
private readonly PlaylistContext _playlistContext;
|
||||||
private readonly IPlaylistSynchronizer _playlistSynchronizer;
|
private readonly IPlaylistSynchronizer _playlistSynchronizer;
|
||||||
|
private readonly IAppConfig _appConfig;
|
||||||
|
|
||||||
public HomeController(PlaylistContext playlistContext, IPlaylistSynchronizer playlistSynchronizer)
|
public HomeController(PlaylistContext playlistContext, IPlaylistSynchronizer playlistSynchronizer, IAppConfig appConfig)
|
||||||
{
|
{
|
||||||
_playlistContext = playlistContext ?? throw new ArgumentNullException(nameof(playlistContext));
|
_playlistContext = playlistContext ?? throw new ArgumentNullException(nameof(playlistContext));
|
||||||
_playlistSynchronizer = playlistSynchronizer ?? throw new ArgumentNullException(nameof(playlistSynchronizer));
|
_playlistSynchronizer = playlistSynchronizer ?? throw new ArgumentNullException(nameof(playlistSynchronizer));
|
||||||
|
_appConfig = appConfig ?? throw new ArgumentNullException(nameof(appConfig));
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
@@ -42,6 +44,14 @@ namespace Tv7Playlist.Controllers
|
|||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Route("synchronize")]
|
[Route("synchronize")]
|
||||||
public async Task<IActionResult> Synchronize()
|
public async Task<IActionResult> Synchronize()
|
||||||
|
{
|
||||||
|
var homeSynchronizeModel = new HomeSynchronizeModel(_appConfig.TV7Url);
|
||||||
|
return View(homeSynchronizeModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
[Route("synchronize")]
|
||||||
|
public async Task<IActionResult> Synchronize(bool ok)
|
||||||
{
|
{
|
||||||
await _playlistSynchronizer.SynchronizeAsync();
|
await _playlistSynchronizer.SynchronizeAsync();
|
||||||
|
|
||||||
|
12
Tv7Playlist/Models/HomeSynchronizeModel.cs
Normal file
12
Tv7Playlist/Models/HomeSynchronizeModel.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
namespace Tv7Playlist.Models
|
||||||
|
{
|
||||||
|
public class HomeSynchronizeModel
|
||||||
|
{
|
||||||
|
public HomeSynchronizeModel(string synchronizationUrl)
|
||||||
|
{
|
||||||
|
SynchronizationUrl = synchronizationUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string SynchronizationUrl { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@@ -1,14 +0,0 @@
|
|||||||
using Tv7Playlist.Data;
|
|
||||||
|
|
||||||
namespace Tv7Playlist.Models
|
|
||||||
{
|
|
||||||
public class PlaylistEntryEditViewModel
|
|
||||||
{
|
|
||||||
public PlaylistEntryEditViewModel(PlaylistEntry playlistEntry)
|
|
||||||
{
|
|
||||||
PlaylistEntry = playlistEntry;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PlaylistEntry PlaylistEntry { get; }
|
|
||||||
}
|
|
||||||
}
|
|
28
Tv7Playlist/Views/Home/Synchronize.cshtml
Normal file
28
Tv7Playlist/Views/Home/Synchronize.cshtml
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
@model HomeSynchronizeModel;
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "TV7 Playlist - Synchronize";
|
||||||
|
}
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col offset-3 col-7">
|
||||||
|
<h3>Synchronize TV7 playlist</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col offset-3 col-1">
|
||||||
|
Synchronization URL:
|
||||||
|
</div>
|
||||||
|
<div class="col col-2">
|
||||||
|
@Model.SynchronizationUrl
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col offset-3 col-7">
|
||||||
|
<form asp-action="Synchronize">
|
||||||
|
<input type="hidden" id="ok" value="true"/>
|
||||||
|
<input type="submit" value="Run Synchronization" class="btn btn-primary"/>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
@@ -1,6 +1,6 @@
|
|||||||
@model Tv7Playlist.Data.PlaylistEntry;
|
@model Tv7Playlist.Data.PlaylistEntry;
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Edit Entry";
|
ViewData["Title"] = $"Edit channel {Model.TrackNumber} - {Model.Name}";
|
||||||
}
|
}
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
Reference in New Issue
Block a user