-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
82 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<template> | ||
<div class='col-12 px-2'> | ||
<TablerLoading | ||
v-if='loading' | ||
desc='Loading Breadcrumb' | ||
/> | ||
<template v-else> | ||
<label class='subheader text-white'><IconRoute :size='24' stroke='1'/>Breadcrumb Loader</label> | ||
|
||
<div class='border border-white rounded my-2 row g-2 px-2 py-2'> | ||
<div class='col-12'> | ||
<TablerEnum | ||
v-model='query.relative' | ||
default='1 Hour' | ||
:options='[ | ||
"1 Hour", | ||
"4 Hours", | ||
"8 Hours", | ||
"24 Hours" | ||
]' | ||
/> | ||
</div> | ||
|
||
<div class='col-12'> | ||
<TablerButton | ||
class='btn-primary w-100' | ||
@click.stop.prevent='loadBreadcrumb' | ||
> | ||
Submit | ||
</TablerButton> | ||
</div> | ||
</div> | ||
</template> | ||
</div> | ||
</template> | ||
|
||
<script setup lang='ts'> | ||
import { ref } from 'vue'; | ||
import { std, stdurl } from '../../../../src/std.ts'; | ||
import type { FeatureCollection } from '../../../../src/types.ts'; | ||
import { | ||
IconRoute | ||
} from '@tabler/icons-vue'; | ||
import { | ||
TablerEnum, | ||
TablerButton, | ||
TablerLoading | ||
} from '@tak-ps/vue-tabler'; | ||
import { useCOTStore } from '../../../../src/stores/cots.ts'; | ||
const cotStore = useCOTStore(); | ||
const props = defineProps<{ | ||
uid: string | ||
}>(); | ||
const query = ref({ | ||
relative: '1 Hour' | ||
}); | ||
const loading = ref(false); | ||
async function loadBreadcrumb() { | ||
loading.value = true; | ||
try { | ||
const url = stdurl(`/api/marti/cot/${props.uid}/all`) | ||
url.searchParams.append('secago', String(60 * Number(query.value.relative.split(' ')[0]))) | ||
url.searchParams.append('track', String(true)) | ||
const crumb = await std(url) as FeatureCollection; | ||
for (const feat of crumb.features) { | ||
cotStore.add(feat) | ||
} | ||
loading.value = false; | ||
} catch (err) { | ||
loading.value = false; | ||
throw err; | ||
} | ||
} | ||
</script> |