Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Core/Resgrid.Config/TelemetryConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,32 @@ public static class TelemetryConfig
{
public static string Exporter = "";

public static TelemetryExporters ExporterType = TelemetryExporters.None;
public static string PostHogUrl = "";
public static string PostHogApiKey = "";

public static string AptabaseUrl = "";
public static string AptabaseWebApiKey = "";
public static string AptabaseServicesApiKey = "";
public static string AptabaseResponderApiKey = "";
public static string AptabaseUnitApiKey = "";
public static string AptabaseBigBoardApiKey = "";
public static string AptabaseDispatchApiKey = "";

public static string GetAnalyticsKey()
{
if (ExporterType == TelemetryExporters.PostHog)
return PostHogApiKey;
else if (ExporterType == TelemetryExporters.Aptabase)
return AptabaseWebApiKey;
return string.Empty;
}
}

public enum TelemetryExporters
{
None = 0,
PostHog = 1,
Aptabase = 2
}
}
40 changes: 29 additions & 11 deletions Core/Resgrid.Localization/Areas/User/Department/Department.en.resx
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,33 @@
<data name="UnitTTLHelp" xml:space="preserve">
<value>In Minutes, how long locations are valid for to be shown in the map. I.e. a value of 60 would mean a marker for a unit would show on the maps for up to 60 minutes, afterwards would not be shown. Setting 0 disables TTL and a location, no matter how old, will be shown on the map.</value>
</data>
<data name="GroupDispatchSettingsHeader" xml:space="preserve">
<value>Group Dispatch Settings</value>
</data>
<data name="UnitDispatchSettingsHeader" xml:space="preserve">
<value>Unit Dispatch Settings</value>
</data>
<data name="UnitDispatchAlsoDispatchToAssignedPersonnelLabel" xml:space="preserve">
<value>Also Dispatch To Assigned Personnel</value>
</data>
<data name="UnitDispatchAlsoDispatchToGroupLabel" xml:space="preserve">
<value>Also Dispatch To Entire Group</value>
</data>
<data name="ShiftSettingsHeader" xml:space="preserve">
<value>Shift Settings</value>
</data>
<data name="SaveShiftSettingsText" xml:space="preserve">
<value>Successfully saved Shift Settings.</value>
</data>
<data name="ShiftSignupSettingsHeader" xml:space="preserve">
<value>Shift Signup Settings</value>
</data>
<data name="ShiftSignupsMultipleGroupsHeader" xml:space="preserve">
<value>Allow Signups For Multiple Groups</value>
</data>
<data name="PersonnelOnUnitSetUnitStatusLabel" xml:space="preserve">
<value>Personnel on Unit Set Unit Status</value>
</data>
<data name="AccountOwner" xml:space="preserve">
<value>Account Owner</value>
</data>
Expand Down Expand Up @@ -477,16 +504,7 @@
<data name="SavedModuleSettings" xml:space="preserve">
<value>Department Module Settings Have Been Saved</value>
</data>
<data name="GroupDispatchSettingsHeader" xml:space="preserve">
<value>Group Dispatch Settings</value>
</data>
<data name="UnitDispatchSettingsHeader" xml:space="preserve">
<value>Unit Dispatch Settings</value>
</data>
<data name="UnitDispatchAlsoDispatchToAssignedPersonnelLabel" xml:space="preserve">
<value>Also Dispatch To Assigned Personnel</value>
</data>
<data name="UnitDispatchAlsoDispatchToGroupLabel" xml:space="preserve">
<value>Also Dispatch To Entire Group</value>
<data name="PersonnelOnUnitSetUnitStatusHelp" xml:space="preserve">
<value>When a unit submits a status and users are setup on roles, the users status will be set to On Unit.</value>
</data>
</root>
23 changes: 13 additions & 10 deletions Core/Resgrid.Localization/Areas/User/Department/Department.es.resx
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,18 @@
<data name="DeleteDepartmentSettingsInfo" xml:space="preserve">
<value />
</data>
<data name="GroupDispatchSettingsHeader" xml:space="preserve">
<value />
</data>
<data name="UnitDispatchSettingsHeader" xml:space="preserve">
<value />
</data>
<data name="UnitDispatchAlsoDispatchToAssignedPersonnelLabel" xml:space="preserve">
<value />
</data>
<data name="UnitDispatchAlsoDispatchToGroupLabel" xml:space="preserve">
<value />
</data>
Comment on lines +123 to +134
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Empty Spanish values will render blank UI; remove to enable fallback or populate with text

Including keys with <value /> in a localized .resx overrides fallback to the neutral/English resource. These four entries will show as empty strings in the Spanish UI. Either remove them (so ResourceManager falls back to English) or populate with text (Spanish or English placeholders).

Also, the PR summary claims these entries were later removed in this file, but they are still present here. Please reconcile to avoid drift.

Option A — remove to enable fallback:

-  <data name="GroupDispatchSettingsHeader" xml:space="preserve">
-    <value />
-  </data>
-  <data name="UnitDispatchSettingsHeader" xml:space="preserve">
-    <value />
-  </data>
-  <data name="UnitDispatchAlsoDispatchToAssignedPersonnelLabel" xml:space="preserve">
-    <value />
-  </data>
-  <data name="UnitDispatchAlsoDispatchToGroupLabel" xml:space="preserve">
-    <value />
-  </data>

Option B — populate with English placeholders to avoid blanks (until Spanish translations are ready):

   <data name="GroupDispatchSettingsHeader" xml:space="preserve">
-    <value />
+    <value>Group Dispatch Settings</value>
   </data>
   <data name="UnitDispatchSettingsHeader" xml:space="preserve">
-    <value />
+    <value>Unit Dispatch Settings</value>
   </data>
   <data name="UnitDispatchAlsoDispatchToAssignedPersonnelLabel" xml:space="preserve">
-    <value />
+    <value>Also dispatch to assigned personnel</value>
   </data>
   <data name="UnitDispatchAlsoDispatchToGroupLabel" xml:space="preserve">
-    <value />
+    <value>Also dispatch to group</value>
   </data>

🏁 Script executed:

#!/bin/bash
grep -n -E "GroupDispatchSettingsHeader|UnitDispatchSettingsHeader|UnitDispatchAlsoDispatchToAssignedPersonnelLabel|UnitDispatchAlsoDispatchToGroupLabel" Core/Resgrid.Localization/Areas/User/Department/Department.es.resx || echo "No matches found"

Length of output: 527


Empty Spanish entries in Department.es.resx will render blank UI—please remove or populate

The following keys in Core/Resgrid.Localization/Areas/User/Department/Department.es.resx still have empty <value/>, which overrides fallback to English and leads to blank labels in the Spanish UI. Additionally, the PR summary states these were removed, but they remain in this file. Please reconcile and then either:

• Remove them so ResourceManager falls back to English
• Populate them with placeholder text (Spanish or English) until translations are available

Affected locations:

  • Department.es.resx: lines 123, 126, 129, 132

Option A — remove entries to enable fallback:

-  <data name="GroupDispatchSettingsHeader" xml:space="preserve">
-    <value />
-  </data>
-  <data name="UnitDispatchSettingsHeader" xml:space="preserve">
-    <value />
-  </data>
-  <data name="UnitDispatchAlsoDispatchToAssignedPersonnelLabel" xml:space="preserve">
-    <value />
-  </data>
-  <data name="UnitDispatchAlsoDispatchToGroupLabel" xml:space="preserve">
-    <value />
-  </data>

Option B — add English placeholders until Spanish copy is ready:

   <data name="GroupDispatchSettingsHeader" xml:space="preserve">
-    <value />
+    <value>Group Dispatch Settings</value>
   </data>
   <data name="UnitDispatchSettingsHeader" xml:space="preserve">
-    <value />
+    <value>Unit Dispatch Settings</value>
   </data>
   <data name="UnitDispatchAlsoDispatchToAssignedPersonnelLabel" xml:space="preserve">
-    <value />
+    <value>Also dispatch to assigned personnel</value>
   </data>
   <data name="UnitDispatchAlsoDispatchToGroupLabel" xml:space="preserve">
-    <value />
+    <value>Also dispatch to group</value>
   </data>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<data name="GroupDispatchSettingsHeader" xml:space="preserve">
<value />
</data>
<data name="UnitDispatchSettingsHeader" xml:space="preserve">
<value />
</data>
<data name="UnitDispatchAlsoDispatchToAssignedPersonnelLabel" xml:space="preserve">
<value />
</data>
<data name="UnitDispatchAlsoDispatchToGroupLabel" xml:space="preserve">
<value />
</data>
<data name="GroupDispatchSettingsHeader" xml:space="preserve">
<value>Group Dispatch Settings</value>
</data>
<data name="UnitDispatchSettingsHeader" xml:space="preserve">
<value>Unit Dispatch Settings</value>
</data>
<data name="UnitDispatchAlsoDispatchToAssignedPersonnelLabel" xml:space="preserve">
<value>Also dispatch to assigned personnel</value>
</data>
<data name="UnitDispatchAlsoDispatchToGroupLabel" xml:space="preserve">
<value>Also dispatch to group</value>
</data>
🤖 Prompt for AI Agents
In Core/Resgrid.Localization/Areas/User/Department/Department.es.resx around
lines 123-134 the keys GroupDispatchSettingsHeader, UnitDispatchSettingsHeader,
UnitDispatchAlsoDispatchToAssignedPersonnelLabel and
UnitDispatchAlsoDispatchToGroupLabel have empty <value/> entries which override
fallback and produce blank UI; either remove these <data> entries so the
ResourceManager falls back to the default English resources, or populate each
<value> with a temporary placeholder (e.g., English text) until proper Spanish
translations are available, and then commit the file reflecting the chosen
option.

<data name="AccountOwner" xml:space="preserve">
<value>Propietario de la cuenta</value>
</data>
Expand Down Expand Up @@ -378,16 +390,7 @@
<data name="DeleteDepartmentSettingsHeader" xml:space="preserve">
<value />
</data>
<data name="GroupDispatchSettingsHeader" xml:space="preserve">
<value />
</data>
<data name="UnitDispatchSettingsHeader" xml:space="preserve">
<value />
</data>
<data name="UnitDispatchAlsoDispatchToAssignedPersonnelLabel" xml:space="preserve">
<value />
</data>
<data name="UnitDispatchAlsoDispatchToGroupLabel" xml:space="preserve">
<data name="PersonnelOnUnitSetUnitStatusHelp" xml:space="preserve">
<value />
</data>
Comment on lines +393 to 395
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add the missing label key for the new PersonnelOnUnitSetUnitStatus setting

UI relies on both the Label and Help resources; es.resx currently contains only the Help key. Add the Label key to keep parity and avoid fallback to the default language.

Apply this diff to add the missing label adjacent to the help entry:

   <data name="DeleteDepartmentSettingsHeader" xml:space="preserve">
     <value />
   </data>
+  <data name="PersonnelOnUnitSetUnitStatusLabel" xml:space="preserve">
+    <value />
+  </data>
   <data name="PersonnelOnUnitSetUnitStatusHelp" xml:space="preserve">
     <value />
   </data>

If you want, I can propose Spanish copy for both Label/Help once the final English strings are confirmed.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<data name="PersonnelOnUnitSetUnitStatusHelp" xml:space="preserve">
<value />
</data>
<data name="DeleteDepartmentSettingsHeader" xml:space="preserve">
<value />
</data>
<data name="PersonnelOnUnitSetUnitStatusLabel" xml:space="preserve">
<value />
</data>
<data name="PersonnelOnUnitSetUnitStatusHelp" xml:space="preserve">
<value />
</data>
🤖 Prompt for AI Agents
In Core/Resgrid.Localization/Areas/User/Department/Department.es.resx around
lines 393 to 395, the resource file contains only the Help entry for
PersonnelOnUnitSetUnitStatus; add a matching Label entry named
"PersonnelOnUnitSetUnitStatus" immediately adjacent to the existing Help <data>
block so the UI has both Label and Help keys (use an empty <value /> for now or
add the Spanish label text once confirmed).

Comment on lines +393 to 395
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

“PersonnelOnUnitSetUnitStatusHelp” is empty; will display as blank in Spanish

Same issue: an empty localized value prevents fallback to neutral/English. Either remove this entry to inherit the English string or populate it.

Option A — remove to enable fallback:

-  <data name="PersonnelOnUnitSetUnitStatusHelp" xml:space="preserve">
-    <value />
-  </data>

Option B — populate with the English help text (from en.resx) for now:

   <data name="PersonnelOnUnitSetUnitStatusHelp" xml:space="preserve">
-    <value />
+    <value>When a unit submits a status and users are setup on roles, the users status will be set to On Unit.</value>
   </data>

If you prefer, I can also add the Spanish translation in a follow-up, or add a <comment> marker to flag it for translators.


🏁 Script executed:

#!/bin/bash
# Search for the key across all .resx files to verify English fallback value
rg -n 'PersonnelOnUnitSetUnitStatusHelp' -n --glob '*.resx'

Length of output: 479


🏁 Script executed:

#!/bin/bash
# Extract the English help text for the key from Department.en.resx
rg -A2 -n 'PersonnelOnUnitSetUnitStatusHelp' --glob '*.resx' Core/Resgrid.Localization/Areas/User/Department/Department.en.resx

Length of output: 338


Empty Spanish localization entry prevents fallback
The <value /> in Department.es.resx will return an empty string instead of falling back to the default (English) text. Please either remove the Spanish entry or supply at least a placeholder so users don’t see a blank field.

• File: Core/Resgrid.Localization/Areas/User/Department/Department.es.resx (lines 393–395)
• Reference English text in Core/Resgrid.Localization/Areas/User/Department/Department.en.resx (line 508)

Option A — remove the empty entry to enable fallback:

-  <data name="PersonnelOnUnitSetUnitStatusHelp" xml:space="preserve">
-    <value />
-  </data>

Option B — add the English text as a temporary placeholder:

   <data name="PersonnelOnUnitSetUnitStatusHelp" xml:space="preserve">
-    <value />
+    <value>When a unit submits a status and users are setup on roles, the users status will be set to On Unit.</value>
   </data>

If you prefer, add a <comment> marker or follow up with the actual Spanish translation later.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<data name="PersonnelOnUnitSetUnitStatusHelp" xml:space="preserve">
<value />
</data>
Suggested change
<data name="PersonnelOnUnitSetUnitStatusHelp" xml:space="preserve">
<value />
</data>
<data name="PersonnelOnUnitSetUnitStatusHelp" xml:space="preserve">
<value>When a unit submits a status and users are setup on roles, the users status will be set to On Unit.</value>
</data>
🤖 Prompt for AI Agents
In Core/Resgrid.Localization/Areas/User/Department/Department.es.resx around
lines 393–395 the PersonnelOnUnitSetUnitStatusHelp entry has an empty <value/>,
which returns an empty string instead of falling back to English; fix by either
removing this Spanish <data> element so the resource system falls back to
Core/Resgrid.Localization/Areas/User/Department/Department.en.resx (see line 508
for the English text), or populate the <value> with a placeholder (e.g., the
English text or a <comment> marker) until a proper Spanish translation is
available.

</root>
18 changes: 18 additions & 0 deletions Core/Resgrid.Localization/Areas/User/Department/Department.resx
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,22 @@
<data name="UnitDispatchAlsoDispatchToGroupLabel" xml:space="preserve">
<value />
</data>
<data name="ShiftSettingsHeader" xml:space="preserve">
<value />
</data>
<data name="SaveShiftSettingsText" xml:space="preserve">
<value />
</data>
<data name="ShiftSignupSettingsHeader" xml:space="preserve">
<value />
</data>
<data name="ShiftSignupsMultipleGroupsHeader" xml:space="preserve">
<value />
</data>
<data name="PersonnelOnUnitSetUnitStatusLabel" xml:space="preserve">
<value />
</data>
<data name="PersonnelOnUnitSetUnitStatusHelp" xml:space="preserve">
<value />
</data>
</root>
15 changes: 15 additions & 0 deletions Core/Resgrid.Model/ActionLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ public class ActionLog : IEntity
[ProtoMember(9)]
public string Note { get; set; }

[ProtoMember(12)]
public int? UnitStateId { get; set; }

[ProtoMember(13)]
public string UnitName { get; set; }

[NotMapped]
[ProtoMember(10)]
public double Eta { get; set; }
Expand Down Expand Up @@ -103,6 +109,11 @@ public string GetActionText()
return "Responding to Station";
case ActionTypes.RespondingToScene:
return "Responding to Scene";
case ActionTypes.OnUnit:
if (!String.IsNullOrWhiteSpace(UnitName))
return $"On Unit ({UnitName})";
else
return "On Unit";
default:
throw new ArgumentOutOfRangeException();
}
Expand All @@ -126,6 +137,8 @@ public string GetActionCss()
return "label-success";
case ActionTypes.RespondingToScene:
return "label-success";
case ActionTypes.OnUnit:
return "label-success";
default:
throw new ArgumentOutOfRangeException();
}
Expand Down Expand Up @@ -177,6 +190,8 @@ public static int GetWeightForAction(this ActionLog actionLog)
return 1;
else if (actionLog.ActionTypeId == (int)ActionTypes.RespondingToScene)
return 1;
else if (actionLog.ActionTypeId == (int)ActionTypes.OnUnit)
return 2;
else if (actionLog.ActionTypeId == (int)ActionTypes.OnScene)
return 2;
else if (actionLog.ActionTypeId == (int)ActionTypes.NotResponding)
Expand Down
8 changes: 7 additions & 1 deletion Core/Resgrid.Model/ActionTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ public enum ActionTypes
/// User is Responding directly to a scene (For a Specific Call)
/// </summary>
[Display(Name = "Responding To Scene")]
RespondingToScene = 6
RespondingToScene = 6,

/// <summary>
/// User is on a Unit and has a state submitted recently
/// </summary>
[Display(Name = "On Unit")]
OnUnit = 7
}
}
1 change: 1 addition & 0 deletions Core/Resgrid.Model/DepartmentSettingTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ public enum DepartmentSettingTypes
ModuleSettings = 32,
UnitDispatchAlsoDispatchToAssignedPersonnel = 33,
UnitDispatchAlsoDispatchToGroup = 34,
PersonnelOnUnitSetUnitStatus = 35,
}
}
2 changes: 2 additions & 0 deletions Core/Resgrid.Model/Services/IActionLogsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,5 +225,7 @@ Task<ActionLog> SetUserActionAsync(string userId, int departmentId, int actionTy
Task<List<ActionLog>> GetActionLogsForCallAsync(int departmentId, int callId);

Task<List<ActionLog>> GetAllActionLogsInDateRangeAsync(int departmentId, DateTime startDate, DateTime endDate);

Task<ActionLog> CreateUnitLinkedStatus(string userId, int departmentId, int unitStateId, string unitName, CancellationToken cancellationToken = default(CancellationToken));
}
}
2 changes: 2 additions & 0 deletions Core/Resgrid.Model/Services/IDepartmentSettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ public interface IDepartmentSettingsService

Task<bool> GetUnitDispatchAlsoDispatchToGroupAsync(int departmentId);

Task<bool> GetPersonnelOnUnitSetUnitStatusAsync(int departmentId, bool bypassCache = false);

Task<DepartmentSetting> SetDepartmentModuleSettingsAsync(int departmentId, DepartmentModuleSettings settings, CancellationToken cancellationToken = default(CancellationToken));
}
}
26 changes: 20 additions & 6 deletions Core/Resgrid.Services/ActionLogsService.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Resgrid.Model.Providers;
using Amazon.SimpleEmail.Model;
using Resgrid.Model;
using Resgrid.Model.Events;
using Resgrid.Model.Providers;
using Resgrid.Model.Repositories;
using Resgrid.Model.Services;
using Resgrid.Providers.Bus;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

namespace Resgrid.Services
{
Expand Down Expand Up @@ -406,5 +407,18 @@ public async Task<List<ActionLog>> GetActionLogsForCallAsync(int departmentId, i
var items = await _actionLogsRepository.GetActionLogsForCallAndTypesAsync(callId, callEnabledStates);
return items.ToList();
}

public async Task<ActionLog> CreateUnitLinkedStatus(string userId, int departmentId, int unitStateId, string unitName, CancellationToken cancellationToken = default(CancellationToken))
{
var al = new ActionLog();
al.ActionTypeId = (int)ActionTypes.OnUnit;
al.DepartmentId = departmentId;
al.UserId = userId;
al.Timestamp = DateTime.UtcNow;
al.UnitStateId = unitStateId;
al.UnitName = unitName;

return await SaveActionLogAsync(al, cancellationToken);
}
}
}
3 changes: 2 additions & 1 deletion Core/Resgrid.Services/CustomStateService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ public List<CustomStateDetail> GetDefaultPersonStatuses()
details.Add(new CustomStateDetail() { CustomStateDetailId = (int)ActionTypes.AvailableStation, ButtonText = "Available Station", ButtonColor = "#d1dade", TextColor = "5E5E5E", NoteType = (int)CustomStateNoteTypes.Optional, DetailType = (int)CustomStateDetailTypes.Stations });
details.Add(new CustomStateDetail() { CustomStateDetailId = (int)ActionTypes.RespondingToStation, ButtonText = "Responding to Station", ButtonColor = "#449d44", TextColor = "#ffffff", NoteType = (int)CustomStateNoteTypes.Optional, DetailType = (int)CustomStateDetailTypes.Stations });
details.Add(new CustomStateDetail() { CustomStateDetailId = (int)ActionTypes.RespondingToScene, ButtonText = "Responding to Scene", ButtonColor = "#449d44", TextColor = "#ffffff", NoteType = (int)CustomStateNoteTypes.Optional, DetailType = (int)CustomStateDetailTypes.Calls });
details.Add(new CustomStateDetail() { CustomStateDetailId = (int)ActionTypes.OnUnit, ButtonText = "On Unit", ButtonColor = "#449d44", TextColor = "#ffffff", NoteType = (int)CustomStateNoteTypes.Optional, DetailType = (int)CustomStateDetailTypes.CallsAndStations });

return details;
}
Expand All @@ -360,7 +361,7 @@ public List<CustomStateDetail> GetDefaultPersonStaffings()
details.Add(new CustomStateDetail() { CustomStateDetailId = (int)UserStateTypes.Unavailable, ButtonText = "Unavailable", ButtonColor = "#ed5565", TextColor = "#ffffff", NoteType = (int)CustomStateNoteTypes.Optional });
details.Add(new CustomStateDetail() { CustomStateDetailId = (int)UserStateTypes.Committed, ButtonText = "Committed", ButtonColor = "#23c6c8", TextColor = "#ffffff", NoteType = (int)CustomStateNoteTypes.Optional });
details.Add(new CustomStateDetail() { CustomStateDetailId = (int)UserStateTypes.OnShift, ButtonText = "On Shift", ButtonColor = "#228bcb", TextColor = "#ffffff", NoteType = (int)CustomStateNoteTypes.Optional });


return details;
}
Expand Down
27 changes: 24 additions & 3 deletions Core/Resgrid.Services/DepartmentSettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class DepartmentSettingsService : IDepartmentSettingsService
private static string StripeCustomerCacheKey = "DSetStripeCus_{0}";
private static string BigBoardCenterGps = "DSetBBCenterGps_{0}";
private static string StaffingSupressInfo = "DSetStaffingSupress_{0}";
private static string PersonnelOnUnitSetUnitStatusCacheKey = "DSetPersonnelOnUnitSetUnitStatus_{0}";
private static TimeSpan LongCacheLength = TimeSpan.FromDays(14);
private static TimeSpan ThatsNotLongThisIsLongCacheLength = TimeSpan.FromDays(365);
private static TimeSpan TwoYearCacheLength = TimeSpan.FromDays(730);
Expand Down Expand Up @@ -54,13 +55,16 @@ public DepartmentSettingsService(IDepartmentSettingsRepository departmentSetting
switch (type)
{
case DepartmentSettingTypes.BigBoardMapCenterGpsCoordinates:
_cacheProvider.Remove(string.Format(BigBoardCenterGps, departmentId));
await _cacheProvider.RemoveAsync(string.Format(BigBoardCenterGps, departmentId));
break;
case DepartmentSettingTypes.DisabledAutoAvailable:
_cacheProvider.Remove(string.Format(DisableAutoAvailableCacheKey, departmentId));
await _cacheProvider.RemoveAsync(string.Format(DisableAutoAvailableCacheKey, departmentId));
break;
case DepartmentSettingTypes.StaffingSuppressStaffingLevels:
_cacheProvider.Remove(string.Format(StaffingSupressInfo, departmentId));
await _cacheProvider.RemoveAsync(string.Format(StaffingSupressInfo, departmentId));
break;
case DepartmentSettingTypes.PersonnelOnUnitSetUnitStatus:
await _cacheProvider.RemoveAsync(string.Format(PersonnelOnUnitSetUnitStatusCacheKey, departmentId));
break;
}

Expand Down Expand Up @@ -715,6 +719,23 @@ public async Task<bool> GetUnitDispatchAlsoDispatchToGroupAsync(int departmentId
return false;
}

public async Task<bool> GetPersonnelOnUnitSetUnitStatusAsync(int departmentId, bool bypassCache = false)
{
async Task<string> getSetting()
{
var s = await GetSettingByDepartmentIdType(departmentId, DepartmentSettingTypes.PersonnelOnUnitSetUnitStatus);
return s?.Setting ?? "false";
}

if (Config.SystemBehaviorConfig.CacheEnabled && !bypassCache)
{
var cachedValue = await _cacheProvider.RetrieveAsync<string>(string.Format(PersonnelOnUnitSetUnitStatusCacheKey, departmentId), getSetting, LongCacheLength);
return bool.Parse(cachedValue);
}

return bool.Parse(await getSetting());
}

public async Task<DepartmentSetting> SetDepartmentModuleSettingsAsync(int departmentId, DepartmentModuleSettings settings, CancellationToken cancellationToken = default(CancellationToken))
{
return await SaveOrUpdateSettingAsync(departmentId, ObjectSerialization.Serialize(settings),
Expand Down
Loading
Loading