mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
add new notification features
This commit is contained in:
parent
b94fa3f72c
commit
28ea06a627
9 changed files with 320 additions and 812 deletions
|
@ -289,7 +289,7 @@
|
|||
$('.lnkBrowseAllImages', page).addClass('hide');
|
||||
}
|
||||
|
||||
ApiClient.getItemImageInfos(currentItem.Id, currentItem.Type, currentItem.Name).done(function (imageInfos) {
|
||||
ApiClient.getItemImageInfos(currentItem.Id).done(function (imageInfos) {
|
||||
|
||||
renderStandardImages(page, item, imageInfos, providers);
|
||||
renderBackdrops(page, item, imageInfos, providers);
|
||||
|
@ -486,7 +486,7 @@
|
|||
|
||||
var imageType = $('#selectImageType', page).val();
|
||||
|
||||
ApiClient.uploadItemImage(currentItem.Id, currentItem.Type, currentItem.Name, imageType, file).done(function () {
|
||||
ApiClient.uploadItemImage(currentItem.Id, imageType, file).done(function () {
|
||||
|
||||
$('#uploadImage', page).val('').trigger('change');
|
||||
$('#popupUpload', page).popup("close");
|
||||
|
@ -504,7 +504,7 @@
|
|||
Dashboard.confirm("Are you sure you wish to delete this image?", "Delete " + type + " Image", function (result) {
|
||||
|
||||
if (result) {
|
||||
ApiClient.deleteItemImage(currentItem.Id, currentItem.Type, currentItem.Name, type, index).done(function () {
|
||||
ApiClient.deleteItemImage(currentItem.Id, type, index).done(function () {
|
||||
|
||||
processImageChangeResult(page);
|
||||
|
||||
|
@ -520,7 +520,7 @@
|
|||
|
||||
var page = $.mobile.activePage;
|
||||
|
||||
ApiClient.updateItemImageIndex(currentItem.Id, currentItem.Type, currentItem.Name, type, index, newIndex).done(function () {
|
||||
ApiClient.updateItemImageIndex(currentItem.Id, type, index, newIndex).done(function () {
|
||||
|
||||
processImageChangeResult(page);
|
||||
|
||||
|
|
|
@ -807,31 +807,7 @@
|
|||
item.RunTimeTicks = seriesRuntime ? (seriesRuntime * 600000000) : null;
|
||||
}
|
||||
|
||||
var updatePromise;
|
||||
|
||||
if (currentItem.Type == "MusicArtist") {
|
||||
updatePromise = ApiClient.updateArtist(item);
|
||||
}
|
||||
else if (currentItem.Type == "Genre") {
|
||||
updatePromise = ApiClient.updateGenre(item);
|
||||
}
|
||||
else if (currentItem.Type == "MusicGenre") {
|
||||
updatePromise = ApiClient.updateMusicGenre(item);
|
||||
}
|
||||
else if (currentItem.Type == "GameGenre") {
|
||||
updatePromise = ApiClient.updateGameGenre(item);
|
||||
}
|
||||
else if (currentItem.Type == "Person") {
|
||||
updatePromise = ApiClient.updatePerson(item);
|
||||
}
|
||||
else if (currentItem.Type == "Studio") {
|
||||
updatePromise = ApiClient.updateStudio(item);
|
||||
}
|
||||
else {
|
||||
updatePromise = ApiClient.updateItem(item);
|
||||
}
|
||||
|
||||
updatePromise.done(function () {
|
||||
ApiClient.updateItem(item).done(function () {
|
||||
|
||||
Dashboard.alert('Item saved.');
|
||||
|
||||
|
@ -1104,33 +1080,9 @@
|
|||
|
||||
$('#refreshLoading', page).show();
|
||||
|
||||
var refreshPromise;
|
||||
|
||||
var force = $('#selectRefreshMode', page).val() == 'all';
|
||||
|
||||
if (currentItem.Type == "MusicArtist") {
|
||||
refreshPromise = ApiClient.refreshArtist(currentItem.Name, force);
|
||||
}
|
||||
else if (currentItem.Type == "Genre") {
|
||||
refreshPromise = ApiClient.refreshGenre(currentItem.Name, force);
|
||||
}
|
||||
else if (currentItem.Type == "MusicGenre") {
|
||||
refreshPromise = ApiClient.refreshMusicGenre(currentItem.Name, force);
|
||||
}
|
||||
else if (currentItem.Type == "GameGenre") {
|
||||
refreshPromise = ApiClient.refreshGameGenre(currentItem.Name, force);
|
||||
}
|
||||
else if (currentItem.Type == "Person") {
|
||||
refreshPromise = ApiClient.refreshPerson(currentItem.Name, force);
|
||||
}
|
||||
else if (currentItem.Type == "Studio") {
|
||||
refreshPromise = ApiClient.refreshStudio(currentItem.Name, force);
|
||||
}
|
||||
else {
|
||||
refreshPromise = ApiClient.refreshItem(currentItem.Id, force, true);
|
||||
}
|
||||
|
||||
refreshPromise.done(function () {
|
||||
ApiClient.refreshItem(currentItem.Id, force, true).done(function () {
|
||||
|
||||
reload(page);
|
||||
|
||||
|
|
|
@ -14,7 +14,8 @@
|
|||
Limit: screenWidth >= 1920 ? 32 : (screenWidth >= 1440 ? 24 : (screenWidth >= 800 ? 18 : 12)),
|
||||
Recursive: true,
|
||||
Fields: "PrimaryImageAspectRatio",
|
||||
Filters: "IsUnplayed"
|
||||
Filters: "IsUnplayed",
|
||||
CollapseBoxSetItems: false
|
||||
};
|
||||
|
||||
ApiClient.getItems(Dashboard.getCurrentUserId(), options).done(function (result) {
|
||||
|
@ -34,7 +35,8 @@
|
|||
Limit: screenWidth >= 1920 ? 8 : (screenWidth >= 1440 ? 8 : 6),
|
||||
Recursive: true,
|
||||
Fields: "PrimaryImageAspectRatio",
|
||||
Filters: "IsUnplayed"
|
||||
Filters: "IsUnplayed",
|
||||
CollapseBoxSetItems: false
|
||||
};
|
||||
|
||||
ApiClient.getItems(Dashboard.getCurrentUserId(), options).done(function (result) {
|
||||
|
|
|
@ -49,7 +49,8 @@
|
|||
Filters: "IsResumable",
|
||||
Limit: screenWidth >= 1920 ? 4 : (screenWidth >= 1440 ? 4 : 3),
|
||||
Recursive: true,
|
||||
Fields: "PrimaryImageAspectRatio"
|
||||
Fields: "PrimaryImageAspectRatio",
|
||||
CollapseBoxSetItems: false
|
||||
};
|
||||
|
||||
ApiClient.getItems(Dashboard.getCurrentUserId(), options).done(function (result) {
|
||||
|
|
169
dashboard-ui/scripts/notificationsetting.js
Normal file
169
dashboard-ui/scripts/notificationsetting.js
Normal file
|
@ -0,0 +1,169 @@
|
|||
(function () {
|
||||
|
||||
function fillItems(elem, items, cssClass, idPrefix, disabledList) {
|
||||
|
||||
var html = '<div data-role="controlgroup">';
|
||||
|
||||
html += items.map(function (u) {
|
||||
|
||||
var id = idPrefix + u.Id;
|
||||
|
||||
var checkedHtml = disabledList.indexOf(u.Id) != -1 ? '' : ' checked="checked"';
|
||||
|
||||
return '<label for="' + id + '">' + u.Name + '</label><input class="' + cssClass + '" type="checkbox" data-itemid="' + u.Id + '" data-mini="true" id="' + id + '"' + checkedHtml + ' />';
|
||||
|
||||
}).join('');
|
||||
|
||||
html += '</div>';
|
||||
|
||||
elem.html(html).trigger('create');
|
||||
}
|
||||
|
||||
function reload(page) {
|
||||
|
||||
var type = getParameterByName('type');
|
||||
|
||||
var promise1 = ApiClient.getUsers();
|
||||
var promise2 = ApiClient.getServerConfiguration();
|
||||
var promise3 = $.getJSON(ApiClient.getUrl("Notifications/Types"));
|
||||
var promise4 = $.getJSON(ApiClient.getUrl("Notifications/Services"));
|
||||
|
||||
$.when(promise1, promise2, promise3, promise4).done(function (response1, response2, response3, response4) {
|
||||
|
||||
var users = response1[0];
|
||||
var config = response2[0];
|
||||
var types = response3[0];
|
||||
var services = response4[0];
|
||||
|
||||
var notificationConfig = config.NotificationOptions.Options.filter(function (n) {
|
||||
|
||||
return n.Type == type;
|
||||
|
||||
})[0];
|
||||
|
||||
var typeInfo = types.filter(function (n) {
|
||||
|
||||
return n.Type == type;
|
||||
|
||||
})[0] || {};
|
||||
|
||||
if (typeInfo.IsBasedOnUserEvent) {
|
||||
$('.monitorUsers', page).show();
|
||||
} else {
|
||||
$('.monitorUsers', page).hide();
|
||||
}
|
||||
|
||||
if (typeInfo.Variables.length) {
|
||||
$('.tokenHelp', page).show();
|
||||
|
||||
$('.tokenList', page).html(typeInfo.Variables.map(function (v) {
|
||||
|
||||
return '{' + v + '}';
|
||||
|
||||
}).join(', '));
|
||||
|
||||
} else {
|
||||
$('.tokenHelp', page).hide();
|
||||
}
|
||||
|
||||
$('.notificationType', page).html(typeInfo.Name || 'Unknown Notification');
|
||||
|
||||
if (!notificationConfig) {
|
||||
|
||||
notificationConfig = {
|
||||
DisabledMonitorUsers: [],
|
||||
DisabledSendToUsers: [],
|
||||
DisabledServices: []
|
||||
};
|
||||
}
|
||||
|
||||
fillItems($('.monitorUsersList', page), users, 'chkMonitor', 'chkMonitor', notificationConfig.DisabledMonitorUsers);
|
||||
fillItems($('.sendToUsersList', page), users, 'chkSendTo', 'chkSendTo', notificationConfig.DisabledSendToUsers);
|
||||
fillItems($('.servicesList', page), services, 'chkService', 'chkService', notificationConfig.DisabledServices);
|
||||
|
||||
$('#chkEnabled', page).checked(notificationConfig.Enabled || false).checkboxradio('refresh');
|
||||
|
||||
$('#txtTitle', page).val(notificationConfig.Title || typeInfo.DefaultTitle);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function save(page) {
|
||||
|
||||
var type = getParameterByName('type');
|
||||
|
||||
var promise1 = ApiClient.getServerConfiguration();
|
||||
var promise2 = $.getJSON(ApiClient.getUrl("Notifications/Types"));
|
||||
|
||||
$.when(promise1, promise2).done(function (response1, response2) {
|
||||
|
||||
var config = response1[0];
|
||||
var types = response2[0];
|
||||
|
||||
var notificationOptions = config.NotificationOptions;
|
||||
|
||||
var notificationConfig = config.NotificationOptions.Options.filter(function (n) {
|
||||
|
||||
return n.Type == type;
|
||||
|
||||
})[0];
|
||||
|
||||
if (!notificationConfig) {
|
||||
notificationConfig = {
|
||||
Type: type
|
||||
};
|
||||
notificationOptions.Options.push(notificationConfig);
|
||||
}
|
||||
|
||||
var typeInfo = types.filter(function (n) {
|
||||
|
||||
return n.Type == type;
|
||||
|
||||
})[0] || {};
|
||||
|
||||
notificationConfig.Enabled = $('#chkEnabled', page).checked();
|
||||
notificationConfig.Title = $('#txtTitle', page).val();
|
||||
|
||||
// Don't persist if it's just the default
|
||||
if (notificationConfig.Title == typeInfo.DefaultTitle) {
|
||||
notificationConfig.Title = null;
|
||||
}
|
||||
|
||||
notificationConfig.DisabledMonitorUsers = $('.chkMonitor:not(:checked)', page).get().map(function (c) {
|
||||
return c.getAttribute('data-itemid');
|
||||
});
|
||||
|
||||
notificationConfig.DisabledSendToUsers = $('.chkSendTo:not(:checked)', page).get().map(function (c) {
|
||||
return c.getAttribute('data-itemid');
|
||||
});
|
||||
|
||||
notificationConfig.DisabledServices = $('.chkService:not(:checked)', page).get().map(function (c) {
|
||||
return c.getAttribute('data-itemid');
|
||||
});
|
||||
|
||||
ApiClient.updateServerConfiguration(config).done(function(r) {
|
||||
|
||||
Dashboard.navigate('notificationsettings.html');
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
$(document).on('pageshow', "#notificationSettingPage", function () {
|
||||
|
||||
var page = this;
|
||||
|
||||
reload(page);
|
||||
});
|
||||
|
||||
window.NotificationSettingPage = {
|
||||
|
||||
onSubmit: function () {
|
||||
|
||||
var page = $(this).parents('.page');
|
||||
save(page);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
})(jQuery, window);
|
|
@ -2,44 +2,50 @@
|
|||
|
||||
function reload(page) {
|
||||
|
||||
ApiClient.getServerConfiguration().done(function (config) {
|
||||
Dashboard.showLoadingMsg();
|
||||
|
||||
var notificationOptions = config.NotificationOptions;
|
||||
|
||||
$('#chkNewLibraryContent', page).checked(notificationOptions.SendOnNewLibraryContent).checkboxradio('refresh');
|
||||
$('#chkFailedTasks', page).checked(notificationOptions.SendOnFailedTasks).checkboxradio('refresh');
|
||||
$('#chkUpdates', page).checked(notificationOptions.SendOnUpdates).checkboxradio('refresh');
|
||||
|
||||
$('#chkServerRestartRequired', page).checked(notificationOptions.SendOnServerRestartRequired).checkboxradio('refresh');
|
||||
$.getJSON(ApiClient.getUrl("Notifications/Types")).done(function (list) {
|
||||
|
||||
$('#chkVideoPlayback', page).checked(notificationOptions.SendOnVideoPlayback).checkboxradio('refresh');
|
||||
$('#chkAudioPlayback', page).checked(notificationOptions.SendOnAudioPlayback).checkboxradio('refresh');
|
||||
$('#chkGamePlayback', page).checked(notificationOptions.SendOnGamePlayback).checkboxradio('refresh');
|
||||
var html = '<ul data-role="listview" data-inset="true">';
|
||||
|
||||
var lastCategory = "";
|
||||
|
||||
html += list.map(function (i) {
|
||||
|
||||
var itemHtml = '';
|
||||
|
||||
if (i.Category != lastCategory) {
|
||||
lastCategory = i.Category;
|
||||
itemHtml += '<li data-role="list-divider">';
|
||||
itemHtml += i.Category;
|
||||
itemHtml += '</li>';
|
||||
}
|
||||
|
||||
itemHtml += '<li>';
|
||||
itemHtml += '<a href="notificationsetting.html?type=' + i.Type + '">';
|
||||
itemHtml += '<h3>' + i.Name + '</h3>';
|
||||
|
||||
if (i.Enabled) {
|
||||
itemHtml += '<p style="color:#009F00;">Enabled</p>';
|
||||
} else {
|
||||
itemHtml += '<p style="color:#cc0000;">Disabled</p>';
|
||||
}
|
||||
|
||||
itemHtml += '</a>';
|
||||
itemHtml += '</li>';
|
||||
|
||||
return itemHtml;
|
||||
|
||||
}).join('');
|
||||
|
||||
html += '</ul>';
|
||||
|
||||
$('.notificationList', page).html(html).trigger('create');
|
||||
|
||||
Dashboard.hideLoadingMsg();
|
||||
});
|
||||
}
|
||||
|
||||
function save(page) {
|
||||
|
||||
ApiClient.getServerConfiguration().done(function (config) {
|
||||
|
||||
var notificationOptions = config.NotificationOptions;
|
||||
|
||||
notificationOptions.SendOnNewLibraryContent = $('#chkNewLibraryContent', page).checked();
|
||||
notificationOptions.SendOnFailedTasks = $('#chkFailedTasks', page).checked();
|
||||
notificationOptions.SendOnUpdates = $('#chkUpdates', page).checked();
|
||||
|
||||
notificationOptions.SendOnServerRestartRequired = $('#chkServerRestartRequired', page).checked();
|
||||
|
||||
notificationOptions.SendOnVideoPlayback = $('#chkVideoPlayback', page).checked();
|
||||
notificationOptions.SendOnAudioPlayback = $('#chkAudioPlayback', page).checked();
|
||||
notificationOptions.SendOnGamePlayback = $('#chkGamePlayback', page).checked();
|
||||
|
||||
ApiClient.updateServerConfiguration(config).done(Dashboard.processServerConfigurationUpdateResult);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
$(document).on('pageshow', "#notificationSettingsPage", function () {
|
||||
|
||||
var page = this;
|
||||
|
@ -47,14 +53,4 @@
|
|||
reload(page);
|
||||
});
|
||||
|
||||
window.NotificationSettingsPage = {
|
||||
|
||||
onSubmit: function () {
|
||||
|
||||
var page = $(this).parents('.page');
|
||||
save(page);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
})(jQuery, window);
|
Loading…
Add table
Add a link
Reference in a new issue