Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
emWebAppTemplate
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Mac Stephens
emWebAppTemplate
Commits
ce430b39
Commit
ce430b39
authored
Mar 25, 2026
by
Mac Stephens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP change to new VM
parent
7c54b21d
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
94 additions
and
127 deletions
+94
-127
Auth.Service.pas
templateWebApp/Auth.Service.pas
+35
-3
ConnectionModule.dfm
templateWebApp/ConnectionModule.dfm
+0
-5
ConnectionModule.pas
templateWebApp/ConnectionModule.pas
+0
-27
Utils.pas
templateWebApp/Utils.pas
+37
-17
templateWebApp.dpr
templateWebApp/templateWebApp.dpr
+16
-49
templateWebApp.dproj
templateWebApp/templateWebApp.dproj
+0
-11
templateXDataServer.ini
templateXDataServer/bin/templateXDataServer.ini
+3
-3
Auth.Database.pas
templateXDataServer/source/Auth.Database.pas
+1
-1
Auth.ServiceImpl.pas
templateXDataServer/source/Auth.ServiceImpl.pas
+2
-0
templateXDataServer.dproj
templateXDataServer/templateXDataServer.dproj
+0
-11
No files found.
templateWebApp/Auth.Service.pas
View file @
ce430b39
...
...
@@ -4,7 +4,7 @@ interface
uses
SysUtils
,
Web
,
JS
,
XData
.
Web
.
Client
;
XData
.
Web
.
Client
,
App
.
Types
;
const
TOKEN_NAME
=
'EMSYS_TEMPLATE_TOKEN'
;
...
...
@@ -23,8 +23,8 @@ type
public
constructor
Create
;
reintroduce
;
destructor
Destroy
;
override
;
procedure
Login
(
AUser
,
APassword
,
AClientVersion
:
string
;
ASuccess
:
TOnLoginSuccess
;
AError
:
TOnLoginError
);
procedure
Login
(
AUser
,
APassword
,
AClientVersion
:
string
;
ASuccess
:
TOnLoginSuccess
;
AError
:
TOnLoginError
);
procedure
VerifyClientVersion
(
AVersion
:
string
;
ACallback
:
TVersionCheckCallback
);
procedure
Logout
;
function
GetToken
:
string
;
function
Authenticated
:
Boolean
;
...
...
@@ -91,6 +91,38 @@ begin
Result
:=
window
.
localStorage
.
getItem
(
TOKEN_NAME
);
end
;
procedure
TAuthService
.
VerifyClientVersion
(
AVersion
:
string
;
ACallback
:
TVersionCheckCallback
);
procedure
OnLoad
(
Response
:
TXDataClientResponse
);
var
JsonResult
:
TJSObject
;
ErrorMsg
:
string
;
begin
JsonResult
:=
TJSObject
(
Response
.
Result
);
if
JsonResult
.
HasOwnProperty
(
'error'
)
then
ErrorMsg
:=
string
(
JsonResult
[
'error'
])
else
ErrorMsg
:=
''
;
if
ErrorMsg
<>
''
then
ACallback
(
False
,
ErrorMsg
)
else
ACallback
(
True
,
''
);
end
;
procedure
OnError
(
Error
:
TXDataClientError
);
begin
ACallback
(
False
,
Format
(
'%s: %s'
,
[
Error
.
ErrorCode
,
Error
.
ErrorMessage
]));
end
;
begin
FClient
.
RawInvoke
(
'IAuthService.VerifyVersion'
,
[
AVersion
],
@
OnLoad
,
@
OnError
);
end
;
procedure
TAuthService
.
Login
(
AUser
,
APassword
,
AClientVersion
:
string
;
ASuccess
:
TOnLoginSuccess
;
AError
:
TOnLoginError
);
...
...
templateWebApp/ConnectionModule.dfm
View file @
ce430b39
...
...
@@ -15,9 +15,4 @@ object DMConnection: TDMConnection
Left = 48
Top = 16
end
object XDataWebClient1: TXDataWebClient
Connection = AuthConnection
Left = 269
Top = 164
end
end
templateWebApp/ConnectionModule.pas
View file @
ce430b39
...
...
@@ -10,7 +10,6 @@ type
TDMConnection
=
class
(
TWebDataModule
)
ApiConnection
:
TXDataWebConnection
;
AuthConnection
:
TXDataWebConnection
;
XDataWebClient1
:
TXDataWebClient
;
procedure
ApiConnectionError
(
Error
:
TXDataWebConnectionError
);
procedure
ApiConnectionRequest
(
Args
:
TXDataWebConnectionRequest
);
procedure
ApiConnectionResponse
(
Args
:
TXDataWebConnectionResponse
);
...
...
@@ -22,7 +21,6 @@ type
const
clientVersion
=
'0.0.1'
;
procedure
InitApp
(
SuccessProc
:
TSuccessProc
;
UnauthorizedAccessProc
:
TUnauthorizedAccessProc
);
procedure
SetClientConfig
(
Callback
:
TVersionCheckCallback
);
end
;
var
...
...
@@ -106,29 +104,4 @@ begin
end
;
procedure
TDMConnection
.
SetClientConfig
(
Callback
:
TVersionCheckCallback
);
begin
XDataWebClient1
.
Connection
:=
AuthConnection
;
XDataWebClient1
.
RawInvoke
(
'IAuthService.VerifyVersion'
,
[
clientVersion
],
procedure
(
Response
:
TXDataClientResponse
)
var
jsonResult
:
TJSObject
;
error
:
string
;
begin
jsonResult
:=
TJSObject
(
Response
.
Result
);
if
jsonResult
.
HasOwnProperty
(
'error'
)
then
error
:=
string
(
jsonResult
[
'error'
])
else
error
:=
''
;
if
error
<>
''
then
Callback
(
False
,
error
)
else
Callback
(
True
,
''
);
end
);
end
;
end
.
templateWebApp/Utils.pas
View file @
ce430b39
...
...
@@ -16,7 +16,7 @@ procedure ApplyReportTitle(CurrentReportType: string);
procedure
ShowToast
(
const
MessageText
:
string
;
const
ToastType
:
string
=
'success'
);
procedure
ShowConfirmationModal
(
msg
,
leftLabel
,
rightLabel
:
string
;
ConfirmProc
:
TProc
<
Boolean
>);
procedure
ShowNotificationModal
(
msg
:
string
);
// function FormatDollarValue(ValueStr: string): string
;
procedure
ShowVersionMismatchAndReload
(
const
ErrorText
,
ClientVersion
:
string
)
;
implementation
...
...
@@ -330,23 +330,43 @@ begin
end
;
// Used html number input type to restrict the input instead of this function
// function FormatDollarValue(ValueStr: string): string;
// var
// i: Integer;
// begin
// Result := ''; // Initialize the result
procedure
ShowVersionMismatchAndReload
(
const
ErrorText
,
ClientVersion
:
string
);
begin
asm
var
dlg
=
document
.
createElement
(
'dialog'
);
dlg
.
style
.
padding
=
'1rem'
;
dlg
.
style
.
maxWidth
=
'520px'
;
dlg
.
style
.
border
=
'1px solid #ccc'
;
dlg
.
style
.
borderRadius
=
'8px'
;
var
title
=
document
.
createElement
(
'h3'
);
title
.
textContent
=
'template web app'
;
title
.
style
.
marginTop
=
'0'
;
var
msg
=
document
.
createElement
(
'pre'
);
msg
.
textContent
=
ErrorText
;
msg
.
style
.
whiteSpace
=
'pre-wrap'
;
msg
.
style
.
fontFamily
=
'inherit'
;
var
btnRow
=
document
.
createElement
(
'div'
);
btnRow
.
style
.
display
=
'flex'
;
btnRow
.
style
.
justifyContent
=
'flex-end'
;
btnRow
.
style
.
marginTop
=
'1rem'
;
var
btn
=
document
.
createElement
(
'button'
);
btn
.
textContent
=
'Reload'
;
btn
.
onclick
=
function
()
{
window.location.reload();
}
;
// // Filter out any characters that are not digits or decimal point
// for i := 1 to Length(ValueStr) do
// begin
// if (Pos(ValueStr[i], '0123456789.') > 0) then
// begin
// Result := Result + ValueStr[i];
// end;
// end;
// end;
btnRow
.
appendChild
(
btn
);
dlg
.
appendChild
(
title
);
dlg
.
appendChild
(
msg
);
dlg
.
appendChild
(
btnRow
);
document
.
body
.
appendChild
(
dlg
);
dlg
.
showModal
();
end
;
end
;
end
.
templateWebApp/templateWebApp.dpr
View file @
ce430b39
...
...
@@ -33,8 +33,7 @@ begin
ConnectProc;
end;
procedure DisplayLoginView(AMessage: string);
procedure DisplayLoginView(AMessage: string = '');
begin
AuthService.Logout;
DMConnection.ApiConnection.Connected := False;
...
...
@@ -43,67 +42,35 @@ begin
TFViewLogin.Display(@DisplayMainView, AMessage);
end;
procedure UnauthorizedAccessProc(AMessage: string);
begin
DisplayLoginView(AMessage);
end;
procedure StartApplication;
var
ClientVer: string;
procedure AfterVerifyClientVersion(Success: Boolean; Error: string);
begin
ClientVer := TDMConnection.clientVersion;
DMConnection.InitApp(
procedure
begin
DMConnection.SetClientConfig(
procedure(Success: Boolean; ErrorMessage: string)
begin
if Success then
begin
if (not AuthService.Authenticated) or AuthService.TokenExpired then
DisplayLoginView
else
DisplayMainView;
end
else
begin
asm
var dlg = document.createElement("dialog");
dlg.classList.add("shadow", "rounded", "border", "p-4");
dlg.style.maxWidth = "500px";
dlg.style.width = "90%";
dlg.style.fontFamily = "system-ui, sans-serif";
dlg.innerHTML =
"<h5 class='fw-bold mb-3 text-danger'>kgOrders web app</h5>" +
"<p class='mb-3' style='white-space: pre-wrap;'>" + ErrorMessage + "</p>" +
"<div class='text-end'>" +
"<button id='refreshBtn' class='btn btn-primary'>Reload</button></div>";
document.body.appendChild(dlg);
dlg.showModal();
if not Success then
begin
ShowVersionMismatchAndReload(Error, DMConnection.clientVersion);
Exit;
end;
document.getElementById("refreshBtn").addEventListener("click", function () {
var base = location.origin + location.pathname;
location.replace(base + "?ver=" + ClientVer + "&r=" + Date.now() + location.hash);
});
end;
end;
end);
end,
@UnauthorizedAccessProc
);
if (not AuthService.Authenticated) or AuthService.TokenExpired then
DisplayLoginView
else
DisplayMainView;
end;
procedure StartApplication;
begin
AuthService.VerifyClientVersion(DMConnection.clientVersion, @AfterVerifyClientVersion);
end;
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TDMConnection, DMConnection);
StartApplication;
Application.Run;
DMConnection.InitApp(@StartApplication, @UnauthorizedAccessProc);
end.
templateWebApp/templateWebApp.dproj
View file @
ce430b39
...
...
@@ -912,9 +912,6 @@
<Platform Name="Win64x">
<Operation>1</Operation>
</Platform>
<Platform Name="WinARM64EC">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="ProjectiOSDeviceDebug">
<Platform Name="iOSDevice32">
...
...
@@ -985,10 +982,6 @@
<RemoteDir>Assets</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="WinARM64EC">
<RemoteDir>Assets</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="UWP_DelphiLogo44">
<Platform Name="Win32">
...
...
@@ -999,10 +992,6 @@
<RemoteDir>Assets</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="WinARM64EC">
<RemoteDir>Assets</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iOS_AppStore1024">
<Platform Name="iOSDevice64">
...
...
templateXDataServer/bin/templateXDataServer.ini
View file @
ce430b39
[Settings]
MemoLogLevel
=
5
FileLogLevel
=
5
LogFileNum
=
3
1
LogFileNum
=
3
9
DevMode
=
0
webClientVersion
=
0.0.1
[Database]
--Server
=
192.168.116.129
--Server
=
Server
=
192.168.102.131
--Port
=
--Database
=
Database
=
sleepdb
--Username
=
--Password
=
...
...
templateXDataServer/source/Auth.Database.pas
View file @
ce430b39
...
...
@@ -53,7 +53,7 @@ begin
except
on
E
:
Exception
do
begin
Logger
.
Log
(
2
,
'--TAuthDatabase.DataModuleCreate -Error connecting to database: '
+
E
.
Message
);
Logger
.
Log
(
1
,
'--TAuthDatabase.DataModuleCreate -Error connecting to database: '
+
E
.
Message
);
end
;
end
;
end
;
...
...
templateXDataServer/source/Auth.ServiceImpl.pas
View file @
ce430b39
...
...
@@ -72,6 +72,7 @@ begin
end
;
end
;
function
TAuthService
.
VerifyVersion
(
clientVersion
:
string
):
TJSONObject
;
var
webClientVersion
:
string
;
...
...
@@ -101,6 +102,7 @@ begin
end
;
end
;
function
TAuthService
.
Login
(
const
username
,
password
,
clientVersion
:
string
):
string
;
var
sql
:
string
;
...
...
templateXDataServer/templateXDataServer.dproj
View file @
ce430b39
...
...
@@ -831,9 +831,6 @@
<Platform Name="Win64x">
<Operation>1</Operation>
</Platform>
<Platform Name="WinARM64EC">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="ProjectiOSDeviceDebug">
<Platform Name="iOSDevice32">
...
...
@@ -904,10 +901,6 @@
<RemoteDir>Assets</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="WinARM64EC">
<RemoteDir>Assets</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="UWP_DelphiLogo44">
<Platform Name="Win32">
...
...
@@ -918,10 +911,6 @@
<RemoteDir>Assets</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="WinARM64EC">
<RemoteDir>Assets</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iOS_AppStore1024">
<Platform Name="iOSDevice64">
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment