update shared dialogs
This commit is contained in:
parent
6e6017eeaf
commit
c17d97e0ba
28 changed files with 204 additions and 62 deletions
101
dashboard-ui/bower_components/emby-webcomponents/itemcontextmenu.js
vendored
Normal file
101
dashboard-ui/bower_components/emby-webcomponents/itemcontextmenu.js
vendored
Normal file
|
@ -0,0 +1,101 @@
|
|||
define(['apphost', 'globalize', 'connectionManager'], function (appHost, globalize, connectionManager) {
|
||||
|
||||
function getCommands(options) {
|
||||
|
||||
var item = options.item;
|
||||
|
||||
var serverId = item.ServerId;
|
||||
var apiClient = connectionManager.getApiClient(serverId);
|
||||
|
||||
return apiClient.getCurrentUser().then(function (user) {
|
||||
|
||||
var commands = [];
|
||||
|
||||
if (item.CanDownload && user.Policy.EnableContentDownloading && appHost.supports('filedownload')) {
|
||||
commands.push({
|
||||
name: globalize.translate('sharedcomponents#Download'),
|
||||
id: 'download'
|
||||
});
|
||||
}
|
||||
|
||||
if (item.Type != 'Timer' && user.Policy.EnablePublicSharing && appHost.supports('sharing')) {
|
||||
commands.push({
|
||||
name: globalize.translate('Share'),
|
||||
id: 'share'
|
||||
});
|
||||
}
|
||||
|
||||
return commands;
|
||||
});
|
||||
}
|
||||
|
||||
function executeCommand(item, id) {
|
||||
|
||||
var itemId = item.Id;
|
||||
var serverId = item.ServerId;
|
||||
var apiClient = connectionManager.getApiClient(serverId);
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
|
||||
switch (id) {
|
||||
|
||||
case 'download':
|
||||
{
|
||||
require(['fileDownloader'], function (fileDownloader) {
|
||||
var downloadHref = apiClient.getUrl("Items/" + itemId + "/Download", {
|
||||
api_key: apiClient.accessToken()
|
||||
});
|
||||
|
||||
fileDownloader.download([
|
||||
{
|
||||
url: downloadHref,
|
||||
itemId: itemId,
|
||||
serverId: serverId
|
||||
}]);
|
||||
|
||||
reject();
|
||||
});
|
||||
|
||||
break;
|
||||
}
|
||||
case 'share':
|
||||
{
|
||||
require(['sharingmanager'], function (sharingManager) {
|
||||
sharingManager.showMenu({
|
||||
serverId: serverId,
|
||||
itemId: itemId
|
||||
|
||||
}).then(reject);
|
||||
});
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function show(options) {
|
||||
|
||||
return getCommands(options).then(function (commands) {
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
|
||||
require(['actionsheet'], function (actionSheet) {
|
||||
|
||||
actionSheet.show({
|
||||
items: commands
|
||||
}).then(function (id) {
|
||||
executeCommand(options.item, id).then(resolve);
|
||||
}, reject);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
getCommands: getCommands,
|
||||
show: show
|
||||
};
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue