File tree Expand file tree Collapse file tree 9 files changed +46
-53
lines changed
Expand file tree Collapse file tree 9 files changed +46
-53
lines changed Original file line number Diff line number Diff line change 6868<Dialog title =" Load from Epidata API" on:close >
6969 <form class ="uk-form-stacked" {id } on:submit ={onSubmit }>
7070 <div >
71- <div class =" uk-form-controls uk-form-controls-text" >
72- <div class =" uk-form-controls uk-form-controls-text api" >
73- <label
74- ><input class ="uk-checkbox" type ="checkbox" bind:checked ={$storeApiKeys } />
75- Save API keys & auth tokens</label
76- >
77- </div >
78- </div >
7971 <div class =" uk-form-label" >Data Source</div >
8072 <div class =" uk-form-controls uk-form-controls-text" >
8173 <label
181173 {/if }
182174 </form >
183175
184- <button slot ="footer" class ="uk-button uk-button-primary" type ="submit" form ={id } disabled ={loading }>
185- Fetch Data
186- {#if loading }
187- <div uk-spinner />
188- {/if }
189- </button >
176+ <div slot =" footer" >
177+ <div class =" uk-form-controls uk-form-controls-text container" >
178+ <button class ="uk-button uk-button-primary" type ="submit" form ={id } disabled ={loading }>
179+ Fetch Data
180+ {#if loading }
181+ <div uk-spinner />
182+ {/if }
183+ </button >
184+ <label
185+ ><input class ="uk-checkbox" type ="checkbox" bind:checked ={$storeApiKeys } />
186+ Save API keys & auth tokens</label
187+ >
188+ </div >
189+ </div >
190190</Dialog >
191191
192192<style >
193- .api {
194- float : right ;
193+ .container {
194+ display : flex ;
195+ align-items : center ;
196+ column-gap : 2em ;
195197 }
196198 </style >
Original file line number Diff line number Diff line change 1- export default class ApiKeySelections {
2- cdc = '' ;
3- fluView = '' ;
4- ght = '' ;
5- quidel = '' ;
6- sensors = '' ;
7- twitter = '' ;
8- }
9-
101export function getStoreApiKeys ( ) {
112 try {
123 if ( localStorage . getItem ( 'store-api' ) ) {
134 return JSON . parse ( localStorage . getItem ( 'store-api' ) ! ) as boolean ;
145 }
15- return true ;
6+ return false ;
167 } catch {
178 localStorage . removeItem ( 'store-api' ) ;
18- return true ;
9+ return false ;
1910 }
2011}
2112
22- export function getApiKeySelections ( ) {
13+ export function getApiKey ( ) {
2314 try {
2415 if ( localStorage . getItem ( 'api' ) ) {
25- return JSON . parse ( localStorage . getItem ( 'api' ) ! ) as ApiKeySelections ;
16+ return JSON . parse ( localStorage . getItem ( 'api' ) ! ) as string ;
2617 }
27- return new ApiKeySelections ( ) ;
18+ return '' ;
2819 } catch {
2920 localStorage . removeItem ( 'api' ) ;
30- return new ApiKeySelections ( ) ;
21+ return '' ;
3122 }
3223}
Original file line number Diff line number Diff line change 33 import { cdcLocations as regions } from ' ../../../data/data' ;
44 import SelectField from ' ../inputs/SelectField.svelte' ;
55 import TextField from ' ../inputs/TextField.svelte' ;
6- import { apiKeySelections } from ' ../../../store' ;
6+ import { apiKey } from ' ../../../store' ;
77
88 export let id: string ;
99
1010 let locations = regions [0 ].value ;
11- let auth = $apiKeySelections . cdc ;
11+ let auth = $apiKey ;
1212
1313 export function importDataSet() {
1414 return importCDC ({ locations , auth });
1919 id =" {id }-auth"
2020 name =" auth"
2121 label =" Authorizaton Token"
22- bind:value ={$apiKeySelections . cdc }
22+ bind:value ={$apiKey }
2323 placeholder =" authorization token"
2424/>
2525<SelectField id =" {id }-r" label ="Location" bind:value ={locations } options ={regions } />
Original file line number Diff line number Diff line change 11<script lang =" ts" >
22 import { importFluView } from ' ../../../api/EpiData' ;
33 import { fluViewRegions } from ' ../../../data/data' ;
4- import { apiKeySelections } from ' ../../../store' ;
4+ import { apiKey } from ' ../../../store' ;
55 import SelectField from ' ../inputs/SelectField.svelte' ;
66 import SelectIssue from ' ../inputs/SelectIssue.svelte' ;
77 import TextField from ' ../inputs/TextField.svelte' ;
1111
1212 let regions = fluViewRegions [0 ].value ;
1313 let issue = DEFAULT_ISSUE ;
14- let auth = $apiKeySelections . fluView ;
14+ let auth = $apiKey ;
1515
1616 export function importDataSet() {
1717 return importFluView ({ regions , ... issue , auth });
2424 id =" {id }-auth"
2525 name =" auth"
2626 label =" Auth Key"
27- bind:value ={$apiKeySelections . fluView }
27+ bind:value ={$apiKey }
2828 required ={false }
2929 placeholder =" authorization token"
3030/>
Original file line number Diff line number Diff line change 11<script lang =" ts" >
22 import { importGHT } from ' ../../../api/EpiData' ;
33 import { ghtLocations as regions } from ' ../../../data/data' ;
4- import { apiKeySelections } from ' ../../../store' ;
4+ import { apiKey } from ' ../../../store' ;
55 import SelectField from ' ../inputs/SelectField.svelte' ;
66 import TextField from ' ../inputs/TextField.svelte' ;
77
88 export let id: string ;
99
1010 let locations = regions [0 ].value ;
11- let auth = $apiKeySelections . ght ;
11+ let auth = $apiKey ;
1212 let query = ' ' ;
1313
1414 export function importDataSet() {
2020 id =" {id }-auth"
2121 name =" auth"
2222 label =" Authorizaton Token"
23- bind:value ={$apiKeySelections . ght }
23+ bind:value ={$apiKey }
2424 placeholder =" authorization token"
2525/>
2626<SelectField id =" {id }-r" label ="Location" bind:value ={locations } options ={regions } />
Original file line number Diff line number Diff line change 11<script lang =" ts" >
22 import { importQuidel } from ' ../../../api/EpiData' ;
33 import { quidelLocations as regions } from ' ../../../data/data' ;
4- import { apiKeySelections } from ' ../../../store' ;
4+ import { apiKey } from ' ../../../store' ;
55 import SelectField from ' ../inputs/SelectField.svelte' ;
66 import TextField from ' ../inputs/TextField.svelte' ;
77
88 export let id: string ;
99
1010 let locations = regions [0 ].value ;
11- let auth = $apiKeySelections . quidel ;
11+ let auth = $apiKey ;
1212
1313 export function importDataSet() {
1414 return importQuidel ({ auth , locations });
1919 id =" {id }-auth"
2020 name =" auth"
2121 label =" Authorizaton Token"
22- bind:value ={$apiKeySelections . quidel }
22+ bind:value ={$apiKey }
2323 placeholder =" authorization token"
2424/>
2525<SelectField id =" {id }-r" label ="Location" bind:value ={locations } options ={regions } />
Original file line number Diff line number Diff line change 11<script lang =" ts" >
22 import { importSensors } from ' ../../../api/EpiData' ;
33 import { sensorLocations as regions , sensorNames } from ' ../../../data/data' ;
4- import { apiKeySelections } from ' ../../../store' ;
4+ import { apiKey } from ' ../../../store' ;
55 import SelectField from ' ../inputs/SelectField.svelte' ;
66 import TextField from ' ../inputs/TextField.svelte' ;
77
88 export let id: string ;
99
1010 let locations = regions [0 ].value ;
11- let auth = $apiKeySelections . sensors ;
11+ let auth = $apiKey ;
1212 let names = sensorNames [0 ].value ;
1313
1414 export function importDataSet() {
2020 id =" {id }-auth"
2121 name =" auth"
2222 label =" Authorizaton Token"
23- bind:value ={$apiKeySelections . sensors }
23+ bind:value ={$apiKey }
2424 placeholder =" authorization token"
2525/>
2626<SelectField id =" {id }-s" label ="Name" bind:value ={names } options ={sensorNames } name =" sensor" />
Original file line number Diff line number Diff line change 11<script lang =" ts" >
22 import { importTwitter } from ' ../../../api/EpiData' ;
33 import { twitterLocations as regions } from ' ../../../data/data' ;
4- import { apiKeySelections } from ' ../../../store' ;
4+ import { apiKey } from ' ../../../store' ;
55 import SelectField from ' ../inputs/SelectField.svelte' ;
66 import TextField from ' ../inputs/TextField.svelte' ;
77
88 export let id: string ;
99
1010 let locations = regions [0 ].value ;
11- let auth = $apiKeySelections . twitter ;
11+ let auth = $apiKey ;
1212 let resolution: ' daily' | ' weekly' = ' daily' ;
1313
1414 export function importDataSet() {
2020 id =" {id }-auth"
2121 name =" auth"
2222 label =" Authorizaton Token"
23- bind:value ={$apiKeySelections . twitter }
23+ bind:value ={$apiKey }
2424 placeholder =" authorization token"
2525/>
2626<SelectField id =" {id }-r" label ="Location" bind:value ={locations } options ={regions } />
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import { get, writable } from 'svelte/store';
22import { NavMode } from './components/chartUtils' ;
33import DataSet , { DataGroup } from './data/DataSet' ;
44import deriveLinkDefaults , { getDirectLinkImpl } from './deriveLinkDefaults' ;
5- import { getApiKeySelections , getStoreApiKeys } from './components/dialogs/apiKeySelections' ;
5+ import { getApiKey , getApiKeySelections , getStoreApiKeys } from './components/dialogs/apiKeySelections' ;
66
77declare const __VERSION__ : string ;
88
@@ -26,9 +26,9 @@ storeApiKeys.subscribe((val) => {
2626 }
2727 localStorage . setItem ( 'store-api' , val . toString ( ) ) ;
2828} ) ;
29- export const apiKeySelections = writable ( getApiKeySelections ( ) ) ;
30- apiKeySelections . subscribe ( ( val ) => {
31- localStorage . setItem ( 'api' , JSON . stringify ( val ) ) ;
29+ export const apiKey = writable ( getApiKey ( ) ) ;
30+ apiKey . subscribe ( ( val ) => {
31+ localStorage . setItem ( 'api' , val . toString ( ) ) ;
3232} ) ;
3333
3434export function addDataSet ( dataset : DataSet | DataGroup ) : void {
You can’t perform that action at this time.
0 commit comments