Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
arildm committed Aug 22, 2023
2 parents b27231d + 9b44cb3 commit 41c82f6
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/auth/auth.composable.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function useAuth() {
router.push("/access-denied");
return;
}
callback();
callback?.();
}

/** Fetch JWT, store it and use it for API client. */
Expand Down
10 changes: 8 additions & 2 deletions src/corpus/Corpus.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,28 @@
</template>

<script setup>
import { computed } from "vue";
import { useAuth } from "@/auth/auth.composable";
import { useCorpusStore } from "@/store/corpus.store";
import useCorpusIdParam from "./corpusIdParam.composable";
import useCorpora from "@/corpora/corpora.composable";
import useCorpus from "./corpus.composable.js";
import useConfig from "./config/config.composable";
import PageTitle from "@/components/PageTitle.vue";
const corpusStore = useCorpusStore();
const { requireAuthentication, isAuthenticated } = useAuth();
const corpusId = useCorpusIdParam();
const { loadCorpora } = useCorpora();
const { loadCorpus } = useCorpus(corpusId);
const { corpusName } = useConfig(corpusId);
const corpus = corpusStore.corpora[corpusId];
const corpus = computed(() => corpusStore.corpora[corpusId]);
requireAuthentication(loadCorpus);
requireAuthentication(async () => {
await loadCorpora();
await loadCorpus();
});
</script>

<style></style>
6 changes: 3 additions & 3 deletions src/corpus/config/config.composable.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export default function useConfig(corpusId) {
const { th } = useLocale();
const mink = useMinkBackend();

const corpus = corpusStore.corpora[corpusId];
const config = computed(() => corpus?.config);
const corpus = computed(() => corpusStore.corpora[corpusId]);
const config = computed(() => corpus.value?.config);
const corpusName = computed(() => th(config.value?.name));

async function loadConfig() {
Expand All @@ -21,7 +21,7 @@ export default function useConfig(corpusId) {
if (error.response?.status == 404) return emptyConfig();
throw error;
});
corpus.config = config;
corpus.value.config = config;
}

async function uploadConfig(config, corpusId_ = corpusId) {
Expand Down
6 changes: 3 additions & 3 deletions src/corpus/exports/exports.composable.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import useMessenger from "@/message/messenger.composable";

export default function useExports(corpusId) {
const corpusStore = useCorpusStore();
const corpus = corpusStore.corpora[corpusId];
const exports = computed(() => corpus?.exports);
const corpus = computed(() => corpusStore.corpora[corpusId]);
const exports = computed(() => corpus.value?.exports);
const mink = useMinkBackend();
const { alertError } = useMessenger();

async function loadExports() {
const exports = await mink.loadExports(corpusId).catch(alertError);
corpus.exports = exports;
corpus.value.exports = exports;
}

async function downloadResult() {
Expand Down
10 changes: 5 additions & 5 deletions src/corpus/job/job.composable.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,31 +49,31 @@ class JobStatus {

export default function useJob(corpusId) {
const corpusStore = useCorpusStore();
const corpus = corpusStore.corpora[corpusId];
const corpus = computed(() => corpusStore.corpora[corpusId]);
const mink = useMinkBackend();
const { alertError } = useMessenger();

async function loadJob() {
corpus.status = await mink
corpus.value.status = await mink
.loadJob(corpusId)
.catch(() => ({}))
.catch(alertError);
}

async function runJob() {
corpus.status = await mink.runJob(corpusId).catch(alertError);
corpus.value.status = await mink.runJob(corpusId).catch(alertError);
}

async function install() {
corpus.status = await mink.install(corpusId).catch(alertError);
corpus.value.status = await mink.install(corpusId).catch(alertError);
}

async function abortJob() {
await mink.abortJob(corpusId).catch(alertError);
await loadJob();
}

const jobStatus = computed(() => corpus?.status);
const jobStatus = computed(() => corpus.value?.status);
const sparvStatus = computed(
() => new JobStatus(jobStatus.value?.job_status?.sparv)
);
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/locale.composable.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useI18n } from "vue-i18n";
import { useStorage } from "@vueuse/core";
import { filesize } from "filesize";

const storedLocale = useStorage("locale");
const storedLocale = useStorage("locale", "");

export default function useLocale() {
const { locale } = useI18n();
Expand Down

0 comments on commit 41c82f6

Please sign in to comment.