Skip to content

Commit

Permalink
allow change language of weather card
Browse files Browse the repository at this point in the history
  • Loading branch information
stepanenko3 committed Mar 30, 2023
1 parent 8f7dad8 commit cf51ec8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dist/js/entry.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions resources/js/cards/Weather.vue
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
endpoint() {
const queryString = new URLSearchParams({
q: this.card.city,
lang: this.card?.lang || '',
}).toString();
return Nova.request().get('/nova-vendor/stepanenko3/nova-cards/weather' + (queryString ? `?${queryString}` :''));
Expand Down
7 changes: 7 additions & 0 deletions src/Cards/WeatherCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ public function city(string $cityName): self
]);
}

public function lang(string $lang): self
{
return $this->withMeta([
'lang' => $lang,
]);
}

/**
* Get the component name for the element.
*
Expand Down
3 changes: 2 additions & 1 deletion src/Http/Controllers/WeatherController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ public function __invoke(Request $request)
'nova-weather-card:' . implode('-', [
$request->input('q', 'Kiev'),
$request->input('units', 'metric'),
config('app.locale'),
$request->input('lang', config('app.locale')),
]),
10,
fn () => Http::get('https://api.openweathermap.org/data/2.5/weather', [
'q' => $request->input('q', 'Kiev'),
'appid' => config('nova-cards.open_weather_token'),
'units' => $request->input('units', 'metric'),
'lang' => $request->input('lang', config('app.locale')),
])->json(),
);

Expand Down

0 comments on commit cf51ec8

Please sign in to comment.