Merge pull request #1763 from umbraco/temp-U4-9545
U4-9545 EntityRepository performs poorly for Media due to unnecessary outer joins
This commit is contained in:
@@ -427,7 +427,9 @@ function mediaResource($q, $http, umbDataFormatter, umbRequestHelper) {
|
||||
* Retrieves all media children with types used as folders.
|
||||
* Uses the convention of looking for media items with mediaTypes ending in
|
||||
* *Folder so will match "Folder", "bannerFolder", "secureFolder" etc,
|
||||
*
|
||||
*
|
||||
* NOTE: This will return a max of 500 folders, if more is required it needs to be paged
|
||||
*
|
||||
* ##usage
|
||||
* <pre>
|
||||
* mediaResource.getChildFolders(1234)
|
||||
@@ -445,14 +447,15 @@ function mediaResource($q, $http, umbDataFormatter, umbRequestHelper) {
|
||||
parentId = -1;
|
||||
}
|
||||
|
||||
//NOTE: This will return a max of 500 folders, if more is required it needs to be paged
|
||||
return umbRequestHelper.resourcePromise(
|
||||
$http.get(
|
||||
umbRequestHelper.getApiUrl(
|
||||
"mediaApiBaseUrl",
|
||||
"GetChildFolders",
|
||||
[
|
||||
{ id: parentId }
|
||||
])),
|
||||
{
|
||||
id: parentId
|
||||
})),
|
||||
'Failed to retrieve child folders for media item ' + parentId);
|
||||
},
|
||||
|
||||
|
||||
@@ -7,6 +7,19 @@ function mediaTypeHelper(mediaTypeResource, $q) {
|
||||
|
||||
var mediaTypeHelperService = {
|
||||
|
||||
isFolderType: function(mediaEntity) {
|
||||
if (!mediaEntity) {
|
||||
throw "mediaEntity is null";
|
||||
}
|
||||
if (!mediaEntity.contentTypeAlias) {
|
||||
throw "mediaEntity.contentTypeAlias is null";
|
||||
}
|
||||
|
||||
//if you create a media type, which has an alias that ends with ...Folder then its a folder: ex: "secureFolder", "bannerFolder", "Folder"
|
||||
//this is the exact same logic that is performed in MediaController.GetChildFolders
|
||||
return mediaEntity.contentTypeAlias.endsWith("Folder");
|
||||
},
|
||||
|
||||
getAllowedImagetypes: function (mediaId){
|
||||
|
||||
// Get All allowedTypes
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
</umb-file-dropzone>
|
||||
|
||||
<umb-folder-grid
|
||||
ng-if="folders.length > 0 && !vm.isRecycleBin"
|
||||
ng-if="folders.length > 0"
|
||||
folders="folders"
|
||||
on-click="vm.selectFolder"
|
||||
on-click-name="vm.goToItem">
|
||||
|
||||
@@ -37,7 +37,8 @@
|
||||
function activate() {
|
||||
vm.itemsWithoutFolders = filterOutFolders($scope.items);
|
||||
|
||||
if($scope.entityType === 'media') {
|
||||
//no need to make another REST/DB call if this data is not used when we are browsing the bin
|
||||
if ($scope.entityType === 'media' && !vm.isRecycleBin) {
|
||||
mediaTypeHelper.getAllowedImagetypes(vm.nodeId).then(function (types) {
|
||||
vm.acceptedMediatypes = types;
|
||||
});
|
||||
|
||||
@@ -53,7 +53,9 @@ function listViewController($rootScope, $scope, $routeParams, $injector, $cookie
|
||||
$scope.isNew = false;
|
||||
$scope.actionInProgress = false;
|
||||
$scope.selection = [];
|
||||
$scope.folders = [];
|
||||
$scope.folders = [];
|
||||
//tracks if we've already loaded the folders for the current node
|
||||
var foldersLoaded = false;
|
||||
$scope.listViewResultSet = {
|
||||
totalPages: 0,
|
||||
items: []
|
||||
@@ -268,12 +270,13 @@ function listViewController($rootScope, $scope, $routeParams, $injector, $cookie
|
||||
});
|
||||
}
|
||||
|
||||
if ($scope.entityType === 'media') {
|
||||
|
||||
if (!foldersLoaded && $scope.entityType === 'media') {
|
||||
//The folders aren't loaded - we only need to do this once since we're never changing node ids
|
||||
mediaResource.getChildFolders($scope.contentId)
|
||||
.then(function (folders) {
|
||||
$scope.folders = folders;
|
||||
$scope.viewLoaded = true;
|
||||
foldersLoaded = true;
|
||||
});
|
||||
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user