mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
update script loading
This commit is contained in:
parent
4352a10709
commit
973a033c2d
1 changed files with 84 additions and 49 deletions
|
@ -14,7 +14,7 @@
|
|||
|
||||
// Compatibility
|
||||
window.Logger = {
|
||||
log: function(msg) {
|
||||
log: function (msg) {
|
||||
console.log(msg);
|
||||
}
|
||||
};
|
||||
|
@ -310,6 +310,10 @@ var Dashboard = {
|
|||
|
||||
showServerRestartWarning: function (systemInfo) {
|
||||
|
||||
if (AppInfo.isNativeApp) {
|
||||
return;
|
||||
}
|
||||
|
||||
var html = '<span style="margin-right: 1em;">' + Globalize.translate('MessagePleaseRestart') + '</span>';
|
||||
|
||||
if (systemInfo.CanSelfRestart) {
|
||||
|
@ -329,6 +333,10 @@ var Dashboard = {
|
|||
|
||||
showDashboardRefreshNotification: function () {
|
||||
|
||||
if (AppInfo.isNativeApp) {
|
||||
return;
|
||||
}
|
||||
|
||||
var html = '<span style="margin-right: 1em;">' + Globalize.translate('MessagePleaseRefreshPage') + '</span>';
|
||||
|
||||
html += '<paper-button raised class="submit mini" onclick="this.disabled=\'disabled\';Dashboard.reloadPage();"><iron-icon icon="refresh"></iron-icon><span>' + Globalize.translate('ButtonRefresh') + '</span></paper-button>';
|
||||
|
@ -364,10 +372,6 @@ var Dashboard = {
|
|||
|
||||
showFooterNotification: function (options) {
|
||||
|
||||
if (!AppInfo.enableFooterNotifications) {
|
||||
return;
|
||||
}
|
||||
|
||||
var removeOnHide = !options.id;
|
||||
|
||||
options.id = options.id || "notification" + new Date().getTime() + parseInt(Math.random());
|
||||
|
@ -1039,8 +1043,32 @@ var Dashboard = {
|
|||
{
|
||||
var args = cmd.Arguments;
|
||||
|
||||
if (args.TimeoutMs) {
|
||||
Dashboard.showFooterNotification({ html: "<div><b>" + args.Header + "</b></div>" + args.Text, timeout: args.TimeoutMs });
|
||||
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 });
|
||||
|
@ -1168,6 +1196,10 @@ var Dashboard = {
|
|||
|
||||
showPackageInstallNotification: function (installation, status) {
|
||||
|
||||
if (AppInfo.isNativeApp) {
|
||||
return;
|
||||
}
|
||||
|
||||
var html = '';
|
||||
|
||||
if (status == 'completed') {
|
||||
|
@ -1229,7 +1261,7 @@ var Dashboard = {
|
|||
|
||||
var newItems = data.ItemsAdded;
|
||||
|
||||
if (!newItems.length || AppInfo.isNativeApp || !window.Notification) {
|
||||
if (!newItems.length || AppInfo.isNativeApp || !window.Notification || Notification.permission !== "granted") {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1254,8 +1286,14 @@ var Dashboard = {
|
|||
var notification = {
|
||||
title: "New " + item.Type,
|
||||
body: item.Name,
|
||||
timeout: 5000,
|
||||
vibrate: true
|
||||
timeout: 15000,
|
||||
vibrate: true,
|
||||
|
||||
data: {
|
||||
options: {
|
||||
url: LibraryBrowser.getHref(item)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var imageTags = item.ImageTags || {};
|
||||
|
@ -1269,25 +1307,22 @@ var Dashboard = {
|
|||
});
|
||||
}
|
||||
|
||||
if (Notification.permission === "granted") {
|
||||
var notif = new Notification(notification.title, notification);
|
||||
|
||||
var notif = new Notification(notification.title, notification);
|
||||
if (notif.show) {
|
||||
notif.show();
|
||||
}
|
||||
|
||||
if (notif.show) {
|
||||
notif.show();
|
||||
}
|
||||
if (notification.timeout) {
|
||||
setTimeout(function () {
|
||||
|
||||
if (notification.timeout) {
|
||||
setTimeout(function () {
|
||||
|
||||
if (notif.close) {
|
||||
notif.close();
|
||||
}
|
||||
else if (notif.cancel) {
|
||||
notif.cancel();
|
||||
}
|
||||
}, notification.timeout);
|
||||
}
|
||||
if (notif.close) {
|
||||
notif.close();
|
||||
}
|
||||
else if (notif.cancel) {
|
||||
notif.cancel();
|
||||
}
|
||||
}, notification.timeout);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1572,7 +1607,6 @@ var AppInfo = {};
|
|||
}
|
||||
}
|
||||
else {
|
||||
AppInfo.enableFooterNotifications = true;
|
||||
AppInfo.enableSupporterMembership = true;
|
||||
|
||||
if (!isAndroid && !isIOS) {
|
||||
|
@ -1618,24 +1652,34 @@ var AppInfo = {};
|
|||
Events.on(apiClient, 'requestfail', Dashboard.onRequestFail);
|
||||
}
|
||||
|
||||
function getSyncProfile() {
|
||||
|
||||
return getRequirePromise(['scripts/mediaplayer']).then(function() {
|
||||
return MediaPlayer.getDeviceProfile(Math.max(screen.height, screen.width));
|
||||
});
|
||||
}
|
||||
|
||||
function onApiClientCreated(e, newApiClient) {
|
||||
initializeApiClient(newApiClient);
|
||||
}
|
||||
|
||||
//localStorage.clear();
|
||||
function createConnectionManager(credentialProviderFactory, capabilities) {
|
||||
|
||||
var credentialKey = Dashboard.isConnectMode() ? null : 'servercredentials4';
|
||||
var credentialProvider = new credentialProviderFactory(credentialKey);
|
||||
|
||||
window.ConnectionManager = new MediaBrowser.ConnectionManager(credentialProvider, AppInfo.appName, AppInfo.appVersion, AppInfo.deviceName, AppInfo.deviceId, capabilities, window.devicePixelRatio);
|
||||
return getSyncProfile().then(function (deviceProfile) {
|
||||
|
||||
capabilities.DeviceProfile = deviceProfile;
|
||||
|
||||
if (window.location.href.toLowerCase().indexOf('wizardstart.html') != -1) {
|
||||
window.ConnectionManager.clearData();
|
||||
}
|
||||
window.ConnectionManager = new MediaBrowser.ConnectionManager(credentialProvider, AppInfo.appName, AppInfo.appVersion, AppInfo.deviceName, AppInfo.deviceId, capabilities, window.devicePixelRatio);
|
||||
|
||||
Events.on(ConnectionManager, 'apiclientcreated', function (e, newApiClient) {
|
||||
if (window.location.href.toLowerCase().indexOf('wizardstart.html') != -1) {
|
||||
window.ConnectionManager.clearData();
|
||||
}
|
||||
|
||||
initializeApiClient(newApiClient);
|
||||
});
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
Events.on(ConnectionManager, 'apiclientcreated', onApiClientCreated);
|
||||
|
||||
if (Dashboard.isConnectMode()) {
|
||||
|
||||
|
@ -1646,28 +1690,23 @@ var AppInfo = {};
|
|||
if (server && server.UserId && server.AccessToken) {
|
||||
Dashboard.showLoadingMsg();
|
||||
|
||||
ConnectionManager.connectToServer(server).then(function (result) {
|
||||
return ConnectionManager.connectToServer(server).then(function (result) {
|
||||
Dashboard.showLoadingMsg();
|
||||
|
||||
if (result.State == MediaBrowser.ConnectionState.SignedIn) {
|
||||
window.ApiClient = result.ApiClient;
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
resolve();
|
||||
|
||||
} else {
|
||||
|
||||
require(['apiclient'], function(apiClientFactory) {
|
||||
return getRequirePromise(['apiclient']).then(function (apiClientFactory) {
|
||||
var apiClient = new apiClientFactory(Dashboard.serverAddress(), AppInfo.appName, AppInfo.appVersion, AppInfo.deviceName, AppInfo.deviceId, window.devicePixelRatio);
|
||||
apiClient.enableAutomaticNetworking = false;
|
||||
ConnectionManager.addApiClient(apiClient);
|
||||
Dashboard.importCss(apiClient.getUrl('Branding/Css'));
|
||||
window.ApiClient = apiClient;
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -2058,7 +2097,6 @@ var AppInfo = {};
|
|||
deps.push('credentialprovider');
|
||||
|
||||
deps.push('appstorage');
|
||||
deps.push('scripts/mediaplayer');
|
||||
deps.push('scripts/appsettings');
|
||||
|
||||
require(deps, function (connectionManagerExports, credentialProviderFactory) {
|
||||
|
@ -2101,12 +2139,9 @@ var AppInfo = {};
|
|||
}
|
||||
}
|
||||
|
||||
var capabilities = Dashboard.capabilities();
|
||||
|
||||
capabilities.DeviceProfile = MediaPlayer.getDeviceProfile(Math.max(screen.height, screen.width));
|
||||
|
||||
var promises = [];
|
||||
deps = [];
|
||||
deps.push('scripts/mediaplayer');
|
||||
deps.push('thirdparty/jquery.unveil-custom.js');
|
||||
deps.push('emby-icons');
|
||||
deps.push('paper-icon-button');
|
||||
|
@ -2116,7 +2151,7 @@ var AppInfo = {};
|
|||
promises.push(getRequirePromise(deps));
|
||||
|
||||
promises.push(Globalize.ensure());
|
||||
promises.push(createConnectionManager(credentialProviderFactory, capabilities));
|
||||
promises.push(createConnectionManager(credentialProviderFactory, Dashboard.capabilities()));
|
||||
|
||||
Promise.all(promises).then(function () {
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue