Skip to content

Commit e0dec60

Browse files
committed
Add cloe data view
1 parent 6348809 commit e0dec60

14 files changed

Lines changed: 402 additions & 49 deletions

File tree

frontend/package-lock.json

Lines changed: 50 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,16 @@
1818
"@types/react": "^19.2.14",
1919
"@types/react-dom": "^19.2.3",
2020
"@vitejs/plugin-react-swc": "^4.2.3",
21+
"chart.js": "^4.5.1",
22+
"chartjs-adapter-luxon": "^1.3.1",
2123
"date-fns": "^4.1.0",
2224
"leaflet": "^1.9.4",
2325
"livekit-client": "^2.17.2",
26+
"luxon": "^3.7.2",
2427
"prettier": "^3.8.1",
2528
"react": "^19.2.4",
2629
"react-big-calendar": "^1.19.4",
30+
"react-chartjs-2": "^5.3.1",
2731
"react-dom": "^19.2.4",
2832
"react-leaflet": "^5.0.0",
2933
"react-modal": "^3.16.3",
@@ -56,6 +60,7 @@
5660
"devDependencies": {
5761
"@eslint/js": "^9.39.2",
5862
"@types/leaflet": "^1.9.20",
63+
"@types/luxon": "^3.7.1",
5964
"@types/react-big-calendar": "^1.16.2",
6065
"@types/react-modal": "^3.16.3",
6166
"@types/styled-components": "^5.1.36",
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { Typography } from '@equinor/eds-core-react'
2+
import { Task } from 'models/Task'
3+
4+
export const TagIdDisplay = ({ task }: { task: Task }) => {
5+
if (!task.tagId) return <Typography key={task.id + 'tagId'}>{'N/A'}</Typography>
6+
7+
if (task.tagLink)
8+
return (
9+
<Typography key={task.id + 'tagId'} link href={task.tagLink} target="_blank">
10+
{task.tagId!}
11+
</Typography>
12+
)
13+
else return <Typography key={task.id + 'tagId'}>{task.tagId!}</Typography>
14+
}
15+
16+
export const DescriptionDisplay = ({ task }: { task: Task }) => {
17+
if (!task.description) return <Typography key={task.id + 'descr'}>{'N/A'}</Typography>
18+
return <Typography key={task.id + 'descr'}>{task.description}</Typography>
19+
}
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
import {
2+
Chart as ChartJS,
3+
CategoryScale,
4+
LinearScale,
5+
PointElement,
6+
LineElement,
7+
Title,
8+
TimeScale,
9+
Tooltip,
10+
Legend,
11+
ChartData,
12+
ChartOptions,
13+
DefaultDataPoint,
14+
ChartDataset,
15+
} from 'chart.js'
16+
import { DateTime } from 'luxon'
17+
import { Line } from 'react-chartjs-2'
18+
import 'chartjs-adapter-luxon' // registers the Luxon adapter for the x-axis time scale
19+
20+
ChartJS.register(TimeScale, CategoryScale, LinearScale, PointElement, LineElement, Title, Tooltip, Legend)
21+
22+
const PALETTE: [string, string][] = [
23+
['rgb(255, 18, 67)', 'rgba(255, 18, 67, 0.5)'],
24+
['rgb(125, 0, 35)', 'rgba(125, 0, 35, 0.5)'],
25+
['rgb(36, 55, 70)', 'rgba(36, 55, 70, 0.5)'],
26+
['rgb(0, 112, 121)', 'rgba(0, 112, 121, 0.5)'],
27+
]
28+
29+
interface TimeseriesLinePlotDataPoint {
30+
time: Date
31+
value: number
32+
}
33+
34+
export interface TimeseriesLinePlotData {
35+
[id: string]: TimeseriesLinePlotDataPoint[]
36+
}
37+
38+
interface Props {
39+
data: TimeseriesLinePlotData
40+
yLabel: string
41+
}
42+
43+
export const TimeseriesLinePlot = ({ data, yLabel }: Props) => {
44+
const options: ChartOptions<'line'> = {
45+
responsive: true,
46+
spanGaps: true,
47+
48+
plugins: {
49+
legend: {
50+
position: 'right' as const,
51+
},
52+
title: {
53+
display: false,
54+
},
55+
},
56+
scales: {
57+
x: {
58+
type: 'time',
59+
adapters: {
60+
date: {
61+
zone: 'Europe/Oslo',
62+
},
63+
},
64+
time: {
65+
// Luxon format tokens (https://moment.github.io/luxon/#/formatting?id=table-of-tokens)
66+
tooltipFormat: 'dd.MM.yy HH:mm',
67+
displayFormats: {
68+
millisecond: 'HH:mm:ss.SSS',
69+
second: 'HH:mm:ss',
70+
minute: 'HH:mm',
71+
hour: 'HH:mm',
72+
day: 'dd.MM',
73+
week: 'dd.MM',
74+
month: 'MM.yyyy',
75+
quarter: 'qq yyyy',
76+
year: 'yyyy',
77+
},
78+
},
79+
title: {
80+
display: true,
81+
text: 'Time',
82+
},
83+
},
84+
y: {
85+
title: {
86+
display: true,
87+
text: yLabel,
88+
},
89+
},
90+
},
91+
}
92+
93+
const labels: string[] = []
94+
// @ts-expect-error ; Date isn't assignable to number for x-axis value - assumption: library can handle it anyways
95+
const datasets: ChartDataset<'line', DefaultDataPoint<'line'>>[] = Object.entries(data).map(
96+
([id, dataPointArray], index: number) => {
97+
const [borderColor, backgroundColor] = PALETTE[index % PALETTE.length]
98+
return {
99+
label: id,
100+
data: dataPointArray.map((dataPoint) => ({
101+
x: DateTime.fromJSDate(dataPoint.time).toISO(),
102+
y: dataPoint.value,
103+
})),
104+
borderColor,
105+
backgroundColor,
106+
}
107+
}
108+
)
109+
110+
const chartData: ChartData<'line'> = { labels, datasets }
111+
return <Line options={options} data={chartData} />
112+
}

frontend/src/components/Styles/StyledComponents.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,19 @@ export const AttributeTitleTypography = styled(Typography)`
6565
fontsize: 14;
6666
color: ${tokens.colors.text.static_icons__secondary.hex};
6767
`
68+
export const StyledTable = styled(Table)`
69+
display: block;
70+
overflow: auto;
71+
max-width: calc(80vw);
72+
`
73+
74+
export const StyledTableAndMap = styled.div`
75+
display: flex;
76+
flex-wrap: wrap;
77+
align-items: top;
78+
gap: 30px;
79+
`
80+
6881
export const StyledTableCell = styled(Table.Cell)`
6982
background-color: ${tokens.colors.ui.background__default.hex};
7083
`
@@ -74,3 +87,14 @@ export const StyledTableBody = styled(Table.Body)`
7487
export const StyledTableCaption = styled(Table.Caption)`
7588
background-color: ${tokens.colors.ui.background__default.hex};
7689
`
90+
export const StyledCardsWidth = styled.div`
91+
display: flex;
92+
flex-direction: column;
93+
max-width: fit-content;
94+
gap: 20px;
95+
`
96+
97+
export const VideoStreamSection = styled.div`
98+
display: grid;
99+
gap: 1rem;
100+
`

frontend/src/language/en.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,5 +377,8 @@
377377
"Loading installation data": "Loading installation data",
378378
"RechargingWithMission": "Recharging",
379379
"GoingToRechargingWithMission": "Returning to recharge",
380-
"PausedToCharge": "Paused for charging"
380+
"PausedToCharge": "Paused for charging",
381+
"Latest Value": "Latest Value",
382+
"Measured oil level throughout the last 7 days": "Measured oil level throughout the last 7 days",
383+
"Fill [%]": "Fill [%]"
381384
}

frontend/src/language/no.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,5 +377,8 @@
377377
"Loading installation data": "Laster installasjonsdata",
378378
"RechargingWithMission": "Lader",
379379
"GoingToRechargingWithMission": "Returnerer for å lade",
380-
"PausedToCharge": "Pauset for lading"
380+
"PausedToCharge": "Pauset for lading",
381+
"Latest Value": "Siste verdi",
382+
"Measured oil level throughout the last 7 days": "Målt oljenivå i løpet av de siste 7 dagene",
383+
"Fill [%]": "Fyll [%]"
381384
}

0 commit comments

Comments
 (0)