Commit e70546bb authored by guerler's avatar guerler
Browse files

Allow creation of visualizations without dataset

parent 979ae54b
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -29,16 +29,21 @@ export interface Plugin {
    html: string;
    logo?: string;
    name: string;
    params?: Record<string, ParamType>;
    target?: string;
    tags?: Array<string>;
    tests?: Array<TestType>;
}

export interface ParamType {
    required?: boolean;
}

export interface PluginData {
    hdas: Array<Dataset>;
}

export interface ParamType {
export interface TestParamType {
    ftype?: string;
    label?: string;
    name: string;
@@ -46,7 +51,7 @@ export interface ParamType {
}

export interface TestType {
    param: ParamType;
    param: TestParamType;
}

export async function fetchPlugins(datasetId?: string): Promise<Array<Plugin>> {
+9 −4
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ import type { OptionType } from "@/components/SelectionField/types";
import { useMarkdown } from "@/composables/markdown";
import { useHistoryStore } from "@/stores/historyStore";

import { getTestExtensions, getTestUrls } from "./utilities";
import { getRequiresDataset, getTestExtensions, getTestUrls } from "./utilities";

import VisualizationExamples from "./VisualizationExamples.vue";
import Heading from "@/components/Common/Heading.vue";
@@ -27,11 +27,12 @@ const props = defineProps<{
}>();

const errorMessage = ref("");
const formatsVisible = ref(false);
const plugin: Ref<Plugin | undefined> = ref();

const urlData = computed(() => getTestUrls(plugin.value));
const extensions = computed(() => getTestExtensions(plugin.value));
const formatsVisible = ref(false);
const requiresDataset = computed(() => getRequiresDataset(plugin.value));
const urlData = computed(() => getTestUrls(plugin.value));

function addHidToName(hdas: Array<Dataset>) {
    return hdas.map((entry) => ({ id: entry.id, name: `${entry.hid}: ${entry.name}` }));
@@ -40,7 +41,11 @@ function addHidToName(hdas: Array<Dataset>) {
async function doQuery() {
    if (currentHistoryId.value && plugin.value) {
        const data = await fetchPluginHistoryItems(plugin.value.name, currentHistoryId.value);
        return addHidToName(data.hdas);
        const entries = addHidToName(data.hdas);
        if (!requiresDataset.value) {
            entries.unshift({ id: "", name: "Create a new visualization..." });
        }
        return entries;
    } else {
        return [];
    }
+6 −6
Original line number Diff line number Diff line
@@ -23,16 +23,16 @@ const iframeRef = ref<HTMLIFrameElement | null>(null);
const srcWithRoot = computed(() => {
    let url = "";
    if (props.visualization === "trackster") {
        if (props.datasetId) {
            url = `/visualization/trackster?dataset_id=${props.datasetId}`;
        } else {
        if (props.visualizationId) {
            url = `/visualization/trackster?id=${props.visualizationId}`;
        }
        } else {
        if (props.datasetId) {
            url = `/plugins/visualizations/${props.visualization}/show?dataset_id=${props.datasetId}`;
            url = `/visualization/trackster?dataset_id=${props.datasetId}`;
        }
    } else {
        if (props.visualizationId) {
            url = `/plugins/visualizations/${props.visualization}/saved?id=${props.visualizationId}`;
        } else {
            url = `/plugins/visualizations/${props.visualization}/show?dataset_id=${props.datasetId}`;
        }
    }

+4 −0
Original line number Diff line number Diff line
import type { Plugin } from "@/api/plugins";

export function getRequiresDataset(plugin?: Plugin): boolean {
    return plugin?.params?.dataset_id?.required || false;
}

export function getTestExtensions(plugin?: Plugin): string[] {
    const results: string[] = [];
    if (plugin?.data_sources) {
+5 −9
Original line number Diff line number Diff line
@@ -72,15 +72,11 @@ class VisualizationsConfigParser:
            log.info("Visualizations plugin disabled: %s. Skipping...", returned["name"])
            return None

        # record the embeddable flag - defaults to False
        returned["embeddable"] = False
        if "embeddable" in xml_tree.attrib:
            returned["embeddable"] = asbool(xml_tree.attrib.get("embeddable"))

        # record the visible flag - defaults to False
        returned["hidden"] = False
        if "hidden" in xml_tree.attrib:
            returned["hidden"] = asbool(xml_tree.attrib.get("hidden"))
        # record boolean flags - defaults to False
        for keyword in ["embeddable", "hidden"]:
            returned[keyword] = False
            if keyword in xml_tree.attrib:
                returned[keyword] = asbool(xml_tree.attrib.get(keyword))

        # a (for now) text description of what the visualization does
        description = xml_tree.find("description")
Loading