Skip to content

Commit fa25cfd

Browse files
committed
Add cloe data view
1 parent 5b725e0 commit fa25cfd

14 files changed

Lines changed: 397 additions & 48 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",
@@ -55,6 +59,7 @@
5559
"devDependencies": {
5660
"@eslint/js": "^9.39.2",
5761
"@types/leaflet": "^1.9.20",
62+
"@types/luxon": "^3.7.1",
5863
"@types/react-big-calendar": "^1.16.2",
5964
"@types/react-modal": "^3.16.3",
6065
"@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: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
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+
23+
24+
const PALETTE: [string, string][] = [
25+
['rgb(255, 18, 67)', 'rgba(255, 18, 67, 0.5)'],
26+
['rgb(125, 0, 35)', 'rgba(125, 0, 35, 0.5)'],
27+
['rgb(36, 55, 70)', 'rgba(36, 55, 70, 0.5)'],
28+
['rgb(0, 112, 121)', 'rgba(0, 112, 121, 0.5)'],
29+
]
30+
31+
interface TimeseriesLinePlotDataPoint {
32+
time: Date,
33+
value: number
34+
}
35+
36+
37+
export interface TimeseriesLinePlotData {
38+
[id: string]: TimeseriesLinePlotDataPoint[]
39+
}
40+
41+
interface Props {
42+
data: TimeseriesLinePlotData
43+
yLabel: string
44+
}
45+
46+
export const TimeseriesLinePlot = ({ data, yLabel }: Props) => {
47+
const options: ChartOptions<'line'> = {
48+
responsive: true,
49+
spanGaps: true,
50+
51+
plugins: {
52+
legend: {
53+
position: 'right' as const,
54+
},
55+
title: {
56+
display: false,
57+
},
58+
},
59+
scales: {
60+
x: {
61+
type: 'time',
62+
adapters: {
63+
date: {
64+
zone: 'Europe/Oslo',
65+
},
66+
},
67+
time: {
68+
// Luxon format tokens (https://moment.github.io/luxon/#/formatting?id=table-of-tokens)
69+
tooltipFormat: 'dd.MM.yy HH:mm',
70+
displayFormats: {
71+
millisecond: 'HH:mm:ss.SSS',
72+
second: 'HH:mm:ss',
73+
minute: 'HH:mm',
74+
hour: 'HH:mm',
75+
day: 'dd.MM',
76+
week: 'dd.MM',
77+
month: 'MM.yyyy',
78+
quarter: 'qq yyyy',
79+
year: 'yyyy',
80+
},
81+
},
82+
title: {
83+
display: true,
84+
text: 'Time'
85+
}
86+
},
87+
y: {
88+
title: {
89+
display: true,
90+
text: yLabel
91+
}
92+
}
93+
}
94+
}
95+
96+
const labels: string[] = []
97+
// @ts-expect-error ; Date isn't assignable to number for x-axis value - assumption: library can handle it anyways
98+
const datasets: ChartDataset<'line', DefaultDataPoint<'line'>>[] = Object.entries(data).map(([id, dataPointArray], index:number) => {
99+
const [borderColor, backgroundColor] = PALETTE[index % PALETTE.length]
100+
return {
101+
label: id,
102+
data: dataPointArray.map(dataPoint => ({x:DateTime.fromJSDate(dataPoint.time).toISO(), y:dataPoint.value})),
103+
borderColor,
104+
backgroundColor,
105+
}
106+
})
107+
108+
const chartData: ChartData<'line'> = { labels, datasets }
109+
return <Line options={options} data={chartData} />
110+
}

frontend/src/components/Styles/StyledComponents.tsx

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

frontend/src/language/en.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,5 +376,8 @@
376376
"Task Success Rate": "Task Success Rate",
377377
"Loading installation data": "Loading installation data",
378378
"RechargingWithMission": "Recharging",
379-
"GoingToRechargingWithMission": "Going home to recharge (mission paused)"
379+
"GoingToRechargingWithMission": "Going home to recharge (mission paused)",
380+
"Latest Value": "Latest Value",
381+
"Measured oil level throughout the last 7 days": "Measured oil level throughout the last 7 days",
382+
"Fill [%]": "Fill [%]"
380383
}

frontend/src/language/no.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,5 +376,8 @@
376376
"Task Success Rate": "Suksessrate for oppgaver",
377377
"Loading installation data": "Laster installasjonsdata",
378378
"RechargingWithMission": "Lader",
379-
"GoingToRechargingWithMission": "Returnerer for å lade (oppdrag pauset)"
379+
"GoingToRechargingWithMission": "Returnerer for å lade (oppdrag pauset)",
380+
"Latest Value": "Siste verdi",
381+
"Measured oil level throughout the last 7 days": "Målt oljenivå i løpet av de siste 7 dagene",
382+
"Fill [%]": "Fyll [%]"
380383
}

0 commit comments

Comments
 (0)