Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DojoCLI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dojo Project (HES-SO)
Projects
UI
DojoCLI
Commits
3d9bfb03
Commit
3d9bfb03
authored
1 year ago
by
michael.minelli
Browse files
Options
Downloads
Patches
Plain Diff
ConfigFiles => Centralize config files instances
parent
b12c271b
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
NodeApp/src/config/ConfigFiles.ts
+9
-0
9 additions, 0 deletions
NodeApp/src/config/ConfigFiles.ts
NodeApp/src/config/LocalConfigFile.ts
+3
-1
3 additions, 1 deletion
NodeApp/src/config/LocalConfigFile.ts
NodeApp/src/managers/SessionManager.ts
+7
-11
7 additions, 11 deletions
NodeApp/src/managers/SessionManager.ts
with
19 additions
and
12 deletions
NodeApp/src/config/ConfigFiles.ts
0 → 100644
+
9
−
0
View file @
3d9bfb03
import
LocalConfigFile
from
'
./LocalConfigFile
'
;
import
Config
from
'
./Config
'
;
const
sessionConfigFile
=
new
LocalConfigFile
(
Config
.
localConfig
.
sessionFile
);
const
stateConfigFile
=
new
LocalConfigFile
(
Config
.
localConfig
.
stateFile
);
export
{
sessionConfigFile
,
stateConfigFile
};
\ No newline at end of file
This diff is collapsed.
Click to expand it.
NodeApp/src/config/LocalConfigFile.ts
+
3
−
1
View file @
3d9bfb03
...
...
@@ -4,7 +4,9 @@ import JSON5 from 'json5';
class
LocalConfigFile
{
constructor
(
private
filename
:
string
)
{}
constructor
(
private
filename
:
string
)
{
this
.
loadConfig
();
}
private
get
configPath
():
string
{
return
`
${
Config
.
localConfig
.
folder
}
/
${
this
.
filename
}
`
;
...
...
This diff is collapsed.
Click to expand it.
NodeApp/src/managers/SessionManager.ts
+
7
−
11
View file @
3d9bfb03
import
*
as
jwt
from
'
jsonwebtoken
'
;
import
User
from
'
../sharedByClients/models/User
'
;
import
LocalConfigFile
from
'
../config/LocalConfigFile
'
;
import
LocalConfigKeys
from
'
../types/LocalConfigKeys
'
;
import
axios
,
{
HttpStatusCode
}
from
'
axios
'
;
import
HttpManager
from
'
./HttpManager
'
;
...
...
@@ -20,6 +19,7 @@ import SharedGitlabManager from '../shared/managers/SharedGitlabManager';
import
GitlabManager
from
'
./GitlabManager
'
;
import
GitlabToken
from
'
../shared/types/Gitlab/GitlabToken
'
;
import
open
from
'
open
'
;
import
{
sessionConfigFile
}
from
'
../config/ConfigFiles
'
;
class
LoginServer
{
...
...
@@ -75,8 +75,6 @@ class LoginServer {
class
SessionManager
{
private
configFile
:
LocalConfigFile
=
new
LocalConfigFile
(
Config
.
localConfig
.
sessionFile
);
public
profile
:
User
|
undefined
=
undefined
;
get
isLogged
():
boolean
{
...
...
@@ -84,7 +82,7 @@ class SessionManager {
}
get
apiToken
():
string
{
const
apisToken
=
this
.
c
onfigFile
.
getParam
(
LocalConfigKeys
.
APIS_TOKEN
)
as
null
|
{
[
key
:
string
]:
string
};
const
apisToken
=
sessionC
onfigFile
.
getParam
(
LocalConfigKeys
.
APIS_TOKEN
)
as
null
|
{
[
key
:
string
]:
string
};
if
(
apisToken
!==
null
&&
ClientsSharedConfig
.
apiURL
in
apisToken
)
{
return
apisToken
[
ClientsSharedConfig
.
apiURL
];
...
...
@@ -94,12 +92,12 @@ class SessionManager {
}
set
apiToken
(
token
:
string
)
{
let
apisToken
=
this
.
c
onfigFile
.
getParam
(
LocalConfigKeys
.
APIS_TOKEN
)
as
null
|
{
[
key
:
string
]:
string
};
let
apisToken
=
sessionC
onfigFile
.
getParam
(
LocalConfigKeys
.
APIS_TOKEN
)
as
null
|
{
[
key
:
string
]:
string
};
if
(
apisToken
===
null
)
{
apisToken
=
{};
}
apisToken
[
ClientsSharedConfig
.
apiURL
]
=
token
;
this
.
c
onfigFile
.
setParam
(
LocalConfigKeys
.
APIS_TOKEN
,
apisToken
);
sessionC
onfigFile
.
setParam
(
LocalConfigKeys
.
APIS_TOKEN
,
apisToken
);
try
{
const
payload
=
jwt
.
decode
(
token
);
...
...
@@ -113,16 +111,14 @@ class SessionManager {
}
get
gitlabCredentials
():
DojoGitlabCredentials
{
return
this
.
c
onfigFile
.
getParam
(
LocalConfigKeys
.
GITLAB
)
as
DojoGitlabCredentials
;
return
sessionC
onfigFile
.
getParam
(
LocalConfigKeys
.
GITLAB
)
as
DojoGitlabCredentials
;
}
set
gitlabCredentials
(
credentials
:
DojoGitlabCredentials
)
{
this
.
c
onfigFile
.
setParam
(
LocalConfigKeys
.
GITLAB
,
credentials
);
sessionC
onfigFile
.
setParam
(
LocalConfigKeys
.
GITLAB
,
credentials
);
}
constructor
()
{
this
.
configFile
.
loadConfig
();
}
constructor
()
{
}
private
async
getGitlabCodeFromHeadlessEnvironment
():
Promise
<
string
>
{
const
indent
:
string
=
'
'
;
...
...
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