Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nghyd
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
A compter du 1er avril, attention à vos pipelines :
Nouvelles limitations de Docker Hub
Show more breadcrumbs
Cassiopée
nghyd
Commits
4d3d919e
Commit
4d3d919e
authored
2 years ago
by
François Grand
Browse files
Options
Downloads
Patches
Plain Diff
feat: add a service to handle user confirmation through GUI
refs
#604
parent
00e67807
No related branches found
No related tags found
2 merge requests
!225
Release v4.17.0
,
!206
Resolve "PWA: l'application ne se met pas à jour"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/app/app.module.ts
+3
-1
3 additions, 1 deletion
src/app/app.module.ts
src/app/services/user-confirmation.service.ts
+69
-0
69 additions, 0 deletions
src/app/services/user-confirmation.service.ts
with
72 additions
and
1 deletion
src/app/app.module.ts
+
3
−
1
View file @
4d3d919e
...
...
@@ -127,6 +127,7 @@ import { SelectSectionDetailsComponent } from "./components/select-section-detai
import
{
ServiceWorkerModule
}
from
'
@angular/service-worker
'
;
import
{
environment
}
from
'
../environments/environment
'
;
import
{
ServiceWorkerUpdateService
}
from
"
./services/service-worker-update.service
"
;
import
{
UserConfirmationService
}
from
"
./services/user-confirmation.service
"
;
const
appRoutes
:
Routes
=
[
{
path
:
"
list/search
"
,
component
:
CalculatorListComponent
},
...
...
@@ -282,7 +283,8 @@ const appRoutes: Routes = [
provide
:
ErrorStateMatcher
,
useClass
:
ImmediateErrorStateMatcher
},
ServiceWorkerUpdateService
ServiceWorkerUpdateService
,
UserConfirmationService
],
schemas
:
[
NO_ERRORS_SCHEMA
],
bootstrap
:
[
AppComponent
]
...
...
This diff is collapsed.
Click to expand it.
src/app/services/user-confirmation.service.ts
0 → 100644
+
69
−
0
View file @
4d3d919e
import
{
Injectable
}
from
"
@angular/core
"
;
import
{
BidirectionalSubject
}
from
"
app/util/bidir_subject
"
;
import
{
Observer
}
from
"
rxjs
"
;
/**
* This service enables any class (even another service) to display a confirmation dialog on GUI ans get the user answer
*/
@
Injectable
()
export
class
UserConfirmationService
{
// used to communicate with UI component in charge of displaying confirmation dialog
// direction 0 : this
// direction 1 : UI
private
_userConfirm
:
BidirectionalSubject
<
{}
>
;
public
constructor
()
{
this
.
_userConfirm
=
new
BidirectionalSubject
<
{}
>
();
// we choose communication canal 0, UI will use 1
this
.
_userConfirm
.
selectPostingChannel
(
this
,
0
);
}
/**
* add subscription from UI
* @param source
*/
public
subscribe
(
source
:
any
)
{
this
.
_userConfirm
.
selectPostingChannel
(
source
,
1
);
}
/**
* remove UI subscription
* @param source
*/
public
unsubscribe
(
source
:
any
)
{
this
.
_userConfirm
.
unselectPostingChannel
(
source
);
}
/**
* add a handler (provided bu UI) to confirmation request
* @param source normally, UI component
* @param obs processing function
*/
public
addHandler
(
source
:
any
,
obs
:
Observer
<
boolean
>
)
{
this
.
_userConfirm
.
addHandler
(
source
,
obs
)
}
/**
* forward user confirmation from UI to requesting object
* @param confirm user confirmation status
*/
public
postConfirmation
(
source
:
any
,
confirm
:
{})
{
this
.
_userConfirm
.
post
(
source
,
confirm
);
}
/**
* forward to UI a request from source to ask a user confirmation with a dialog
* @param source object requesting confirmation
* @param title confirmation dialog title
* @param text confirmation dialog body text
* @returns a Promise resolving to a boolean holding user confirmation status
*/
public
askUserConfirmation
(
title
:
string
,
text
:
string
):
Promise
<
{}
>
{
const
ret
=
this
.
_userConfirm
.
getReceivePromise
(
this
);
this
.
_userConfirm
.
post
(
this
,
{
title
:
title
,
body
:
text
});
// false or true, we don't care
return
ret
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment