1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

switch to unified notifications

This commit is contained in:
Luke Pulverenti 2016-07-22 13:30:39 -04:00
parent fa438393af
commit cec6b66c27
19 changed files with 200 additions and 514 deletions

View file

@ -15,12 +15,12 @@
}, },
"devDependencies": {}, "devDependencies": {},
"ignore": [], "ignore": [],
"version": "1.4.113", "version": "1.4.114",
"_release": "1.4.113", "_release": "1.4.114",
"_resolution": { "_resolution": {
"type": "version", "type": "version",
"tag": "1.4.113", "tag": "1.4.114",
"commit": "03c34e718b6b72ec847567dcedb114e32ff8a1f0" "commit": "cf5d4390c6b08e025aaa3d7086172c483bc440ed"
}, },
"_source": "https://github.com/MediaBrowser/emby-webcomponents.git", "_source": "https://github.com/MediaBrowser/emby-webcomponents.git",
"_target": "^1.2.0", "_target": "^1.2.0",

View file

@ -1,4 +1,4 @@
define(['connectionManager', 'playbackManager', 'events', 'inputManager', 'focusManager'], function (connectionManager, playbackManager, events, inputManager, focusManager) { define(['connectionManager', 'playbackManager', 'events', 'inputManager', 'focusManager', 'embyRouter'], function (connectionManager, playbackManager, events, inputManager, focusManager, embyRouter) {
function displayMessage(cmd) { function displayMessage(cmd) {
@ -18,7 +18,14 @@ define(['connectionManager', 'playbackManager', 'events', 'inputManager', 'focus
} }
} }
function processGeneralCommand(cmd) { function displayContent(cmd, apiClient) {
apiClient.getItem(apiClient.getCurrentUserId(), cmd.ItemId).then(function (item) {
embyRouter.showItem(item);
});
}
function processGeneralCommand(cmd, apiClient) {
// Full list // Full list
// https://github.com/MediaBrowser/MediaBrowser/blob/master/MediaBrowser.Model/Session/GeneralCommand.cs#L23 // https://github.com/MediaBrowser/MediaBrowser/blob/master/MediaBrowser.Model/Session/GeneralCommand.cs#L23
@ -93,7 +100,7 @@ define(['connectionManager', 'playbackManager', 'events', 'inputManager', 'focus
inputManager.trigger('settings'); inputManager.trigger('settings');
break; break;
case 'DisplayContent': case 'DisplayContent':
//Dashboard.onBrowseCommand(cmd.Arguments); displayContent(cmd, apiClient);
break; break;
case 'GoToSearch': case 'GoToSearch':
inputManager.trigger('search'); inputManager.trigger('search');
@ -164,7 +171,7 @@ define(['connectionManager', 'playbackManager', 'events', 'inputManager', 'focus
} }
else if (msg.MessageType === "GeneralCommand") { else if (msg.MessageType === "GeneralCommand") {
var cmd = msg.Data; var cmd = msg.Data;
processGeneralCommand(cmd); processGeneralCommand(cmd, apiClient);
} }
} }
@ -174,10 +181,10 @@ define(['connectionManager', 'playbackManager', 'events', 'inputManager', 'focus
events.on(apiClient, "websocketmessage", onWebSocketMessageReceived); events.on(apiClient, "websocketmessage", onWebSocketMessageReceived);
} }
//var current = connectionManager.currentApiClient(); var current = connectionManager.currentApiClient();
//if (current) { if (current) {
// bindEvents(current); bindEvents(current);
//} }
events.on(connectionManager, 'apiclientcreated', function (e, newApiClient) { events.on(connectionManager, 'apiclientcreated', function (e, newApiClient) {

View file

@ -116,17 +116,13 @@ define(['playbackManager', 'focusManager', 'embyRouter'], function (playbackMana
// TODO // TODO
break; break;
case 'next': case 'next':
if (playbackManager.isPlayingVideo()) { if (playbackManager.isPlaying()) {
playbackManager.nextChapter();
} else if (playbackManager.isPlaying()) {
playbackManager.nextTrack(); playbackManager.nextTrack();
} }
break; break;
case 'previous': case 'previous':
if (playbackManager.isPlayingVideo()) { if (playbackManager.isPlaying()) {
playbackManager.previousChapter();
} else if (playbackManager.isPlaying()) {
playbackManager.previousTrack(); playbackManager.previousTrack();
} }
break; break;

View file

@ -0,0 +1,117 @@
define(['connectionManager', 'playbackManager', 'events', 'inputManager', 'focusManager', 'embyRouter'], function (connectionManager, playbackManager, events, inputManager, focusManager, embyRouter) {
function onOneDocumentClick() {
document.removeEventListener('click', onOneDocumentClick);
document.removeEventListener('keydown', onOneDocumentClick);
if (window.Notification) {
Notification.requestPermission();
}
}
document.addEventListener('click', onOneDocumentClick);
document.addEventListener('keydown', onOneDocumentClick);
function onLibraryChanged(data, apiClient) {
var newItems = data.ItemsAdded;
if (!newItems.length || /*AppInfo.isNativeApp ||*/ !window.Notification || Notification.permission !== "granted") {
return;
}
if (playbackManager.isPlayingVideo()) {
return;
}
apiClient.getItems(apiClient.getCurrentUserId(), {
Recursive: true,
Limit: 3,
IsFolder: false,
SortBy: "DateCreated",
SortOrder: "Descending",
ImageTypes: "Primary",
Ids: newItems.join(',')
}).then(function (result) {
var items = result.Items;
for (var i = 0, length = items.length ; i < length; i++) {
var item = items[i];
var notification = {
title: "New " + item.Type,
body: item.Name,
timeout: 15000,
vibrate: true,
data: {
//options: {
// url: LibraryBrowser.getHref(item)
//}
}
};
var imageTags = item.ImageTags || {};
if (imageTags.Primary) {
notification.icon = apiClient.getScaledImageUrl(item.Id, {
width: 80,
tag: imageTags.Primary,
type: "Primary"
});
}
var notif = new Notification(notification.title, notification);
if (notif.show) {
notif.show();
}
if (notification.timeout) {
setTimeout(function () {
if (notif.close) {
notif.close();
}
else if (notif.cancel) {
notif.cancel();
}
}, notification.timeout);
}
}
});
}
function onWebSocketMessageReceived(e, msg) {
var apiClient = this;
if (msg.MessageType === "LibraryChanged") {
var cmd = msg.Data;
onLibraryChanged(cmd, apiClient);
}
}
function bindEvents(apiClient) {
if (!apiClient) {
return;
}
events.off(apiClient, "websocketmessage", onWebSocketMessageReceived);
events.on(apiClient, "websocketmessage", onWebSocketMessageReceived);
}
bindEvents(connectionManager.currentApiClient());
events.on(connectionManager, 'apiclientcreated', function (e, newApiClient) {
bindEvents(newApiClient);
});
});

View file

@ -29,14 +29,14 @@
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0" "webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
}, },
"ignore": [], "ignore": [],
"homepage": "https://github.com/polymerelements/iron-behaviors", "homepage": "https://github.com/PolymerElements/iron-behaviors",
"_release": "1.0.17", "_release": "1.0.17",
"_resolution": { "_resolution": {
"type": "version", "type": "version",
"tag": "v1.0.17", "tag": "v1.0.17",
"commit": "ef8e89b5f0aa4e8a6b51ca6491ea453bf395f94f" "commit": "ef8e89b5f0aa4e8a6b51ca6491ea453bf395f94f"
}, },
"_source": "git://github.com/polymerelements/iron-behaviors.git", "_source": "git://github.com/PolymerElements/iron-behaviors.git",
"_target": "^1.0.0", "_target": "^1.0.0",
"_originalSource": "polymerelements/iron-behaviors" "_originalSource": "PolymerElements/iron-behaviors"
} }

View file

@ -31,14 +31,14 @@
"web-component-tester": "*" "web-component-tester": "*"
}, },
"private": true, "private": true,
"homepage": "https://github.com/Polymer/polymer", "homepage": "https://github.com/polymer/polymer",
"_release": "1.6.0", "_release": "1.6.0",
"_resolution": { "_resolution": {
"type": "version", "type": "version",
"tag": "v1.6.0", "tag": "v1.6.0",
"commit": "8715c83bf04a228de00ec662ed43eb6141e61b91" "commit": "8715c83bf04a228de00ec662ed43eb6141e61b91"
}, },
"_source": "git://github.com/Polymer/polymer.git", "_source": "git://github.com/polymer/polymer.git",
"_target": "^1.1.0", "_target": "^1.1.0",
"_originalSource": "Polymer/polymer" "_originalSource": "polymer/polymer"
} }

View file

@ -197,7 +197,7 @@
return; return;
} }
Dashboard.showModalLoadingMsg(); Dashboard.showLoadingMsg();
ApiClient.ajax({ ApiClient.ajax({
type: "GET", type: "GET",
@ -220,7 +220,7 @@
$('#selectListing', page).val(listingsId); $('#selectListing', page).val(listingsId);
} }
Dashboard.hideModalLoadingMsg(); Dashboard.hideLoadingMsg();
}, function (result) { }, function (result) {
@ -228,7 +228,7 @@
message: Globalize.translate('ErrorGettingTvLineups') message: Globalize.translate('ErrorGettingTvLineups')
}); });
refreshListings(''); refreshListings('');
Dashboard.hideModalLoadingMsg(); Dashboard.hideLoadingMsg();
}); });
} }

View file

@ -574,53 +574,6 @@
} }
} }
/** homePageSmallBackdropCard */
.homePageSmallBackdropCard .cardPadder {
padding-bottom: 56.25%;
}
.homePageSmallBackdropCard {
width: 50%;
}
@media all and (min-width: 540px) {
.homePageSmallBackdropCard {
width: 33.333%;
}
}
@media all and (min-width: 600px) {
.homePageSmallBackdropCard {
width: 25%;
}
}
@media all and (min-width: 800px) {
.homePageSmallBackdropCard {
width: 20%;
}
}
@media all and (min-width: 1100px) {
.homePageSmallBackdropCard {
width: 16.66666666666667%;
}
}
@media all and (min-width: 1440px) {
.homePageSmallBackdropCard {
width: 12.5%;
}
}
/** horizontalBackdropCard */ /** horizontalBackdropCard */
.horizontalBackdropCard .cardPadder { .horizontalBackdropCard .cardPadder {
padding-bottom: 56.25%; padding-bottom: 56.25%;

View file

@ -365,9 +365,9 @@ body:not(.dashboardDocument) .btnNotifications {
} }
i.sidebarLinkIcon { i.sidebarLinkIcon {
font-size: 24px; font-size: 150%;
height: 24px; height: auto;
width: 24px; width: auto;
} }
.darkDrawer i.sidebarLinkIcon { .darkDrawer i.sidebarLinkIcon {
@ -441,7 +441,6 @@ body:not(.dashboardDocument) .headerAppsButton {
.dashboardDocument .libraryMenuButtonText { .dashboardDocument .libraryMenuButtonText {
font-size: 150%; font-size: 150%;
margin-left: 1em;
} }
.dashboardDocument .mainDrawerPanelContent { .dashboardDocument .mainDrawerPanelContent {
@ -507,45 +506,3 @@ body:not(.dashboardDocument) .headerAppsButton {
.title-separator { .title-separator {
margin: 0 .5em; margin: 0 .5em;
} }
.adminAppsMenu {
position: fixed;
top: 5vh !important;
left: 2vw !important;
padding: 1.5em 1em !important;
font-size: 110%;
margin: 0 !important;
color: #333;
}
.adminAppsMenuRow {
display: flex;
padding: 0 !important;
margin: 0 !important;
}
.adminAppsMenuRow + .adminAppsMenuRow {
margin-top: 1.5em !important;
border-top: 1px solid #ddd;
padding-top: 1em !important;
}
.adminAppsButton {
display: block;
color: inherit !important;
font-weight: normal !important;
text-align: center;
}
.adminAppsButton {
width: 5.3vw;
}
.adminAppsButton + .adminAppsButton {
margin-left: 1.5em;
}
.adminAppsButton paper-icon-button {
width: 4.5vh;
height: 4.5vh;
}

View file

@ -2,16 +2,16 @@
function login(page, username, password) { function login(page, username, password) {
Dashboard.showModalLoadingMsg(); Dashboard.showLoadingMsg();
ConnectionManager.loginToConnect(username, password).then(function () { ConnectionManager.loginToConnect(username, password).then(function () {
Dashboard.hideModalLoadingMsg(); Dashboard.hideLoadingMsg();
Dashboard.navigate('selectserver.html'); Dashboard.navigate('selectserver.html');
}, function () { }, function () {
Dashboard.hideModalLoadingMsg(); Dashboard.hideLoadingMsg();
Dashboard.alert({ Dashboard.alert({
message: Globalize.translate('MessageInvalidUser'), message: Globalize.translate('MessageInvalidUser'),
@ -26,7 +26,7 @@
function handleConnectionResult(page, result) { function handleConnectionResult(page, result) {
Dashboard.hideModalLoadingMsg(); Dashboard.hideLoadingMsg();
switch (result.State) { switch (result.State) {
@ -75,7 +75,7 @@
function loadAppConnection(page) { function loadAppConnection(page) {
Dashboard.showModalLoadingMsg(); Dashboard.showLoadingMsg();
ConnectionManager.connect().then(function (result) { ConnectionManager.connect().then(function (result) {
@ -167,7 +167,7 @@
host += ':' + port; host += ':' + port;
} }
Dashboard.showModalLoadingMsg(); Dashboard.showLoadingMsg();
ConnectionManager.connectToAddress(host).then(function (result) { ConnectionManager.connectToAddress(host).then(function (result) {

View file

@ -68,10 +68,10 @@
return Sections.loadLibraryTiles(elem, user, 'backdrop', index, false, showLibraryTileNames); return Sections.loadLibraryTiles(elem, user, 'backdrop', index, false, showLibraryTileNames);
} }
else if (section == 'smalllibrarytiles') { else if (section == 'smalllibrarytiles') {
return Sections.loadLibraryTiles(elem, user, 'homePageSmallBackdrop', index, false, showLibraryTileNames); return Sections.loadLibraryTiles(elem, user, 'smallBackdrop', index, false, showLibraryTileNames);
} }
else if (section == 'smalllibrarytiles-automobile') { else if (section == 'smalllibrarytiles-automobile') {
return Sections.loadLibraryTiles(elem, user, 'homePageSmallBackdrop', index, true, showLibraryTileNames); return Sections.loadLibraryTiles(elem, user, 'smallBackdrop', index, true, showLibraryTileNames);
} }
else if (section == 'librarytiles-automobile') { else if (section == 'librarytiles-automobile') {
return Sections.loadLibraryTiles(elem, user, 'backdrop', index, true, showLibraryTileNames); return Sections.loadLibraryTiles(elem, user, 'backdrop', index, true, showLibraryTileNames);

View file

@ -835,7 +835,7 @@
return html; return html;
}, },
shapes: ['square', 'portrait', 'banner', 'smallBackdrop', 'homePageSmallBackdrop', 'backdrop', 'overflowBackdrop', 'overflowPortrait', 'overflowSquare'], shapes: ['square', 'portrait', 'banner', 'smallBackdrop', 'backdrop', 'overflowBackdrop', 'overflowPortrait', 'overflowSquare'],
getPostersPerRow: function (screenWidth) { getPostersPerRow: function (screenWidth) {
@ -881,14 +881,6 @@
if (screenWidth >= 540) return 3; if (screenWidth >= 540) return 3;
if (screenWidth >= 420) return 2; if (screenWidth >= 420) return 2;
return 1; return 1;
case 'homePageSmallBackdrop':
if (screenWidth >= 1440) return 8;
if (screenWidth >= 1100) return 6;
if (screenWidth >= 800) return 5;
if (screenWidth >= 600) return 4;
if (screenWidth >= 540) return 3;
if (screenWidth >= 420) return 2;
return 1;
case 'overflowPortrait': case 'overflowPortrait':
if (screenWidth >= 1000) return 100 / 23; if (screenWidth >= 1000) return 100 / 23;
if (screenWidth >= 640) return 100 / 36; if (screenWidth >= 640) return 100 / 36;
@ -1015,10 +1007,6 @@
else if (options.shape == 'smallBackdrop') { else if (options.shape == 'smallBackdrop') {
thumbWidth = posterInfo.smallBackdropWidth; thumbWidth = posterInfo.smallBackdropWidth;
} }
else if (options.shape == 'homePageSmallBackdrop') {
thumbWidth = posterInfo.homePageSmallBackdropWidth;
posterWidth = posterInfo.homePageSmallBackdropWidth;
}
else if (options.shape == 'detailPagePortrait') { else if (options.shape == 'detailPagePortrait') {
posterWidth = 200; posterWidth = 200;
} }

View file

@ -14,7 +14,7 @@
html += '<button type="button" is="paper-icon-button-light" class="headerButton headerButtonLeft headerBackButton hide autoSize"><i class="md-icon">' + backIcon + '</i></button>'; html += '<button type="button" is="paper-icon-button-light" class="headerButton headerButtonLeft headerBackButton hide autoSize"><i class="md-icon">' + backIcon + '</i></button>';
html += '<button type="button" is="paper-icon-button-light" class="headerButton mainDrawerButton barsMenuButton headerButtonLeft autoSize"><i class="md-icon">menu</i></button>'; html += '<button type="button" is="paper-icon-button-light" class="headerButton mainDrawerButton barsMenuButton headerButtonLeft autoSize"><i class="md-icon">menu</i></button>';
html += '<button type="button" is="paper-icon-button-light" class="headerButton headerAppsButton barsMenuButton headerButtonLeft autoSize"><i class="md-icon">menu</i></button>'; html += '<button type="button" is="paper-icon-button-light" class="headerButton headerAppsButton barsMenuButton headerButtonLeft autoSize"><i class="md-icon">home</i></button>';
html += '<div class="libraryMenuButtonText headerButton">' + Globalize.translate('ButtonHome') + '</div>'; html += '<div class="libraryMenuButtonText headerButton">' + Globalize.translate('ButtonHome') + '</div>';
@ -179,57 +179,7 @@
function onHeaderAppsButtonClick() { function onHeaderAppsButtonClick() {
require(['dialogHelper', 'dom'], function (dialogHelper, dom) { Dashboard.navigate('home.html');
var dlg = dialogHelper.createDialog({
removeOnClose: true,
modal: false,
autoFocus: false,
entryAnimationDuration: 160,
exitAnimationDuration: 160,
enableHistory: false
});
dlg.classList.add('ui-body-a');
dlg.classList.add('background-theme-a');
dlg.classList.add('adminAppsMenu');
var html = '';
html += '<div class="adminAppsMenuRow">';
html += '<a class="adminAppsButton" href="home.html">';
html += '<button is="paper-icon-button-light" class="autoSize"><i class="md-icon">home</i></button>';
html += '<div>' + Globalize.translate('ButtonHome') + '</div>';
html += '</a>';
html += '</div>';
html += '<div class="adminAppsMenuRow">';
html += '<a class="adminAppsButton" href="edititemmetadata.html">';
html += '<button is="paper-icon-button-light" class="autoSize"><i class="md-icon">mode_edit</i></button>';
html += '<div>' + Globalize.translate('ButtonMetadataManager') + '</div>';
html += '</a>';
html += '<a class="adminAppsButton" href="reports.html">';
html += '<button is="paper-icon-button-light" class="autoSize"><i class="md-icon">insert_chart</i></button>';
html += '<div>' + Globalize.translate('ButtonReports') + '</div>';
html += '</a>';
html += '</div>';
dlg.innerHTML = html;
document.body.appendChild(dlg);
dlg.addEventListener('click', function (e) {
var link = dom.parentWithTag(e.target, 'A');
if (link) {
dialogHelper.close(dlg);
}
});
dialogHelper.open(dlg);
});
} }
function bindMenuEvents() { function bindMenuEvents() {

View file

@ -801,10 +801,7 @@
break; break;
default: default:
{ {
if (player.isLocalPlayer) { if (!player.isLocalPlayer) {
// Not player-related
Dashboard.processGeneralCommand(cmd);
} else {
player.sendCommand(cmd); player.sendCommand(cmd);
} }
break; break;
@ -1070,60 +1067,12 @@
function onWebSocketMessageReceived(e, msg) { function onWebSocketMessageReceived(e, msg) {
var localPlayer; if (msg.MessageType === "ServerShuttingDown") {
if (msg.MessageType === "Play") {
localPlayer = MediaController.getLocalPlayer();
if (msg.Data.PlayCommand == "PlayNext") {
localPlayer.queueNext({ ids: msg.Data.ItemIds });
}
else if (msg.Data.PlayCommand == "PlayLast") {
localPlayer.queue({ ids: msg.Data.ItemIds });
}
else {
localPlayer.play({ ids: msg.Data.ItemIds, startPositionTicks: msg.Data.StartPositionTicks });
}
}
else if (msg.MessageType === "ServerShuttingDown") {
MediaController.setDefaultPlayerActive(); MediaController.setDefaultPlayerActive();
} }
else if (msg.MessageType === "ServerRestarting") { else if (msg.MessageType === "ServerRestarting") {
MediaController.setDefaultPlayerActive(); MediaController.setDefaultPlayerActive();
} }
else if (msg.MessageType === "Playstate") {
localPlayer = MediaController.getLocalPlayer();
if (msg.Data.Command === 'Stop') {
localPlayer.stop();
}
else if (msg.Data.Command === 'Pause') {
localPlayer.pause();
}
else if (msg.Data.Command === 'Unpause') {
localPlayer.unpause();
}
else if (msg.Data.Command === 'Seek') {
localPlayer.seek(msg.Data.SeekPositionTicks);
}
else if (msg.Data.Command === 'NextTrack') {
localPlayer.nextTrack();
}
else if (msg.Data.Command === 'PreviousTrack') {
localPlayer.previousTrack();
}
}
else if (msg.MessageType === "GeneralCommand") {
var cmd = msg.Data;
localPlayer = MediaController.getLocalPlayer();
MediaController.sendCommand(cmd, localPlayer);
}
} }
function initializeApiClient(apiClient) { function initializeApiClient(apiClient) {

View file

@ -783,10 +783,14 @@ define(['appSettings', 'userSettings', 'appStorage', 'datetime'], function (appS
return null; return null;
}; };
self.displayContent = function (options) { self.displayContent = function (cmd) {
// Handle it the same as a remote control command var apiClient = ApiClient;
Dashboard.onBrowseCommand(options); apiClient.getItem(apiClient.getCurrentUserId(), cmd.ItemId).then(function (item) {
require(['embyRouter'], function (embyRouter) {
embyRouter.showItem(item);
});
});
}; };
self.getItemsForPlayback = function (query) { self.getItemsForPlayback = function (query) {

View file

@ -118,7 +118,7 @@
html = libraryBrowser.getPosterViewHtml({ html = libraryBrowser.getPosterViewHtml({
items: result.Items, items: result.Items,
shape: "portrait", shape: "auto",
context: 'movies', context: 'movies',
showTitle: true, showTitle: true,
showYear: true, showYear: true,
@ -132,7 +132,7 @@
// Poster // Poster
html = libraryBrowser.getPosterViewHtml({ html = libraryBrowser.getPosterViewHtml({
items: result.Items, items: result.Items,
shape: "portrait", shape: "auto",
context: 'movies', context: 'movies',
centerText: true, centerText: true,
lazy: true, lazy: true,

View file

@ -260,10 +260,8 @@
loadResume(tabContent, userId, parentId); loadResume(tabContent, userId, parentId);
loadLatest(tabContent, userId, parentId); loadLatest(tabContent, userId, parentId);
if (AppInfo.enableMovieHomeSuggestions) {
loadSuggestions(tabContent, userId, parentId); loadSuggestions(tabContent, userId, parentId);
} }
}
return function (view, params) { return function (view, params) {

View file

@ -71,7 +71,7 @@
function showGeneralError() { function showGeneralError() {
Dashboard.hideModalLoadingMsg(); Dashboard.hideLoadingMsg();
Dashboard.alert({ Dashboard.alert({
message: Globalize.translate('DefaultErrorMessage') message: Globalize.translate('DefaultErrorMessage')
}); });
@ -138,12 +138,12 @@
function acceptInvitation(page, id) { function acceptInvitation(page, id) {
Dashboard.showModalLoadingMsg(); Dashboard.showLoadingMsg();
// Add/Update connect info // Add/Update connect info
ConnectionManager.acceptServer(id).then(function () { ConnectionManager.acceptServer(id).then(function () {
Dashboard.hideModalLoadingMsg(); Dashboard.hideLoadingMsg();
loadPage(page); loadPage(page);
}, function () { }, function () {
@ -154,12 +154,12 @@
function deleteServer(page, serverId) { function deleteServer(page, serverId) {
Dashboard.showModalLoadingMsg(); Dashboard.showLoadingMsg();
// Add/Update connect info // Add/Update connect info
ConnectionManager.deleteServer(serverId).then(function () { ConnectionManager.deleteServer(serverId).then(function () {
Dashboard.hideModalLoadingMsg(); Dashboard.hideLoadingMsg();
loadPage(page); loadPage(page);
@ -172,12 +172,12 @@
function rejectInvitation(page, id) { function rejectInvitation(page, id) {
Dashboard.showModalLoadingMsg(); Dashboard.showLoadingMsg();
// Add/Update connect info // Add/Update connect info
ConnectionManager.rejectServer(id).then(function () { ConnectionManager.rejectServer(id).then(function () {
Dashboard.hideModalLoadingMsg(); Dashboard.hideLoadingMsg();
loadPage(page); loadPage(page);

View file

@ -1,18 +1,4 @@
(function () { var Dashboard = {
function onOneDocumentClick() {
document.removeEventListener('click', onOneDocumentClick);
if (window.Notification) {
Notification.requestPermission();
}
}
document.addEventListener('click', onOneDocumentClick);
})();
var Dashboard = {
isConnectMode: function () { isConnectMode: function () {
@ -72,20 +58,6 @@ var Dashboard = {
} }
}, },
onPopupOpen: function () {
Dashboard.popupCount = (Dashboard.popupCount || 0) + 1;
document.body.classList.add('bodyWithPopupOpen');
},
onPopupClose: function () {
Dashboard.popupCount = (Dashboard.popupCount || 1) - 1;
if (!Dashboard.popupCount) {
document.body.classList.remove('bodyWithPopupOpen');
}
},
getCurrentUser: function () { getCurrentUser: function () {
return window.ApiClient.getCurrentUser(); return window.ApiClient.getCurrentUser();
@ -415,32 +387,6 @@ var Dashboard = {
}); });
}, },
getModalLoadingMsg: function () {
var elem = document.querySelector('.modalLoading');
if (!elem) {
elem = document.createElement('modalLoading');
elem.classList.add('modalLoading');
elem.classList.add('hide');
document.body.appendChild(elem);
}
return elem;
},
showModalLoadingMsg: function () {
Dashboard.getModalLoadingMsg().classList.remove('hide');
Dashboard.showLoadingMsg();
},
hideModalLoadingMsg: function () {
Dashboard.getModalLoadingMsg().classList.add('hide');
Dashboard.hideLoadingMsg();
},
processPluginConfigurationUpdateResult: function () { processPluginConfigurationUpdateResult: function () {
Dashboard.hideLoadingMsg(); Dashboard.hideLoadingMsg();
@ -784,12 +730,22 @@ var Dashboard = {
name: Globalize.translate('TabLogs'), name: Globalize.translate('TabLogs'),
href: "log.html", href: "log.html",
pageIds: ['logPage'], pageIds: ['logPage'],
icon: 'folder-open' icon: 'folder_open'
}, { }, {
name: Globalize.translate('TabScheduledTasks'), name: Globalize.translate('TabScheduledTasks'),
href: "scheduledtasks.html", href: "scheduledtasks.html",
pageIds: ['scheduledTasksPage', 'scheduledTaskPage'], pageIds: ['scheduledTasksPage', 'scheduledTaskPage'],
icon: 'schedule' icon: 'schedule'
}, {
name: Globalize.translate('ButtonMetadataManager'),
href: "edititemmetadata.html",
pageIds: [],
icon: 'mode_edit'
}, {
name: Globalize.translate('ButtonReports'),
href: "reports.html",
pageIds: [],
icon: 'insert_chart'
}, { }, {
name: Globalize.translate('TabHelp'), name: Globalize.translate('TabHelp'),
href: "about.html", href: "about.html",
@ -801,87 +757,11 @@ var Dashboard = {
}, },
processGeneralCommand: function (cmd) {
// Full list
// https://github.com/MediaBrowser/MediaBrowser/blob/master/MediaBrowser.Model/Session/GeneralCommand.cs#L23
switch (cmd.Name) {
case 'GoHome':
Dashboard.navigate('home.html');
break;
case 'GoToSettings':
Dashboard.navigate('dashboard.html');
break;
case 'DisplayContent':
Dashboard.onBrowseCommand(cmd.Arguments);
break;
case 'GoToSearch':
Dashboard.navigate('search.html');
break;
case 'DisplayMessage':
{
var args = cmd.Arguments;
if (args.TimeoutMs && window.Notification && Notification.permission === "granted") {
var notification = {
title: args.Header,
body: args.Text,
vibrate: true,
timeout: args.TimeoutMs
};
var notif = new Notification(notification.title, notification);
if (notif.show) {
notif.show();
}
if (notification.timeout) {
setTimeout(function () {
if (notif.close) {
notif.close();
}
else if (notif.cancel) {
notif.cancel();
}
}, notification.timeout);
}
}
else {
Dashboard.alert({ title: args.Header, message: args.Text });
}
break;
}
case 'VolumeUp':
case 'VolumeDown':
case 'Mute':
case 'Unmute':
case 'ToggleMute':
case 'SetVolume':
case 'SetAudioStreamIndex':
case 'SetSubtitleStreamIndex':
case 'ToggleFullscreen':
case 'SetRepeatMode':
break;
default:
console.log('Unrecognized command: ' + cmd.Name);
break;
}
},
onWebSocketMessageReceived: function (e, data) { onWebSocketMessageReceived: function (e, data) {
var msg = data; var msg = data;
if (msg.MessageType === "LibraryChanged") { if (msg.MessageType === "ServerShuttingDown") {
Dashboard.processLibraryUpdateNotification(msg.Data);
}
else if (msg.MessageType === "ServerShuttingDown") {
Dashboard.hideServerRestartWarning(); Dashboard.hideServerRestartWarning();
} }
else if (msg.MessageType === "ServerRestarting") { else if (msg.MessageType === "ServerRestarting") {
@ -929,50 +809,6 @@ var Dashboard = {
} }
}); });
} }
else if (msg.MessageType === "GeneralCommand") {
var cmd = msg.Data;
// Media Controller should catch this
//Dashboard.processGeneralCommand(cmd);
}
},
onBrowseCommand: function (cmd) {
var url;
var type = (cmd.ItemType || "").toLowerCase();
if (type == "genre") {
url = "itemdetails.html?id=" + cmd.ItemId;
}
else if (type == "musicgenre") {
url = "itemdetails.html?id=" + cmd.ItemId;
}
else if (type == "gamegenre") {
url = "itemdetails.html?id=" + cmd.ItemId;
}
else if (type == "studio") {
url = "itemdetails.html?id=" + cmd.ItemId;
}
else if (type == "person") {
url = "itemdetails.html?id=" + cmd.ItemId;
}
else if (type == "musicartist") {
url = "itemdetails.html?id=" + cmd.ItemId;
}
if (url) {
Dashboard.navigate(url);
return;
}
ApiClient.getItem(Dashboard.getCurrentUserId(), cmd.ItemId).then(function (item) {
Dashboard.navigate(LibraryBrowser.getHref(item, null, ''));
});
}, },
showPackageInstallNotification: function (installation, status) { showPackageInstallNotification: function (installation, status) {
@ -1038,77 +874,6 @@ var Dashboard = {
Dashboard.showFooterNotification({ html: html, id: installation.Id, timeout: timeout, forceShow: forceShow, allowHide: allowHide }); Dashboard.showFooterNotification({ html: html, id: installation.Id, timeout: timeout, forceShow: forceShow, allowHide: allowHide });
}, },
processLibraryUpdateNotification: function (data) {
var newItems = data.ItemsAdded;
if (!newItems.length || AppInfo.isNativeApp || !window.Notification || Notification.permission !== "granted") {
return;
}
ApiClient.getItems(Dashboard.getCurrentUserId(), {
Recursive: true,
Limit: 3,
Filters: "IsNotFolder",
SortBy: "DateCreated",
SortOrder: "Descending",
ImageTypes: "Primary",
Ids: newItems.join(',')
}).then(function (result) {
var items = result.Items;
for (var i = 0, length = Math.min(items.length, 2) ; i < length; i++) {
var item = items[i];
var notification = {
title: "New " + item.Type,
body: item.Name,
timeout: 15000,
vibrate: true,
data: {
options: {
url: LibraryBrowser.getHref(item)
}
}
};
var imageTags = item.ImageTags || {};
if (imageTags.Primary) {
notification.icon = ApiClient.getScaledImageUrl(item.Id, {
width: 60,
tag: imageTags.Primary,
type: "Primary"
});
}
var notif = new Notification(notification.title, notification);
if (notif.show) {
notif.show();
}
if (notification.timeout) {
setTimeout(function () {
if (notif.close) {
notif.close();
}
else if (notif.cancel) {
notif.cancel();
}
}, notification.timeout);
}
}
});
},
setPageTitle: function (title, documentTitle) { setPageTitle: function (title, documentTitle) {
LibraryMenu.setTitle(title || 'Emby'); LibraryMenu.setTitle(title || 'Emby');
@ -1466,8 +1231,6 @@ var AppInfo = {};
var isCordova = Dashboard.isRunningInCordova(); var isCordova = Dashboard.isRunningInCordova();
AppInfo.enableDetailPageChapters = true; AppInfo.enableDetailPageChapters = true;
AppInfo.enableDetailsMenuImages = true;
AppInfo.enableMovieHomeSuggestions = true;
AppInfo.enableSearchInTopMenu = true; AppInfo.enableSearchInTopMenu = true;
AppInfo.enableHomeFavorites = true; AppInfo.enableHomeFavorites = true;
AppInfo.enableNowPlayingBar = true; AppInfo.enableNowPlayingBar = true;
@ -1500,8 +1263,6 @@ var AppInfo = {};
} else { } else {
AppInfo.enableDetailPageChapters = false; AppInfo.enableDetailPageChapters = false;
AppInfo.enableDetailsMenuImages = false;
AppInfo.enableMovieHomeSuggestions = false;
} }
} }
@ -3258,6 +3019,12 @@ var AppInfo = {};
postInitDependencies.push('robotoFont'); postInitDependencies.push('robotoFont');
} }
postInitDependencies.push('bower_components/emby-webcomponents/input/api');
if (window.Notification && !AppInfo.isNativeApp) {
postInitDependencies.push('bower_components/emby-webcomponents/librarychangednotifications');
}
require(postInitDependencies); require(postInitDependencies);
upgradeLayouts(); upgradeLayouts();
}); });