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
Iterations
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
FS Info TU Dortmund
Infoscreen
Infoscreen
Commits
6533cd44
Commit
6533cd44
authored
1 year ago
by
Niklas Schrötler
Browse files
Options
Downloads
Patches
Plain Diff
App: Added error handling for panels and backgroundImage functionality
parent
2e2c327a
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/App.tsx
+31
-10
31 additions, 10 deletions
src/App.tsx
with
31 additions
and
10 deletions
src/App.tsx
+
31
−
10
View file @
6533cd44
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
'
./App.css
'
;
import
'
./App.css
'
;
import
ScreenWrapper
from
"
./meta/ScreenWrapper
"
;
import
ScreenWrapper
from
"
./meta/ScreenWrapper
"
;
import
PanelWrapper
from
"
./meta/PanelWrapper
"
;
import
PanelTitle
from
"
./meta/PanelTitle
"
;
import
PanelContent
from
"
./meta/PanelContent
"
;
import
FahrplanPanel
from
"
./panels/Fahrplan/FahrplanPanel
"
;
import
LayoutElement
from
"
./layout/LayoutElement
"
;
import
useLayout
from
"
./hooks/useLayout
"
;
import
useLayout
from
"
./hooks/useLayout
"
;
import
{
PanelRenderers
}
from
"
./panels/_Panels
"
;
import
{
PanelRenderers
}
from
"
./panels/_Panels
"
;
import
LayoutElement
from
"
./layout/LayoutElement
"
;
import
ErrorPanel
from
"
./panels/Error
"
;
import
{
ErrorBoundary
}
from
"
react-error-boundary
"
;
function
App
()
{
function
App
()
{
const
layout
=
useLayout
();
const
layout
=
useLayout
();
...
@@ -22,14 +20,37 @@ function App() {
...
@@ -22,14 +20,37 @@ function App() {
return
(
return
(
<
div
className
=
{
"
overflow-hidden w-screen h-screen bg-zinc-950 text-white
"
}
style
=
{
{
fontFamily
:
"
Inter
"
}
}
>
<
div
className
=
{
"
overflow-hidden w-screen h-screen bg-zinc-950 text-white
"
}
style
=
{
{
fontFamily
:
"
Inter
"
}
}
>
<
ScreenWrapper
>
<
ScreenWrapper
backgroundImage
=
{
layout
.
background
}
>
{
{
layout
.
panels
.
map
(
panel
=>
{
layout
.
panels
.
map
(
panel
=>
{
const
Renderer
=
PanelRenderers
[
panel
.
type
];
try
{
const
Renderer
=
PanelRenderers
[
panel
.
type
];
if
(
!
Renderer
)
{
console
.
error
(
`Rendering a panel of type
${
panel
.
type
}
at (
${
panel
.
position
.
x
}
,
${
panel
.
position
.
y
}
) failed. Config:`
,
panel
.
config
)
return
(
<
LayoutElement
config
=
{
panel
}
>
<
ErrorPanel
message
=
{
`Unable to find a panel definition for type "
${
panel
.
type
}
"`
}
/>
</
LayoutElement
>
)
}
return
(
<
LayoutElement
config
=
{
panel
}
>
<
ErrorBoundary
fallback
=
{
<
ErrorPanel
message
=
{
`Panel of type
${
panel
.
type
}
failed to render. Please check the config you provided.`
}
/>
}
>
<
Renderer
definition
=
{
panel
.
config
}
/>
</
ErrorBoundary
>
</
LayoutElement
>
)
}
catch
(
e
)
{
return
(
}
<
Renderer
definition
=
{
panel
.
config
}
/>
)
})
})
}
}
</
ScreenWrapper
>
</
ScreenWrapper
>
...
...
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