Skip to content

Commit 9c78def

Browse files
committed
Merge remote-tracking branch 'origin/dev' into rzatserkovnyi/persistent-forms
2 parents a8394f3 + 6b6fe3b commit 9c78def

File tree

11 files changed

+109
-49
lines changed

11 files changed

+109
-49
lines changed

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "www-epivis",
3-
"version": "2.1.4",
3+
"version": "2.1.5",
44
"private": true,
55
"license": "MIT",
66
"description": "",

src/components/dialogs/ImportAPIDialog.svelte

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import NowCast from './dataSources/Nowcast.svelte';
2020
import CovidHosp from './dataSources/COVIDHosp.svelte';
2121
import CoviDcast from './dataSources/COVIDcast.svelte';
22-
import { navMode } from '../../store';
22+
import { navMode, storeApiKeys } from '../../store';
2323
import { NavMode } from '../chartUtils';
2424
import { formSelections } from '../../store';
2525
@@ -224,10 +224,26 @@
224224
{/if}
225225
</form>
226226

227-
<button slot="footer" class="uk-button uk-button-primary" type="submit" form={id} disabled={loading}>
228-
Fetch Data
229-
{#if loading}
230-
<div uk-spinner />
231-
{/if}
232-
</button>
227+
<div slot="footer">
228+
<div class="uk-form-controls uk-form-controls-text container">
229+
<button class="uk-button uk-button-primary" type="submit" form={id} disabled={loading}>
230+
Fetch Data
231+
{#if loading}
232+
<div uk-spinner />
233+
{/if}
234+
</button>
235+
<label
236+
><input class="uk-checkbox" type="checkbox" bind:checked={$storeApiKeys} />
237+
Save API key (auth token) between visits</label
238+
>
239+
</div>
240+
</div>
233241
</Dialog>
242+
243+
<style>
244+
.container {
245+
display: flex;
246+
align-items: center;
247+
column-gap: 2em;
248+
}
249+
</style>

src/components/dialogs/dataSources/CDC.svelte

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,20 @@
33
import { cdcLocations as regions } from '../../../data/data';
44
import SelectField from '../inputs/SelectField.svelte';
55
import TextField from '../inputs/TextField.svelte';
6-
import { formSelections } from '../../../store';
6+
import { apiKey, formSelections } from '../../../store';
77
88
export let id: string;
99
10-
let auth = '';
11-
1210
export function importDataSet() {
13-
return importCDC({ locations: $formSelections.cdc.locations, auth });
11+
return importCDC({ locations: $formSelections.cdc.locations, auth: $apiKey });
1412
}
1513
</script>
1614

17-
<TextField id="{id}-auth" name="auth" label="Authorizaton Token" bind:value={auth} placeholder="authorization token" />
15+
<TextField
16+
id="{id}-auth"
17+
name="auth"
18+
label="Authorizaton Token"
19+
bind:value={$apiKey}
20+
placeholder="authorization token"
21+
/>
1822
<SelectField id="{id}-r" label="Location" bind:value={$formSelections.cdc.locations} options={regions} />

src/components/dialogs/dataSources/COVIDcast.svelte

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,13 @@
44
import type { LabelValue } from '../../../data/data';
55
import SelectField from '../inputs/SelectField.svelte';
66
import TextField from '../inputs/TextField.svelte';
7-
import { formSelections } from '../../../store';
7+
import { apiKey, formSelections } from '../../../store';
88
99
export let id: string;
10-
11-
let api_key = '';
1210
let data_source = $formSelections.covidcast.dataSource;
1311
let signal = $formSelections.covidcast.signal;
1412
let geo_type = $formSelections.covidcast.geoType;
1513
let geo_value = $formSelections.covidcast.geoValue;
16-
let form_key = '';
1714
let valid_key = true;
1815
1916
let dataSources: (LabelValue & { signals: string[] })[] = [];
@@ -38,12 +35,11 @@
3835
};
3936
4037
function fetchMetadata() {
41-
fetchCOVIDcastMeta(form_key).then((res) => {
38+
fetchCOVIDcastMeta($apiKey).then((res) => {
4239
if (res.length == 0) {
4340
valid_key = false;
4441
} else {
4542
valid_key = true;
46-
api_key = form_key; // API key is valid -> use it to fetch data later on
4743
geoTypes = [...new Set(res.map((d) => d.geo_type))];
4844
const byDataSource = new Map<string, LabelValue & { signals: string[] }>();
4945
for (const row of res) {
@@ -71,10 +67,10 @@
7167
});
7268
7369
export function importDataSet() {
74-
return fetchCOVIDcastMeta(api_key).then((res) => {
70+
return fetchCOVIDcastMeta($apiKey).then((res) => {
7571
const meta = res.filter((row) => row.data_source === data_source && row.signal === signal);
7672
const time_type = meta[0].time_type;
77-
return importCOVIDcast({ data_source, signal, geo_type, geo_value, time_type, api_key });
73+
return importCOVIDcast({ data_source, signal, geo_type, geo_value, time_type, api_key: $apiKey });
7874
});
7975
}
8076
</script>
@@ -91,7 +87,7 @@
9187
class:uk-form-danger={!valid_key}
9288
name="api_key"
9389
required={false}
94-
bind:value={form_key}
90+
bind:value={$apiKey}
9591
on:input={debounce(() => fetchMetadata(), 500)}
9692
/>
9793
{#if !valid_key}

src/components/dialogs/dataSources/FluView.svelte

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@
44
import SelectField from '../inputs/SelectField.svelte';
55
import SelectIssue from '../inputs/SelectIssue.svelte';
66
import TextField from '../inputs/TextField.svelte';
7-
import { formSelections } from '../../../store';
7+
import { apiKey, formSelections } from '../../../store';
88
99
export let id: string;
1010
11-
let auth: string = '';
12-
1311
export function importDataSet() {
14-
return importFluView({ regions: $formSelections.fluView.locations, ...$formSelections.fluView.issue, auth });
12+
return importFluView({
13+
regions: $formSelections.fluView.locations,
14+
...$formSelections.fluView.issue,
15+
auth: $apiKey,
16+
});
1517
}
1618
</script>
1719

@@ -21,7 +23,7 @@
2123
id="{id}-auth"
2224
name="auth"
2325
label="Auth Key"
24-
bind:value={auth}
26+
bind:value={$apiKey}
2527
required={false}
2628
placeholder="authorization token"
2729
/>

src/components/dialogs/dataSources/GHT.svelte

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,21 @@
33
import { ghtLocations as regions } from '../../../data/data';
44
import SelectField from '../inputs/SelectField.svelte';
55
import TextField from '../inputs/TextField.svelte';
6-
import { formSelections } from '../../../store';
6+
import { apiKey, formSelections } from '../../../store';
77
88
export let id: string;
99
10-
let auth = '';
11-
1210
export function importDataSet() {
13-
return importGHT({ auth, locations: $formSelections.ght.locations, query: $formSelections.ght.query });
11+
return importGHT({ auth: $apiKey, locations: $formSelections.ght.locations, query: $formSelections.ght.query });
1412
}
1513
</script>
1614

17-
<TextField id="{id}-auth" name="auth" label="Authorizaton Token" bind:value={auth} placeholder="authorization token" />
15+
<TextField
16+
id="{id}-auth"
17+
name="auth"
18+
label="Authorizaton Token"
19+
bind:value={$apiKey}
20+
placeholder="authorization token"
21+
/>
1822
<SelectField id="{id}-r" label="Location" bind:value={$formSelections.ght.locations} options={regions} />
1923
<TextField id="{id}-query" name="query" label="Search Query or Topic" bind:value={$formSelections.ght.query} />

src/components/dialogs/dataSources/Quidel.svelte

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,20 @@
33
import { quidelLocations as regions } from '../../../data/data';
44
import SelectField from '../inputs/SelectField.svelte';
55
import TextField from '../inputs/TextField.svelte';
6-
import { formSelections } from '../../../store';
6+
import { apiKey, formSelections } from '../../../store';
77
88
export let id: string;
99
10-
let auth = '';
11-
1210
export function importDataSet() {
13-
return importQuidel({ auth, locations: $formSelections.quidel.locations });
11+
return importQuidel({ auth: $apiKey, locations: $formSelections.quidel.locations });
1412
}
1513
</script>
1614

17-
<TextField id="{id}-auth" name="auth" label="Authorizaton Token" bind:value={auth} placeholder="authorization token" />
15+
<TextField
16+
id="{id}-auth"
17+
name="auth"
18+
label="Authorizaton Token"
19+
bind:value={$apiKey}
20+
placeholder="authorization token"
21+
/>
1822
<SelectField id="{id}-r" label="Location" bind:value={$formSelections.quidel.locations} options={regions} />

src/components/dialogs/dataSources/Sensors.svelte

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,25 @@
33
import { sensorLocations as regions, sensorNames } from '../../../data/data';
44
import SelectField from '../inputs/SelectField.svelte';
55
import TextField from '../inputs/TextField.svelte';
6-
import { formSelections } from '../../../store';
6+
import { apiKey, formSelections } from '../../../store';
77
88
export let id: string;
99
10-
let auth = '';
11-
1210
export function importDataSet() {
13-
return importSensors({ auth, names: $formSelections.sensors.names, locations: $formSelections.sensors.locations });
11+
return importSensors({
12+
auth: $apiKey,
13+
names: $formSelections.sensors.names,
14+
locations: $formSelections.sensors.locations,
15+
});
1416
}
1517
</script>
1618

17-
<TextField id="{id}-auth" name="auth" label="Authorizaton Token" bind:value={auth} placeholder="authorization token" />
19+
<TextField
20+
id="{id}-auth"
21+
name="auth"
22+
label="Authorizaton Token"
23+
bind:value={$apiKey}
24+
placeholder="authorization token"
25+
/>
1826
<SelectField id="{id}-s" label="Name" bind:value={$formSelections.sensors.names} options={sensorNames} name="sensor" />
1927
<SelectField id="{id}-r" label="Location" bind:value={$formSelections.sensors.locations} options={regions} />

src/components/dialogs/dataSources/Twitter.svelte

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,26 @@
33
import { twitterLocations as regions } from '../../../data/data';
44
import SelectField from '../inputs/SelectField.svelte';
55
import TextField from '../inputs/TextField.svelte';
6-
import { formSelections } from '../../../store';
6+
import { apiKey, formSelections } from '../../../store';
77
88
export let id: string;
99
10-
let auth = '';
11-
1210
export function importDataSet() {
1311
return importTwitter({
14-
auth,
12+
auth: $apiKey,
1513
locations: $formSelections.twitter.locations,
1614
resolution: $formSelections.twitter.resolution,
1715
});
1816
}
1917
</script>
2018

21-
<TextField id="{id}-auth" name="auth" label="Authorizaton Token" bind:value={auth} placeholder="authorization token" />
19+
<TextField
20+
id="{id}-auth"
21+
name="auth"
22+
label="Authorizaton Token"
23+
bind:value={$apiKey}
24+
placeholder="authorization token"
25+
/>
2226
<SelectField id="{id}-r" label="Location" bind:value={$formSelections.twitter.locations} options={regions} />
2327
<div>
2428
<div class="uk-form-label">Temporal Resolution</div>

0 commit comments

Comments
 (0)