Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
H
HIAST-Clinics
Project
Project
Details
Activity
Releases
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
almohanad.hafez
HIAST-Clinics
Commits
0f2dd34b
Commit
0f2dd34b
authored
Aug 22, 2024
by
Almouhannad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(F) Test signalR on front-end
parent
38391d0c
Changes
8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
271 additions
and
5 deletions
+271
-5
package-lock.json
Clinics.Frontend/package-lock.json
+179
-4
package.json
Clinics.Frontend/package.json
+1
-0
app-routing.module.ts
Clinics.Frontend/src/app/app-routing.module.ts
+11
-0
app.module.ts
Clinics.Frontend/src/app/app.module.ts
+5
-1
signal-r.service.ts
Clinics.Frontend/src/app/notifications/signal-r.service.ts
+41
-0
test-signal-r.component.css
...rontend/src/app/test-signal-r/test-signal-r.component.css
+0
-0
test-signal-r.component.html
...ontend/src/app/test-signal-r/test-signal-r.component.html
+8
-0
test-signal-r.component.ts
...Frontend/src/app/test-signal-r/test-signal-r.component.ts
+26
-0
No files found.
Clinics.Frontend/package-lock.json
View file @
0f2dd34b
This diff is collapsed.
Click to expand it.
Clinics.Frontend/package.json
View file @
0f2dd34b
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
"@angular/platform-browser-dynamic"
:
"^18.1.0"
,
"@angular/platform-browser-dynamic"
:
"^18.1.0"
,
"@angular/router"
:
"^18.1.0"
,
"@angular/router"
:
"^18.1.0"
,
"@fortawesome/fontawesome-free"
:
"^6.6.0"
,
"@fortawesome/fontawesome-free"
:
"^6.6.0"
,
"@microsoft/signalr"
:
"^8.0.7"
,
"@ng-bootstrap/ng-bootstrap"
:
"^17.0.0"
,
"@ng-bootstrap/ng-bootstrap"
:
"^17.0.0"
,
"@popperjs/core"
:
"^2.11.8"
,
"@popperjs/core"
:
"^2.11.8"
,
"bootstrap"
:
"^5.3.2"
,
"bootstrap"
:
"^5.3.2"
,
...
...
Clinics.Frontend/src/app/app-routing.module.ts
View file @
0f2dd34b
...
@@ -5,6 +5,7 @@ import { RoleGuard } from './services/authentication/guards/role-guard';
...
@@ -5,6 +5,7 @@ import { RoleGuard } from './services/authentication/guards/role-guard';
import
{
Roles
}
from
'./classes/Authentication/roles'
;
import
{
Roles
}
from
'./classes/Authentication/roles'
;
import
{
ForbiddenComponent
}
from
'./components/errors/forbidden/forbidden.component'
;
import
{
ForbiddenComponent
}
from
'./components/errors/forbidden/forbidden.component'
;
import
{
NotFoundComponent
}
from
'./components/errors/not-found/not-found.component'
;
import
{
NotFoundComponent
}
from
'./components/errors/not-found/not-found.component'
;
import
{
TestSignalRComponent
}
from
'./test-signal-r/test-signal-r.component'
;
const
routes
:
Routes
=
[
const
routes
:
Routes
=
[
{
{
...
@@ -25,6 +26,16 @@ const routes: Routes = [
...
@@ -25,6 +26,16 @@ const routes: Routes = [
canActivate
:
[
RoleGuard
],
canActivate
:
[
RoleGuard
],
data
:
{
role
:
Roles
.
NotRegistered
}
data
:
{
role
:
Roles
.
NotRegistered
}
},
},
// #region Testing SignalR
{
path
:
'testing'
,
component
:
TestSignalRComponent
,
canActivate
:
[
RoleGuard
],
data
:
{
role
:
Roles
.
NotRegistered
}
},
// #endregion
// Everything else
// Everything else
{
{
path
:
'**'
,
path
:
'**'
,
...
...
Clinics.Frontend/src/app/app.module.ts
View file @
0f2dd34b
...
@@ -18,6 +18,8 @@ import { AuthenticationService } from './services/authentication/authentication.
...
@@ -18,6 +18,8 @@ import { AuthenticationService } from './services/authentication/authentication.
import
{
AuthenticationInterceptor
}
from
'./services/authentication/interceptor/authentication.interceptor'
;
import
{
AuthenticationInterceptor
}
from
'./services/authentication/interceptor/authentication.interceptor'
;
import
{
ForbiddenComponent
}
from
'./components/errors/forbidden/forbidden.component'
;
import
{
ForbiddenComponent
}
from
'./components/errors/forbidden/forbidden.component'
;
import
{
NotFoundComponent
}
from
'./components/errors/not-found/not-found.component'
;
import
{
NotFoundComponent
}
from
'./components/errors/not-found/not-found.component'
;
import
{
TestSignalRComponent
}
from
'./test-signal-r/test-signal-r.component'
;
import
{
SignalRService
}
from
'./notifications/signal-r.service'
;
@
NgModule
({
@
NgModule
({
...
@@ -39,6 +41,7 @@ import { NotFoundComponent } from './components/errors/not-found/not-found.compo
...
@@ -39,6 +41,7 @@ import { NotFoundComponent } from './components/errors/not-found/not-found.compo
providers
:
[
providers
:
[
AuthenticationService
,
AuthenticationService
,
{
provide
:
HTTP_INTERCEPTORS
,
useClass
:
AuthenticationInterceptor
,
multi
:
true
},
{
provide
:
HTTP_INTERCEPTORS
,
useClass
:
AuthenticationInterceptor
,
multi
:
true
},
SignalRService
],
],
// components and directives that belong to this module
// components and directives that belong to this module
...
@@ -52,7 +55,8 @@ import { NotFoundComponent } from './components/errors/not-found/not-found.compo
...
@@ -52,7 +55,8 @@ import { NotFoundComponent } from './components/errors/not-found/not-found.compo
HomeComponent
,
HomeComponent
,
LoginFormComponent
,
LoginFormComponent
,
ForbiddenComponent
,
ForbiddenComponent
,
NotFoundComponent
NotFoundComponent
,
TestSignalRComponent
],
],
// identifies the root component that Angular should
// identifies the root component that Angular should
...
...
Clinics.Frontend/src/app/notifications/signal-r.service.ts
0 → 100644
View file @
0f2dd34b
import
{
Injectable
}
from
'@angular/core'
;
import
{
HubConnectionBuilder
}
from
'@microsoft/signalr'
;
import
*
as
config
from
'../../../config'
@
Injectable
({
providedIn
:
'root'
})
export
class
SignalRService
{
constructor
()
{
}
private
readonly
NOTIFICATIONS_ENDPOINT
:
string
=
`
${
config
.
apiUrl
}
/Notifications`
hubConnection
:
signalR
.
HubConnection
;
startConnection
():
void
{
this
.
hubConnection
=
new
HubConnectionBuilder
()
.
withUrl
(
this
.
NOTIFICATIONS_ENDPOINT
)
.
build
();
this
.
hubConnection
.
start
()
.
then
(()
=>
{
console
.
log
(
'Connected to signalR!'
)
})
.
catch
(
err
=>
console
.
error
(
'Error while starting connection: '
+
err
))
}
endConnection
():
void
{
if
(
this
.
hubConnection
)
{
this
.
hubConnection
.
stop
()
.
then
(()
=>
{
console
.
log
(
'disonnected from signalR!'
);
})
.
catch
(
err
=>
console
.
error
(
'Error while stopping connection: '
+
err
));
}
else
{
console
.
log
(
'No active connection to stop.'
);
}
}
}
\ No newline at end of file
Clinics.Frontend/src/app/test-signal-r/test-signal-r.component.css
0 → 100644
View file @
0f2dd34b
Clinics.Frontend/src/app/test-signal-r/test-signal-r.component.html
0 → 100644
View file @
0f2dd34b
<div>
<div
class=
"text-center"
>
<h2>
Notifications:
</h2>
<h3>
{{notification}}
</h3>
<button
(
click
)="
onClick
()"
class=
"btn btn-outline-danger"
>
Stop
</button>
</div>
</div>
\ No newline at end of file
Clinics.Frontend/src/app/test-signal-r/test-signal-r.component.ts
0 → 100644
View file @
0f2dd34b
import
{
Component
,
OnInit
}
from
'@angular/core'
;
import
{
SignalRService
}
from
'../notifications/signal-r.service'
;
@
Component
({
selector
:
'app-test-signal-r'
,
templateUrl
:
'./test-signal-r.component.html'
,
styleUrls
:
[
'./test-signal-r.component.css'
]
})
export
class
TestSignalRComponent
implements
OnInit
{
notification
:
string
=
''
;
constructor
(
private
signalR
:
SignalRService
){}
ngOnInit
():
void
{
this
.
signalR
.
startConnection
();
this
.
signalR
.
hubConnection
.
on
(
'ReceiveNotification'
,
(
message
)
=>
{
this
.
notification
=
message
;
})
}
onClick
():
void
{
this
.
signalR
.
endConnection
();
}
}
\ No newline at end of file
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