1
0
Fork 0
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:
Luke Pulverenti 2015-12-27 13:48:36 -05:00
parent 4352a10709
commit 973a033c2d

View file

@ -310,6 +310,10 @@ var Dashboard = {
showServerRestartWarning: function (systemInfo) { showServerRestartWarning: function (systemInfo) {
if (AppInfo.isNativeApp) {
return;
}
var html = '<span style="margin-right: 1em;">' + Globalize.translate('MessagePleaseRestart') + '</span>'; var html = '<span style="margin-right: 1em;">' + Globalize.translate('MessagePleaseRestart') + '</span>';
if (systemInfo.CanSelfRestart) { if (systemInfo.CanSelfRestart) {
@ -329,6 +333,10 @@ var Dashboard = {
showDashboardRefreshNotification: function () { showDashboardRefreshNotification: function () {
if (AppInfo.isNativeApp) {
return;
}
var html = '<span style="margin-right: 1em;">' + Globalize.translate('MessagePleaseRefreshPage') + '</span>'; 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>'; 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) { showFooterNotification: function (options) {
if (!AppInfo.enableFooterNotifications) {
return;
}
var removeOnHide = !options.id; var removeOnHide = !options.id;
options.id = options.id || "notification" + new Date().getTime() + parseInt(Math.random()); options.id = options.id || "notification" + new Date().getTime() + parseInt(Math.random());
@ -1039,8 +1043,32 @@ var Dashboard = {
{ {
var args = cmd.Arguments; var args = cmd.Arguments;
if (args.TimeoutMs) { if (args.TimeoutMs && window.Notification && Notification.permission === "granted") {
Dashboard.showFooterNotification({ html: "<div><b>" + args.Header + "</b></div>" + args.Text, timeout: args.TimeoutMs });
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 { else {
Dashboard.alert({ title: args.Header, message: args.Text }); Dashboard.alert({ title: args.Header, message: args.Text });
@ -1168,6 +1196,10 @@ var Dashboard = {
showPackageInstallNotification: function (installation, status) { showPackageInstallNotification: function (installation, status) {
if (AppInfo.isNativeApp) {
return;
}
var html = ''; var html = '';
if (status == 'completed') { if (status == 'completed') {
@ -1229,7 +1261,7 @@ var Dashboard = {
var newItems = data.ItemsAdded; var newItems = data.ItemsAdded;
if (!newItems.length || AppInfo.isNativeApp || !window.Notification) { if (!newItems.length || AppInfo.isNativeApp || !window.Notification || Notification.permission !== "granted") {
return; return;
} }
@ -1254,8 +1286,14 @@ var Dashboard = {
var notification = { var notification = {
title: "New " + item.Type, title: "New " + item.Type,
body: item.Name, body: item.Name,
timeout: 5000, timeout: 15000,
vibrate: true vibrate: true,
data: {
options: {
url: LibraryBrowser.getHref(item)
}
}
}; };
var imageTags = item.ImageTags || {}; var imageTags = item.ImageTags || {};
@ -1269,8 +1307,6 @@ var Dashboard = {
}); });
} }
if (Notification.permission === "granted") {
var notif = new Notification(notification.title, notification); var notif = new Notification(notification.title, notification);
if (notif.show) { if (notif.show) {
@ -1289,7 +1325,6 @@ var Dashboard = {
}, notification.timeout); }, notification.timeout);
} }
} }
}
}); });
}, },
@ -1572,7 +1607,6 @@ var AppInfo = {};
} }
} }
else { else {
AppInfo.enableFooterNotifications = true;
AppInfo.enableSupporterMembership = true; AppInfo.enableSupporterMembership = true;
if (!isAndroid && !isIOS) { if (!isAndroid && !isIOS) {
@ -1618,24 +1652,34 @@ var AppInfo = {};
Events.on(apiClient, 'requestfail', Dashboard.onRequestFail); 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(); //localStorage.clear();
function createConnectionManager(credentialProviderFactory, capabilities) { function createConnectionManager(credentialProviderFactory, capabilities) {
var credentialKey = Dashboard.isConnectMode() ? null : 'servercredentials4'; var credentialKey = Dashboard.isConnectMode() ? null : 'servercredentials4';
var credentialProvider = new credentialProviderFactory(credentialKey); var credentialProvider = new credentialProviderFactory(credentialKey);
return getSyncProfile().then(function (deviceProfile) {
capabilities.DeviceProfile = deviceProfile;
window.ConnectionManager = new MediaBrowser.ConnectionManager(credentialProvider, AppInfo.appName, AppInfo.appVersion, AppInfo.deviceName, AppInfo.deviceId, capabilities, window.devicePixelRatio); window.ConnectionManager = new MediaBrowser.ConnectionManager(credentialProvider, AppInfo.appName, AppInfo.appVersion, AppInfo.deviceName, AppInfo.deviceId, capabilities, window.devicePixelRatio);
if (window.location.href.toLowerCase().indexOf('wizardstart.html') != -1) { if (window.location.href.toLowerCase().indexOf('wizardstart.html') != -1) {
window.ConnectionManager.clearData(); window.ConnectionManager.clearData();
} }
Events.on(ConnectionManager, 'apiclientcreated', function (e, newApiClient) { Events.on(ConnectionManager, 'apiclientcreated', onApiClientCreated);
initializeApiClient(newApiClient);
});
return new Promise(function (resolve, reject) {
if (Dashboard.isConnectMode()) { if (Dashboard.isConnectMode()) {
@ -1646,28 +1690,23 @@ var AppInfo = {};
if (server && server.UserId && server.AccessToken) { if (server && server.UserId && server.AccessToken) {
Dashboard.showLoadingMsg(); Dashboard.showLoadingMsg();
ConnectionManager.connectToServer(server).then(function (result) { return ConnectionManager.connectToServer(server).then(function (result) {
Dashboard.showLoadingMsg(); Dashboard.showLoadingMsg();
if (result.State == MediaBrowser.ConnectionState.SignedIn) { if (result.State == MediaBrowser.ConnectionState.SignedIn) {
window.ApiClient = result.ApiClient; window.ApiClient = result.ApiClient;
} }
resolve();
}); });
return;
} }
} }
resolve();
} else { } else {
return getRequirePromise(['apiclient']).then(function (apiClientFactory) {
require(['apiclient'], function(apiClientFactory) {
var apiClient = new apiClientFactory(Dashboard.serverAddress(), AppInfo.appName, AppInfo.appVersion, AppInfo.deviceName, AppInfo.deviceId, window.devicePixelRatio); var apiClient = new apiClientFactory(Dashboard.serverAddress(), AppInfo.appName, AppInfo.appVersion, AppInfo.deviceName, AppInfo.deviceId, window.devicePixelRatio);
apiClient.enableAutomaticNetworking = false; apiClient.enableAutomaticNetworking = false;
ConnectionManager.addApiClient(apiClient); ConnectionManager.addApiClient(apiClient);
Dashboard.importCss(apiClient.getUrl('Branding/Css')); Dashboard.importCss(apiClient.getUrl('Branding/Css'));
window.ApiClient = apiClient; window.ApiClient = apiClient;
resolve();
}); });
} }
}); });
@ -2058,7 +2097,6 @@ var AppInfo = {};
deps.push('credentialprovider'); deps.push('credentialprovider');
deps.push('appstorage'); deps.push('appstorage');
deps.push('scripts/mediaplayer');
deps.push('scripts/appsettings'); deps.push('scripts/appsettings');
require(deps, function (connectionManagerExports, credentialProviderFactory) { 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 = []; var promises = [];
deps = []; deps = [];
deps.push('scripts/mediaplayer');
deps.push('thirdparty/jquery.unveil-custom.js'); deps.push('thirdparty/jquery.unveil-custom.js');
deps.push('emby-icons'); deps.push('emby-icons');
deps.push('paper-icon-button'); deps.push('paper-icon-button');
@ -2116,7 +2151,7 @@ var AppInfo = {};
promises.push(getRequirePromise(deps)); promises.push(getRequirePromise(deps));
promises.push(Globalize.ensure()); promises.push(Globalize.ensure());
promises.push(createConnectionManager(credentialProviderFactory, capabilities)); promises.push(createConnectionManager(credentialProviderFactory, Dashboard.capabilities()));
Promise.all(promises).then(function () { Promise.all(promises).then(function () {