Skip to content

Commit 49ba526

Browse files
committed
DBC22-6145: not showing all 30km away stations for cameras
DBC22-6145: fixed elevation not found error DBC22-6145: not showing all 30km away stations for cameras DBC22-6145: fixed elevation not found error DBC22-6145: fixed the issue that spin all the time when not stations DBC22-6145: fixed weather station not updated when camera switched DBC22-6145: updated nearbyweather ui when there is no station associated added missing file
1 parent 35ae122 commit 49ba526

3 files changed

Lines changed: 40 additions & 13 deletions

File tree

package-lock.json

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

src/backend/apps/webcam/tasks.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,10 @@ def update_camera_weather_station(camera, weather_class):
550550
elevation__lte=camera.elevation + 300,
551551
elevation__gte=camera.elevation - 300,
552552
)
553+
elif weather_class == RegionalWeather or weather_class == HighElevationForecast:
554+
stations_qs = stations_qs.filter(
555+
distance__lte=D(km=30),
556+
)
553557

554558
closest_station = stations_qs.order_by('distance').first()
555559

src/frontend/src/Components/cameras/nearbyweathers/NearbyWeathers.js

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,13 @@ export default function NearbyWeathers(props) {
5454
const defaultActiveTab = weatherTabs.length ? weatherTabs[0].key : null;
5555
const [activeTab, setActiveTab] = useState(defaultActiveTab);
5656

57+
const hasWeather = localWeather || regionalWeather || hef;
58+
5759
// Effects
5860
// find regional weather and set state
5961
useEffect(() => {
6062
if (!regionalWeatherList || !camera.regional_weather_station) {
63+
setRegionalWeather(null);
6164
return;
6265
}
6366

@@ -69,6 +72,7 @@ export default function NearbyWeathers(props) {
6972
// find local weather and set state
7073
useEffect(() => {
7174
if (!currentWeatherList || !camera.local_weather_station) {
75+
setLocalWeather(null);
7276
return;
7377
}
7478

@@ -80,6 +84,7 @@ export default function NearbyWeathers(props) {
8084
// find hef and set state
8185
useEffect(() => {
8286
if (!hefList || !camera.hev_station) {
87+
setHef(null);
8388
return;
8489
}
8590

@@ -102,7 +107,7 @@ export default function NearbyWeathers(props) {
102107

103108
/* Rendering */
104109
// Loading state
105-
if (!regionalWeather && !localWeather && !hef) {
110+
if ((regionalWeather || localWeather || hef) && (!regionalWeather && !localWeather && !hef)) {
106111
return (
107112
<div>
108113
<Skeleton height={48}/>
@@ -139,18 +144,30 @@ export default function NearbyWeathers(props) {
139144
})}
140145
</div>
141146
</div>
142-
143-
{ activeTab === 'Roadside' && localWeather &&
144-
<NearbyLocalWeather weather={localWeather} />
145-
}
146-
147-
{ activeTab === 'Regional' && regionalWeather &&
148-
<NearbyRegionalWeather weather={regionalWeather} />
149-
}
150-
151-
{ activeTab === 'High elevation' && hef &&
152-
<NearbyHevWeather weather={hef} />
153-
}
147+
<div>
148+
{!hasWeather ? (
149+
<div className="weather-empty">
150+
<h3>No nearby weather available</h3>
151+
<p>
152+
Unfortunately there is no nearby weather data available for this camera.
153+
</p>
154+
</div>
155+
) : (
156+
<>
157+
{activeTab === 'Roadside' && localWeather && (
158+
<NearbyLocalWeather weather={localWeather} />
159+
)}
160+
161+
{activeTab === 'Regional' && regionalWeather && (
162+
<NearbyRegionalWeather weather={regionalWeather} />
163+
)}
164+
165+
{activeTab === 'High elevation' && hef && (
166+
<NearbyHevWeather weather={hef} />
167+
)}
168+
</>
169+
)}
170+
</div>
154171
</div>
155172
</React.Fragment>
156173
);

0 commit comments

Comments
 (0)