Commit de1aebb1 by Mac Stephens

wip from old vm

parent 1d985813
......@@ -7,27 +7,27 @@ object ApiDatabaseModule: TApiDatabaseModule
SpecificOptions.Strings = (
'PostgreSQL.Schema=envoy')
LoginPrompt = False
Left = 77
Top = 137
Left = 35
Top = 29
end
object PostgreSQLUniProvider1: TPostgreSQLUniProvider
Left = 228
Top = 138
Left = 180
Top = 30
end
object UniQuery1: TUniQuery
Connection = ucEnvoy
SQL.Strings = (
'')
Left = 363
Top = 138
Left = 351
Top = 34
end
object OracleUniProvider1: TOracleUniProvider
Left = 226
Top = 236
Left = 182
Top = 98
end
object uqBooking: TUniQuery
Left = 374
Top = 222
Left = 350
Top = 98
end
object uqMapUnits: TUniQuery
Connection = ucENTCAD
......@@ -41,8 +41,8 @@ object ApiDatabaseModule: TApiDatabaseModule
' uc.GPS_LONGITUDE'
'FROM UNITS_CURRENT@AVL_LINK uc')
ReadOnly = True
Left = 366
Top = 306
Left = 470
Top = 414
object uqMapUnitsENTRYID: TFloatField
FieldName = 'ENTRYID'
end
......@@ -125,8 +125,8 @@ object ApiDatabaseModule: TApiDatabaseModule
''
'')
ReadOnly = True
Left = 446
Top = 394
Left = 278
Top = 322
object uqUnitListUNITID: TFloatField
FieldName = 'UNITID'
end
......@@ -241,8 +241,8 @@ object ApiDatabaseModule: TApiDatabaseModule
'WHERE ca.COMPLAINTID = :COMPLAINTID'
'ORDER BY ca.DATEDISPATCHED')
ReadOnly = True
Left = 256
Top = 308
Left = 470
Top = 356
ParamData = <
item
DataType = ftUnknown
......@@ -290,8 +290,8 @@ object ApiDatabaseModule: TApiDatabaseModule
'WHERE cm.CFSID = :CFSID'
'ORDER BY cm.TIMESTAMP ASC')
ReadOnly = True
Left = 284
Top = 388
Left = 278
Top = 382
ParamData = <
item
DataType = ftUnknown
......@@ -375,8 +375,8 @@ object ApiDatabaseModule: TApiDatabaseModule
'')
ReadOnly = True
OnCalcFields = uqComplaintListCalcFields
Left = 76
Top = 324
Left = 94
Top = 320
object uqComplaintListCOMPLAINTID: TFloatField
FieldName = 'COMPLAINTID'
Required = True
......@@ -507,31 +507,15 @@ object ApiDatabaseModule: TApiDatabaseModule
object uqComplaintDetails: TUniQuery
Connection = ucENTCAD
SQL.Strings = (
'-- uqComplaintActive_Detail'
'SELECT'
' ca.COMPLAINTID,'
' ca.CFSID,'
' ca.COMPLAINT,'
' ca.AGENCY,'
' ca.PRIORITY,'
' ca.DISPATCHCODE,'
' cdc.CODE_DESC AS DISPATCH_CODE_DESC,'
' ca.SOURCE,'
' ccs.CODE_DESC AS SOURCE_DESC,'
' ca.PRIORITY,'
' ca.ADDRESSID,'
' ca.ADDRESS,'
' ca.APARTMENT,'
' ca.CITY,'
' ca.BUSINESS,'
' ca.DISPATCHDISTRICT,'
' ca.DISPATCHSECTOR,'
' ca.ADDRESSDISTRICT,'
' ca.ADDRESSSECTOR,'
' ca.XCOORD,'
' ca.YCOORD,'
' ca.WARNINGS,'
' ca.CONTACTS,'
' ca.HISTORY,'
' ca.ADDRESS,'
' ct.DATEREPORTED,'
' ct.DATERECEIVED,'
' ct.DATEDISPATCHED,'
......@@ -541,10 +525,10 @@ object ApiDatabaseModule: TApiDatabaseModule
'FROM COMPLAINT_ACTIVE ca'
'JOIN COMPLAINT_TIMES ct ON ca.COMPLAINTID = ct.COMPLAINTID'
'LEFT JOIN CD_DISPATCHCODES cdc ON ca.DISPATCHCODE = cdc.CODE'
'LEFT JOIN CD_CALLSOURCES ccs ON ca.SOURCE = ccs.CODE'
'WHERE ca.COMPLAINTID = :COMPLAINTID')
'WHERE ca.COMPLAINTID = :COMPLAINTID;'
'')
ReadOnly = True
Left = 74
Left = 92
Top = 376
ParamData = <
item
......@@ -563,8 +547,8 @@ object ApiDatabaseModule: TApiDatabaseModule
FieldName = 'COMPLAINT'
Size = 10
end
object uqComplaintDetailsAGENCY: TStringField
FieldName = 'AGENCY'
object uqComplaintDetailsPRIORITY: TStringField
FieldName = 'PRIORITY'
Size = 6
end
object uqComplaintDetailsDISPATCHCODE: TStringField
......@@ -576,68 +560,14 @@ object ApiDatabaseModule: TApiDatabaseModule
ReadOnly = True
Size = 60
end
object uqComplaintDetailsSOURCE: TStringField
FieldName = 'SOURCE'
Size = 6
end
object uqComplaintDetailsSOURCE_DESC: TStringField
FieldName = 'SOURCE_DESC'
ReadOnly = True
Size = 120
end
object uqComplaintDetailsPRIORITY: TStringField
FieldName = 'PRIORITY'
object uqComplaintDetailsDISPATCHDISTRICT: TStringField
FieldName = 'DISPATCHDISTRICT'
Size = 6
end
object uqComplaintDetailsADDRESSID: TFloatField
FieldName = 'ADDRESSID'
end
object uqComplaintDetailsADDRESS: TStringField
FieldName = 'ADDRESS'
Size = 64
end
object uqComplaintDetailsAPARTMENT: TStringField
FieldName = 'APARTMENT'
Size = 6
end
object uqComplaintDetailsCITY: TStringField
FieldName = 'CITY'
end
object uqComplaintDetailsBUSINESS: TStringField
FieldName = 'BUSINESS'
Size = 35
end
object uqComplaintDetailsDISPATCHDISTRICT: TStringField
FieldName = 'DISPATCHDISTRICT'
Size = 6
end
object uqComplaintDetailsDISPATCHSECTOR: TStringField
FieldName = 'DISPATCHSECTOR'
Size = 6
end
object uqComplaintDetailsADDRESSDISTRICT: TStringField
FieldName = 'ADDRESSDISTRICT'
Size = 5
end
object uqComplaintDetailsADDRESSSECTOR: TStringField
FieldName = 'ADDRESSSECTOR'
Size = 5
end
object uqComplaintDetailsXCOORD: TFloatField
FieldName = 'XCOORD'
end
object uqComplaintDetailsYCOORD: TFloatField
FieldName = 'YCOORD'
end
object uqComplaintDetailsWARNINGS: TFloatField
FieldName = 'WARNINGS'
end
object uqComplaintDetailsCONTACTS: TFloatField
FieldName = 'CONTACTS'
end
object uqComplaintDetailsHISTORY: TFloatField
FieldName = 'HISTORY'
end
object uqComplaintDetailsDATEREPORTED: TDateTimeField
FieldName = 'DATEREPORTED'
ReadOnly = True
......@@ -668,9 +598,10 @@ object ApiDatabaseModule: TApiDatabaseModule
Port = 1521
Username = 'ENTCAD'
Server = 'BUFENTCAD'
Connected = True
LoginPrompt = False
Left = 76
Top = 244
Left = 36
Top = 98
EncryptedPassword = 'BAFFB1FFABFFBCFFBEFFBBFF'
end
object uqMapComplaints: TUniQuery
......@@ -715,8 +646,8 @@ object ApiDatabaseModule: TApiDatabaseModule
'')
ReadOnly = True
OnCalcFields = uqMapComplaintsCalcFields
Left = 476
Top = 308
Left = 470
Top = 296
object uqMapComplaintsCOMPLAINTID: TFloatField
FieldName = 'COMPLAINTID'
Required = True
......@@ -756,4 +687,30 @@ object ApiDatabaseModule: TApiDatabaseModule
Calculated = True
end
end
object uqBadgeCounts: TUniQuery
Connection = ucENTCAD
SQL.Strings = (
'select'
' (select count(*)'
' from COMPLAINT_ACTIVE ca'
' join COMPLAINT_TIMES ct on ct.COMPLAINTID = ca.COMPLAINTID'
' where ca.COMPLAINT is not null) as Complaints,'
''
' (select count(distinct dua.UNITID)'
' from DIS_UNIT_ACTIVE dua) as Units'
'from dual;'
'')
ReadOnly = True
Active = True
Left = 194
Top = 270
object uqBadgeCountsCOMPLAINTS: TFloatField
FieldName = 'COMPLAINTS'
ReadOnly = True
end
object uqBadgeCountsUNITS: TFloatField
FieldName = 'UNITS'
ReadOnly = True
end
end
end
......@@ -49,35 +49,6 @@ type
uqComplaintListDATERESPONDED: TDateTimeField;
uqComplaintListDATEARRIVED: TDateTimeField;
uqComplaintListDATECLEARED: TDateTimeField;
uqComplaintDetailsCOMPLAINTID: TFloatField;
uqComplaintDetailsCFSID: TFloatField;
uqComplaintDetailsCOMPLAINT: TStringField;
uqComplaintDetailsAGENCY: TStringField;
uqComplaintDetailsDISPATCHCODE: TStringField;
uqComplaintDetailsDISPATCH_CODE_DESC: TStringField;
uqComplaintDetailsSOURCE: TStringField;
uqComplaintDetailsSOURCE_DESC: TStringField;
uqComplaintDetailsPRIORITY: TStringField;
uqComplaintDetailsADDRESSID: TFloatField;
uqComplaintDetailsADDRESS: TStringField;
uqComplaintDetailsAPARTMENT: TStringField;
uqComplaintDetailsCITY: TStringField;
uqComplaintDetailsBUSINESS: TStringField;
uqComplaintDetailsDISPATCHDISTRICT: TStringField;
uqComplaintDetailsDISPATCHSECTOR: TStringField;
uqComplaintDetailsADDRESSDISTRICT: TStringField;
uqComplaintDetailsADDRESSSECTOR: TStringField;
uqComplaintDetailsXCOORD: TFloatField;
uqComplaintDetailsYCOORD: TFloatField;
uqComplaintDetailsWARNINGS: TFloatField;
uqComplaintDetailsCONTACTS: TFloatField;
uqComplaintDetailsHISTORY: TFloatField;
uqComplaintDetailsDATEREPORTED: TDateTimeField;
uqComplaintDetailsDATERECEIVED: TDateTimeField;
uqComplaintDetailsDATEDISPATCHED: TDateTimeField;
uqComplaintDetailsDATERESPONDED: TDateTimeField;
uqComplaintDetailsDATEARRIVED: TDateTimeField;
uqComplaintDetailsDATECLEARED: TDateTimeField;
uqComplaintUnitsCOMPLAINTID: TFloatField;
uqComplaintUnitsUNITID: TFloatField;
uqComplaintUnitsUNITNAME: TStringField;
......@@ -133,6 +104,23 @@ type
uqMapComplaintsDISPATCHCODECATEGORY: TStringField;
uqMapComplaintspriorityKey: TStringField;
uqMapComplaintspngName: TStringField;
uqBadgeCounts: TUniQuery;
uqBadgeCountsCOMPLAINTS: TFloatField;
uqBadgeCountsUNITS: TFloatField;
uqComplaintDetailsCOMPLAINTID: TFloatField;
uqComplaintDetailsCFSID: TFloatField;
uqComplaintDetailsCOMPLAINT: TStringField;
uqComplaintDetailsPRIORITY: TStringField;
uqComplaintDetailsDISPATCHCODE: TStringField;
uqComplaintDetailsDISPATCH_CODE_DESC: TStringField;
uqComplaintDetailsDISPATCHDISTRICT: TStringField;
uqComplaintDetailsADDRESS: TStringField;
uqComplaintDetailsDATEREPORTED: TDateTimeField;
uqComplaintDetailsDATERECEIVED: TDateTimeField;
uqComplaintDetailsDATEDISPATCHED: TDateTimeField;
uqComplaintDetailsDATERESPONDED: TDateTimeField;
uqComplaintDetailsDATEARRIVED: TDateTimeField;
uqComplaintDetailsDATECLEARED: TDateTimeField;
procedure DataModuleCreate(Sender: TObject);
procedure uqComplaintListCalcFields(DataSet: TDataSet);
procedure uqMapComplaintsCalcFields(DataSet: TDataSet);
......@@ -141,6 +129,7 @@ type
public
function DerivePriorityKeyFromPriorityString(const priorityString: string): string;
function HandleUniqueFilenames(const category: string): string;
function BadgeCounts(const BaseQuery: TUniQuery): Integer;
class procedure ExecSQL(const SQL: string);
end;
......@@ -282,4 +271,28 @@ begin
Result := '5-9';
end;
function TApiDatabaseModule.BadgeCounts(const BaseQuery: TUniQuery): Integer;
var
Q: TUniQuery;
WrappedSQL: string;
begin
Q := TUniQuery.Create(nil);
try
Q.Connection := BaseQuery.Connection;
// Wrap the original query text in a COUNT(*) shell
WrappedSQL := 'select count(*) as CNT from (' + BaseQuery.SQL.Text + ') t';
Q.SQL.Text := WrappedSQL;
// Carry over params (if the base query uses any)
Q.Params.AssignValues(BaseQuery.Params);
Q.Open;
Result := Q.Fields[0].AsInteger;
finally
Q.Free;
end;
end;
end.
......@@ -16,10 +16,12 @@ type
[ServiceContract, Model(API_MODEL)]
IApiService = interface(IInvokable)
['{4FCB7FAF-44E5-49D6-9C0F-EE44BFB33313}']
[HttpGet] function GetBadgeCounts: TJSONObject;
[HttpGet] function GetComplaintList: TJSONObject;
[HttpGet] function GetUnitList: TJSONObject;
[HttpGet] function GetComplaintMap: TJSONObject;
[HttpGet] function GetUnitMap: TJSONObject;
[HttpGet] function GetComplaintDetails(const ComplaintId: string): TJSONObject;
end;
implementation
......
......@@ -17,10 +17,12 @@ type
procedure AfterConstruction; override;
procedure BeforeDestruction; override;
public
function GetBadgeCounts: TJSONObject;
function GetComplaintList: TJSONObject;
function GetUnitList: TJSONObject;
function GetComplaintMap: TJSONObject;
function GetUnitMap: TJSONObject;
function GetComplaintDetails(const ComplaintId: string): TJSONObject;
end;
implementation
......@@ -43,6 +45,36 @@ begin
end;
function TApiService.GetBadgeCounts: TJSONObject;
begin
Logger.Log(3, '---TApiService.GetBadgeCounts initiated');
Result := TJSONObject.Create;
TXDataOperationContext.Current.Handler.ManagedObjects.Add(Result);
try
with ApiDB.uqBadgeCounts do
begin
Open;
try
// NOTE: your TUniQuery exposes fields named COMPLAINTS and UNITS
Result.AddPair('BadgeComplaints', TJSONNumber.Create(FieldByName('COMPLAINTS').AsInteger));
Result.AddPair('BadgeUnits', TJSONNumber.Create(FieldByName('UNITS').AsInteger));
finally
Close;
end;
end;
except
on E: Exception do
begin
Logger.Log(3, '---TApiService.GetBadgeCounts End (error): ' + E.Message);
raise EXDataHttpException.Create(500, 'Failed to load badge counts');
end;
end;
Logger.Log(3, '---TApiService.GetBadgeCounts End');
end;
function TApiService.GetComplaintMap: TJSONObject;
var
data: TJSONArray;
......@@ -316,6 +348,71 @@ end;
function TApiService.GetComplaintDetails(const ComplaintId: string): TJSONObject;
var
obj: TJSONObject;
begin
Logger.Log(3,'---TApiService.GetComplaintDetails initiated: '+ComplaintId);
Result := TJSONObject.Create;
TXDataOperationContext.Current.Handler.ManagedObjects.Add(Result);
try
with ApiDB.uqComplaintDetails do
begin
ParamByName('COMPLAINTID').AsString := ComplaintId;
Open;
try
if Eof then raise EXDataHttpException.Create(404,'Complaint not found');
obj := TJSONObject.Create;
obj.AddPair('ComplaintId',FieldByName('COMPLAINTID').AsString);
obj.AddPair('CFSId',FieldByName('CFSID').AsString);
obj.AddPair('Complaint',FieldByName('COMPLAINT').AsString);
obj.AddPair('Priority',FieldByName('PRIORITY').AsString);
obj.AddPair('DispatchCode',FieldByName('DISPATCHCODE').AsString);
obj.AddPair('DispatchCodeDesc',FieldByName('DISPATCH_CODE_DESC').AsString);
obj.AddPair('DispatchDistrict',FieldByName('DISPATCHDISTRICT').AsString);
obj.AddPair('Address',FieldByName('ADDRESS').AsString);
if FieldByName('DATEREPORTED').IsNull
then obj.AddPair('DateReported','')
else obj.AddPair('DateReported',FormatDateTime('yyyy-mm-dd hh:nn:ss',(FieldByName('DATEREPORTED') as TDateTimeField).AsDateTime));
if FieldByName('DATERECEIVED').IsNull
then obj.AddPair('DateReceived','')
else obj.AddPair('DateReceived',FormatDateTime('yyyy-mm-dd hh:nn:ss',(FieldByName('DATERECEIVED') as TDateTimeField).AsDateTime));
if FieldByName('DATEDISPATCHED').IsNull
then obj.AddPair('DateDispatched','')
else obj.AddPair('DateDispatched',FormatDateTime('yyyy-mm-dd hh:nn:ss',(FieldByName('DATEDISPATCHED') as TDateTimeField).AsDateTime));
if FieldByName('DATERESPONDED').IsNull
then obj.AddPair('DateResponded','')
else obj.AddPair('DateResponded',FormatDateTime('yyyy-mm-dd hh:nn:ss',(FieldByName('DATERESPONDED') as TDateTimeField).AsDateTime));
if FieldByName('DATEARRIVED').IsNull
then obj.AddPair('DateArrived','')
else obj.AddPair('DateArrived',FormatDateTime('yyyy-mm-dd hh:nn:ss',(FieldByName('DATEARRIVED') as TDateTimeField).AsDateTime));
if FieldByName('DATECLEARED').IsNull
then obj.AddPair('DateCleared','')
else obj.AddPair('DateCleared',FormatDateTime('yyyy-mm-dd hh:nn:ss',(FieldByName('DATECLEARED') as TDateTimeField).AsDateTime));
Result.AddPair('data',obj);
finally
Close;
end;
end;
except
on E: EXDataHttpException do
begin
Logger.Log(3,'---TApiService.GetComplaintDetails not found');
raise;
end;
on E: Exception do
begin
Logger.Log(3,'---TApiService.GetComplaintDetails error: '+E.Message);
raise EXDataHttpException.Create(500,'Failed to load complaint details');
end;
end;
Logger.Log(3,'---TApiService.GetComplaintDetails End');
end;
initialization
......
......@@ -4,7 +4,6 @@ object AuthDatabase: TAuthDatabase
Height = 249
Width = 433
object uq: TUniQuery
Connection = ucEnvoy
SQL.Strings = (
'select * from users')
FetchRows = 100
......@@ -52,14 +51,6 @@ object AuthDatabase: TAuthDatabase
Left = 249
Top = 45
end
object ucEnvoy: TUniConnection
ProviderName = 'PostgreSQL'
SpecificOptions.Strings = (
'PostgreSQL.Schema=envoy')
LoginPrompt = False
Left = 43
Top = 79
end
object PostgreSQLUniProvider1: TPostgreSQLUniProvider
Left = 276
Top = 156
......
......@@ -10,7 +10,6 @@ type
TAuthDatabase = class(TDataModule)
uq: TUniQuery;
uqMisc: TUniQuery;
ucEnvoy: TUniConnection;
PostgreSQLUniProvider1: TPostgreSQLUniProvider;
uquser_id: TLargeintField;
uqusername: TStringField;
......@@ -55,22 +54,12 @@ var
begin
iniFile := TIniFile.Create(ChangeFileExt(Application.ExeName, '.ini'));
try
ucEnvoy.Server := iniFile.ReadString('Database', 'Server', '');
ucEnvoy.Database := iniFile.ReadString('Database', 'Database', '');
ucEnvoy.Username := iniFile.ReadString('Database', 'Username', '');
ucEnvoy.Password := iniFile.ReadString('Database', 'Password', '');
ucBooking.Server := IniFile.ReadString('EMB Database', 'Server', 'EMBOOKING');
ucBooking.Username := IniFile.ReadString('EMB Database', 'Username', 'emBooking');
ucBooking.Password := IniFile.ReadString('EMB Database', 'Password', 'embook01');
try
Logger.Log(2, '');
Logger.Log(2, 'Connecting to envoyCalls Database...');
Logger.Log(2, Format('--ucEnvoy.Server: %s ucEnvoy.Username: %s', [ucEnvoy.Server, ucEnvoy.Username]));
if not ucEnvoy.Connected then
ucEnvoy.Connect;
Logger.Log(2, '--ucEnvoy connected!');
Logger.Log(2, '');
Logger.Log(2, 'Connecting to emBooking Database...');
if not ucBooking.Connected then
ucBooking.Connect;
......@@ -104,7 +93,6 @@ end;
procedure TAuthDatabase.DataModuleDestroy(Sender: TObject);
begin
ucEnvoy.Connected := false;
ucBooking.Connected := false;
end;
......
......@@ -282,4 +282,5 @@ begin
Result := uq.FieldByName('surname').AsString + ', ' + uq.FieldByName('given1').AsString + ' (' + uq.FieldByName('empno').AsString + ')';
end;
end.
[Settings]
LogFileNum=484
LogFileNum=493
webClientVersion=0.1.0
TwilioUpdateTime=0
......
object FViewComplaintDetails: TFViewComplaintDetails
Width = 640
Height = 480
end
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>TMS Web Project</title>
<style>
</style>
</head>
<body>
</body>
</html>
\ No newline at end of file
unit View.ComplaintDetails;
interface
uses
System.SysUtils, System.Classes, JS, Web, WEBLib.Graphics, WEBLib.Controls,
WEBLib.Forms, WEBLib.Dialogs;
type
TFViewComplaintDetails = class(TWebForm)
private
{ Private declarations }
public
{ Public declarations }
end;
var
FViewComplaintDetails: TFViewComplaintDetails;
implementation
{$R *.dfm}
end.
\ No newline at end of file
......@@ -11,6 +11,7 @@ object FViewComplaints: TFViewComplaints
ParentFont = False
Visible = True
OnCreate = WebFormCreate
OnDestroy = WebFormDestroy
object lblEntries: TWebLabel
Left = 44
Top = 88
......@@ -84,15 +85,20 @@ object FViewComplaints: TFViewComplaints
Style = lsListGroup
DataSource = wdsComplaints
ItemTemplate =
'<div class="list-section-header small fw-semibold bg-secondary t' +
'ext-white rounded-1 px-2 mb-1"> (%DistrictHeader%)</div><div cl' +
'ass="card border shadow-sm" style="--bs-card-bg:(%PriorityCo' +
'lor%); --bs-card-color:(%PriorityTextColor%);"> <div class="car' +
'd-body py-2 px-3"> <div class="fw-bold text-uppercase small">' +
'(%Priority%): (%DispatchCodeDesc%)</div> <div class="small">(' +
'%Address%)</div> <div class="small text-opacity-75">(%Complai' +
'nt%): (%Status%)&nbsp;&nbsp;(%DistrictSector%)</div> <div cla' +
'ss="small text-opacity-75">(%DateReported%)</div> </div></div>'
'<div class="list-section-header small fw-semibold bg-secondary ' +
'text-white rounded-1 px-2 mb-1"> (%DistrictHeader%)</div><div ' +
'class="card border shadow-sm" style=" --bs-card-bg: (%Priori' +
'tyColor%); --bs-card-color: (%PriorityTextColor%); "> <div ' +
'class="card-body py-2 px-3"> <div class="fw-bold text-upperca' +
'se small"> (%Priority%): (%DispatchCodeDesc%) </div> ' +
'<div class="small">(%Address%)</div> <div class="small text-o' +
'pacity-75"> (%Complaint%): (%Status%)&nbsp;&nbsp;(%District' +
'Sector%) </div> <div class="small text-opacity-75">(%DateR' +
'eported%)</div> <div class="d-flex justify-content-end mt-2' +
'"> <button type="button" class="btn btn-li' +
'ght btn-sm complaint-details-btn" data-id="(%Comp' +
'laintId%)"> Details </button> </div> </div' +
'></div>'
ListSource = wdsComplaints
end
object xdwcComplaints: TXDataWebClient
......
......@@ -38,10 +38,13 @@ type
procedure WebFormCreate(Sender: TObject);
procedure btnRefreshClick(Sender: TObject);
procedure tmrRefreshTimer(Sender: TObject);
procedure WebFormDestroy(Sender: TObject);
private
FLoading: Boolean;
[async] procedure GetComplaints;
procedure HandleListClick(e: TJSMouseEvent);
public
end;
var
......@@ -53,15 +56,30 @@ implementation
procedure TFViewComplaints.WebFormCreate(Sender: TObject);
begin
console.log('WebFormCreate: Starting setup...');
DMConnection.ApiConnection.Connected := True;
console.log('API connection active:', DMConnection.ApiConnection.Connected);
Document.addEventListener('click', @HandleListClick);
ShowSpinner('spinner');
tmrRefresh.Enabled := False;
GetComplaints;
tmrRefresh.Enabled := True;
end;
procedure TFViewComplaints.HandleListClick(e: TJSMouseEvent);
var el: TJSElement; id: string;
begin
el := TJSElement(e.target);
if (el is TJSHtmlElement) and TJSHtmlElement(el).classList.contains('complaint-details-btn') then
begin
id := string(TJSHtmlElement(el).dataset['id']); // comes from (%ComplaintId%)
e.preventDefault;
e.stopPropagation;
end;
end;
procedure TFViewComplaints.WebFormDestroy(Sender: TObject);
begin
Document.removeEventListener('click', @HandleListClick);
end;
//HTML for individual complaint cards can be found in the twebdblistcontrol HTMLString property
procedure TFViewComplaints.btnRefreshClick(Sender: TObject);
......
......@@ -151,9 +151,15 @@ object FViewMain: TFViewMain
WidthPercent = 100.000000000000000000
OnClick = btnUnitsClick
end
object XDataWebClient: TXDataWebClient
object xdwcBadgeCounts: TXDataWebClient
Connection = DMConnection.ApiConnection
Left = 44
Top = 280
end
object tmrBadgeCounts: TWebTimer
Interval = 30000
OnTimer = tmrBadgeCountsTimer
Left = 42
Top = 360
end
end
......@@ -17,12 +17,13 @@ type
WebMessageDlg1: TWebMessageDlg;
lblAppTitle: TWebLabel;
WebMemo1: TWebMemo;
XDataWebClient: TXDataWebClient;
xdwcBadgeCounts: TXDataWebClient;
lblCallsList: TWebLinkLabel;
lblUsers: TWebLinkLabel;
btnMap: TWebButton;
btnComplaints: TWebButton;
btnUnits: TWebButton;
tmrBadgeCounts: TWebTimer;
procedure WebFormCreate(Sender: TObject);
procedure mnuLogoutClick(Sender: TObject);
procedure wllblUserProfileClick(Sender: TObject);
......@@ -32,6 +33,7 @@ type
procedure btnUnitsClick(Sender: TObject);
procedure btnComplaintsClick(Sender: TObject);
procedure btnMapClick(Sender: TObject);
procedure tmrBadgeCountsTimer(Sender: TObject);
private
{ Private declarations }
FUserInfo: string;
......@@ -43,6 +45,7 @@ type
//procedure EditUser( AParam, BParam, CParam, DParam, EParam: string);
function GetUserInfo: string;
procedure SetActiveNavButton(const BtnId: string);
[async] procedure RefreshBadgesAsync;
public
{ Public declarations }
class procedure Display(LogoutProc: TLogoutProc);
......@@ -81,6 +84,7 @@ begin
lblUsers.Visible := false;
ShowForm(TFViewMap);
RefreshBadgesAsync;
end;
......@@ -181,6 +185,7 @@ begin
FChildForm := TFViewUsers.CreateForm(WebPanel1.ElementID, Info);
end;
procedure TFViewMain.SetActiveNavButton(const btnId: string);
var
m, c, u: TJSHTMLElement;
......@@ -203,4 +208,42 @@ begin
u.classList.add('active');
end;
procedure TFViewMain.tmrBadgeCountsTimer(Sender: TObject);
begin
console.log('Badges Refreshed');
RefreshBadgesAsync;
end;
[async] procedure TFViewMain.RefreshBadgesAsync;
var
resp: TXDataClientResponse;
badgeObj: TJSObject;
el: TJSElement;
begin
try
resp := await(xdwcBadgeCounts.RawInvokeAsync('IApiService.GetBadgeCounts', []));
badgeObj := TJSObject(resp.Result);
el := Document.getElementById('view.main.badgecomplaints');
if Assigned(el) then
TJSHtmlElement(el).innerText := string(badgeObj['BadgeComplaints']);
el := Document.getElementById('view.main.badgeunits');
if Assigned(el) then
TJSHtmlElement(el).innerText := string(badgeObj['BadgeUnits']);
except
on E: Exception do
begin
el := Document.getElementById('view.main.badgecomplaints');
if Assigned(el) then TJSHtmlElement(el).innerText := '';
el := Document.getElementById('view.main.badgeunits');
if Assigned(el) then TJSHtmlElement(el).innerText := '';
Console.Log('Badge refresh error: ' + E.Message);
end;
end;
end;
end.
......@@ -18,7 +18,8 @@ uses
View.Users in 'View.Users.pas' {FViewUsers: TWebForm} {*.html},
View.EditUser in 'View.EditUser.pas' {FViewEditUser: TWebForm} {*.html},
Utils in 'Utils.pas',
View.ErrorPage in 'View.ErrorPage.pas' {FViewErrorPage: TWebForm} {*.html};
View.ErrorPage in 'View.ErrorPage.pas' {FViewErrorPage: TWebForm} {*.html},
View.ComplaintDetails in 'View.ComplaintDetails.pas' {FViewComplaintDetails: TWebForm} {*.html};
{$R *.res}
......
......@@ -176,6 +176,11 @@
<FormType>dfm</FormType>
<DesignClass>TWebForm</DesignClass>
</DCCReference>
<DCCReference Include="View.ComplaintDetails.pas">
<Form>FViewComplaintDetails</Form>
<FormType>dfm</FormType>
<DesignClass>TWebForm</DesignClass>
</DCCReference>
<None Include="index.html"/>
<None Include="css\app.css"/>
<None Include="css\spinner.css"/>
......
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