From bf954cf3b0ec04827a6772b7111eec2b437e72c3 Mon Sep 17 00:00:00 2001 From: Falkvinge Date: Tue, 9 May 2017 22:18:10 +0200 Subject: [PATCH] More code for live profit --- FrontSocket/FrontendLoop.cs | 6 +++--- FrontSocket/FrontendServices.cs | 6 +++--- Site/Scripts/Swarmops-v5.js | 6 ++++++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/FrontSocket/FrontendLoop.cs b/FrontSocket/FrontendLoop.cs index 9498ce93..cb3c20a2 100644 --- a/FrontSocket/FrontendLoop.cs +++ b/FrontSocket/FrontendLoop.cs @@ -308,9 +308,9 @@ namespace Swarmops.Frontend.Socket Int64 annualProfitLossCents = GetOrganizationProfitLossCents(organization); JObject json = new JObject(); - json["messageType"] = "AnnualProfitLossCents"; - json["profitLossCents"] = annualProfitLossCents.ToString(); - json["organizationId"] = organization.Identity; + json["MessageType"] = "AnnualProfitLossCents"; + json["ProfitLossCents"] = annualProfitLossCents.ToString(); + json["OrganizationId"] = organization.Identity; BroadcastToOrganization(organization, json); } diff --git a/FrontSocket/FrontendServices.cs b/FrontSocket/FrontendServices.cs index be2fb229..c7d8047a 100644 --- a/FrontSocket/FrontendServices.cs +++ b/FrontSocket/FrontendServices.cs @@ -67,9 +67,9 @@ namespace Swarmops.Frontend.Socket base.OnOpen(); JObject json = new JObject(); - json ["messageType"] = json["messageType"] = "AnnualProfitLossCents"; - json["profitLossCents"] = FrontendLoop.GetOrganizationProfitLossCents(this._authority.Organization).ToString(); - json["organizationId"] = this._authority.Organization.Identity; + json ["MessageType"] = json["messageType"] = "AnnualProfitLossCents"; + json["ProfitLossCents"] = FrontendLoop.GetOrganizationProfitLossCents(this._authority.Organization).ToString(); + json["OrganizationId"] = this._authority.Organization.Identity; this.Send(json.ToString()); } diff --git a/Site/Scripts/Swarmops-v5.js b/Site/Scripts/Swarmops-v5.js index 6a422647..5554b552 100644 --- a/Site/Scripts/Swarmops-v5.js +++ b/Site/Scripts/Swarmops-v5.js @@ -105,6 +105,12 @@ function _masterInitializeSocket(authenticationTicket) { else if (message.MessageType == "Malfunctions") { _master_updateMalfunctions (message.MalfunctionsList); } + else if (message.MessageType == "AnnualProfitLossCents") { + if (odoProfitLossToDate != undefined) // if there's a P&L odometer on the current page + { + odoProfitLossToDate.innerHTML = (message.ProfitLossCents / 100.0) + 0.001; // update it; +0.001 needed for %.2f + } + } else if (message.MessageType == "SandboxUpdate") { if (odoLocalParticipation != undefined) { // Real ugly accessing specific page elements here, but it's temporary odoLocalParticipation.innerHTML = message.Local;