More work on progress bars

This commit is contained in:
Rick Falkvinge
2018-02-11 20:52:43 +01:00
parent 9ea850b793
commit 76ba50fa3f
9 changed files with 33 additions and 21 deletions
+1
View File
@@ -17,6 +17,7 @@ using Swarmops.Logic.Communications.Resolution;
using Swarmops.Logic.Financial;
using Swarmops.Logic.Structure;
using Swarmops.Logic.Support;
using Swarmops.Logic.Support.SocketMessages;
using Swarmops.Utility;
using Swarmops.Utility.BotCode;
using Swarmops.Utility.Communications;
@@ -7,6 +7,7 @@ using Newtonsoft.Json.Linq;
using Swarmops.Logic;
using Swarmops.Logic.Security;
using Swarmops.Logic.Support;
using Swarmops.Logic.Support.SocketMessages;
using Swarmops.Utility.BotCode;
using WebSocketSharp;
using WebSocketSharp.Server;
+1
View File
@@ -18,6 +18,7 @@ using Swarmops.Logic.Security;
using Swarmops.Logic.Structure;
using Swarmops.Logic.Support;
using Swarmops.Logic.Financial;
using Swarmops.Logic.Support.SocketMessages;
using WebSocketSharp;
using WebSocketSharp.Server;
using ErrorEventArgs = WebSocketSharp.ErrorEventArgs;
+8 -7
View File
@@ -15,6 +15,7 @@ using Swarmops.Logic.Security;
using Swarmops.Logic.Structure;
using Swarmops.Logic.Support;
using Swarmops.Logic.Support.BackendServices;
using Swarmops.Logic.Support.SocketMessages;
using Swarmops.Logic.Swarm;
using WebSocketSharp;
using WebSocketSharp.Server;
@@ -51,10 +52,6 @@ namespace Swarmops.Frontend.Socket
case "Metapackage":
ProcessMetapackage((string) json["XmlData"]);
break;
case "BroadcastProgress":
Sessions.Broadcast("{\"messageType\":\"ProgressUpdate\",\"Guid\":\"" + json["Guid"] +
"\",\"Progress\":\"" + json["Progress"] + "\"}");
break;
case "Ping":
// TODO: Request heartbeat from backend
// Sessions.Broadcast("{\"messageType\":\"Heartbeat\"}");
@@ -110,13 +107,17 @@ namespace Swarmops.Frontend.Socket
switch (message.MessageType)
{
case "...":
// some future to-be-defined processing
case "BroadcastProgress":
JObject progressBroadcast = new JObject();
progressBroadcast["messageType"] = "ProgressUpdate";
progressBroadcast["Guid"] = message.Guid.Replace("-", "_"); // enables JS tokens from Guid
progressBroadcast["Progress"] = message.Progress;
Sessions.Broadcast(progressBroadcast.ToString());
break;
default:
// we're not handling here, send to backend
Console.WriteLine(" - sending " + message.MessageType + " upstream");
FrontendLoop.SendMessageUpstream(message);
break;
}
+1
View File
@@ -6,6 +6,7 @@ using Swarmops.Common.Interfaces;
using Swarmops.Database;
using Swarmops.Logic.Structure;
using Swarmops.Logic.Support;
using Swarmops.Logic.Support.SocketMessages;
using Swarmops.Logic.Swarm;
namespace Swarmops.Logic.Financial
+1 -1
View File
@@ -223,7 +223,7 @@
<Compile Include="Communications\Payload\PayloadEnvelope.cs" />
<Compile Include="Communications\Payload\NotificationPayload.cs" />
<Compile Include="Security\Impersonation.cs" />
<Compile Include="SocketMessage.cs" />
<Compile Include="Support\SocketMessages\SocketMessageBase.cs" />
<Compile Include="Support\BackendServiceOrder.cs" />
<Compile Include="Support\BackendServiceOrders.cs" />
<Compile Include="Support\BackendServices\BackendServiceOrderBase.cs" />
+8 -1
View File
@@ -5,6 +5,7 @@ using System.Text;
using System.Threading.Tasks;
using NUnit.Framework.Constraints;
using Swarmops.Logic.Cache;
using Swarmops.Logic.Support.SocketMessages;
namespace Swarmops.Logic.Support
{
@@ -18,7 +19,13 @@ namespace Swarmops.Logic.Support
public void Set (int progress)
{
GuidCache.Set(this.Guid + "-Progress", progress);
SocketMessage message = new SocketMessage
{
MessageType = "BroadcastProgress",
Guid = this.Guid,
Progress = progress
};
message.SendUpstream();
}
public string Guid { get; private set; }
@@ -1,17 +1,12 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Swarmops.Logic.Support;
using System.Xml.Serialization;
using Newtonsoft.Json.Linq;
using Swarmops.Logic.Security;
using WebSocketSharp;
namespace Swarmops.Logic
namespace Swarmops.Logic.Support.SocketMessages
{
[Serializable]
public class SocketMessage : SocketMessageBase<SocketMessage>
@@ -94,6 +89,8 @@ namespace Swarmops.Logic
public int FinancialAccountId { get; set; }
public int GeographyId { get; set; }
public int PersonId { get; set; }
public string Guid { get; set; }
public int Progress { get; set; }
public string XmlData { get; set; }
}
+9 -6
View File
@@ -35,10 +35,14 @@
if (newProgress > <%=this.ClientID%>_lastProgress) {
$("#Div_<%=this.ClientID %>_ProgressBar .progressbar-value").animate(
if (newProgress < 100) {
// The 100% complete case is dealt with later
$("#Div_<%=this.ClientID %>_ProgressBar .progressbar-value").animate(
{
width: newProgress + "%"
}, { queue: false });
}
if (<%=this.ClientID%>_lastProgress < 50 && newProgress >= 50) {
// check for halfway callback
@@ -52,11 +56,10 @@
if (<%=this.ClientID%>_lastProgress < 100 && newProgress >= 100) {
$("#Div_<%=this.ClientID %>_ProgressBar .progressbar-value").animate(
{
width: "100%"
}, { queue: false });
$("#Div_<%=this.ClientID %>_ProgressBar .progressbar-value").animate(
{
width: "100%"
}, { queue: false });
// check for completion callback