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
Show more breadcrumbs
Cassiopée
nghyd
Commits
3257756f
Commit
3257756f
authored
6 years ago
by
mathias.chouet
Browse files
Options
Downloads
Patches
Plain Diff
Le service de configuration avertit ses observateurs lorsque le fichier de config JSON est chargé
parent
009f2ca5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!29
Resolve "Remplacer mdbootstrap par angular-material"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/app/components/app-setup/app-setup.component.ts
+21
-13
21 additions, 13 deletions
src/app/components/app-setup/app-setup.component.ts
src/app/services/app-setup/app-setup.service.ts
+7
-4
7 additions, 4 deletions
src/app/services/app-setup/app-setup.service.ts
with
28 additions
and
17 deletions
src/app/components/app-setup/app-setup.component.ts
+
21
−
13
View file @
3257756f
...
...
@@ -41,6 +41,7 @@ export class ApplicationSetupComponent extends BaseComponent implements Observer
private
intlService
:
InternationalisationService
)
{
super
();
this
.
appSetupService
.
addObserver
(
this
);
}
public
get
currentLanguageLabel
():
string
{
...
...
@@ -90,19 +91,26 @@ export class ApplicationSetupComponent extends BaseComponent implements Observer
// interface Observer
public
update
(
sender
:
any
,
data
:
any
):
void
{
const
p
:
NgBaseParam
=
sender
;
switch
(
p
.
symbol
)
{
case
"
dp
"
:
this
.
appSetupService
.
displayPrecision
=
+
data
;
break
;
case
"
cp
"
:
this
.
appSetupService
.
computePrecision
=
+
data
;
break
;
case
"
nmi
"
:
this
.
appSetupService
.
newtonMaxIterations
=
+
data
;
break
;
if
(
sender
instanceof
NgBaseParam
)
{
// someone typed a new value in the app-setup form
const
p
:
NgBaseParam
=
sender
;
switch
(
p
.
symbol
)
{
case
"
dp
"
:
this
.
appSetupService
.
displayPrecision
=
+
data
;
break
;
case
"
cp
"
:
this
.
appSetupService
.
computePrecision
=
+
data
;
break
;
case
"
nmi
"
:
this
.
appSetupService
.
newtonMaxIterations
=
+
data
;
break
;
}
}
if
(
sender
instanceof
ApplicationSetupService
)
{
// if app starts on /setup page, wait for config file to be (re)loaded by app-setup service
this
.
init
();
}
}
}
This diff is collapsed.
Click to expand it.
src/app/services/app-setup/app-setup.service.ts
+
7
−
4
View file @
3257756f
import
{
HttpService
}
from
"
../http/http.service
"
;
import
{
Injectable
}
from
"
@angular/core
"
;
import
{
Observable
}
from
"
jalhyd
"
;
/**
* Stores app preferences
*/
@
Injectable
()
export
class
ApplicationSetupService
{
export
class
ApplicationSetupService
extends
Observable
{
private
CONFIG_FILE_PATH
=
"
app/config.json
"
;
...
...
@@ -19,6 +20,8 @@ export class ApplicationSetupService {
public
constructor
(
private
httpService
:
HttpService
)
{
super
();
this
.
readValuesFromConfig
();
}
...
...
@@ -28,9 +31,7 @@ export class ApplicationSetupService {
// @TODO save preferences in cookie / localStorage ?
// read default values from config
// @TODO notify (?) so that if a user starts the app on the /setup page the values are correct
// (atm the default builtin values will be visible until the user changes page and goes back to /setup)
// read default values from config and notify observers
private
readValuesFromConfig
()
{
this
.
httpService
.
httpGetRequestPromise
(
this
.
CONFIG_FILE_PATH
).
then
((
data
:
any
)
=>
{
this
.
displayPrecision
=
data
.
params
.
displayPrecision
;
...
...
@@ -38,6 +39,8 @@ export class ApplicationSetupService {
this
.
newtonMaxIterations
=
data
.
params
.
newtonMaxIterations
;
this
.
language
=
data
.
params
.
language
;
this
.
themes
=
data
.
themes
;
this
.
notifyObservers
(
null
);
});
}
}
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