mirror of
https://github.com/pawelmalak/flame.git
synced 2025-07-19 03:29:37 +02:00
remove API KEYS
This commit is contained in:
parent
b234bc16ff
commit
6a054c76cd
9 changed files with 19 additions and 25 deletions
|
@ -42,10 +42,10 @@ export const WeatherSettings = (): JSX.Element => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
// Check for api key input
|
// Check for api key input
|
||||||
if ((formData.lat || formData.long) && !formData.WEATHER_API_KEY) {
|
if ((formData.lat || formData.long) && !formData.weather_enabled) {
|
||||||
createNotification({
|
createNotification({
|
||||||
title: 'Warning',
|
title: 'Warning',
|
||||||
message: 'API key is missing. Weather Module will NOT work',
|
message: 'You need to enable the weather module to use it',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,25 +97,19 @@ export const WeatherSettings = (): JSX.Element => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form onSubmit={(e) => formSubmitHandler(e)}>
|
<form onSubmit={(e) => formSubmitHandler(e)}>
|
||||||
<SettingsHeadline text="API" />
|
<SettingsHeadline text="Enabled" />
|
||||||
{/* API KEY */}
|
{/* API KEY */}
|
||||||
<InputGroup>
|
<InputGroup>
|
||||||
<label htmlFor="WEATHER_API_KEY">API key</label>
|
<label htmlFor="enabled">Enable weather module</label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="checkbox"
|
||||||
id="WEATHER_API_KEY"
|
id="weather_enabled"
|
||||||
name="WEATHER_API_KEY"
|
name="weather_enabled"
|
||||||
placeholder="secret"
|
checked={formData.weather_enabled}
|
||||||
value={formData.WEATHER_API_KEY}
|
|
||||||
onChange={(e) => inputChangeHandler(e)}
|
onChange={(e) => inputChangeHandler(e)}
|
||||||
/>
|
/>
|
||||||
<span>
|
<span>
|
||||||
Using
|
Required for weather module to work.
|
||||||
<a href="https://www.weatherapi.com/pricing.aspx" target="blank">
|
|
||||||
{' '}
|
|
||||||
Weather API
|
|
||||||
</a>
|
|
||||||
. Key is required for weather module to work.
|
|
||||||
</span>
|
</span>
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ export const WeatherWidget = (): JSX.Element => {
|
||||||
return (
|
return (
|
||||||
<div className={classes.WeatherWidget}>
|
<div className={classes.WeatherWidget}>
|
||||||
{configLoading ||
|
{configLoading ||
|
||||||
(config.WEATHER_API_KEY && weather.id > 0 && (
|
(config.weather_enabled && weather.id > 0 && (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<div className={classes.WeatherIcon}>
|
<div className={classes.WeatherIcon}>
|
||||||
<WeatherIcon
|
<WeatherIcon
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { WeatherData } from '../types';
|
import { WeatherData } from '../types';
|
||||||
|
|
||||||
export interface Config {
|
export interface Config {
|
||||||
WEATHER_API_KEY: string;
|
weather_enabled: boolean;
|
||||||
lat: number;
|
lat: number;
|
||||||
long: number;
|
long: number;
|
||||||
isCelsius: boolean;
|
isCelsius: boolean;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { WeatherData } from '../types';
|
import { WeatherData } from '../types';
|
||||||
|
|
||||||
export interface WeatherForm {
|
export interface WeatherForm {
|
||||||
WEATHER_API_KEY: string;
|
weather_enabled: boolean;
|
||||||
lat: number;
|
lat: number;
|
||||||
long: number;
|
long: number;
|
||||||
isCelsius: boolean;
|
isCelsius: boolean;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Config } from '../../interfaces';
|
import { Config } from '../../interfaces';
|
||||||
|
|
||||||
export const configTemplate: Config = {
|
export const configTemplate: Config = {
|
||||||
WEATHER_API_KEY: '',
|
weather_enabled: false,
|
||||||
lat: 0,
|
lat: 0,
|
||||||
long: 0,
|
long: 0,
|
||||||
isCelsius: true,
|
isCelsius: true,
|
||||||
|
|
|
@ -23,7 +23,7 @@ export const uiSettingsTemplate: UISettingsForm = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const weatherSettingsTemplate: WeatherForm = {
|
export const weatherSettingsTemplate: WeatherForm = {
|
||||||
WEATHER_API_KEY: '',
|
weather_enabled: false,
|
||||||
lat: 0,
|
lat: 0,
|
||||||
long: 0,
|
long: 0,
|
||||||
isCelsius: true,
|
isCelsius: true,
|
||||||
|
|
|
@ -3,7 +3,7 @@ const axios = require('axios');
|
||||||
const loadConfig = require('./loadConfig');
|
const loadConfig = require('./loadConfig');
|
||||||
|
|
||||||
const getExternalWeather = async () => {
|
const getExternalWeather = async () => {
|
||||||
const { WEATHER_API_KEY: secret, lat, long } = await loadConfig();
|
const { lat, long } = await loadConfig();
|
||||||
|
|
||||||
// Fetch data from external API
|
// Fetch data from external API
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"WEATHER_API_KEY": "",
|
"weather_enabled": false,
|
||||||
"lat": 0,
|
"lat": 0,
|
||||||
"long": 0,
|
"long": 0,
|
||||||
"isCelsius": true,
|
"isCelsius": true,
|
||||||
|
|
|
@ -7,9 +7,9 @@ const loadConfig = require('./loadConfig');
|
||||||
const logger = new Logger();
|
const logger = new Logger();
|
||||||
|
|
||||||
module.exports = async function () {
|
module.exports = async function () {
|
||||||
const { WEATHER_API_KEY } = await loadConfig();
|
const { weather_enabled } = await loadConfig();
|
||||||
|
|
||||||
if (WEATHER_API_KEY != '') {
|
if (weather_enabled) {
|
||||||
// Update weather data every 15 minutes
|
// Update weather data every 15 minutes
|
||||||
const weatherJob = schedule.scheduleJob(
|
const weatherJob = schedule.scheduleJob(
|
||||||
'updateWeather',
|
'updateWeather',
|
||||||
|
@ -20,7 +20,7 @@ module.exports = async function () {
|
||||||
|
|
||||||
Sockets.getSocket('weather').socket.send(JSON.stringify(weatherData));
|
Sockets.getSocket('weather').socket.send(JSON.stringify(weatherData));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (WEATHER_API_KEY) {
|
if (weather_enabled) {
|
||||||
logger.log(err.message, 'ERROR');
|
logger.log(err.message, 'ERROR');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue