generated from League-of-Foundry-Developers/FoundryVTT-Module-Template
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #22 - CSV loading without uploading it to the foundry
- Loading branch information
Showing
6 changed files
with
106 additions
and
29 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<script lang="ts"> | ||
import { loadDataFromCSV } from '../csv'; | ||
export let syncMethod: 'yes' | 'no'; | ||
interface Option { | ||
value: 'yes' | 'no'; | ||
title: string; | ||
} | ||
let options: Option[]; | ||
$: { | ||
options = [ | ||
{ value: 'no', title: 'No - stick to CSV file' }, | ||
{ value: 'yes', title: 'Yes - use API' } | ||
]; | ||
} | ||
function onCSVSelected(e: any) { | ||
const csv = e.target.files[0]; | ||
console.log('SyrinControl | onCSVSelected', csv); | ||
ui.notifications?.info(`SyrinControl | Loading ${csv.name}.`); | ||
let reader = new FileReader(); | ||
reader.readAsText(csv); | ||
reader.onload = () => { | ||
const controlLinks = reader.result; | ||
if (typeof controlLinks === 'string') { | ||
console.debug('SyrinControl | Loaded', reader.result); | ||
loadDataFromCSV(csv.name, controlLinks); | ||
} | ||
}; | ||
reader.onerror = () => { | ||
ui.notifications?.error('SyrinControl | ' + reader.error); | ||
console.error('SyrinControl | ', reader.error); | ||
}; | ||
} | ||
</script> | ||
|
||
<div class="form-group" id="fvtt-syrin-control-settings"> | ||
<!-- svelte-ignore a11y-label-has-associated-control --> | ||
<label>Synchronization method</label> | ||
<div class="form-fields"> | ||
<select name="fvtt-syrin-control.syncMethod" data-dtype="String" bind:value={syncMethod}> | ||
{#each options as option} | ||
<option value={option.value}>{option.title}</option> | ||
{/each} | ||
</select> | ||
</div> | ||
<p class="notes">Should the module use online API to retrieve mood list?</p> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<!-- svelte-ignore a11y-label-has-associated-control --> | ||
<label>Control Links</label> | ||
<div class="form-fields"> | ||
<input disabled={syncMethod === 'yes'} type="file" accept=".csv" on:change={onCSVSelected} /> | ||
</div> | ||
<p class="notes"> | ||
{#if syncMethod === 'yes'} | ||
Control links CSV - disabled because of online API synchronization method | ||
{:else} | ||
Control links CSV - click "Download Remote Control Links" in Master Panel and upload it here. | ||
{/if} | ||
</p> | ||
</div> |
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