forked from GladysAssistant/Gladys
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix GladysAssistant#726: Replace DarkSky by OpenWeatherMap API integr…
…ation (GladysAssistant#837) * feat(openweather): implementation to API openweather TODO : Have a decision about DarkSky (keep it and enable weather with 2 services) or remove it * feat(openweather): remove darksky integration * feat(openweather): add unit test * feat(openweather): solve merge conflicts * fix: review comment * Improve integrations tab UI (GladysAssistant#805) -> merge report * fix: review comments "si", 'si' -> 'metric' * Fix weather key in front Co-authored-by: Julien Mellano <julien.spam82@gmail.com>
- Loading branch information
1 parent
ac054ad
commit cb47690
Showing
37 changed files
with
812 additions
and
2,035 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[ | ||
{ | ||
"key": "darkSky", | ||
"img": "/assets/integrations/cover/darksky.jpg" | ||
"key": "openWeather", | ||
"img": "/assets/integrations/cover/openweather.jpg" | ||
} | ||
] |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { RequestStatus } from '../../../../utils/consts'; | ||
|
||
const actions = store => ({ | ||
updateApiKey(state, e) { | ||
store.setState({ | ||
openWeatherApiKey: e.target.value | ||
}); | ||
}, | ||
async getApiKey(state) { | ||
store.setState({ | ||
openWeatherGetApiKeyStatus: RequestStatus.Getting | ||
}); | ||
try { | ||
const variable = await state.httpClient.get('/api/v1/service/openweather/variable/OPENWEATHER_API_KEY'); | ||
store.setState({ | ||
openWeatherApiKey: variable.value, | ||
openWeatherGetApiKeyStatus: RequestStatus.Success | ||
}); | ||
} catch (e) { | ||
store.setState({ | ||
openWeatherGetApiKeyStatus: RequestStatus.Error | ||
}); | ||
} | ||
}, | ||
async saveApiKey(state, e) { | ||
e.preventDefault(); | ||
store.setState({ | ||
openWeatherSaveApiKeyStatus: RequestStatus.Getting | ||
}); | ||
try { | ||
store.setState({ | ||
openWeatheryApiKey: state.openWeatherApiKey.trim() | ||
}); | ||
// save api key | ||
await state.httpClient.post('/api/v1/service/openweather/variable/OPENWEATHER_API_KEY', { | ||
value: state.openWeatherApiKey.trim() | ||
}); | ||
// start service | ||
await state.httpClient.post('/api/v1/service/openweather/start'); | ||
store.setState({ | ||
openWeatherSaveApiKeyStatus: RequestStatus.Success | ||
}); | ||
} catch (e) { | ||
store.setState({ | ||
openWeatherSaveApiKeyStatus: RequestStatus.Error | ||
}); | ||
} | ||
} | ||
}); | ||
|
||
export default actions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Component } from 'preact'; | ||
import { connect } from 'unistore/preact'; | ||
import actions from './actions'; | ||
import OpenWeatherPage from './OpenWeather'; | ||
import { RequestStatus } from '../../../../utils/consts'; | ||
|
||
@connect('user,openWeatherApiKey,openWeatherSaveApiKeyStatus,openWeatherGetApiKeyStatus', actions) | ||
class OpenWeatherIntegration extends Component { | ||
componentWillMount() { | ||
this.props.getApiKey(); | ||
} | ||
|
||
render(props, {}) { | ||
const loading = | ||
props.openWeatherSaveApiKeyStatus === RequestStatus.Getting || | ||
props.openWeatherGetApiKeyStatus === RequestStatus.Getting; | ||
return <OpenWeatherPage {...props} loading={loading} />; | ||
} | ||
} | ||
|
||
export default OpenWeatherIntegration; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.