Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
Infoscreen
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Evy Storozhenko
Infoscreen
Commits
6a9c7b82
Unverified
Commit
6a9c7b82
authored
1 year ago
by
Fabian van Rissenbeck
Browse files
Options
Downloads
Patches
Plain Diff
LayoutService: periodic config reload
parent
cfb1d00a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/services/LayoutService.ts
+20
-10
20 additions, 10 deletions
src/services/LayoutService.ts
with
20 additions
and
10 deletions
src/services/LayoutService.ts
+
20
−
10
View file @
6a9c7b82
...
@@ -13,11 +13,14 @@ export class LayoutService {
...
@@ -13,11 +13,14 @@ export class LayoutService {
static
async
init
():
Promise
<
void
>
{
static
async
init
():
Promise
<
void
>
{
try
{
try
{
const
activeConfigs
=
await
fetch
(
"
/activeConfigs.json
"
).
then
(
content
=>
content
.
json
());
LayoutService
.
configs
=
await
fetchActiveConfigs
();
const
configFetches
=
(
activeConfigs
as
string
[])
const
autoRefreshInterval
=
1000
*
60
*
10
;
.
map
(
configPath
=>
fetch
(
configPath
).
then
(
content
=>
content
.
json
()));
setInterval
(()
=>
{
LayoutService
.
configs
=
await
Promise
.
all
(
configFetches
);
fetchActiveConfigs
()
.
then
(
cfg
=>
this
.
configs
=
cfg
)
.
catch
(
_
=>
console
.
log
(
"
cannot refresh layout config
"
));
},
autoRefreshInterval
);
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
error
(
"
LayoutService could not init
"
,
e
)
console
.
error
(
"
LayoutService could not init
"
,
e
)
}
}
...
@@ -37,10 +40,17 @@ export class LayoutService {
...
@@ -37,10 +40,17 @@ export class LayoutService {
},
false
);
},
false
);
});
});
console
.
log
(
activeConfigs
)
const
defaultConfig
=
this
.
configs
.
filter
(
config
=>
config
.
id
===
"
default
"
).
at
(
0
);
return
activeConfigs
.
at
(
0
)
??
defaultConfig
??
NO_LAYOUT_CONFIG
;
/* ToDo: This is not great, as it assumes there is always an active layout. If you don't configure this correctly,
consider yourself warned now and don't blame me */
return
activeConfigs
.
at
(
0
)
??
NO_LAYOUT_CONFIG
;
}
}
}
}
async
function
fetchActiveConfigs
():
Promise
<
LayoutConfig
[]
>
{
const
activeConfigs
=
await
fetch
(
"
/activeConfigs.json
"
).
then
(
content
=>
content
.
json
());
const
configFetches
=
(
activeConfigs
as
string
[])
.
map
(
configPath
=>
fetch
(
configPath
).
then
(
content
=>
content
.
json
()));
const
configs
:
LayoutConfig
[]
=
(
await
Promise
.
all
(
configFetches
)).
map
(
item
=>
item
as
LayoutConfig
);
return
configs
;
}
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