degligy medialibrarypage
This commit is contained in:
parent
e8ae9b3605
commit
e9d2c73c5e
1 changed files with 97 additions and 52 deletions
|
@ -3,42 +3,48 @@ define(["jQuery", "apphost", "scripts/taskbutton", "loading", "libraryMenu", "gl
|
|||
|
||||
function addVirtualFolder(page) {
|
||||
require(["medialibrarycreator"], function (medialibrarycreator) {
|
||||
(new medialibrarycreator).show({
|
||||
new medialibrarycreator().show({
|
||||
collectionTypeOptions: getCollectionTypeOptions().filter(function (f) {
|
||||
return !f.hidden;
|
||||
}),
|
||||
refresh: shouldRefreshLibraryAfterChanges(page)
|
||||
}).then(function (hasChanges) {
|
||||
hasChanges && reloadLibrary(page);
|
||||
})
|
||||
})
|
||||
if (hasChanges) {
|
||||
reloadLibrary(page);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function editVirtualFolder(page, virtualFolder) {
|
||||
require(["medialibraryeditor"], function (medialibraryeditor) {
|
||||
(new medialibraryeditor).show({
|
||||
new medialibraryeditor().show({
|
||||
refresh: shouldRefreshLibraryAfterChanges(page),
|
||||
library: virtualFolder
|
||||
}).then(function (hasChanges) {
|
||||
hasChanges && reloadLibrary(page);
|
||||
})
|
||||
})
|
||||
if (hasChanges) {
|
||||
reloadLibrary(page);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function deleteVirtualFolder(page, virtualFolder) {
|
||||
var msg = globalize.translate("MessageAreYouSureYouWishToRemoveMediaFolder");
|
||||
|
||||
if (virtualFolder.Locations.length) {
|
||||
msg += "<br/><br/>" + globalize.translate("MessageTheFollowingLocationWillBeRemovedFromLibrary") + "<br/><br/>";
|
||||
msg += virtualFolder.Locations.join("<br/>");
|
||||
}
|
||||
|
||||
require(["confirm"], function (confirm) {
|
||||
confirm(msg, globalize.translate("HeaderRemoveMediaFolder")).then(function () {
|
||||
var refreshAfterChange = shouldRefreshLibraryAfterChanges(page);
|
||||
ApiClient.removeVirtualFolder(virtualFolder.Name, refreshAfterChange).then(function () {
|
||||
reloadLibrary(page);
|
||||
})
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function refreshVirtualFolder(page, virtualFolder) {
|
||||
|
@ -97,6 +103,7 @@ define(["jQuery", "apphost", "scripts/taskbutton", "loading", "libraryMenu", "gl
|
|||
id: "refresh",
|
||||
ironIcon: "refresh"
|
||||
});
|
||||
|
||||
require(["actionsheet"], function (actionsheet) {
|
||||
actionsheet.show({
|
||||
items: menuItems,
|
||||
|
@ -106,15 +113,19 @@ define(["jQuery", "apphost", "scripts/taskbutton", "loading", "libraryMenu", "gl
|
|||
case "edit":
|
||||
editVirtualFolder(page, virtualFolder);
|
||||
break;
|
||||
|
||||
case "editimages":
|
||||
editImages(page, virtualFolder);
|
||||
break;
|
||||
|
||||
case "rename":
|
||||
renameVirtualFolder(page, virtualFolder);
|
||||
break;
|
||||
|
||||
case "delete":
|
||||
deleteVirtualFolder(page, virtualFolder);
|
||||
break;
|
||||
|
||||
case "refresh":
|
||||
refreshVirtualFolder(page, virtualFolder);
|
||||
}
|
||||
|
@ -148,8 +159,9 @@ define(["jQuery", "apphost", "scripts/taskbutton", "loading", "libraryMenu", "gl
|
|||
|
||||
for (var i = 0; i < virtualFolders.length; i++) {
|
||||
var virtualFolder = virtualFolders[i];
|
||||
html += getVirtualFolderHtml(page, virtualFolder, i)
|
||||
html += getVirtualFolderHtml(page, virtualFolder, i);
|
||||
}
|
||||
|
||||
var divVirtualFolders = page.querySelector("#divVirtualFolders");
|
||||
divVirtualFolders.innerHTML = html;
|
||||
divVirtualFolders.classList.add("itemsContainer");
|
||||
|
@ -164,7 +176,10 @@ define(["jQuery", "apphost", "scripts/taskbutton", "loading", "libraryMenu", "gl
|
|||
var card = $(this).parents(".card")[0];
|
||||
var index = parseInt(card.getAttribute("data-index"));
|
||||
var virtualFolder = virtualFolders[index];
|
||||
virtualFolder.ItemId && editVirtualFolder(page, virtualFolder);
|
||||
|
||||
if (virtualFolder.ItemId) {
|
||||
editVirtualFolder(page, virtualFolder);
|
||||
}
|
||||
});
|
||||
loading.hide();
|
||||
}
|
||||
|
@ -177,7 +192,7 @@ define(["jQuery", "apphost", "scripts/taskbutton", "loading", "libraryMenu", "gl
|
|||
}).then(function () {
|
||||
reloadLibrary(page);
|
||||
});
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function getLink(text, url) {
|
||||
|
@ -214,25 +229,32 @@ define(["jQuery", "apphost", "scripts/taskbutton", "loading", "libraryMenu", "gl
|
|||
name: globalize.translate("FolderTypeUnset"),
|
||||
value: "mixed",
|
||||
message: globalize.translate("MessageUnsetContentHelp")
|
||||
}]
|
||||
}];
|
||||
}
|
||||
|
||||
function getVirtualFolderHtml(page, virtualFolder, index) {
|
||||
var html = "";
|
||||
var style = "";
|
||||
page.classList.contains("wizardPage") && (style += "min-width:33.3%;");
|
||||
|
||||
if (page.classList.contains("wizardPage")) {
|
||||
style += "min-width:33.3%;";
|
||||
}
|
||||
|
||||
html += '<div class="card backdropCard scalableCard backdropCard-scalable" style="' + style + '" data-index="' + index + '" data-id="' + virtualFolder.ItemId + '">';
|
||||
html += '<div class="cardBox visualCardBox">';
|
||||
html += '<div class="cardScalable visualCardBox-cardScalable">';
|
||||
html += '<div class="cardPadder cardPadder-backdrop"></div>';
|
||||
html += '<div class="cardContent">';
|
||||
var imgUrl = "";
|
||||
|
||||
if (virtualFolder.PrimaryImageItemId) {
|
||||
imgUrl = ApiClient.getScaledImageUrl(virtualFolder.PrimaryImageItemId, {
|
||||
type: "Primary"
|
||||
});
|
||||
}
|
||||
|
||||
var hasCardImageContainer;
|
||||
|
||||
if (imgUrl) {
|
||||
html += '<div class="cardImageContainer editLibrary" style="cursor:pointer;background-image:url(\'' + imgUrl + "');\">";
|
||||
hasCardImageContainer = true;
|
||||
|
@ -241,38 +263,60 @@ define(["jQuery", "apphost", "scripts/taskbutton", "loading", "libraryMenu", "gl
|
|||
html += '<i class="cardImageIcon-small md-icon">' + (virtualFolder.icon || imageHelper.getLibraryIcon(virtualFolder.CollectionType)) + "</i>";
|
||||
hasCardImageContainer = true;
|
||||
}
|
||||
|
||||
if (hasCardImageContainer) {
|
||||
html += '<div class="cardIndicators backdropCardIndicators">';
|
||||
html += '<div is="emby-itemrefreshindicator"' + (virtualFolder.RefreshProgress || virtualFolder.RefreshStatus && "Idle" !== virtualFolder.RefreshStatus ? "" : ' class="hide"') + ' data-progress="' + (virtualFolder.RefreshProgress || 0) + '" data-status="' + virtualFolder.RefreshStatus + '"></div>';
|
||||
html += "</div>";
|
||||
html += "</div>";
|
||||
}
|
||||
|
||||
if (!imgUrl && virtualFolder.showNameWithIcon) {
|
||||
html += '<h3 class="cardImageContainer addLibrary" style="position:absolute;top:0;left:0;right:0;bottom:0;cursor:pointer;flex-direction:column;">';
|
||||
html += '<i class="cardImageIcon-small md-icon">' + (virtualFolder.icon || imageHelper.getLibraryIcon(virtualFolder.CollectionType)) + "</i>";
|
||||
virtualFolder.showNameWithIcon && (html += '<div style="margin:1em 0;position:width:100%;">', html += virtualFolder.Name, html += "</div>");
|
||||
|
||||
if (virtualFolder.showNameWithIcon) {
|
||||
html += '<div style="margin:1em 0;position:width:100%;">';
|
||||
html += virtualFolder.Name;
|
||||
html += "</div>";
|
||||
}
|
||||
|
||||
html += "</h3>";
|
||||
}
|
||||
html += "</div>";
|
||||
html += "</div>";
|
||||
html += '<div class="cardFooter visualCardBox-cardFooter">';
|
||||
|
||||
// always show menu unless explicitly hidden
|
||||
html += "</div>";
|
||||
html += "</div>";
|
||||
html += '<div class="cardFooter visualCardBox-cardFooter">'; // always show menu unless explicitly hidden
|
||||
|
||||
if (virtualFolder.showMenu !== false) {
|
||||
html += '<div style="text-align:right; float:right;padding-top:5px;">';
|
||||
html += '<button type="button" is="paper-icon-button-light" class="btnCardMenu autoSize"><i class="md-icon"></i></button>';
|
||||
html += "</div>";
|
||||
}
|
||||
|
||||
html += "<div class='cardText'>";
|
||||
virtualFolder.showNameWithIcon ? html += " " : html += virtualFolder.Name;
|
||||
|
||||
if (virtualFolder.showNameWithIcon) {
|
||||
html += " ";
|
||||
} else {
|
||||
html += virtualFolder.Name;
|
||||
}
|
||||
|
||||
html += "</div>";
|
||||
var typeName = getCollectionTypeOptions().filter(function (t) {
|
||||
return t.value == virtualFolder.CollectionType
|
||||
return t.value == virtualFolder.CollectionType;
|
||||
})[0];
|
||||
typeName = typeName ? typeName.name : globalize.translate("FolderTypeUnset");
|
||||
html += "<div class='cardText cardText-secondary'>";
|
||||
virtualFolder.showType === false ? html += " " : html += typeName;
|
||||
|
||||
if (virtualFolder.showType === false) {
|
||||
html += " ";
|
||||
} else {
|
||||
html += typeName;
|
||||
}
|
||||
|
||||
html += "</div>";
|
||||
|
||||
if (virtualFolder.showLocations === false) {
|
||||
html += "<div class='cardText cardText-secondary'>";
|
||||
html += " ";
|
||||
|
@ -286,6 +330,7 @@ define(["jQuery", "apphost", "scripts/taskbutton", "loading", "libraryMenu", "gl
|
|||
html += globalize.translate("NumLocationsValue", virtualFolder.Locations.length);
|
||||
html += "</div>";
|
||||
}
|
||||
|
||||
html += "</div>";
|
||||
html += "</div>";
|
||||
html += "</div>";
|
||||
|
@ -305,12 +350,12 @@ define(["jQuery", "apphost", "scripts/taskbutton", "loading", "libraryMenu", "gl
|
|||
}, {
|
||||
href: "metadatanfo.html",
|
||||
name: globalize.translate("TabNfoSettings")
|
||||
}]
|
||||
}];
|
||||
}
|
||||
|
||||
window.WizardLibraryPage = {
|
||||
next: function () {
|
||||
Dashboard.navigate("wizardsettings.html")
|
||||
Dashboard.navigate("wizardsettings.html");
|
||||
}
|
||||
};
|
||||
pageClassOn("pageshow", "mediaLibraryPage", function () {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue