Commit 1ae13009 authored by Yakubov, Sergey's avatar Yakubov, Sergey
Browse files

fix stuff to make it start

parent 08b58f44
Loading
Loading
Loading
Loading
Loading
+0 −134
Original line number Diff line number Diff line
/**
 * Simple ajax queries that run against the api.
 *
 * A few history queries still hit routes that don't begin with /api. I have noted them
 * in the comments.
 */

import axios from "axios";
import { prependPath } from "utils/redirect";

/**
 * Generic json getter
 * @param {*} response
 */

const doResponse = (response) => {
    if (response.status != 200) {
        throw new Error(response);
    }
    return response.data;
};

/**
 * Legacy query string rendering. (generates q/qv syntax queries).
 * TODO: remove these converters when the api is modernized.
 */
function buildQueryStringFrom(filters) {
    const queryString = Object.entries(filters)
        .map(([f, v]) => `q=${f}&qv=${v}`)
        .join("&");
    return queryString;
}

// #endregion

/**
 * Content Queries
 */

/**
 * Deletes item from history
 *
 * @param {Object} content Content object
 * @param {Boolean} purge Permanent delete
 * @param {Boolean} recursive Scorch the earth?
 */
export async function deleteContent(content, deleteParams = {}) {
    const defaults = { purge: false, recursive: false, stop_job: true };
    const params = Object.assign({}, defaults, deleteParams);
    const { history_id, history_content_type, id } = content;
    const url = `api/histories/${history_id}/contents/${history_content_type}s/${id}`;
    const response = await axios.delete(prependPath(url), { params });
    return doResponse(response);
}

/**
* Stops job and marks it as complete.
*/
export async function stopJob(job_id) {
    const url = `api/jobs/${job_id}/finish`;
    const response = await axios.put(prependPath(url));
    return doResponse(response);
}

/**
 * Update specific fields on datasets or collections.
 * @param {Object} content content object
 * @param {Object} newFields key/value object of properties to update
 */
export async function updateContentFields(content, newFields = {}) {
    const { history_id, id, history_content_type: type } = content;
    const url = `api/histories/${history_id}/contents/${type}s/${id}`;
    const response = await axios.put(prependPath(url), newFields);
    return doResponse(response);
}

/** Get all objects that match filters in a history
 *
 * @param {string} historyId
 * @param {Object} filters
 * @param {string} type
 *
 */
export async function getHistoryContent(historyId, filters = {}, type = "dataset") {
    const filterQuery = buildQueryStringFrom(filters);
    const url = `api/histories/${historyId}/contents/${type}s?v=dev&${filterQuery}`;
    const response = await axios.get(prependPath(url));
    return doResponse(response);
}

/**
 * Performs an operation on a specific set of items or all the items
 * matching the filters.
 * If a specific set of items is provided, the filters are ignored, otherwise
 * the filters will determine which items are processed.
 *
 * @param {Object} history The history that contains the items
 * @param {String} operation The operation to perform on all items
 * @param {Object} filters The filter query parameters
 * @param {Object[]} items The set of items to process as `{ id, history_content_type }`
 * @param {Object} params Optional extra parameters passed to the operation
 */
export async function bulkUpdate(history, operation, filters, items = [], params = null) {
    const { id } = history;
    const filterQuery = buildQueryStringFrom(filters);
    const url = `api/histories/${id}/contents/bulk?${filterQuery}`;
    const payload = {
        operation,
        items,
        params,
    };
    const response = await axios.put(prependPath(url), payload);
    return doResponse(response);
}

/**
 * Collections
 */

export async function createDatasetCollection(history, inputs = {}) {
    const defaults = {
        collection_type: "list",
        copy_elements: true,
        name: "list",
        element_identifiers: [],
        hide_source_items: true,
        type: "dataset_collection",
    };

    const payload = Object.assign({}, defaults, inputs);
    const url = `api/histories/${history.id}/contents`;
    const response = await axios.post(prependPath(url), payload);
    return doResponse(response);
}
+18 −0
Original line number Diff line number Diff line
@@ -32,6 +32,24 @@ export async function deleteContent(
    return data;
}

/**
* Stops job and marks it as complete.
*/
export async function stopJob(jobId: string) {
// todo: gcage
//    const { data, error } = await GalaxyApi().PUT("api/jobs/${job_id}/finish", {
//        params: { path: { job_id: jobId, theme } },
//    });


//    if (error) {
//        rethrowSimple(error);
//    }
//    return data;
    return {}
}


/**
 * Update specific fields on datasets or collections.
 */
+0 −12
Original line number Diff line number Diff line
@@ -87,18 +87,6 @@ function updateConsoleOutputs(output) {
    }
}

function updateConsoleOutputs(output) {
    // Keep stdout in memory and only fetch new text via JobProvider
    if (output) {
        if (output.stdout != null) {
            stdout_text.value += output.stdout;
        }
        if (output.stderr != null) {
            stderr_text.value += output.stderr;
        }
    }
}

function filterMetadata(jobMessages) {
    return jobMessages.map((item) => {
        return Object.entries(item).reduce((acc, [key, value]) => {
+10 −4
Original line number Diff line number Diff line
@@ -6,7 +6,10 @@ import { useServerMock } from "@/api/client/__mocks__";
import { useHistoryStore } from "@/stores/historyStore";
import { useUserStore } from "@/stores/userStore";

import UploadContainerORNL from "./UploadContainerORNL.vue";
// todo: gcage
#import UploadContainerORNL from "./UploadContainerORNL.vue";
import UploadContainer from "./UploadContainer.vue";

import UploadModal from "./UploadModal.vue";

jest.mock("@/composables/config", () => ({
@@ -84,13 +87,15 @@ describe("UploadModal.vue", () => {
    });

    it("should load with correct defaults", async () => {
        const contentWrapper = wrapper.findComponent(UploadContainerORNL);
        //const contentWrapper = wrapper.findComponent(UploadContainerORNL);
        const contentWrapper = wrapper.findComponent(UploadContainer);
        expect(contentWrapper.vm.auto.id).toBe("auto");
        expect(contentWrapper.vm.datatypesDisableAuto).toBe(false);
    });

    it("should fetch datatypes and parse them", async () => {
        const contentWrapper = wrapper.findComponent(UploadContainerORNL);
        //const contentWrapper = wrapper.findComponent(UploadContainerORNL);
        const contentWrapper = wrapper.findComponent(UploadContainer);
        expect(contentWrapper.exists()).toBe(true);
        expect(contentWrapper.vm.listExtensions.length).toBe(2);
        expect(contentWrapper.vm.listExtensions[0].id).toBe("auto");
@@ -98,7 +103,8 @@ describe("UploadModal.vue", () => {
    });

    it("should fetch genomes and parse them", async () => {
        const contentWrapper = wrapper.findComponent(UploadContainerORNL);
        //const contentWrapper = wrapper.findComponent(UploadContainerORNL);
        const contentWrapper = wrapper.findComponent(UploadContainer);
        expect(contentWrapper.vm.listDbKeys.length).toBe(3);
    });
});
+4 −2
Original line number Diff line number Diff line
@@ -9,7 +9,9 @@ import { useUserHistories } from "@/composables/userHistories";
import { useUserStore } from "@/stores/userStore";
import { wait } from "@/utils/utils";

import UploadContainerORNL from "./UploadContainerORNL.vue";
// todo: gcage
//import UploadContainerORNL from "./UploadContainerORNL.vue";
import UploadContainer from "./UploadContainer.vue";
import ExternalLink from "../ExternalLink.vue";
import HelpText from "../Help/HelpText.vue";

@@ -127,7 +129,7 @@ defineExpose({
                </BCarousel>
            </div>
        </template>
        <UploadContainerORNL
        <UploadContainer
            v-if="currentHistoryId"
            ref="content"
            :current-user-id="currentUser?.id"
Loading