Commit b413e9f0 by Mac Stephens

Improve BFD incident details, unit status colors and map markers, fix token…

Improve BFD incident details, unit status colors and map markers, fix token handling and password conversions, and document LEMS SQL updates.
parent cc6a6599
......@@ -546,7 +546,13 @@ function TAuthService.TokenExpired: Boolean;
begin
if not Authenticated then
Exit(False);
try
Result := TJwtHelper.TokenExpired(GetToken);
except
Result := True;
end;
if Result then
DeleteToken;
end;
function TAuthService.TokenPayload: JS.TJSObject;
......@@ -600,7 +606,7 @@ end;
class function TJwtHelper.TokenExpired(AToken: string): Boolean;
begin
if not HasExpirationDate(AToken) then
Exit(False);
Exit(True);
Result := TJSDate.now > toInteger(TokenExpirationDate(AToken).valueOf);
end;
......
......@@ -48,66 +48,6 @@ object FViewComplaintDetails: TFViewComplaintDetails
WidthPercent = 100.000000000000000000
OnClick = btnContactsClick
end
object btnCmp: TWebButton
Left = 190
Top = 165
Width = 96
Height = 25
Caption = 'CMP'
ChildOrder = 1
ElementID = 'btn_cmp'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
TabStop = False
WidthPercent = 100.000000000000000000
OnClick = btnCmpClick
end
object btnE911: TWebButton
Left = 294
Top = 165
Width = 96
Height = 25
Caption = 'E-911'
ChildOrder = 1
ElementID = 'btn_e911'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
TabStop = False
WidthPercent = 100.000000000000000000
OnClick = btnE911Click
end
object btnREM: TWebButton
Left = 404
Top = 165
Width = 96
Height = 25
Caption = 'REM'
ChildOrder = 1
ElementID = 'btn_rem'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
TabStop = False
WidthPercent = 100.000000000000000000
OnClick = btnREMClick
end
object btnUnt: TWebButton
Left = 506
Top = 165
Width = 96
Height = 25
Caption = 'UNT'
ChildOrder = 1
ElementID = 'btn_unt'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
TabStop = False
WidthPercent = 100.000000000000000000
OnClick = btnUntClick
end
object tblRemarks: TWebDBTableControl
Left = 8
Top = 196
......@@ -353,11 +293,10 @@ object FViewComplaintDetails: TFViewComplaintDetails
DataSource = wdsWarnings
ItemTemplate =
'<div class="card mb-2 small"> <div class="card-body py-2"> <' +
'div cl' +
'ass="d-flex justify-content-between gap-2"> <div class="fw-' +
'semibold">(%CodeDesc%)</div> <div class="text-muted text-en' +
'd">(%ADDRESS%)</div> </div> <div class="mt-1">' +
'(%NOTES%)</div> </div></div>'
'div class="d-flex justify-content-between gap-2"> <div clas' +
's="fw-semibold">(%CodeDesc%)</div> <div class="text-muted t' +
'ext-end">(%ADDRESS%)</div> </div> <div class="mt-1">(%NOTE' +
'S%)</div> </div></div>'
ListSource = wdsWarnings
end
object btnComplaintViewOnMap: TWebButton
......@@ -388,6 +327,56 @@ object FViewComplaintDetails: TFViewComplaintDetails
WidthPercent = 100.000000000000000000
OnClick = btnArchiveClick
end
object tblUnits: TWebDBTableControl
Left = 12
Top = 406
Width = 191
Height = 147
ElementId = 'tbl_units'
BorderColor = clSilver
ChildOrder = 8
ElementFont = efCSS
ElementHeaderClassName = 'table-light'
ElementTableClassName =
'table table-sm table-striped table-hover table-bordered mb-0 ali' +
'gn-middle small'
Footer.ButtonActiveElementClassName = 'btn btn-primary'
Footer.ButtonElementClassName = 'btn btn-light'
Footer.DropDownElementClassName = 'form-control'
Footer.InputElementClassName = 'form-control'
Footer.LinkActiveElementClassName = 'link-primary'
Footer.LinkElementClassName = 'link-secondary'
Footer.ListElementClassName = 'pagination'
Footer.ListItemElementClassName = 'page-item'
Footer.ListLinkElementClassName = 'page-link'
Header.ButtonActiveElementClassName = 'btn btn-primary'
Header.ButtonElementClassName = 'btn btn-light'
Header.DropDownElementClassName = 'form-control'
Header.InputElementClassName = 'form-control'
Header.LinkActiveElementClassName = 'link-primary'
Header.LinkElementClassName = 'link-secondary'
Header.ListElementClassName = 'pagination'
Header.ListItemElementClassName = 'page-item'
Header.ListLinkElementClassName = 'page-link'
WordWrap = True
Columns = <
item
ElementClassName = 'text-nowrap'
DataField = 'UnitName'
Title = 'Unit'
end
item
ElementClassName = 'text-nowrap'
DataField = 'Status'
Title = 'Status'
end
item
DataField = 'StatusUpdated'
Title = 'Status Updated'
end>
DataSource = wdsUnits
OnGetCellClass = tblUnitsGetCellClass
end
object xdwcComplaintDetails: TXDataWebClient
Connection = DMConnection.ApiConnection
Left = 384
......@@ -486,4 +475,43 @@ object FViewComplaintDetails: TFViewComplaintDetails
Left = 712
Top = 422
end
object btnUnits: TWebButton
Left = 190
Top = 134
Width = 96
Height = 25
Caption = 'Units'
ChildOrder = 1
ElementID = 'btn_units'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
TabStop = False
WidthPercent = 100.000000000000000000
OnClick = btnUnitsClick
end
object xdwdsUnits: TXDataWebDataSet
Left = 40
Top = 574
object xdwdsUnitsUnitName: TStringField
FieldName = 'UnitName'
Size = 80
end
object xdwdsUnitsStatus: TStringField
FieldName = 'Status'
Size = 80
end
object xdwdsUnitsUnitStatus: TStringField
FieldName = 'UnitStatus'
end
object xdwdsUnitsStatusUpdated: TStringField
FieldName = 'StatusUpdated'
Size = 40
end
end
object wdsUnits: TWebDataSource
DataSet = xdwdsUnits
Left = 120
Top = 574
end
end
......@@ -46,10 +46,6 @@
<td class="w-100" id="lbl_dispatch_code"></td>
</tr>
<tr>
<th scope="row" class="fw-semibold text-nowrap pe-2 w-auto">Units:</th>
<td class="w-100" id="lbl_units"></td>
</tr>
<tr>
<th scope="row" class="fw-semibold text-nowrap pe-2 w-auto">Address:</th>
<td class="w-100" id="lbl_address"></td>
</tr>
......@@ -89,23 +85,16 @@
<!-- Buttons -->
<div class="pb-2">
<div class="complaint-detail-tabs d-flex flex-wrap gap-2 justify-content-center">
<button type="button" class="btn btn-success btn-sm px-3 active" id="btn_remarks" aria-pressed="true">Remarks</button>
<button type="button" class="btn btn-success btn-sm px-3" id="btn_history">History</button>
<button type="button" class="btn btn-success btn-sm px-3" id="btn_warnings">Warnings</button>
<button type="button" class="btn btn-success btn-sm px-3" id="btn_contacts">Contacts</button>
</div>
<!-- Remarks toggle filters (only visible on Remarks tab) -->
<div class="d-flex flex-wrap gap-2 justify-content-center mt-2" id="row_remarks_toggles">
<button type="button" class="btn btn-success btn-sm px-3 active" id="btn_cmp" aria-pressed="true">CMP</button>
<button type="button" class="btn btn-success btn-sm px-3 active" id="btn_e911" aria-pressed="true">E-911</button>
<button type="button" class="btn btn-success btn-sm px-3 active" id="btn_rem" aria-pressed="true">REM</button>
<button type="button" class="btn btn-success btn-sm px-3 active" id="btn_unt" aria-pressed="true">UNT</button>
<button type="button" class="btn btn-success btn-sm px-2 active" id="btn_remarks" aria-pressed="true">Remarks</button>
<button type="button" class="btn btn-success btn-sm px-2" id="btn_units" aria-pressed="false">Units</button>
<button type="button" class="btn btn-success btn-sm px-2" id="btn_history">History</button>
<button type="button" class="btn btn-success btn-sm px-2" id="btn_warnings">Warnings</button>
<button type="button" class="btn btn-success btn-sm px-2" id="btn_contacts">Contacts</button>
</div>
<!-- History action row (only visible on History tab) -->
<div class="d-flex flex-wrap gap-2 justify-content-center mt-2 tab-hidden" id="row_history_actions">
<button type="button" class="btn btn-secondary btn-sm px-3 disabled" id="btn_archive" disabled>Archive</button>
<button type="button" class="btn btn-secondary btn-sm px-2 disabled" id="btn_archive" disabled>Archive</button>
</div>
</div>
......@@ -114,6 +103,7 @@
<!-- Tables (scroll with page) -->
<div class="card border-0 shadow-sm">
<div class="card-body p-0">
<div id="tbl_units" class="tab-hidden"></div>
<div id="tbl_remarks"></div>
<div id="tbl_history" class="tab-hidden"></div>
<div id="tbl_warnings" class="d-none d-md-block"></div>
......
......@@ -48,37 +48,32 @@ type
btnHistory: TWebButton;
btnWarnings: TWebButton;
btnContacts: TWebButton;
btnCmp: TWebButton;
btnE911: TWebButton;
btnREM: TWebButton;
btnUnt: TWebButton;
lstWarnings: TWebDBListControl;
btnComplaintViewOnMap: TWebButton;
xdwdsHistoryComplaintId: TStringField;
btnArchive: TWebButton;
tblUnits: TWebDBTableControl;
btnUnits: TWebButton;
xdwdsUnits: TXDataWebDataSet;
wdsUnits: TWebDataSource;
xdwdsUnitsUnitName: TStringField;
xdwdsUnitsStatus: TStringField;
xdwdsUnitsUnitStatus: TStringField;
xdwdsUnitsStatusUpdated: TStringField;
procedure btnUnitsClick(Sender: TObject);
procedure tblUnitsGetCellClass(Sender: TObject; ACol, ARow: Integer; AField: TField; AValue: string; var AClassName: string);
procedure btnRemarksClick(Sender: TObject);
procedure btnHistoryClick(Sender: TObject);
procedure btnContactsClick(Sender: TObject);
procedure btnWarningsClick(Sender: TObject);
procedure btnCmpClick(Sender: TObject);
procedure btnComplaintViewOnMapClick(Sender: TObject);
procedure btnE911Click(Sender: TObject);
procedure btnREMClick(Sender: TObject);
procedure btnUntClick(Sender: TObject);
procedure btnArchiveClick(Sender: TObject);
private
FComplaintId: string;
FCfsId: string;
FLoading: Boolean;
FAllMemos: TJSArray;
FShowCmp: Boolean;
FShowE911: Boolean;
FShowRem: Boolean;
FShowUnt: Boolean;
FHasHistory: Boolean;
FHasContacts: Boolean;
FHasWarnings: Boolean;
......@@ -94,14 +89,11 @@ type
procedure CloseClick(Event: TJSEvent);
procedure SetTextById(const elementId, value: string);
function MemoTypeInList(const memoType: string; const list: array of string): Boolean;
function MemoTypeLabel(const memoTypeCode: string): string;
procedure SetDataSetJsonData(dataSet: TXDataWebDataSet; dataArr: TJSArray);
procedure SetHiddenById(const elementId: string; hidden: Boolean);
procedure SetActiveTab(const tabName: string);
procedure UpdateToggleButtonCss(const buttonId: string; isOn: Boolean);
procedure UpdateTabButtonCss(const activeTabName: string);
procedure SetButtonEnabledById(const buttonId: string; enabled: Boolean);
......@@ -110,7 +102,6 @@ type
procedure ClearHistorySelection;
procedure SelectHistoryRowByIndex(rowIndex: Integer);
procedure ApplyRemarksFilters;
[async] procedure ApplyTabAsync(const tabName: string);
......@@ -158,11 +149,8 @@ begin
xdwdsHistory.Connection := DMConnection.ApiConnection;
xdwdsContacts.Connection := DMConnection.ApiConnection;
xdwdsWarnings.Connection := DMConnection.ApiConnection;
xdwdsUnits.Connection := DMConnection.ApiConnection;
FShowCmp := True;
FShowE911 := True;
FShowRem := True;
FShowUnt := True;
FHasHistory := True;
FHasContacts := True;
......@@ -209,31 +197,6 @@ begin
TJSHtmlElement(el).innerText := value;
end;
function TFViewComplaintDetails.MemoTypeInList(const memoType: string; const list: array of string): Boolean;
var
i: Integer;
begin
Result := False;
for i := Low(list) to High(list) do
begin
if memoType = list[i] then
Exit(True);
end;
end;
function TFViewComplaintDetails.MemoTypeLabel(const memoTypeCode: string): string;
begin
if MemoTypeInList(memoTypeCode, ['30', '31', '32', '33', '34']) then
Exit('UNT');
if MemoTypeInList(memoTypeCode, ['3', '4']) then
Exit('CMP');
if MemoTypeInList(memoTypeCode, ['2']) then
Exit('E-911');
if MemoTypeInList(memoTypeCode, ['1']) then
Exit('REM');
Result := memoTypeCode;
end;
procedure TFViewComplaintDetails.SetDataSetJsonData(dataSet: TXDataWebDataSet; dataArr: TJSArray);
begin
dataSet.Close;
......@@ -255,36 +218,9 @@ begin
TJSElement(el).classList.remove('tab-hidden');
end;
procedure TFViewComplaintDetails.UpdateToggleButtonCss(const buttonId: string; isOn: Boolean);
var
el: TJSElement;
btn: TJSHTMLButtonElement;
begin
el := Document.getElementById(buttonId);
if el = nil then
Exit;
btn := TJSHTMLButtonElement(el);
btn.classList.remove('btn-success');
btn.classList.remove('btn-secondary');
btn.classList.remove('active');
if isOn then
begin
btn.classList.add('btn-success');
btn.classList.add('active');
btn.setAttribute('aria-pressed', 'true');
end
else
begin
btn.classList.add('btn-secondary');
btn.setAttribute('aria-pressed', 'false');
end;
end;
procedure TFViewComplaintDetails.UpdateTabButtonCss(const activeTabName: string);
var
tabUnits: TJSElement;
tabRemarks: TJSElement;
tabHistory: TJSElement;
tabContacts: TJSElement;
......@@ -310,11 +246,13 @@ var
end;
begin
tabUnits := Document.getElementById('btn_units');
tabRemarks := Document.getElementById('btn_remarks');
tabHistory := Document.getElementById('btn_history');
tabContacts := Document.getElementById('btn_contacts');
tabWarnings := Document.getElementById('btn_warnings');
SetTab(tabUnits, activeTabName = 'units');
SetTab(tabRemarks, activeTabName = 'remarks');
SetTab(tabHistory, activeTabName = 'history');
SetTab(tabContacts, activeTabName = 'contacts');
......@@ -453,6 +391,7 @@ end;
procedure TFViewComplaintDetails.SetActiveTab(const tabName: string);
begin
SetHiddenById('tbl_units', tabName <> 'units');
SetHiddenById('tbl_remarks', tabName <> 'remarks');
SetHiddenById('tbl_history', tabName <> 'history');
......@@ -464,63 +403,23 @@ begin
SetHiddenById('tbl_warnings', tabName <> 'warnings');
SetHiddenById('lst_warnings', tabName <> 'warnings');
SetHiddenById('row_remarks_toggles', tabName <> 'remarks');
SetHiddenById('row_history_actions', tabName <> 'history');
UpdateTabButtonCss(tabName);
end;
procedure TFViewComplaintDetails.ApplyRemarksFilters;
var
filteredArr: TJSArray;
i: Integer;
rowObj: TJSObject;
memoType: string;
showRow: Boolean;
[async] procedure TFViewComplaintDetails.ApplyTabAsync(const tabName: string);
begin
if not Assigned(FAllMemos) then
Exit;
filteredArr := TJSArray.new;
for i := 0 to Integer(FAllMemos.length) - 1 do
if tabName = 'units' then
begin
rowObj := TJSObject(FAllMemos[i]);
memoType := string(rowObj['MemoTypeCode']);
showRow := False;
if FShowCmp and MemoTypeInList(memoType, ['3', '4']) then
showRow := True;
if FShowE911 and MemoTypeInList(memoType, ['2']) then
showRow := True;
if FShowRem and MemoTypeInList(memoType, ['1']) then
showRow := True;
if FShowUnt and MemoTypeInList(memoType, ['30', '31', '32', '33', '34']) then
showRow := True;
if showRow then
filteredArr.push(rowObj);
SetActiveTab('units');
Exit;
end;
SetDataSetJsonData(xdwdsRemarks, filteredArr);
UpdateToggleButtonCss('btn_cmp', FShowCmp);
UpdateToggleButtonCss('btn_e911', FShowE911);
UpdateToggleButtonCss('btn_rem', FShowRem);
UpdateToggleButtonCss('btn_unt', FShowUnt);
end;
[async] procedure TFViewComplaintDetails.ApplyTabAsync(const tabName: string);
begin
if tabName = 'remarks' then
begin
SetActiveTab('remarks');
ApplyRemarksFilters;
Exit;
end;
......@@ -590,6 +489,23 @@ begin
ApplyTabAsync('remarks');
end;
procedure TFViewComplaintDetails.btnUnitsClick(Sender: TObject);
begin
ApplyTabAsync('units');
end;
procedure TFViewComplaintDetails.tblUnitsGetCellClass(Sender: TObject; ACol, ARow: Integer; AField: TField; AValue: string; var AClassName: string);
begin
if (ARow = 0) or (AField <> xdwdsUnitsUnitName) then
Exit;
case StrToIntDef(xdwdsUnitsUnitStatus.AsString, 0) of
51, 52: AClassName := AClassName + ' text-warning';
else
AClassName := AClassName + ' text-success';
end;
end;
procedure TFViewComplaintDetails.btnHistoryClick(Sender: TObject);
begin
ApplyTabAsync('history');
......@@ -614,36 +530,12 @@ begin
FViewMain.ShowComplaintArchive(FSelectedArchiveComplaintId);
end;
procedure TFViewComplaintDetails.btnCmpClick(Sender: TObject);
begin
FShowCmp := not FShowCmp;
ApplyRemarksFilters;
end;
procedure TFViewComplaintDetails.btnComplaintViewOnMapClick(Sender: TObject);
begin
if Assigned(FViewMain) then
FViewMain.ShowMapFocusComplaint(FComplaintId);
end;
procedure TFViewComplaintDetails.btnE911Click(Sender: TObject);
begin
FShowE911 := not FShowE911;
ApplyRemarksFilters;
end;
procedure TFViewComplaintDetails.btnREMClick(Sender: TObject);
begin
FShowRem := not FShowRem;
ApplyRemarksFilters;
end;
procedure TFViewComplaintDetails.btnUntClick(Sender: TObject);
begin
FShowUnt := not FShowUnt;
ApplyRemarksFilters;
end;
[async] procedure TFViewComplaintDetails.LoadComplaintAsync;
var
resp: TXDataClientResponse;
......@@ -713,7 +605,8 @@ begin
SetTextById('lbl_priority', priorityText);
SetTextById('lbl_status', statusText);
SetTextById('lbl_dispatch_code', dispatchDisplayText);
SetTextById('lbl_units', string(dataObj['Units']));
SetDataSetJsonData(xdwdsUnits, TJSArray(dataObj['Units']));
SetButtonEnabledById('btn_units', not xdwdsUnits.IsEmpty);
SetTextById('lbl_address', addressText);
SetTextById('lbl_business', businessText);
SetTextById('lbl_date_reported', dateReportedText);
......@@ -754,7 +647,6 @@ begin
await(LoadMemosAsync);
SetActiveTab('remarks');
ApplyRemarksFilters;
except
on E: EXDataClientRequestException do
Utils.ShowErrorModal(E.ErrorResult.ErrorMessage);
......@@ -772,9 +664,6 @@ var
resp: TXDataClientResponse;
rootObj: TJSObject;
dataArr: TJSArray;
i: Integer;
rowObj: TJSObject;
memoTypeCode: string;
begin
if Trim(FCfsId) = '' then
Exit;
......@@ -783,16 +672,6 @@ begin
rootObj := TJSObject(resp.Result);
dataArr := TJSArray(rootObj['data']);
FAllMemos := dataArr;
for i := 0 to Integer(dataArr.length) - 1 do
begin
rowObj := TJSObject(dataArr[i]);
memoTypeCode := string(rowObj['MemoType']);
rowObj['MemoTypeCode'] := memoTypeCode;
rowObj['MemoType'] := MemoTypeLabel(memoTypeCode);
end;
SetDataSetJsonData(xdwdsRemarks, dataArr);
end;
......
......@@ -43,7 +43,9 @@ object FViewComplaints: TFViewComplaints
DataSource = wdsComplaints
ItemTemplate =
'<div class="card border shadow-sm"><div class="card-body py-2' +
' px-3 d-flex gap-2"><div class="flex-grow-1"><div class="fw-bold' +
' px-3 d-flex gap-2"><img src="assets/markers/(%pngName%)" class="flex-shrink' +
'-0 align-self-center" style="width:28px;height:36px;object-fit:contain" alt="">' +
'<div class="flex-grow-1"><div class="fw-bold' +
' text-uppercase small">Incident: (%Complaint%)</div><div class="' +
'small">Response: (%Priority%) &middot; (%DispatchCodeDesc%)</div' +
'><div class="small">(%Address%)</div><div class="small d-none co' +
......@@ -84,6 +86,10 @@ object FViewComplaints: TFViewComplaints
FieldName = 'DispatchCodeDesc'
Size = 160
end
object xdwdsComplaintspngName: TStringField
FieldName = 'pngName'
Size = 80
end
object xdwdsComplaintsAddress: TStringField
FieldName = 'Address'
Size = 160
......
......@@ -19,6 +19,7 @@ type
xdwdsComplaintsAgency: TStringField;
xdwdsComplaintsPriority: TStringField;
xdwdsComplaintsDispatchCodeDesc: TStringField;
xdwdsComplaintspngName: TStringField;
xdwdsComplaintsAddress: TStringField;
xdwdsComplaintsStatus: TStringField;
xdwdsComplaintsDateReported: TStringField;
......
......@@ -41,7 +41,8 @@ object FViewUnits: TFViewUnits
ItemTemplate =
'<div class="list-section-header small fw-semibold bg-body-second' +
'ary text-dark rounded-1 px-2 mb-1">(%StationHeader%)</div><div c' +
'lass="card border shadow-sm"> <div class="card-body py-2 px-3 d' +
'lass="card border-0 shadow-sm" style="--bs-card-bg:(%BackgroundColor%);">' +
' <div class="card-body py-2 px-3 d' +
'-flex gap-2"> <div class="flex-grow-1"> <div class="fw-b' +
'old text-uppercase small">(%UnitName%)&nbsp;-&nbsp;(%Status%)</d' +
'iv> <div class="small text-body-secondary mb-1 (%UnitDescCl' +
......@@ -103,6 +104,10 @@ object FViewUnits: TFViewUnits
FieldName = 'Status'
Size = 160
end
object xdwdsUnitsBackgroundColor: TStringField
FieldName = 'BackgroundColor'
Size = 7
end
object xdwdsUnitsManpower: TStringField
FieldName = 'Manpower'
end
......
......@@ -25,6 +25,7 @@ type
xdwdsUnitsCurrentStation: TStringField;
xdwdsUnitsMovingToStation: TStringField;
xdwdsUnitsStatus: TStringField;
xdwdsUnitsBackgroundColor: TStringField;
xdwdsUnitsManpower: TStringField;
xdwdsUnitsUndermanned: TBooleanField;
xdwdsUnitsUndermannedClass: TStringField;
......@@ -153,6 +154,14 @@ begin
begin
item := TJSObject(data[i]);
case StrToIntDef(string(item['UnitStatus']), 0) of
51, 52: item['BackgroundColor'] := '#FFFAEB';
53..56: item['BackgroundColor'] := '#EBF5EB';
70, 102: item['BackgroundColor'] := '#F2F2F2';
else
item['BackgroundColor'] := '#FCEFF0';
end;
stationHeader := Trim(string(item['StationHeader']));
if (stationHeader <> '') and
not SameText(stationHeader, 'No Station') and
......
......@@ -54,6 +54,9 @@ begin
if (iconUrl.indexOf("_dispatched.png") !== -1) {
return { background: "#FFC107", text: "#111827" };
}
if (iconUrl.indexOf("_cleared.png") !== -1) {
return { background: "#008000", text: "#FFFFFF" };
}
if (iconUrl.indexOf("_oos.png") !== -1) {
return { background: "#000000", text: "#FFFFFF" };
}
......
......@@ -286,6 +286,10 @@
<ResourceType>RCDATA</ResourceType>
<ResourceId>engine_dispatched</ResourceId>
</RcItem>
<RcItem Include="assets\markers\engine_cleared.png">
<ResourceType>RCDATA</ResourceType>
<ResourceId>engine_cleared</ResourceId>
</RcItem>
<RcItem Include="assets\markers\engine_oos.png">
<ResourceType>RCDATA</ResourceType>
<ResourceId>engine_oos</ResourceId>
......@@ -298,6 +302,10 @@
<ResourceType>RCDATA</ResourceType>
<ResourceId>ladder_dispatched</ResourceId>
</RcItem>
<RcItem Include="assets\markers\ladder_cleared.png">
<ResourceType>RCDATA</ResourceType>
<ResourceId>ladder_cleared</ResourceId>
</RcItem>
<RcItem Include="assets\markers\ladder_oos.png">
<ResourceType>RCDATA</ResourceType>
<ResourceId>ladder_oos</ResourceId>
......@@ -310,6 +318,10 @@
<ResourceType>RCDATA</ResourceType>
<ResourceId>other_dispatched</ResourceId>
</RcItem>
<RcItem Include="assets\markers\other_cleared.png">
<ResourceType>RCDATA</ResourceType>
<ResourceId>other_cleared</ResourceId>
</RcItem>
<RcItem Include="assets\markers\other_oos.png">
<ResourceType>RCDATA</ResourceType>
<ResourceId>other_oos</ResourceId>
......@@ -676,6 +688,12 @@
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="assets\markers\engine_cleared.png" Configuration="Debug" Class="ProjectFile">
<Platform Name="Win32">
<RemoteDir>.\</RemoteDir>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="assets\markers\engine_oos.png" Configuration="Debug" Class="ProjectFile">
<Platform Name="Win32">
<RemoteDir>.\</RemoteDir>
......@@ -694,6 +712,12 @@
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="assets\markers\ladder_cleared.png" Configuration="Debug" Class="ProjectFile">
<Platform Name="Win32">
<RemoteDir>.\</RemoteDir>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="assets\markers\ladder_oos.png" Configuration="Debug" Class="ProjectFile">
<Platform Name="Win32">
<RemoteDir>.\</RemoteDir>
......@@ -712,6 +736,12 @@
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="assets\markers\other_cleared.png" Configuration="Debug" Class="ProjectFile">
<Platform Name="Win32">
<RemoteDir>.\</RemoteDir>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="assets\markers\other_oos.png" Configuration="Debug" Class="ProjectFile">
<Platform Name="Win32">
<RemoteDir>.\</RemoteDir>
......
......@@ -574,7 +574,13 @@ function TAuthService.TokenExpired: Boolean;
begin
if not Authenticated then
Exit(False);
try
Result := TJwtHelper.TokenExpired(GetToken);
except
Result := True;
end;
if Result then
DeleteToken;
end;
function TAuthService.TokenPayload: JS.TJSObject;
......@@ -628,7 +634,7 @@ end;
class function TJwtHelper.TokenExpired(AToken: string): Boolean;
begin
if not HasExpirationDate(AToken) then
Exit(False);
Exit(True);
Result := TJSDate.now > toInteger(TokenExpirationDate(AToken).valueOf);
end;
......
......@@ -467,6 +467,16 @@ object BFDAPIDataModule: TBFDAPIDataModule
' cft.COMPLAINTID,'
' cft.UNITID,'
' NVL(dua.UNITNAME, cfs.UNITNAME) AS UNITNAME,'
' NVL(cus.CODE_DESC, TO_CHAR(dua.STATUS)) AS UNIT_STATUS_DESC,'
' dua.STATUS AS UNIT_STATUS,'
' CASE dua.STATUS'
' WHEN 51 THEN cfs.DATEDISPATCHED'
' WHEN 52 THEN cfs.DATERESPONDED'
' WHEN 53 THEN cfs.DATEARRIVED'
' WHEN 54 THEN cfs.DATETOHOSPITAL'
' WHEN 55 THEN cfs.DATEATHOSPITAL'
' WHEN 56 THEN cfs.DATECLEARED'
' END AS STATUS_UPDATED,'
' cft.DISPATCHED AS DATEDISPATCHED,'
' cft.ENROUTE AS DATERESPONDED,'
' cft.ONSCENE AS DATEARRIVED,'
......@@ -475,6 +485,7 @@ object BFDAPIDataModule: TBFDAPIDataModule
' cft.REPORTING_UNIT'
'FROM COMPLAINT_FIREUNIT_TIMES cft'
'LEFT JOIN DIS_UNIT_ACTIVE dua ON dua.UNITID = cft.UNITID'
'LEFT JOIN CD_UNITSTATUS cus ON cus.CODE = dua.STATUS'
'LEFT JOIN CFS_ACTIVE cfs ON cfs.COMPLAINTID = cft.COMPLAINTID AN' +
'D cfs.UNITID = cft.UNITID'
......@@ -502,6 +513,16 @@ object BFDAPIDataModule: TBFDAPIDataModule
FieldName = 'unitname'
Size = 10
end
object uqComplaintUnitsunit_status_desc: TStringField
FieldName = 'unit_status_desc'
Size = 80
end
object uqComplaintUnitsunit_status: TFloatField
FieldName = 'unit_status'
end
object uqComplaintUnitsstatus_updated: TDateTimeField
FieldName = 'status_updated'
end
object uqComplaintUnitsdatedispatched: TDateTimeField
FieldName = 'datedispatched'
end
......@@ -536,6 +557,7 @@ object BFDAPIDataModule: TBFDAPIDataModule
' cm.REMARKS'
'FROM CFS_MEMOS cm'
'WHERE cm.CFSID = :CFSID'
' AND (cm.MEMO_TYPE IS NULL OR cm.MEMO_TYPE NOT IN (30, 31, 32, 33, 34))'
'ORDER BY cm.TIMESTAMP DESC')
ReadOnly = True
Left = 199
......@@ -576,6 +598,7 @@ object BFDAPIDataModule: TBFDAPIDataModule
' ca.COMPLAINT,'
' ca.AGENCY,'
' cdc.CODE_DESC AS DISPATCH_CODE_DESC,'
' cdc.CATEGORY AS DISPATCHCODECATEGORY,'
' ca.SOURCE,'
' ccs.CODE_DESC AS SOURCE_DESC,'
' ca.PRIORITY,'
......@@ -732,6 +755,16 @@ object BFDAPIDataModule: TBFDAPIDataModule
FieldName = 'complaintNumber'
Calculated = True
end
object uqComplaintListdispatchcodecategory: TStringField
FieldName = 'dispatchcodecategory'
Size = 80
end
object uqComplaintListpngName: TStringField
FieldKind = fkCalculated
FieldName = 'pngName'
Size = 80
Calculated = True
end
object uqComplaintListstatus: TStringField
FieldName = 'status'
Size = 3
......
......@@ -56,6 +56,8 @@ type
uqComplaintListdatecleared: TDateTimeField;
uqComplaintListpriority_color: TFloatField;
uqComplaintListcomplaintNumber: TStringField;
uqComplaintListdispatchcodecategory: TStringField;
uqComplaintListpngName: TStringField;
uqComplaintDetailscomplaintid: TFloatField;
uqComplaintDetailscfsid: TFloatField;
uqComplaintDetailscomplaint: TStringField;
......@@ -141,6 +143,9 @@ type
uqComplaintUnitscomplaintid: TFloatField;
uqComplaintUnitsunitid: TFloatField;
uqComplaintUnitsunitname: TStringField;
uqComplaintUnitsunit_status_desc: TStringField;
uqComplaintUnitsunit_status: TFloatField;
uqComplaintUnitsstatus_updated: TDateTimeField;
uqComplaintUnitsdatedispatched: TDateTimeField;
uqComplaintUnitsdateresponded: TDateTimeField;
uqComplaintUnitsdatearrived: TDateTimeField;
......@@ -340,6 +345,8 @@ end;
procedure TBFDAPIDataModule.uqComplaintListCalcFields(DataSet: TDataSet);
var
raw: string;
rawCategory: string;
statusKey: string;
begin
raw := uqComplaintListCOMPLAINT.AsString.Trim;
......@@ -349,6 +356,20 @@ begin
uqComplaintListcomplaintNumber.AsString := raw + '-'
else
uqComplaintListcomplaintNumber.AsString := raw;
rawCategory := uqComplaintListdispatchcodecategory.AsString;
case StrToIntDef(Trim(uqComplaintListSTATUS.AsString), 1) of
2: statusKey := 'active';
4, 5: statusKey := 'hold';
6: statusKey := 'suspend';
else
statusKey := 'pending';
end;
if Trim(rawCategory) = '' then
uqComplaintListpngName.AsString := Format('default_%s.png', [statusKey])
else
uqComplaintListpngName.AsString := Format('%s_%s.png', [HandleUniqueFilenames(rawCategory), statusKey]);
end;
......@@ -742,8 +763,9 @@ begin
item.AddPair('Status', unitStatus);
item.AddPair('CurrentStatus', uqMapUnitsCURRENT_STATUS.AsString);
case uqMapUnitsCURRENT_STATUS.AsInteger of
51..55: markerStatus := 'dispatched';
70: markerStatus := 'oos';
51, 52: markerStatus := 'dispatched';
53..56: markerStatus := 'cleared';
70, 102: markerStatus := 'oos';
else
markerStatus := 'available';
end;
......@@ -866,6 +888,7 @@ begin
item.AddPair('Agency', uqComplaintListAGENCY.AsString);
item.AddPair('Priority', uqComplaintListPRIORITY.AsString);
item.AddPair('DispatchCodeDesc', uqComplaintListDISPATCH_CODE_DESC.AsString);
item.AddPair('pngName', uqComplaintListpngName.AsString);
item.AddPair('Address', uqComplaintListADDRESS.AsString);
item.AddPair('Business', uqComplaintListBUSINESS.AsString);
item.AddPair('CFSId', uqComplaintListCFSID.AsString);
......@@ -1062,7 +1085,8 @@ var
obj: TJSONObject;
status: string;
statusColor: string;
unitsText: string;
units: TJSONArray;
unitObj: TJSONObject;
begin
Logger.Log(3, '---TBFDAPIDataModule.GetComplaintDetails initiated: ' + ComplaintId);
......@@ -1104,7 +1128,8 @@ begin
obj.AddPair('Priority', uqComplaintDetailsPRIORITY.AsString);
obj.AddPair('DispatchCode', uqComplaintDetailsDISPATCHCODE.AsString);
obj.AddPair('DispatchCodeDesc', uqComplaintDetailsDISPATCH_CODE_DESC.AsString);
unitsText := '';
units := TJSONArray.Create;
obj.AddPair('Units', units);
uqComplaintUnits.Close;
uqComplaintUnits.ParamByName('COMPLAINTID').AsString := ComplaintId;
uqComplaintUnits.Open;
......@@ -1112,13 +1137,22 @@ begin
while not uqComplaintUnits.Eof do
begin
if (not uqComplaintUnitsDATEDISPATCHED.IsNull) and uqComplaintUnitsDATECLEARED.IsNull then
unitsText := Trim(unitsText + ' ' + Trim(uqComplaintUnitsUNITNAME.AsString));
begin
unitObj := TJSONObject.Create;
units.AddElement(unitObj);
unitObj.AddPair('UnitName', uqComplaintUnitsUNITNAME.AsString);
unitObj.AddPair('Status', uqComplaintUnitsunit_status_desc.AsString);
unitObj.AddPair('UnitStatus', uqComplaintUnitsunit_status.AsString);
if uqComplaintUnitsstatus_updated.IsNull then
unitObj.AddPair('StatusUpdated', '')
else
unitObj.AddPair('StatusUpdated', FormatDateTime('yyyy-mm-dd hh:nn:ss', uqComplaintUnitsstatus_updated.AsDateTime));
end;
uqComplaintUnits.Next;
end;
finally
uqComplaintUnits.Close;
end;
obj.AddPair('Units', unitsText);
obj.AddPair('Address', uqComplaintDetailsADDRESS.AsString);
obj.AddPair('Business', uqComplaintDetailsBUSINESS.AsString);
......
......@@ -6,6 +6,7 @@ object ApiServerModule: TApiServerModule
Top = 30
end
object XDataServer1: TXDataServer
BaseUrl = 's'
Dispatcher = SparkleHttpSysDispatcher
ModelName = 'Api'
EntitySetPermissions = <>
......
......@@ -7,7 +7,7 @@ uses
XData.Server.Module,
Auth.Service,
Agency.Auth, Device.Store,
Uni, Data.DB, System.JSON, System.SysUtils, System.IOUtils, IniFiles;
Uni, Data.DB, System.JSON, System.AnsiStrings, System.SysUtils, System.IOUtils, IniFiles;
type
[ServiceImplementation]
......@@ -1333,7 +1333,7 @@ end;
function TAuthService.CheckUser(const User, Password, Agency: string): Integer;
var
userStr: string;
decryptedPassword: AnsiString;
decryptedPassword: string;
passwordKey: AnsiString;
begin
Logger.Log(3, Format('LoginService.CheckUser - User: "%s" Agency: "%s"', [User, Agency]));
......@@ -1350,7 +1350,7 @@ begin
Result := 1
else
begin
decryptedPassword := Uppercase(Trim(Decrypt(authDB.UserData.FieldByName('password').AsString, passwordKey)));
decryptedPassword := Uppercase(Trim(string(Decrypt(AnsiString(authDB.UserData.FieldByName('password').AsString), passwordKey))));
if decryptedPassword = Uppercase(Trim(Password)) then
begin
userName := authDB.UserData.FieldByName('user_name').AsString;
......@@ -1399,7 +1399,7 @@ begin
k := (k + i) mod 256;
outStr := outStr + AnsiChar(Integer(inStr[i+1]) xor Integer(tempKeyStr[k+1]));
end;
Result := Trim(outStr);
Result := System.AnsiStrings.Trim(outStr);
end;
initialization
......
<?xml version="1.0" encoding="utf-8"?>
<BorlandProject>
<ProjectSortOrder AutoSort="0" SortType="0">
<File Path="Source"/>
<File Path="Source\BFD"/>
<File Path="Source\BFD\BFD.Api.Database.pas"/>
<File Path="Source\BFD\BFD.Api.Database.dfm"/>
<File Path="Source\BFD\BFD.Auth.Database.pas"/>
<File Path="Source\BFD\BFD.Auth.Database.dfm"/>
<File Path="Source\Common"/>
<File Path="Source\Common\Agency.Auth.pas"/>
<File Path="Source\Common\Agency.Data.pas"/>
<File Path="Source\Common\Agency.Selection.pas"/>
<File Path="Source\Common\Api.Server.Module.pas"/>
<File Path="Source\Common\Api.Server.Module.dfm"/>
<File Path="Source\Common\Api.Service.pas"/>
<File Path="Source\Common\Api.ServiceImpl.pas"/>
<File Path="Source\Common\App.Server.Module.pas"/>
<File Path="Source\Common\App.Server.Module.dfm"/>
<File Path="Source\Common\Auth.Server.Module.pas"/>
<File Path="Source\Common\Auth.Server.Module.dfm"/>
<File Path="Source\Common\Auth.Service.pas"/>
<File Path="Source\Common\Auth.ServiceImpl.pas"/>
<File Path="Source\Common\BaseRequest.pas"/>
<File Path="Source\Common\Common.Config.pas"/>
<File Path="Source\Common\Common.Ini.pas"/>
<File Path="Source\Common\Common.Logging.pas"/>
<File Path="Source\Common\Common.Middleware.Logging.pas"/>
<File Path="Source\Common\Device.Store.pas"/>
<File Path="Source\Common\Main.pas"/>
<File Path="Source\Common\Main.dfm"/>
<File Path="Source\Common\Oracle.Device.Database.pas"/>
<File Path="Source\Common\Oracle.Device.Database.dfm"/>
<File Path="Source\Common\Pkg.Json.DTO.pas"/>
<File Path="Source\Common\PostgreSQL.Device.Database.pas"/>
<File Path="Source\Common\PostgreSQL.Device.Database.dfm"/>
<File Path="Source\Common\uLibrary.pas"/>
<File Path="Source\Common\Webauthn.Cbor.pas"/>
<File Path="Source\Common\Webauthn.Crypto.pas"/>
<File Path="Source\Common\WebSocket.Manager.pas"/>
<File Path="Source\Common\Ws.DataModel.pas"/>
<File Path="Source\Common\Ws.Server.Module.pas"/>
<File Path="Source\Common\Ws.Server.Module.dfm"/>
<File Path="Source\Common\WsMessages.pas"/>
<File Path="Source\Lems"/>
<File Path="Source\Lems\WC.Api.Database.pas"/>
<File Path="Source\Lems\WC.Api.Database.dfm"/>
<File Path="Source\Lems\WC.Auth.Database.pas"/>
<File Path="Source\Lems\WC.Auth.Database.dfm"/>
</ProjectSortOrder>
</BorlandProject>
......@@ -2,7 +2,7 @@
Agency=BFD
[Settings]
LogFileNum=200
LogFileNum=206
webClientVersion=0.9.4.9
MemoLogLevel=3
FileLogLevel=4
......
SQL Updates for lems_wcso and BFD deployed databases
LEMS
Note: These updates assume the existing device_registrations and redeem_codes tables are already installed.
ALTER TABLE lems.device_registrations
ADD COLUMN IF NOT EXISTS verification_code VARCHAR(6),
ADD COLUMN IF NOT EXISTS verification_expires_at TIMESTAMPTZ;
ALTER TABLE lems.device_registrations
ADD COLUMN IF NOT EXISTS device_type VARCHAR(20);
Note:
- Delete all devices that do not have a phone number from the database (this can be done in device management or in the database itself)
- If keeping old devices, ensure they have one of the following in device_type
- iphone
- android
- browser
- other
BFD
CREATE TABLE DEVICE_REGISTRATIONS (
ID NUMBER(10) GENERATED BY DEFAULT AS IDENTITY,
CREDENTIAL_ID VARCHAR2(2000 BYTE),
DEVICE_NAME VARCHAR2(255 CHAR),
DEVICE_TYPE VARCHAR2(20 CHAR),
PHONE_NUMBER VARCHAR2(20 CHAR),
USER_AGENT CLOB,
PUBLIC_KEY_X RAW(32),
PUBLIC_KEY_Y RAW(32),
PUBLIC_KEY_ALG NUMBER(10) DEFAULT -7 NOT NULL,
SIGN_COUNT NUMBER(19) DEFAULT 0 NOT NULL,
REGISTERED_AT TIMESTAMP(6) WITH TIME ZONE DEFAULT SYSTIMESTAMP,
REVOKED_AT TIMESTAMP(6) WITH TIME ZONE,
REVOKED_BY VARCHAR2(255 CHAR),
STATUS VARCHAR2(10 CHAR) DEFAULT 'active' NOT NULL,
KEY_TYPE VARCHAR2(10 CHAR) DEFAULT 'webauthn',
USERNAME VARCHAR2(50 CHAR),
AGENCY VARCHAR2(20 CHAR),
VERIFICATION_CODE VARCHAR2(6 CHAR),
VERIFICATION_EXPIRES_AT TIMESTAMP(6) WITH TIME ZONE,
CONSTRAINT PK_DEVICE_REGISTRATIONS PRIMARY KEY (ID),
CONSTRAINT UQ_DEVICE_REG_CREDENTIAL UNIQUE (CREDENTIAL_ID)
);
CREATE INDEX IX_DEVICE_REG_PHONE_STATUS
ON DEVICE_REGISTRATIONS (PHONE_NUMBER, STATUS);
CREATE TABLE REDEEM_CODES (
ID NUMBER(10) GENERATED BY DEFAULT AS IDENTITY,
CODE VARCHAR2(20 CHAR) NOT NULL,
USED_AT TIMESTAMP(6) WITH TIME ZONE,
USED_FOR VARCHAR2(20 CHAR),
CONSTRAINT PK_REDEEM_CODES PRIMARY KEY (ID),
CONSTRAINT UQ_REDEEM_CODES_CODE UNIQUE (CODE)
);
Note:
- Add BFD devices through Device Management with a phone number and device type.
- REDEEM_CODES starts empty. Add BFD app redemption codes before using the iPhone Send Link feature; do not copy Wyoming codes.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment