diff --git a/src/Umbraco.Web.UI.Client/lib/jquery/jquery.upload/js/jquery.fileupload-angular.js b/src/Umbraco.Web.UI.Client/lib/jquery/jquery.upload/js/jquery.fileupload-angular.js index 7372d74a7c..8ddfc47c72 100755 --- a/src/Umbraco.Web.UI.Client/lib/jquery/jquery.upload/js/jquery.fileupload-angular.js +++ b/src/Umbraco.Web.UI.Client/lib/jquery/jquery.upload/js/jquery.fileupload-angular.js @@ -324,7 +324,7 @@ } ]) - // Provide File Upload progress feedback: + /* Provide File Upload progress feedback: .controller('FileUploadProgressController', [ '$scope', '$attrs', '$parse', function ($scope, $attrs, $parse) { @@ -360,14 +360,14 @@ $element.append(file.preview); } } - ]) + ])*/ .directive('fileUpload', function () { return { controller: 'FileUploadController' }; }) - +/* .directive('fileUploadProgress', function () { return { controller: 'FileUploadProgressController' @@ -378,7 +378,7 @@ return { controller: 'FileUploadPreviewController' }; - }) + })*/ // Enhance the HTML5 download attribute to // allow drag&drop of files to the desktop: diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/autoscale.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/autoscale.directive.js index e6d581c115..daa432d5ba 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/autoscale.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/autoscale.directive.js @@ -28,7 +28,7 @@ angular.module("umbraco.directives") setTimeout(function () { el.height(window.height() - (el.offset().top + totalOffset)); - }, 300); + }, 500); window.bind("resize", function () { el.height(window.height() - (el.offset().top + totalOffset)); diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/entity.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/entity.resource.js index 7ea411df02..dca97d35ac 100644 --- a/src/Umbraco.Web.UI.Client/src/common/resources/entity.resource.js +++ b/src/Umbraco.Web.UI.Client/src/common/resources/entity.resource.js @@ -11,6 +11,21 @@ * the entity only contains the basic node data, name, id and guid, whereas content * nodes fetched through the entity service also contains additional meta data such * as icon, document type, path and so on. + * + * ##Entity object types? + * As an optional parameter, you can pass in the specific type name. So if you know you + * are looking for a specific type, you should pass in the object name, to make lookup faster + * and to return more data. + * + * The core object types are: + * + * - Document + * - Media + * - Member + * - Template + * - DocumentType + * - MediaType + * - MemberType **/ function entityResource($q, $http, umbRequestHelper) { @@ -32,19 +47,27 @@ function entityResource($q, $http, umbRequestHelper) { * var myDoc = ent; * alert('its here!'); * }); + * + * //Only return users + * entityResource.getEntityById(0, "User") + * .then(function(ent) { + * var myDoc = ent; + * alert('its here!'); + * }); * * - * @param {Int} id id of entity to return + * @param {Int} id id of entity to return + * @param {string} type optional Object type name * @returns {Promise} resourcePromise object containing the entity. * */ - getEntityById: function (id) { + getById: function (id, type) { return umbRequestHelper.resourcePromise( $http.get( umbRequestHelper.getApiUrl( "entityApiBaseUrl", - "GetEntityById", - [{ id: id }])), + "GetById", + [{ id: id, type: type }])), 'Failed to retreive entity data for id ' + id); }, @@ -63,13 +86,21 @@ function entityResource($q, $http, umbRequestHelper) { * var myDoc = contentArray; * alert('they are here!'); * }); + * + * //Only return templates + * entityResource.getEntitiesByIds( [1234,2526,28262], "Template") + * .then(function(templateArray) { + * var myDoc = contentArray; + * alert('they are here!'); + * }); * * - * @param {Array} ids ids of entities to return as an array + * @param {Array} ids ids of entities to return as an array + * @param {string} type optional type name * @returns {Promise} resourcePromise object containing the entity array. * */ - getEntitiesByIds: function (ids) { + getByIds: function (ids) { var idQuery = ""; _.each(ids, function(item) { @@ -80,11 +111,90 @@ function entityResource($q, $http, umbRequestHelper) { $http.get( umbRequestHelper.getApiUrl( "entityApiBaseUrl", - "GetEntitiesByIds", + "GetByIds", idQuery)), 'Failed to retreive entity data for ids ' + idQuery); }, + /** + * @ngdoc method + * @name umbraco.resources.entityResource#getEntityById + * @methodOf umbraco.resources.entityResource + * + * @description + * Gets an entity with a given id + * + * ##usage + *
+         * //returns all entities, you should NEVER do that
+         * entityResource.getAll()
+         *    .then(function(ent) {
+         *        var myDoc = ent; 
+         *        alert('its here!');
+         *    });
+         *
+         * //Only return users
+         * entityResource.getAll("User")
+         *    .then(function(ent) {
+         *        var myDoc = ent; 
+         *        alert('its here!');
+         *    });
+         * 
+ * + * @param {string} type Object type name + * @returns {Promise} resourcePromise object containing the entity. + * + */ + getAll: function (type) { + return umbRequestHelper.resourcePromise( + $http.get( + umbRequestHelper.getApiUrl( + "entityApiBaseUrl", + "GetAll", + [{type: type }])), + 'Failed to retreive entity data for id ' + id); + }, + + /** + * @ngdoc method + * @name umbraco.resources.entityResource#getEntityById + * @methodOf umbraco.resources.entityResource + * + * @description + * Gets an entity with a given id + * + * ##usage + *
+         * //returns all entities, you should NEVER do that
+         * entityResource.getAll()
+         *    .then(function(ent) {
+         *        var myDoc = ent; 
+         *        alert('its here!');
+         *    });
+         *
+         * //Only return users
+         * entityResource.getAll("User")
+         *    .then(function(ent) {
+         *        var myDoc = ent; 
+         *        alert('its here!');
+         *    });
+         * 
+ * + * @param {string} type Object type name + * @returns {Promise} resourcePromise object containing the entity. + * + */ + getAncestors: function (id) { + return umbRequestHelper.resourcePromise( + $http.get( + umbRequestHelper.getApiUrl( + "entityApiBaseUrl", + "GetAncestors", + [{id: id}])), + 'Failed to retreive entity data for id ' + id); + }, + + /** * @ngdoc method * @name umbraco.resources.entityResource#getDocumentById diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/media.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/media.resource.js index 3df61e4d5a..87e90fbe40 100644 --- a/src/Umbraco.Web.UI.Client/src/common/resources/media.resource.js +++ b/src/Umbraco.Web.UI.Client/src/common/resources/media.resource.js @@ -108,6 +108,18 @@ function mediaResource($q, $http, umbDataFormatter, umbRequestHelper) { /** saves or updates a media object */ save: function (media, isNew, files) { return saveMediaItem(media, "save" + (isNew ? "New" : ""), files); + }, + + //** shorthand for creating a new folder under a given parent **/ + addFolder: function(name, parentId){ + return umbRequestHelper.resourcePromise( + $http.post(umbRequestHelper + .getApiUrl("mediaApiBaseUrl", "PostAddFolder"), + { + name: name, + parentId: parentId + }), + 'Failed to add folder'); } }; } diff --git a/src/Umbraco.Web.UI.Client/src/common/services/dialog.service.js b/src/Umbraco.Web.UI.Client/src/common/services/dialog.service.js index b979b36632..d7d5a34734 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/dialog.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/dialog.service.js @@ -173,8 +173,11 @@ angular.module('umbraco.services') }; scope.select = function(item) { - if (scope.dialogData.selection.indexOf(item) < 0) { + var i = scope.dialogData.selection.indexOf(item); + if (i < 0) { scope.dialogData.selection.push(item); + }else{ + scope.dialogData.selection.splice(i, 1); } }; diff --git a/src/Umbraco.Web.UI.Client/src/less/forms.less b/src/Umbraco.Web.UI.Client/src/less/forms.less index 110502b558..9fa781c401 100644 --- a/src/Umbraco.Web.UI.Client/src/less/forms.less +++ b/src/Umbraco.Web.UI.Client/src/less/forms.less @@ -15,6 +15,13 @@ .hover-show{visibility: hidden;} *:hover > .hover-show{visibility: visible;} +//breadcrumb modifications + +.breadcrumb{height: 30px; display: block; margin-top: 10px;} +.breadcrumb li{height: 30px; vertical-align: middle;} +.breadcrumb li a{vertical-align: middle; height: 30px;} +.breadcrumb input{font-size: 11px !Important;} + /* SEACH FORM */ diff --git a/src/Umbraco.Web.UI.Client/src/less/tree.less b/src/Umbraco.Web.UI.Client/src/less/tree.less index 7fae143b47..a61078b711 100644 --- a/src/Umbraco.Web.UI.Client/src/less/tree.less +++ b/src/Umbraco.Web.UI.Client/src/less/tree.less @@ -313,7 +313,7 @@ height:1px; overflow:hidden; } -.umb-tree li div.l div{ +.umb-tree li div.l div, div.umb-loader{ background-color: @blue; margin-top:0; margin-left:-100%; diff --git a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/mediapicker.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/mediapicker.controller.js index 7229c34cfe..3ffdad1546 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/mediapicker.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/mediapicker.controller.js @@ -1,16 +1,41 @@ //used for the media picker dialog angular.module("umbraco") .controller("Umbraco.Dialogs.MediaPickerController", - function ($scope, mediaResource, $log, imageHelper) { + function ($scope, mediaResource, umbRequestHelper, entityResource, $log, imageHelper) { $scope.options = { - url: "/umbraco/UmbracoApi/MediaUpload/Post", + url: umbRequestHelper.getApiUrl("mediaApiBaseUrl", "PostAddFile"), + autoUpload: true, formData:{ currentFolder: -1 } }; + $scope.submitFolder = function(e){ + if(e.keyCode === 13){ + $scope.showFolderInput = false; + + mediaResource + .addFolder($scope.newFolderName, $scope.options.formData.currentFolder) + .then(function(data){ + + $scope.gotoFolder(data.id); + }); + } + }; + $scope.gotoFolder = function(folderId){ + + if(folderId > 0){ + entityResource.getAncestors(folderId) + .then(function(anc){ + anc.splice(0,1); + $scope.path = anc; + }); + }else{ + $scope.path = []; + } + //mediaResource.rootMedia() mediaResource.getChildren(folderId) .then(function(data) { @@ -20,33 +45,25 @@ angular.module("umbraco") img.thumbnail = imageHelper.getThumbnail({ imageModel: img, scope: $scope }); }); }); - } - - $scope.$on('fileuploadadd', function(event, files){ - $scope.submitFiles(); - }); + $scope.options.formData.currentFolder = folderId; + }; + $scope.$on('fileuploadstop', function(event, files){ - alert("done"); + $scope.gotoFolder($scope.options.formData.currentFolder); }); $scope.selectMediaItem = function(image) { - if (image.contentTypeAlias.toLowerCase() == 'folder') { - options.formData.currentFolder = image.id; - mediaResource.getChildren(image.id) - .then(function(data) { - $scope.images = data; - //update the thumbnail property - _.each($scope.images, function (img) { - img.thumbnail = imageHelper.getThumbnail({ imageModel: img, scope: $scope }); - }); - }); + if (image.contentTypeAlias.toLowerCase() == 'folder') { + $scope.options.formData.currentFolder = image.id; + $scope.gotoFolder(image.id); } else if (image.contentTypeAlias.toLowerCase() == 'image') { $scope.select(image); } }; + $scope.gotoFolder(-1); }); \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/mediapicker.html b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/mediapicker.html index ff8fb83842..75b588aff3 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/mediapicker.html +++ b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/mediapicker.html @@ -1,5 +1,5 @@
+data-file-upload="options" data-file-upload-progress="" data-ng-class="{'fileupload-processing': processing() || loadingFiles}">
@@ -17,9 +17,6 @@ data-file-upload="options" data-ng-class="{'fileupload-processing': processing()
- - {{progress | json}} - @@ -29,65 +26,56 @@ data-file-upload="options" data-ng-class="{'fileupload-processing': processing()
-
-
-
+ +
+
+ + +
+ +
+ +
diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/mediapicker/mediapicker.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/mediapicker/mediapicker.controller.js index be27f0bafa..92a152ac08 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/mediapicker/mediapicker.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/mediapicker/mediapicker.controller.js @@ -3,7 +3,7 @@ angular.module('umbraco').controller("Umbraco.Editors.MediaPickerController", function($rootScope, $scope, dialogService, $log){ // - $( "#draggable" ).draggable(); + //$( "#draggable" ).draggable(); $scope.openMediaPicker =function(value){ var d = dialogService.mediaPicker({scope: $scope, callback: populate}); diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/mediapicker/mediapicker.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/mediapicker/mediapicker.html index 4e729987b9..c06e78ec60 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/mediapicker/mediapicker.html +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/mediapicker/mediapicker.html @@ -1,62 +1,32 @@
-
-
- - - + +
+
+ + + +
+ +
+ + + +
-
- - - -
-
- +
\ No newline at end of file diff --git a/src/Umbraco.Web.UI/mediabighead.jpg b/src/Umbraco.Web.UI/mediabighead.jpg new file mode 100644 index 0000000000..2373785c97 Binary files /dev/null and b/src/Umbraco.Web.UI/mediabighead.jpg differ diff --git a/src/Umbraco.Web.UI/mediaexploding head.gif b/src/Umbraco.Web.UI/mediaexploding head.gif new file mode 100644 index 0000000000..512524e37e Binary files /dev/null and b/src/Umbraco.Web.UI/mediaexploding head.gif differ diff --git a/src/Umbraco.Web.UI/umbraco/Views/common/dialogs/mediapicker.html b/src/Umbraco.Web.UI/umbraco/Views/common/dialogs/mediapicker.html index ff8fb83842..75b588aff3 100644 --- a/src/Umbraco.Web.UI/umbraco/Views/common/dialogs/mediapicker.html +++ b/src/Umbraco.Web.UI/umbraco/Views/common/dialogs/mediapicker.html @@ -1,5 +1,5 @@ +data-file-upload="options" data-file-upload-progress="" data-ng-class="{'fileupload-processing': processing() || loadingFiles}">
@@ -17,9 +17,6 @@ data-file-upload="options" data-ng-class="{'fileupload-processing': processing()
- - {{progress | json}} - @@ -29,65 +26,56 @@ data-file-upload="options" data-ng-class="{'fileupload-processing': processing()
-
-
-
+ +
+
+ + +
+ +
+ +
diff --git a/src/Umbraco.Web/Editors/MediaController.cs b/src/Umbraco.Web/Editors/MediaController.cs index 28aacd463b..0fe23d641f 100644 --- a/src/Umbraco.Web/Editors/MediaController.cs +++ b/src/Umbraco.Web/Editors/MediaController.cs @@ -207,6 +207,37 @@ namespace Umbraco.Web.Editors } } + //shorthand to use with the media dialog + public MediaItemDisplay PostAddFolder(MediaFolderSave folder) + { + var mediaService = base.ApplicationContext.Services.MediaService; + var f = mediaService.CreateMedia(folder.Name, folder.ParentId, "Folder"); + mediaService.Save(f); + + return Mapper.Map(f); + } + + //short hand to use with the uploader in the media dialog + public HttpResponseMessage PostAddFile() + { + var context = UmbracoContext.HttpContext; + if(context.Request.Files.Count > 0){ + var parentId = int.Parse(context.Request.Form[0]); + var file = context.Request.Files[0]; + var name = file.FileName; + + var mediaService = base.ApplicationContext.Services.MediaService; + var f = mediaService.CreateMedia(name, parentId, "Image"); + f.SetValue("umbracoFile", file); + mediaService.Save(f); + + return new HttpResponseMessage( HttpStatusCode.OK); + } + + return new HttpResponseMessage(HttpStatusCode.InternalServerError); + } + + /// /// Performs a permissions check for the user to check if it has access to the node based on /// start node and/or permissions for the node diff --git a/src/Umbraco.Web/Editors/MediaUploadController.cs b/src/Umbraco.Web/Editors/MediaUploadController.cs index a49a8e396b..46cc2d2699 100644 --- a/src/Umbraco.Web/Editors/MediaUploadController.cs +++ b/src/Umbraco.Web/Editors/MediaUploadController.cs @@ -149,6 +149,9 @@ namespace Umbraco.Web.Editors // Upload entire file private void UploadWholeFile(HttpContext context, List statuses) { + var folderId = context.Request.Form["currentFolder"]; + + for (int i = 0; i < context.Request.Files.Count; i++) { var file = context.Request.Files[i]; diff --git a/src/Umbraco.Web/Models/ContentEditing/MediaFolderSave.cs b/src/Umbraco.Web/Models/ContentEditing/MediaFolderSave.cs new file mode 100644 index 0000000000..9b8c18e83a --- /dev/null +++ b/src/Umbraco.Web/Models/ContentEditing/MediaFolderSave.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; + +namespace Umbraco.Web.Models.ContentEditing +{ + [DataContract(Name = "media", Namespace = "")] + public class MediaFolderSave + { + [DataMember(Name = "name", IsRequired = true)] + [Required] + public string Name { get; set; } + + [DataMember(Name = "parentId", IsRequired = true)] + [Required] + public int ParentId { get; set; } + } +} diff --git a/src/Umbraco.Web/PropertyEditors/MediaPicker.cs b/src/Umbraco.Web/PropertyEditors/MediaPicker.cs new file mode 100644 index 0000000000..fca582eb1f --- /dev/null +++ b/src/Umbraco.Web/PropertyEditors/MediaPicker.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Umbraco.Core; +using Umbraco.Core.PropertyEditors; + + +namespace Umbraco.Web.PropertyEditors +{ + [PropertyEditor(Constants.PropertyEditors.MediaPicker, "Media Picker", "mediapicker")] + public class MediaPickerPropertyEditor : PropertyEditor + { + } +} diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index e4847bf658..427ba38685 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -307,6 +307,7 @@ + @@ -322,6 +323,7 @@ +