mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-14 02:26:55 -07:00
Started working on #26
This commit is contained in:
parent
2b20af5df0
commit
748fe2ca2d
6 changed files with 169 additions and 8 deletions
|
@ -10,9 +10,11 @@
|
|||
$(function () {
|
||||
|
||||
var searchSource = $("#search-template").html();
|
||||
var seasonsSource = $("#seasons-template").html();
|
||||
var musicSource = $("#music-template").html();
|
||||
var searchTemplate = Handlebars.compile(searchSource);
|
||||
var musicTemplate = Handlebars.compile(musicSource);
|
||||
var seasonsTemplate = Handlebars.compile(seasonsSource);
|
||||
|
||||
var base = $('#baseUrl').text();
|
||||
|
||||
|
@ -162,7 +164,7 @@ $(function () {
|
|||
$.ajax({
|
||||
type: "post",
|
||||
url: url,
|
||||
data: {notify: checked},
|
||||
data: { notify: checked },
|
||||
dataType: "json",
|
||||
success: function (response) {
|
||||
console.log(response);
|
||||
|
@ -301,7 +303,7 @@ $(function () {
|
|||
|
||||
var html = musicTemplate(context);
|
||||
$("#musicList").append(html);
|
||||
getCoverArt(context.id);
|
||||
getCoverArt(context.id);
|
||||
});
|
||||
}
|
||||
else {
|
||||
|
@ -385,4 +387,67 @@ $(function () {
|
|||
return context;
|
||||
}
|
||||
|
||||
$('#seasonsModal').on('show.bs.modal', function (event) {
|
||||
var button = $(event.relatedTarget); // Button that triggered the modal
|
||||
var id = button.data('identifier'); // Extract info from data-* attributes
|
||||
var url = createBaseUrl(base, '/search/seasons/');
|
||||
|
||||
$.ajax({
|
||||
type: "get",
|
||||
url: url,
|
||||
data: { tvId: id },
|
||||
dataType: "json",
|
||||
success: function (results) {
|
||||
var $content = $("#seasonsBody");
|
||||
$('#selectedSeasonsId').val(id);
|
||||
results.forEach(function(result) {
|
||||
var context = buildSeasonsContext(result);
|
||||
$content.append(seasonsTemplate(context));
|
||||
});
|
||||
},
|
||||
error: function (e) {
|
||||
console.log(e);
|
||||
generateNotify("Something went wrong!", "danger");
|
||||
}
|
||||
});
|
||||
|
||||
function buildSeasonsContext(result) {
|
||||
var context = {
|
||||
id: result
|
||||
};
|
||||
return context;
|
||||
};
|
||||
});
|
||||
|
||||
$('#seasonsRequest').click(function(e) {
|
||||
e.preventDefault();
|
||||
var tvId = $('#selectedSeasonsId').val();
|
||||
var url = createBaseUrl(base, '/search/seasons/');
|
||||
|
||||
if ($("#" + tvId).attr('disabled')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$("#" + tvId).prop("disabled", true);
|
||||
loadingButton(tvId, "primary");
|
||||
|
||||
|
||||
var $form = $('#form' + tvId);
|
||||
var data = $form.serialize();
|
||||
var seasonsParam = "&seasons=";
|
||||
|
||||
var testimonials = document.querySelectorAll('.selectedSeasons');
|
||||
Array.prototype.forEach.call(testimonials, function (elements, index) {
|
||||
seasonsParam = seasonsParam + elements.text() + ",";
|
||||
});
|
||||
|
||||
data = data + seasonsParam;
|
||||
|
||||
var type = $form.prop('method');
|
||||
var url = $form.prop('action');
|
||||
|
||||
sendRequestAjax(data, type, url, tvId);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -310,7 +310,7 @@ namespace PlexRequests.UI.Modules
|
|||
|
||||
private Response DeleteRequest(int requestid)
|
||||
{
|
||||
this.RequiresClaims (UserClaims.PowerUser, UserClaims.Admin);
|
||||
this.RequiresClaims (UserClaims.Admin);
|
||||
|
||||
var currentEntity = Service.Get(requestid);
|
||||
Service.DeleteRequest(currentEntity);
|
||||
|
|
|
@ -106,6 +106,8 @@ namespace PlexRequests.UI.Modules
|
|||
|
||||
Post["/notifyuser"] = x => NotifyUser((bool)Request.Form.notify);
|
||||
Get["/notifyuser"] = x => GetUserNotificationSettings();
|
||||
|
||||
Get["/seasons"] = x => GetSeasons();
|
||||
}
|
||||
private IPlexApi PlexApi { get; }
|
||||
private TheMovieDbApi MovieApi { get; }
|
||||
|
@ -942,11 +944,20 @@ namespace PlexRequests.UI.Modules
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
public Response GetUserNotificationSettings()
|
||||
private Response GetUserNotificationSettings()
|
||||
{
|
||||
var retval = UsersToNotifyRepo.GetAll().FirstOrDefault(x => x.Username == Username);
|
||||
return Response.AsJson(retval != null);
|
||||
}
|
||||
|
||||
private Response GetSeasons()
|
||||
{
|
||||
var tv = new TvMazeApi();
|
||||
var seriesId = (int)Request.Query.tvId;
|
||||
var show = tv.ShowLookupByTheTvDbId(seriesId);
|
||||
var seasons = tv.GetSeasons(show.id);
|
||||
var model = seasons.Select(x => x.number);
|
||||
return Response.AsJson(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@
|
|||
<div class="input-group">
|
||||
<div class="input-group-addon input-group-sm"></div>
|
||||
</div>
|
||||
<br/>
|
||||
<br />
|
||||
|
||||
<!-- Notifications content -->
|
||||
<form class="form-horizontal" method="POST" id="notificationsForm">
|
||||
|
@ -190,6 +190,7 @@
|
|||
<li><a id="{{id}}" season-select="0" class="dropdownTv " href="#">All Seasons</a></li>
|
||||
<li><a id="{{id}}" season-select="1" class="dropdownTv" href="#">First Season</a></li>
|
||||
<li><a id="{{id}}" season-select="2" class="dropdownTv" href="#">Latest Season</a></li>
|
||||
<li><a id="SeasonSelect" data-identifier="{{id}}" data-toggle="modal" data-target="#seasonsModal" href="#">Select...</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
{{/if_eq}}
|
||||
|
@ -253,7 +254,36 @@
|
|||
|
||||
</div>
|
||||
<hr />
|
||||
|
||||
</script>
|
||||
|
||||
<div class="modal fade" id="seasonsModal">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title">Seasons</h4>
|
||||
</div>
|
||||
<div class="modal-body" id="seasonsBody">
|
||||
|
||||
</div>
|
||||
|
||||
<div hidden="hidden" id="selectedSeasonsId"></div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
||||
<button type="button" id="seasonsRequest" class="btn btn-primary">Request</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script id="seasons-template" type="text/x-handlebars-template">
|
||||
<div class="form-group">
|
||||
<div class="checkbox">
|
||||
<input type="checkbox" class=".selectedSeasons" id="{{id}}" name="{{id}}"><label for="{{id}}">Season {{id}}</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</script>
|
||||
|
||||
@Html.LoadSearchAssets()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue