Commit db85c9d8 by Mac Stephens

Add markers for directed patrol, missing person, and agency assist; update view…

Add markers for directed patrol, missing person, and agency assist; update view on map button text to map, add new panels for complaints, units, and map, functionality for loading and displaying them, add zoom for locate button
parent 0b3cc8d2
......@@ -21,3 +21,7 @@ emiMobileServer/Source/__recovery/
*.tvsconfig
*.dxsettings
*.zip
*.log
*.dll
[Settings]
LogFileNum=616
LogFileNum=622
webClientVersion=0.1.0
object FViewComplaintDetails: TFViewComplaintDetails
Width = 800
Height = 672
Caption = 'tbl_logs'
CSSLibrary = cssBootstrap
ElementFont = efCSS
object btnHistory: TWebButton
......
......@@ -98,7 +98,7 @@
type="button"
class="btn btn-primary btn-sm shadow position-fixed"
style="right: 12px; bottom: 72px; z-index: 1040;">
View On Map
Map
</button>
</div>
......@@ -57,7 +57,6 @@ implementation
procedure TFViewComplaints.WebFormCreate(Sender: TObject);
begin
Document.addEventListener('click', @HandleListClick);
ShowSpinner('spinner');
tmrRefresh.Enabled := False;
GetComplaints;
tmrRefresh.Enabled := True;
......@@ -161,7 +160,6 @@ begin
Exit;
FLoading := True;
ShowSpinner('spinner');
try
try
xdcResponse := await(xdwcComplaints.RawInvokeAsync('IApiService.GetComplaintList', []));
......@@ -182,7 +180,6 @@ begin
Utils.ShowErrorModal(E.Message);
end;
finally
HideSpinner('spinner');
FLoading := False;
end;
end;
......
......@@ -76,7 +76,6 @@ procedure TFViewEditUser.btnCancelClick(Sender: TObject);
// Cancels the edit or addition
begin
Info := 'Failure:Changes discarded!';
FViewMain.ShowUserForm(Info);
end;
procedure TFViewEditUser.btnCloseNotificationClick(Sender: TObject);
......@@ -222,7 +221,6 @@ begin
if (not Info.Contains('Failure')) then
begin
console.log('Navigating back to user list...');
FViewMain.ShowUserForm(Info);
end
else
begin
......
object FViewMain: TFViewMain
Width = 640
Height = 586
Width = 1208
Height = 810
CSSLibrary = cssBootstrap
ElementFont = efCSS
OnCreate = WebFormCreate
......@@ -16,18 +16,6 @@ object FViewMain: TFViewMain
Visible = False
WidthPercent = 100.000000000000000000
end
object wllblUserProfile: TWebLinkLabel
Left = 529
Top = 21
Width = 63
Height = 15
ElementID = 'dropdown.menu.userprofile'
Visible = False
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = wllblUserProfileClick
Caption = ' User Profile'
end
object wllblLogout: TWebLinkLabel
Left = 551
Top = 85
......@@ -61,7 +49,6 @@ object FViewMain: TFViewMain
Visible = False
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = lblCallsListClick
Caption = 'Calls'
end
object lblUsers: TWebLinkLabel
......@@ -74,7 +61,6 @@ object FViewMain: TFViewMain
Visible = False
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = lblUsersClick
Caption = 'Users'
end
object lblMainTitle: TWebLabel
......@@ -88,12 +74,12 @@ object FViewMain: TFViewMain
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object WebPanel1: TWebPanel
object pnlMain: TWebPanel
Left = 136
Top = 110
Width = 471
Height = 369
ElementID = 'main.webpanel'
ElementID = 'pnl_main'
ChildOrder = 3
TabOrder = 0
end
......@@ -108,7 +94,7 @@ object FViewMain: TFViewMain
end
object WebMemo1: TWebMemo
Left = 136
Top = 467
Top = 469
Width = 471
Height = 83
ElementID = 'main.debugmemo'
......@@ -162,6 +148,33 @@ object FViewMain: TFViewMain
WidthPercent = 100.000000000000000000
OnClick = btnUnitsClick
end
object pnlMap: TWebPanel
Left = 660
Top = 337
Width = 335
Height = 221
ElementID = 'pnl_map'
ChildOrder = 3
TabOrder = 6
end
object pnlUnits: TWebPanel
Left = 660
Top = 110
Width = 335
Height = 221
ElementID = 'pnl_units'
ChildOrder = 3
TabOrder = 7
end
object pnlComplaints: TWebPanel
Left = 660
Top = 574
Width = 335
Height = 221
ElementID = 'pnl_complaints'
ChildOrder = 3
TabOrder = 8
end
object xdwcBadgeCounts: TXDataWebClient
Connection = DMConnection.ApiConnection
Left = 44
......
......@@ -17,9 +17,10 @@
</nav>
<!-- Main content: fills space between navbars -->
<main id="main.webpanel" class="flex-grow-1 position-relative p-0 overflow-hidden" style="min-height:0;">
<!-- TWebPanel content gets injected here -->
</main>
<div id="pnl_main" class="flex-grow-1 position-relative p-0 overflow-hidden d-none" style="min-height:0;"></div>
<div id="pnl_map" class="flex-grow-1 position-relative p-0 overflow-hidden" style="min-height:0;"></div>
<div id="pnl_units" class="flex-grow-1 position-relative p-0 overflow-hidden d-none" style="min-height:0;"></div>
<div id="pnl_complaints" class="flex-grow-1 position-relative p-0 overflow-hidden d-none" style="min-height:0;"></div>
<!-- Bottom Nav -->
<nav class="navbar navbar-dark bg-primary py-2 flex-shrink-0">
......
......@@ -6,14 +6,13 @@ uses
System.SysUtils, System.Classes, JS, Web, WEBLib.Graphics, WEBLib.Controls,
WEBLib.Forms, WEBLib.Dialogs, WEBLib.ExtCtrls, Vcl.Controls, Vcl.StdCtrls,
WEBLib.StdCtrls, Data.DB, XData.Web.JsonDataset, XData.Web.Dataset,
App.Types, ConnectionModule, XData.Web.Client;
App.Types, ConnectionModule, XData.Web.Client, View.Map, View.Units, View.Complaints;
type
TFViewMain = class(TWebForm)
lblUsername: TWebLabel;
wllblUserProfile: TWebLinkLabel;
wllblLogout: TWebLinkLabel;
WebPanel1: TWebPanel;
pnlMain: TWebPanel;
WebMessageDlg1: TWebMessageDlg;
lblAppTitle: TWebLabel;
WebMemo1: TWebMemo;
......@@ -25,12 +24,12 @@ type
btnUnits: TWebButton;
tmrBadgeCounts: TWebTimer;
lblMainTitle: TWebLabel;
pnlMap: TWebPanel;
pnlUnits: TWebPanel;
pnlComplaints: TWebPanel;
procedure WebFormCreate(Sender: TObject);
procedure mnuLogoutClick(Sender: TObject);
procedure wllblUserProfileClick(Sender: TObject);
procedure wllblLogoutClick(Sender: TObject);
procedure lblCallsListClick(Sender: TObject);
procedure lblUsersClick(Sender: TObject);
procedure btnUnitsClick(Sender: TObject);
procedure btnComplaintsClick(Sender: TObject);
procedure btnMapClick(Sender: TObject);
......@@ -38,13 +37,11 @@ type
private
{ Private declarations }
FUserInfo: string;
FSearchSettings: string;
FChildForm: TWebForm;
FMapForm: TFViewMap;
FUnitsForm: TFViewUnits;
FComplaintsForm: TFViewComplaints;
FLogoutProc: TLogoutProc;
FSearchProc: TSearchProc;
procedure ShowCrudForm( AFormClass: TWebFormClass );
//procedure EditUser( AParam, BParam, CParam, DParam, EParam: string);
function GetUserInfo: string;
[async] procedure RefreshBadgesAsync;
procedure ShowUnitDetails(UnitId: string);
procedure SetHeaderTitle(const title: string);
......@@ -52,12 +49,12 @@ type
{ Public declarations }
class procedure Display(LogoutProc: TLogoutProc);
procedure ShowForm( AFormClass: TWebFormClass );
procedure EditUser( Mode, FullName, Username, Phone, Email: string; admin, active: boolean);
procedure ShowUserForm(Info: string);
procedure ShowComplaintDetails(ComplaintId: string);
procedure SetActiveNavButton(const BtnId: string);
procedure ShowMapFocusUnit(const unitId: string);
procedure ShowMapFocusComplaint(const complaintId: string);
procedure HidePanel(aPanel: TWebPanel);
procedure ShowPanel(aPanel: TWebPanel);
end;
var
......@@ -69,10 +66,7 @@ uses
Auth.Service,
View.Login,
View.UserProfile,
View.Map,
View.Complaints,
View.ComplaintDetails,
View.Units,
View.Admin,
View.Users,
View.EditUser,
......@@ -85,7 +79,6 @@ procedure TFViewMain.WebFormCreate(Sender: TObject);
var
userName: string;
begin
FUserInfo := GetUserInfo;
userName := JS.toString(AuthService.TokenPayload.Properties['user_name']);
lblUsername.Caption := ' ' + userName.ToLower + ' ';
FChildForm := nil;
......@@ -93,7 +86,6 @@ begin
lblUsers.Visible := false;
Utils.HideSpinner('spinner');
ShowForm(TFViewMap);
SetHeaderTitle('Map');
RefreshBadgesAsync;
end;
......@@ -108,16 +100,6 @@ begin
end;
procedure TFViewMain.lblUsersClick(Sender: TObject);
begin
ShowForm(TFViewUsers);
end;
procedure TFViewMain.lblCallsListClick(Sender: TObject);
begin
ShowForm(TFViewComplaints);
end;
procedure TFViewMain.mnuLogoutClick(Sender: TObject);
begin
FLogoutProc;
......@@ -130,55 +112,24 @@ begin
end;
procedure TFViewMain.wllblUserProfileClick(Sender: TObject);
begin
ShowCrudForm(TFViewUserProfile);
end;
function TFViewMain.GetUserInfo: string;
var
userStr: string;
begin
userStr := '?username=' + JS.toString(AuthService.TokenPayload.Properties['user_name']);
userStr := userStr + '&fullname=' + JS.toString(AuthService.TokenPayload.Properties['user_fullname']);
userStr := userStr + '&agency=' + JS.toString(AuthService.TokenPayload.Properties['user_agency']);
userStr := userStr + '&badge=' + JS.toString(AuthService.TokenPayload.Properties['user_badge']);
userStr := userStr + '&userid=' + JS.toString(AuthService.TokenPayload.Properties['user_id']);
userStr := userStr + '&personnelid=' + JS.toString(AuthService.TokenPayload.Properties['user_personnelid']);
Result := userStr;
end;
procedure TFViewMain.btnComplaintsClick(Sender: TObject);
begin
SetHeaderTitle('Complaints');
SetActiveNavButton('view.main.btncomplaints');
ShowForm(TFViewComplaints);
if (FChildForm is TFViewComplaints) then
TFViewComplaints(FChildForm).OnShowDetails :=
procedure(AComplaintId: string)
begin
ShowComplaintDetails(AComplaintId);
end;
end;
procedure TFViewMain.btnMapClick(Sender: TObject);
begin
SetHeaderTitle('Map');
SetActiveNavButton('view.main.btnmap');
ShowForm(TFViewMap);
end;
procedure TFViewMain.btnUnitsClick(Sender: TObject);
begin
SetHeaderTitle('Units');
SetActiveNavButton('view.main.btnunits');
ShowForm(TFViewUnits);
end;
class procedure TFViewMain.Display(LogoutProc: TLogoutProc);
begin
if Assigned(FViewMain) then
......@@ -188,47 +139,122 @@ begin
end;
procedure TFViewMain.ShowCrudForm(AFormClass: TWebFormClass);
procedure TFViewMain.ShowForm(AFormClass: TWebFormClass);
begin
ShowForm(AFormClass);
end;
// Map (cached in pnlMapHost -> ElementID = 'pnl_map')
if AFormClass = TFViewMap then
begin
HidePanel(pnlMain);
HidePanel(pnlUnits);
HidePanel(pnlComplaints);
ShowPanel(pnlMap);
SetHeaderTitle('Map');
SetActiveNavButton('view.main.btnmap');
if not Assigned(FMapForm) then
Application.CreateForm(TFViewMap, pnlMap.ElementID, TWebForm(FMapForm));
FChildForm := FMapForm;
Exit;
end;
if AFormClass = TFViewUnits then
begin
HidePanel(pnlMain);
HidePanel(pnlMap);
HidePanel(pnlComplaints);
ShowPanel(pnlUnits);
procedure TFViewMain.ShowForm(AFormClass: TWebFormClass);
begin
if Assigned(FChildForm) then
SetHeaderTitle('Units');
SetActiveNavButton('view.main.btnunits');
if not Assigned(FUnitsForm) then
Application.CreateForm(TFViewUnits, pnlUnits.ElementID, TWebForm(FUnitsForm));
FChildForm := FUnitsForm;
Exit;
end;
if AFormClass = TFViewComplaints then
begin
HidePanel(pnlMain);
HidePanel(pnlMap);
HidePanel(pnlUnits);
ShowPanel(pnlComplaints);
SetHeaderTitle('Complaints');
SetActiveNavButton('view.main.btncomplaints');
if not Assigned(FComplaintsForm) then
Application.CreateForm(TFViewComplaints, pnlComplaints.ElementID, TWebForm(FComplaintsForm));
FChildForm := FComplaintsForm;
Exit;
end;
// Everything else: use pnlMain
HidePanel(pnlMap);
HidePanel(pnlUnits);
HidePanel(pnlComplaints);
ShowPanel(pnlMain);
if Assigned(FChildForm) and (FChildForm <> FMapForm) and (FChildForm <> FUnitsForm) and (FChildForm <> FComplaintsForm) then
FChildForm.Free;
Application.CreateForm(AFormClass, WebPanel1.ElementID, FChildForm);
Application.CreateForm(AFormClass, pnlMain.ElementID, FChildForm);
end;
procedure TFViewMain.EditUser( Mode, FullName, Username, Phone, Email: string; Admin, Active: boolean);
procedure TFViewMain.HidePanel(aPanel: TWebPanel);
var
el: TJSHTMLElement;
begin
if Assigned(FChildForm) then
FChildForm.Free;
FChildForm := TFViewEditUser.CreateForm(WebPanel1.ElementID, Mode, FullName, Username, Phone, Email, Admin, Active);
if (aPanel = nil) or (aPanel.ElementHandle = nil) then
Exit;
el := TJSHTMLElement(aPanel.ElementHandle);
el.classList.add('d-none');
end;
procedure TFViewMain.ShowUserForm(Info: string);
procedure TFViewMain.ShowPanel(aPanel: TWebPanel);
var
el: TJSHTMLElement;
begin
if Assigned(FChildForm) then
FChildForm.Free;
FChildForm := TFViewUsers.CreateForm(WebPanel1.ElementID, Info);
if (aPanel = nil) or (aPanel.ElementHandle = nil) then
Exit;
el := TJSHTMLElement(aPanel.ElementHandle);
el.classList.remove('d-none');
end;
procedure TFViewMain.ShowComplaintDetails(ComplaintId: string);
begin
SetHeaderTitle('Complaint Details');
if Assigned(FChildForm) then
HidePanel(pnlMap);
HidePanel(pnlUnits);
HidePanel(pnlComplaints);
ShowPanel(pnlMain);
if Assigned(FChildForm) and (FChildForm <> FMapForm) and (FChildForm <> FUnitsForm) and (FChildForm <> FComplaintsForm) then
FChildForm.Free;
FChildForm := TFViewComplaintDetails.CreateForm(WebPanel1.ElementID, ComplaintId);
FChildForm := TFViewComplaintDetails.CreateForm(pnlMain.ElementID, ComplaintId);
end;
procedure TFViewMain.ShowUnitDetails(UnitId: string);
begin
SetHeaderTitle('Unit Details');
if Assigned(FChildForm) then
HidePanel(pnlMap);
HidePanel(pnlUnits);
HidePanel(pnlComplaints);
ShowPanel(pnlMain);
if Assigned(FChildForm) and (FChildForm <> FMapForm) and (FChildForm <> FUnitsForm) and (FChildForm <> FComplaintsForm) then
FChildForm.Free;
FChildForm := TFViewUnitDetails.CreateForm(WebPanel1.ElementID, UnitId);
FChildForm := TFViewUnitDetails.CreateForm(pnlMain.ElementID, UnitId);
end;
......@@ -296,8 +322,6 @@ procedure TFViewMain.ShowMapFocusUnit(const unitId: string);
var
pendingUnitId: string;
begin
SetHeaderTitle('Map');
SetActiveNavButton('view.main.btnmap');
ShowForm(TFViewMap);
pendingUnitId := unitId;
......@@ -314,8 +338,6 @@ procedure TFViewMain.ShowMapFocusComplaint(const complaintId: string);
var
pendingComplaintId: string;
begin
SetHeaderTitle('Map');
SetActiveNavButton('view.main.btnmap');
ShowForm(TFViewMap);
pendingComplaintId := complaintId;
......
......@@ -70,20 +70,16 @@ begin
httpReqGeoJson.Execute;
asm
window.showComplaintDetails = function (id) {
console.log('JS bridge showComplaintDetails called, id=', id);
try {
pas['View.Main'].FViewMain.ShowComplaintDetails(id);
} catch (e) {
console.log('Error in TFViewMain.ShowComplaintDetails', e);
}
};
window.showUnitDetails = function (id) {
console.log('JS bridge showUnitDetails called, id=', id);
try {
pas['View.Main'].FViewMain.ShowUnitDetails(id);
} catch (e) {
console.log('Error in TFViewMain.ShowUnitDetails', e);
}
};
end;
......@@ -155,9 +151,7 @@ begin
try
lfMap.Polygons.Clear;
Console.Log('GeoJSON len=' + AResponse.Length.ToString);
lfMap.LoadGeoJSONFromText(AResponse, True, Trim(FPendingUnitId) = '');
Console.Log('Loaded polygons count=' + lfMap.Polygons.Count.ToString);
for i := 0 to lfMap.Polygons.Count - 1 do
begin
......@@ -404,7 +398,6 @@ begin
'</div>';
m.DataString := 'unit|' + unitId;
console.log('Unit marker ds=' + m.DataString);
m.IconURL := CarIconForDistrict(dist);
end;
end;
......@@ -662,6 +655,13 @@ begin
coord := CreateCoordinate(userLocationMarker.Latitude, userLocationMarker.Longitude);
lfMap.SetCenterCoordinate(coord);
FPendingFocusCoord := coord;
FPendingFocusZoom := 17;
FDoFocusZoom := True;
tmrLocate.Interval := 250;
tmrLocate.Enabled := True;
end;
......
......@@ -132,7 +132,6 @@ begin
FLoading := True;
console.log('GetUnits: Invoking API...');
Utils.ShowSpinner('spinner');
try
try
xdcResponse := await(xdwcUnits.RawInvokeAsync('IApiService.GetUnitList', []));
......@@ -141,27 +140,21 @@ begin
respObj := TJSObject(xdcResponse.Result);
xdwdsUnits.Close;
console.log('Units dataset closed');
xdwdsUnits.SetJsonData(respObj['data']);
console.log('JsonData set on units dataset:', respObj['data']);
xdwdsUnits.Open;
console.log('Units dataset opened. Record count:', xdwdsUnits.RecordCount);
unitCount := Integer(respObj['count']);
lblEntries.Caption := Format('%d units', [unitCount]);
console.log('Units label updated:', lblEntries.Caption);
except
on E: EXDataClientRequestException do
begin
console.log('XData exception (units):', E.ErrorResult.ErrorMessage);
Utils.ShowErrorModal(E.ErrorResult.ErrorMessage);
end;
end;
finally
FLoading := False;
Utils.HideSpinner('spinner');
console.log('GetUnits complete');
end;
end;
......
......@@ -150,7 +150,6 @@ begin
isActive := false
else
isActive := true;
FViewMain.EditUser('Edit', Username.innerText, FullName.innerText, PhoneNum.innerText, Email.innerText, isAdmin, isActive);
end;
......@@ -483,8 +482,7 @@ end;
procedure TFViewUsers.btnAddUserClick(Sender: TObject);
begin
//Info := '';
FViewMain.EditUser('Add', '', '', '', '', false, true);
//Info := '';mm
end;
procedure TFViewUsers.btnCloseNotificationClick(Sender: TObject);
......
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