Commit 500f8e0f authored by Cage, Gregory's avatar Cage, Gregory
Browse files

Merge branch '118-update-upload-dialog' into 'dev'

Update ORNL upload components to include target history

Closes #118

See merge request !94
parents 540ac15b d2db0439
Loading
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -91,6 +91,7 @@ const uploadCompleted = ref(0);
const uploadFile = ref(null);
const uploadItems = ref({});
const uploadSize = ref(0);
const queue = ref(createUploadQueue());

const counterNonRunning = computed(() => counterAnnounce.value + counterSuccess.value + counterError.value);
const enableBuild = computed(
@@ -106,7 +107,7 @@ const listExtensions = computed(() => props.effectiveExtensions.filter((ext) =>
const showHelper = computed(() => Object.keys(uploadItems.value).length === 0);
const uploadValues = computed(() => Object.values(uploadItems.value));

const queue = computed(() => createUploadQueue());


function createUploadQueue() {
    return new UploadQueue({
@@ -115,7 +116,6 @@ function createUploadQueue() {
        complete: eventComplete,
        error: eventError,
        get: (index) => uploadItems.value[index],
        historyId: historyId.value,
        multiple: props.multiple,
        progress: eventProgress,
        success: eventSuccess,
@@ -312,6 +312,11 @@ function eventStart() {
        uploadValues.value.forEach((model) => {
            if (model.status === "init") {
                model.status = "queued";
                if (!model.targetHistoryId) {
                    // Associate with current history once upload starts
                    // This will not change if the current history is changed during upload
                    model.targetHistoryId = historyId.value;
                }
                uploadSize.value += model.fileSize;
            }
        });
+13 −3
Original line number Diff line number Diff line
<script setup>
import { BTab, BTabs } from "bootstrap-vue";
import { BAlert, BTab, BTabs } from "bootstrap-vue";
import { getDatatypesMapper } from "components/Datatypes";
import LoadingSpan from "components/LoadingSpan";

import {
    AUTO_EXTENSION,
    DEFAULT_DBKEY,
@@ -13,6 +12,8 @@ import {
import { storeToRefs } from "pinia";
import { computed, onMounted, ref } from "vue";

import { canMutateHistory } from "@/api";
import { useHistoryStore } from "@/stores/historyStore";
import { useUploadStore } from "@/stores/uploadStore";
import { uploadPayload } from "@/utils/upload-payload.js";

@@ -83,6 +84,8 @@ const regular = ref(null);

const { percentage, status } = storeToRefs(useUploadStore());

const { currentHistory } = storeToRefs(useHistoryStore());

const effectiveExtensions = computed(() => {
    if (props.formats === null || !datatypesMapperReady.value) {
        return listExtensions.value;
@@ -107,6 +110,7 @@ const historyAvailable = computed(() => Boolean(props.currentHistoryId));
const ready = computed(
    () => dbKeysSet.value && extensionsSet.value && historyAvailable.value && datatypesMapperReady.value
);
const canUploadToHistory = computed(() => currentHistory.value && canMutateHistory(currentHistory.value));
const showCollection = computed(() => !props.formats && props.multiple);
// const showComposite = computed(() => !props.formats || hasCompositeExtension);
const showComposite = false;
@@ -163,7 +167,13 @@ defineExpose({
</script>

<template>
    <BTabs v-if="ready">
    <BAlert v-if="!canUploadToHistory" variant="warning" show>
        <span v-localize>
            The current history is immutable and you cannot upload data to it. Please select a different history or
            create a new one.
        </span>
    </BAlert>
    <BTabs v-else-if="ready">
        <BTab v-if="showRegular" id="regular" title="Regular" button-id="tab-title-link-regular">
            <DefaultBoxORNL
                ref="regular"