mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Merge remote-tracking branch 'origin/master' into fadein
This commit is contained in:
commit
d3d482dcac
255 changed files with 6006 additions and 3239 deletions
135
src/scripts/settings/appSettings.js
Normal file
135
src/scripts/settings/appSettings.js
Normal file
|
@ -0,0 +1,135 @@
|
|||
define(['appStorage', 'events'], function (appStorage, events) {
|
||||
'use strict';
|
||||
|
||||
function getKey(name, userId) {
|
||||
if (userId) {
|
||||
name = userId + '-' + name;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
function AppSettings() {
|
||||
}
|
||||
|
||||
AppSettings.prototype.enableAutoLogin = function (val) {
|
||||
if (val != null) {
|
||||
this.set('enableAutoLogin', val.toString());
|
||||
}
|
||||
|
||||
return this.get('enableAutoLogin') !== 'false';
|
||||
};
|
||||
|
||||
AppSettings.prototype.enableAutomaticBitrateDetection = function (isInNetwork, mediaType, val) {
|
||||
var key = 'enableautobitratebitrate-' + mediaType + '-' + isInNetwork;
|
||||
if (val != null) {
|
||||
if (isInNetwork && mediaType === 'Audio') {
|
||||
val = true;
|
||||
}
|
||||
|
||||
this.set(key, val.toString());
|
||||
}
|
||||
|
||||
if (isInNetwork && mediaType === 'Audio') {
|
||||
return true;
|
||||
} else {
|
||||
return this.get(key) !== 'false';
|
||||
}
|
||||
};
|
||||
|
||||
AppSettings.prototype.maxStreamingBitrate = function (isInNetwork, mediaType, val) {
|
||||
var key = 'maxbitrate-' + mediaType + '-' + isInNetwork;
|
||||
if (val != null) {
|
||||
if (isInNetwork && mediaType === 'Audio') {
|
||||
// nothing to do, this is always a max value
|
||||
} else {
|
||||
this.set(key, val);
|
||||
}
|
||||
}
|
||||
|
||||
if (isInNetwork && mediaType === 'Audio') {
|
||||
// return a huge number so that it always direct plays
|
||||
return 150000000;
|
||||
} else {
|
||||
return parseInt(this.get(key) || '0') || 1500000;
|
||||
}
|
||||
};
|
||||
|
||||
AppSettings.prototype.maxStaticMusicBitrate = function (val) {
|
||||
if (val !== undefined) {
|
||||
this.set('maxStaticMusicBitrate', val);
|
||||
}
|
||||
|
||||
var defaultValue = 320000;
|
||||
return parseInt(this.get('maxStaticMusicBitrate') || defaultValue.toString()) || defaultValue;
|
||||
};
|
||||
|
||||
AppSettings.prototype.maxChromecastBitrate = function (val) {
|
||||
if (val != null) {
|
||||
this.set('chromecastBitrate1', val);
|
||||
}
|
||||
|
||||
val = this.get('chromecastBitrate1');
|
||||
return val ? parseInt(val) : null;
|
||||
};
|
||||
|
||||
AppSettings.prototype.syncOnlyOnWifi = function (val) {
|
||||
if (val != null) {
|
||||
this.set('syncOnlyOnWifi', val.toString());
|
||||
}
|
||||
|
||||
return this.get('syncOnlyOnWifi') !== 'false';
|
||||
};
|
||||
|
||||
AppSettings.prototype.syncPath = function (val) {
|
||||
if (val != null) {
|
||||
this.set('syncPath', val);
|
||||
}
|
||||
|
||||
return this.get('syncPath');
|
||||
};
|
||||
|
||||
AppSettings.prototype.cameraUploadServers = function (val) {
|
||||
if (val != null) {
|
||||
this.set('cameraUploadServers', val.join(','));
|
||||
}
|
||||
|
||||
val = this.get('cameraUploadServers');
|
||||
if (val) {
|
||||
return val.split(',');
|
||||
}
|
||||
|
||||
return [];
|
||||
};
|
||||
|
||||
AppSettings.prototype.runAtStartup = function (val) {
|
||||
if (val != null) {
|
||||
this.set('runatstartup', val.toString());
|
||||
}
|
||||
|
||||
return this.get('runatstartup') === 'true';
|
||||
};
|
||||
|
||||
AppSettings.prototype.set = function (name, value, userId) {
|
||||
var currentValue = this.get(name, userId);
|
||||
appStorage.setItem(getKey(name, userId), value);
|
||||
|
||||
if (currentValue !== value) {
|
||||
events.trigger(this, 'change', [name]);
|
||||
}
|
||||
};
|
||||
|
||||
AppSettings.prototype.get = function (name, userId) {
|
||||
return appStorage.getItem(getKey(name, userId));
|
||||
};
|
||||
|
||||
AppSettings.prototype.enableSystemExternalPlayers = function (val) {
|
||||
if (val != null) {
|
||||
this.set('enableSystemExternalPlayers', val.toString());
|
||||
}
|
||||
|
||||
return this.get('enableSystemExternalPlayers') === 'true';
|
||||
};
|
||||
|
||||
return new AppSettings();
|
||||
});
|
255
src/scripts/settings/userSettings.js
Normal file
255
src/scripts/settings/userSettings.js
Normal file
|
@ -0,0 +1,255 @@
|
|||
define(['appSettings', 'events'], function (appSettings, events) {
|
||||
'use strict';
|
||||
|
||||
function onSaveTimeout() {
|
||||
var self = this;
|
||||
self.saveTimeout = null;
|
||||
self.currentApiClient.updateDisplayPreferences('usersettings', self.displayPrefs, self.currentUserId, 'emby');
|
||||
}
|
||||
|
||||
function saveServerPreferences(instance) {
|
||||
if (instance.saveTimeout) {
|
||||
clearTimeout(instance.saveTimeout);
|
||||
}
|
||||
|
||||
instance.saveTimeout = setTimeout(onSaveTimeout.bind(instance), 50);
|
||||
}
|
||||
|
||||
function UserSettings() {
|
||||
}
|
||||
|
||||
UserSettings.prototype.setUserInfo = function (userId, apiClient) {
|
||||
if (this.saveTimeout) {
|
||||
clearTimeout(this.saveTimeout);
|
||||
}
|
||||
|
||||
this.currentUserId = userId;
|
||||
this.currentApiClient = apiClient;
|
||||
|
||||
if (!userId) {
|
||||
this.displayPrefs = null;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
var self = this;
|
||||
|
||||
return apiClient.getDisplayPreferences('usersettings', userId, 'emby').then(function (result) {
|
||||
result.CustomPrefs = result.CustomPrefs || {};
|
||||
self.displayPrefs = result;
|
||||
});
|
||||
};
|
||||
|
||||
UserSettings.prototype.getData = function () {
|
||||
return this.displayPrefs;
|
||||
};
|
||||
|
||||
UserSettings.prototype.importFrom = function (instance) {
|
||||
this.displayPrefs = instance.getData();
|
||||
};
|
||||
|
||||
UserSettings.prototype.set = function (name, value, enableOnServer) {
|
||||
var userId = this.currentUserId;
|
||||
var currentValue = this.get(name, enableOnServer);
|
||||
var result = appSettings.set(name, value, userId);
|
||||
|
||||
if (enableOnServer !== false && this.displayPrefs) {
|
||||
this.displayPrefs.CustomPrefs[name] = value == null ? value : value.toString();
|
||||
saveServerPreferences(this);
|
||||
}
|
||||
|
||||
if (currentValue !== value) {
|
||||
events.trigger(this, 'change', [name]);
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
UserSettings.prototype.get = function (name, enableOnServer) {
|
||||
var userId = this.currentUserId;
|
||||
if (enableOnServer !== false && this.displayPrefs) {
|
||||
return this.displayPrefs.CustomPrefs[name];
|
||||
}
|
||||
|
||||
return appSettings.get(name, userId);
|
||||
};
|
||||
|
||||
UserSettings.prototype.serverConfig = function (config) {
|
||||
var apiClient = this.currentApiClient;
|
||||
if (config) {
|
||||
return apiClient.updateUserConfiguration(this.currentUserId, config);
|
||||
}
|
||||
|
||||
return apiClient.getUser(this.currentUserId).then(function (user) {
|
||||
return user.Configuration;
|
||||
});
|
||||
};
|
||||
|
||||
UserSettings.prototype.enableCinemaMode = function (val) {
|
||||
if (val != null) {
|
||||
return this.set('enableCinemaMode', val.toString(), false);
|
||||
}
|
||||
|
||||
val = this.get('enableCinemaMode', false);
|
||||
return val !== 'false';
|
||||
};
|
||||
|
||||
UserSettings.prototype.enableNextVideoInfoOverlay = function (val) {
|
||||
if (val != null) {
|
||||
return this.set('enableNextVideoInfoOverlay', val.toString());
|
||||
}
|
||||
|
||||
val = this.get('enableNextVideoInfoOverlay', false);
|
||||
return val !== 'false';
|
||||
};
|
||||
|
||||
UserSettings.prototype.enableThemeSongs = function (val) {
|
||||
if (val != null) {
|
||||
return this.set('enableThemeSongs', val.toString(), false);
|
||||
}
|
||||
|
||||
val = this.get('enableThemeSongs', false);
|
||||
return val !== 'false';
|
||||
};
|
||||
|
||||
UserSettings.prototype.enableThemeVideos = function (val) {
|
||||
if (val != null) {
|
||||
return this.set('enableThemeVideos', val.toString(), false);
|
||||
}
|
||||
|
||||
val = this.get('enableThemeVideos', false);
|
||||
return val !== 'false';
|
||||
};
|
||||
|
||||
UserSettings.prototype.enableFastFadein = function (val) {
|
||||
if (val != null) {
|
||||
return this.set('fastFadein', val.toString(), false);
|
||||
}
|
||||
|
||||
val = this.get('fastFadein', false);
|
||||
return val !== 'false';
|
||||
};
|
||||
|
||||
UserSettings.prototype.enableBackdrops = function (val) {
|
||||
if (val != null) {
|
||||
return this.set('enableBackdrops', val.toString(), false);
|
||||
}
|
||||
|
||||
val = this.get('enableBackdrops', false);
|
||||
return val !== 'false';
|
||||
};
|
||||
|
||||
UserSettings.prototype.language = function (val) {
|
||||
if (val != null) {
|
||||
return this.set('language', val.toString(), false);
|
||||
}
|
||||
|
||||
return this.get('language', false);
|
||||
};
|
||||
|
||||
UserSettings.prototype.dateTimeLocale = function (val) {
|
||||
if (val != null) {
|
||||
return this.set('datetimelocale', val.toString(), false);
|
||||
}
|
||||
|
||||
return this.get('datetimelocale', false);
|
||||
};
|
||||
|
||||
UserSettings.prototype.skipBackLength = function (val) {
|
||||
if (val != null) {
|
||||
return this.set('skipBackLength', val.toString());
|
||||
}
|
||||
|
||||
return parseInt(this.get('skipBackLength') || '10000');
|
||||
};
|
||||
|
||||
UserSettings.prototype.skipForwardLength = function (val) {
|
||||
if (val != null) {
|
||||
return this.set('skipForwardLength', val.toString());
|
||||
}
|
||||
|
||||
return parseInt(this.get('skipForwardLength') || '30000');
|
||||
};
|
||||
|
||||
UserSettings.prototype.dashboardTheme = function (val) {
|
||||
if (val != null) {
|
||||
return this.set('dashboardTheme', val);
|
||||
}
|
||||
|
||||
return this.get('dashboardTheme');
|
||||
};
|
||||
|
||||
UserSettings.prototype.skin = function (val) {
|
||||
if (val != null) {
|
||||
return this.set('skin', val, false);
|
||||
}
|
||||
|
||||
return this.get('skin', false);
|
||||
};
|
||||
|
||||
UserSettings.prototype.theme = function (val) {
|
||||
if (val != null) {
|
||||
return this.set('appTheme', val, false);
|
||||
}
|
||||
|
||||
return this.get('appTheme', false);
|
||||
};
|
||||
|
||||
UserSettings.prototype.screensaver = function (val) {
|
||||
if (val != null) {
|
||||
return this.set('screensaver', val, false);
|
||||
}
|
||||
|
||||
return this.get('screensaver', false);
|
||||
};
|
||||
|
||||
UserSettings.prototype.soundEffects = function (val) {
|
||||
if (val != null) {
|
||||
return this.set('soundeffects', val, false);
|
||||
}
|
||||
|
||||
return this.get('soundeffects', false);
|
||||
};
|
||||
|
||||
UserSettings.prototype.loadQuerySettings = function (key, query) {
|
||||
var values = this.get(key);
|
||||
if (values) {
|
||||
values = JSON.parse(values);
|
||||
return Object.assign(query, values);
|
||||
}
|
||||
|
||||
return query;
|
||||
};
|
||||
|
||||
UserSettings.prototype.saveQuerySettings = function (key, query) {
|
||||
var values = {};
|
||||
if (query.SortBy) {
|
||||
values.SortBy = query.SortBy;
|
||||
}
|
||||
|
||||
if (query.SortOrder) {
|
||||
values.SortOrder = query.SortOrder;
|
||||
}
|
||||
|
||||
return this.set(key, JSON.stringify(values));
|
||||
};
|
||||
|
||||
UserSettings.prototype.getSubtitleAppearanceSettings = function (key) {
|
||||
key = key || 'localplayersubtitleappearance3';
|
||||
return JSON.parse(this.get(key, false) || '{}');
|
||||
};
|
||||
|
||||
UserSettings.prototype.setSubtitleAppearanceSettings = function (value, key) {
|
||||
key = key || 'localplayersubtitleappearance3';
|
||||
return this.set(key, JSON.stringify(value), false);
|
||||
};
|
||||
|
||||
UserSettings.prototype.setFilter = function (key, value) {
|
||||
return this.set(key, value, true);
|
||||
};
|
||||
|
||||
UserSettings.prototype.getFilter = function (key) {
|
||||
return this.get(key, true);
|
||||
};
|
||||
|
||||
return new UserSettings();
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue