mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
connect updates
This commit is contained in:
parent
90082ed4bc
commit
83d7b945d7
25 changed files with 686 additions and 312 deletions
|
@ -10,7 +10,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
|
|||
* @param {String} clientName
|
||||
* @param {String} applicationVersion
|
||||
*/
|
||||
return function (serverAddress, clientName, applicationVersion, deviceName, deviceId) {
|
||||
return function (serverAddress, clientName, applicationVersion, deviceName, deviceId, capabilities) {
|
||||
|
||||
if (!serverAddress) {
|
||||
throw new Error("Must supply a serverAddress");
|
||||
|
@ -26,6 +26,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
|
|||
var currentUserId;
|
||||
var accessToken;
|
||||
var webSocket;
|
||||
var serverInfo;
|
||||
|
||||
/**
|
||||
* Gets the server address.
|
||||
|
@ -40,6 +41,13 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
|
|||
return "/mediabrowser";
|
||||
};
|
||||
|
||||
self.serverInfo = function (info) {
|
||||
|
||||
serverInfo = info || serverInfo;
|
||||
|
||||
return serverInfo;
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets or sets the current user id.
|
||||
*/
|
||||
|
@ -89,27 +97,29 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
|
|||
/**
|
||||
* Wraps around jQuery ajax methods to add additional info to the request.
|
||||
*/
|
||||
self.ajax = function (request) {
|
||||
self.ajax = function (request, includeAuthorization) {
|
||||
|
||||
if (!request) {
|
||||
throw new Error("Request cannot be null");
|
||||
}
|
||||
|
||||
if (clientName) {
|
||||
if (includeAuthorization !== false) {
|
||||
if (clientName) {
|
||||
|
||||
var auth = 'MediaBrowser Client="' + clientName + '", Device="' + deviceName + '", DeviceId="' + deviceId + '", Version="' + applicationVersion + '"';
|
||||
var auth = 'MediaBrowser Client="' + clientName + '", Device="' + deviceName + '", DeviceId="' + deviceId + '", Version="' + applicationVersion + '"';
|
||||
|
||||
if (currentUserId) {
|
||||
auth += ', UserId="' + currentUserId + '"';
|
||||
if (currentUserId) {
|
||||
auth += ', UserId="' + currentUserId + '"';
|
||||
}
|
||||
|
||||
request.headers = {
|
||||
Authorization: auth
|
||||
};
|
||||
}
|
||||
|
||||
request.headers = {
|
||||
Authorization: auth
|
||||
};
|
||||
}
|
||||
|
||||
if (accessToken) {
|
||||
request.headers['X-MediaBrowser-Token'] = accessToken;
|
||||
if (accessToken) {
|
||||
request.headers['X-MediaBrowser-Token'] = accessToken;
|
||||
}
|
||||
}
|
||||
|
||||
return $.ajax(request);
|
||||
|
@ -146,7 +156,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
|
|||
return url;
|
||||
};
|
||||
|
||||
self.enableAutomaticNetworking = function(server, connectionMode) {
|
||||
self.enableAutomaticNetworking = function (server, connectionMode) {
|
||||
|
||||
};
|
||||
|
||||
|
@ -171,6 +181,8 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
|
|||
|
||||
self.sendWebSocketMessage("Identity", clientName + "|" + deviceId + "|" + applicationVersion + "|" + deviceName);
|
||||
|
||||
self.reportCapabilities(capabilities);
|
||||
|
||||
$(self).trigger("websocketopen");
|
||||
|
||||
}, 500);
|
||||
|
@ -848,6 +860,21 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
|
|||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the current server status
|
||||
*/
|
||||
self.getPublicSystemInfo = function () {
|
||||
|
||||
var url = self.getUrl("System/Info/Public");
|
||||
|
||||
return self.ajax({
|
||||
type: "GET",
|
||||
url: url,
|
||||
dataType: "json"
|
||||
|
||||
}, false);
|
||||
};
|
||||
|
||||
self.getInstantMixFromSong = function (itemId, options) {
|
||||
|
||||
var url = self.getUrl("Songs/" + itemId + "/InstantMix", options);
|
||||
|
@ -2049,7 +2076,8 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
|
|||
type: "GET",
|
||||
url: url,
|
||||
dataType: "json"
|
||||
});
|
||||
|
||||
}, false);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -2081,7 +2109,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
|
|||
};
|
||||
|
||||
var supportsWebP = false;
|
||||
self.supportsWebP = function(val) {
|
||||
self.supportsWebP = function (val) {
|
||||
|
||||
if (val != null) {
|
||||
supportsWebP = val;
|
||||
|
@ -2264,7 +2292,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
|
|||
dataType: "json",
|
||||
contentType: "application/json"
|
||||
|
||||
}).done(function(result) {
|
||||
}).done(function (result) {
|
||||
|
||||
|
||||
$(self).trigger('authenticated', [result]);
|
||||
|
@ -3170,7 +3198,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
|
|||
|
||||
(function (store) {
|
||||
|
||||
MediaBrowser.ApiClient.generateDeviceId = function() {
|
||||
MediaBrowser.ApiClient.generateDeviceId = function () {
|
||||
|
||||
var keys = [];
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue