mirror of
https://github.com/Sonarr/Sonarr
synced 2024-12-26 01:37:07 +00:00
Toggle episode monitored status from the table
This commit is contained in:
parent
966b9d62b7
commit
3aa0507912
6 changed files with 52 additions and 14 deletions
|
@ -19,6 +19,7 @@ namespace NzbDrone.Api.Episodes
|
||||||
_mediaFileRepository = mediaFileRepository;
|
_mediaFileRepository = mediaFileRepository;
|
||||||
|
|
||||||
GetResourceAll = GetEpisodes;
|
GetResourceAll = GetEpisodes;
|
||||||
|
UpdateResource = SetMonitored;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<EpisodeResource> GetEpisodes()
|
private List<EpisodeResource> GetEpisodes()
|
||||||
|
@ -35,5 +36,12 @@ namespace NzbDrone.Api.Episodes
|
||||||
|
|
||||||
return resource.ToList();
|
return resource.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private EpisodeResource SetMonitored(EpisodeResource episodeResource)
|
||||||
|
{
|
||||||
|
_episodeService.SetEpisodeMonitored(episodeResource.Id, episodeResource.Monitored);
|
||||||
|
|
||||||
|
return episodeResource;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -140,6 +140,7 @@
|
||||||
<Compile Include="RootFolders\RootFolderResource.cs" />
|
<Compile Include="RootFolders\RootFolderResource.cs" />
|
||||||
<Compile Include="RootFolders\RootFolderConnection.cs" />
|
<Compile Include="RootFolders\RootFolderConnection.cs" />
|
||||||
<Compile Include="Seasons\SeasonModule.cs" />
|
<Compile Include="Seasons\SeasonModule.cs" />
|
||||||
|
<Compile Include="Seasons\SeasonResource.cs" />
|
||||||
<Compile Include="Series\SeriesConnection.cs" />
|
<Compile Include="Series\SeriesConnection.cs" />
|
||||||
<Compile Include="Series\SeriesResource.cs" />
|
<Compile Include="Series\SeriesResource.cs" />
|
||||||
<Compile Include="Series\SeriesModule.cs" />
|
<Compile Include="Series\SeriesModule.cs" />
|
||||||
|
|
|
@ -1,29 +1,37 @@
|
||||||
using System.Linq;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using Nancy;
|
using Nancy;
|
||||||
using NzbDrone.Api.Extensions;
|
using NzbDrone.Api.Extensions;
|
||||||
|
using NzbDrone.Api.REST;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
|
|
||||||
namespace NzbDrone.Api.Seasons
|
namespace NzbDrone.Api.Seasons
|
||||||
{
|
{
|
||||||
public class SeasonModule : NzbDroneApiModule
|
public class SeasonModule : NzbDroneRestModule<SeasonResource>
|
||||||
{
|
{
|
||||||
private readonly ISeasonService _seasonService;
|
private readonly ISeasonService _seasonService;
|
||||||
|
|
||||||
public SeasonModule(ISeasonService seasonService)
|
public SeasonModule(ISeasonService seasonService)
|
||||||
: base("/Season")
|
: base("/season")
|
||||||
{
|
{
|
||||||
_seasonService = seasonService;
|
_seasonService = seasonService;
|
||||||
|
|
||||||
Get["/"] = x => GetSeasons();
|
GetResourceAll = GetSeasons;
|
||||||
|
UpdateResource = SetMonitored;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Response GetSeasons()
|
private List<SeasonResource> GetSeasons()
|
||||||
{
|
{
|
||||||
var seriesId = Request.Query.SeriesId;
|
var seriesId = Request.Query.SeriesId;
|
||||||
|
|
||||||
return JsonExtensions.AsResponse(_seasonService.GetSeasonsBySeries(seriesId));
|
return ToListResource<Season>(() => _seasonService.GetSeasonsBySeries(seriesId));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private SeasonResource SetMonitored(SeasonResource seasonResource)
|
||||||
|
{
|
||||||
|
_seasonService.SetMonitored(seasonResource.SeriesId, seasonResource.SeasonNumber, seasonResource.Monitored);
|
||||||
|
|
||||||
|
return seasonResource;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
16
NzbDrone.Api/Seasons/SeasonResource.cs
Normal file
16
NzbDrone.Api/Seasons/SeasonResource.cs
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using NzbDrone.Api.REST;
|
||||||
|
using NzbDrone.Core.Tv;
|
||||||
|
|
||||||
|
namespace NzbDrone.Api.Seasons
|
||||||
|
{
|
||||||
|
public class SeasonResource : RestResource
|
||||||
|
{
|
||||||
|
public int SeriesId { get; set; }
|
||||||
|
public int SeasonNumber { get; set; }
|
||||||
|
public Boolean Monitored { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,11 +21,8 @@ define(
|
||||||
this.model.save();
|
this.model.save();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
render: function () {
|
render: function () {
|
||||||
this.$el.empty();
|
this.$el.empty();
|
||||||
|
|
||||||
|
|
||||||
this.$el.html('<i />');
|
this.$el.html('<i />');
|
||||||
|
|
||||||
var name = this.column.get('name');
|
var name = this.column.get('name');
|
||||||
|
@ -36,6 +33,13 @@ define(
|
||||||
else {
|
else {
|
||||||
this.$('i').addClass(this.column.get('falseClass'));
|
this.$('i').addClass(this.column.get('falseClass'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var tooltip = this.column.get('tooltip');
|
||||||
|
|
||||||
|
if (tooltip) {
|
||||||
|
this.$('i').attr('title', tooltip);
|
||||||
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -28,11 +28,12 @@ define(
|
||||||
columns:
|
columns:
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
name : 'ignored',
|
name : 'monitored',
|
||||||
label : '',
|
label : '',
|
||||||
cell : ToggleCell,
|
cell : ToggleCell,
|
||||||
trueClass : 'icon-bookmark-empty',
|
trueClass : 'icon-bookmark',
|
||||||
falseClass: 'icon-bookmark'
|
falseClass: 'icon-bookmark-empty',
|
||||||
|
tooltip : 'Toggle monitored status'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name : 'episodeNumber',
|
name : 'episodeNumber',
|
||||||
|
|
Loading…
Reference in a new issue