Skip to content

Commit

Permalink
Handle source not found
Browse files Browse the repository at this point in the history
  • Loading branch information
arildm committed Jan 25, 2024
1 parent 8937032 commit 0f37915
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/corpus/sources/SourceView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import useSources from "./sources.composable";
import SourceText from "./SourceText.vue";
import PendingContent from "@/spin/PendingContent.vue";
import useLocale from "@/i18n/locale.composable";
import MessageAlert from "@/message/MessageAlert.vue";
const props = defineProps<{
corpusId: string;
Expand All @@ -19,11 +20,9 @@ const { downloadSource, downloadPlaintext } = useSources(props.corpusId);
const { isJobDone } = useJob(props.corpusId);
const { filesize } = useLocale();
// TODO Handle missing source (e.g. due to user visiting old url)
const sources = computed(() => corpusStore.corpora[props.corpusId].sources);
const metadata = computed(() =>
corpusStore.corpora[props.corpusId].sources?.find(
(source) => source.name === props.filename
)
sources.value?.find((source) => source.name === props.filename)
);
const isBinary = computed(() => metadata.value?.type.indexOf("text/") !== 0);
const isPlaintext = computed(() => metadata.value?.type == "text/plain");
Expand All @@ -42,6 +41,11 @@ async function loadPlain() {
<template>
<LayoutSection>
<h2>{{ filename }}</h2>
<MessageAlert
v-if="sources && !metadata"
:message="$t('source.notfound')"
status="error"
/>
<table v-if="metadata" class="w-full mt-4">
<tbody>
<tr>
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ source.limit.file.max: Maximum file size
source.limit.upload.max: Maximum batch upload size
source.limit.corpus.recommended: Recommended max corpus size
source.limit.corpus.max: Maximum corpus size
source.notfound: This source file was not found
source.uploading: Uploading text file | Uploading text files
source.upload.drop.empty: No file was dropped. Drag-and-drop may not be supported on your system.
source.list.loading: Listing source texts
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/sv.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ source.limit.file.max: Högsta tillåtna filstorlek
source.limit.upload.max: Största tillåtna uppladdning
source.limit.corpus.recommended: Rekommenderad korpusstorlek
source.limit.corpus.max: Största tillåtna korpus
source.notfound: Denna källfil kunde inte hittas
source.uploading: Laddar upp källfil | Laddar upp källfiler
source.upload.drop.empty: Ingen fil släpptes. Dra-och-släpp kanske inte stöds på ditt system.
source.list.loading: Hämtar textlista
Expand Down

0 comments on commit 0f37915

Please sign in to comment.