Gets the messages being pumped out to the UI. Updates the ContentService and MediaServices to have a SaveWithStatus in order to determine the response, we'll need to update most of the methods to also have this OperationStatus. Now messages can be added to the UI for Saving & publishing for media and content services, we'll need to update more to support everything.

This commit is contained in:
Shannon
2015-07-24 11:44:09 +02:00
parent a6a2b02cd8
commit aa08a4ca37
25 changed files with 475 additions and 120 deletions

View File

@@ -0,0 +1,66 @@
using System;
using System.Net.Http;
using System.Web.Http.Filters;
using Umbraco.Core.Events;
using Umbraco.Web.Models.ContentEditing;
using Umbraco.Web.UI;
namespace Umbraco.Web.WebApi.Filters
{
/// <summary>
/// Automatically checks if any request is a non-GET and if the
/// resulting message is INotificationModel in which case it will append any Event Messages
/// currently in the request.
/// </summary>
internal sealed class AppendCurrentEventMessagesAttribute : ActionFilterAttribute
{
public override void OnActionExecuted(HttpActionExecutedContext context)
{
if (context.Response == null) return;
if (context.Response.IsSuccessStatusCode == false) return;
if (context.Request.Method == HttpMethod.Get) return;
if (UmbracoContext.Current == null) return;
var obj = context.Response.Content as ObjectContent;
if (obj == null) return;
var notifications = obj.Value as INotificationModel;
if (notifications == null) return;
var msgs = UmbracoContext.Current.GetCurrentEventMessages();
if (msgs == null) return;
foreach (var eventMessage in msgs.GetAll())
{
SpeechBubbleIcon msgType;
switch (eventMessage.MessageType)
{
case EventMessageType.Default:
msgType = SpeechBubbleIcon.Save;
break;
case EventMessageType.Info:
msgType = SpeechBubbleIcon.Info;
break;
case EventMessageType.Error:
msgType = SpeechBubbleIcon.Error;
break;
case EventMessageType.Success:
msgType = SpeechBubbleIcon.Success;
break;
case EventMessageType.Warning:
msgType = SpeechBubbleIcon.Warning;
break;
default:
throw new ArgumentOutOfRangeException();
}
notifications.Notifications.Add(new Notification
{
Message = eventMessage.Message,
Header = eventMessage.Category,
NotificationType = msgType
});
}
}
}
}

View File

@@ -2,7 +2,6 @@
using System.Linq;
using System.Net.Http.Formatting;
using System.Web.Http.Controllers;
using System.Web.Http.Filters;
using Umbraco.Core;
namespace Umbraco.Web.WebApi.Filters
@@ -10,7 +9,7 @@ namespace Umbraco.Web.WebApi.Filters
/// <summary>
/// Sets the json outgoing/serialized datetime format
/// </summary>
internal sealed class OutgoingDateTimeFormatAttribute : Attribute, IControllerConfiguration
internal sealed class OutgoingDateTimeFormatAttribute : Attribute, IControllerConfiguration
{
private readonly string _format = "yyyy-MM-dd HH:mm:ss";
@@ -27,8 +26,9 @@ namespace Umbraco.Web.WebApi.Filters
/// <summary>
/// Will use the standard ISO format
/// </summary>
public OutgoingDateTimeFormatAttribute(){
public OutgoingDateTimeFormatAttribute()
{
}
public void Initialize(HttpControllerSettings controllerSettings, HttpControllerDescriptor controllerDescriptor)