Skip to content

Commit

Permalink
Handle root consistently within api interface
Browse files Browse the repository at this point in the history
  • Loading branch information
guerler committed Nov 2, 2024
1 parent 21dc854 commit 39586df
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
4 changes: 3 additions & 1 deletion src/api/datasets.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { fetchApi } from "@/api/client";
import { useConfigStore } from "@/store/configStore";

export async function datasetsGetColumns(datasetId, columnList) {
try {
Expand Down Expand Up @@ -29,5 +30,6 @@ export async function datasetsGetColumns(datasetId, columnList) {
}

export function datasetsGetUrl(datasetId) {
return `/api/datasets/${datasetId}/display`;
const configStore = useConfigStore();
return `${configStore.getRoot()}api/datasets/${datasetId}/display`;
}
12 changes: 8 additions & 4 deletions src/api/visualizations.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import axios from "axios";
import { rethrowSimple } from "@/utilities/simpleError";
export async function visualizationsCreate(root, type, title, config) {
import { useConfigStore } from "@/store/configStore";

export async function visualizationsCreate(type, title, config) {
const configStore = useConfigStore();
try {
const { data } = await axios.post(`${root}api/visualizations`, {
const { data } = await axios.post(`${configStore.getRoot()}api/visualizations`, {
type,
title,
config,
Expand All @@ -13,9 +16,10 @@ export async function visualizationsCreate(root, type, title, config) {
}
}

export async function visualizationsSave(root, id, title, config) {
export async function visualizationsSave(id, title, config) {
const configStore = useConfigStore();
try {
const response = await axios.put(`${root}api/visualizations/${id}`, {
const response = await axios.put(`${configStore.getRoot()}api/visualizations/${id}`, {
title,
config,
});
Expand Down
4 changes: 2 additions & 2 deletions src/components/GalaxyCharts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ parsePlugin(props.xml, visualizationPlugin, visualizationConfig).then(({ plugin,
const datasetId = visualizationConfig.dataset_id;
if (visualizationConfig.dataset_url) {
datasetUrl.value = visualizationConfig.dataset_url;
console.debug(`ViewPort: Evaluating dataset url: ${datasetUrl.value}.`);
console.debug(`GalaxyCharts: Evaluating dataset url: ${datasetUrl.value}.`);
} else {
if (!datasetId) {
errorMessage.value = "Visualization requires `dataset_id` or `dataset_url`.";
} else {
datasetUrl.value = datasetsGetUrl(datasetId);
console.debug(`ViewPort: Built dataset url from dataset id: ${datasetUrl.value}.`);
console.debug(`GalaxyCharts: Built dataset url from dataset id: ${datasetUrl.value}.`);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/SidePanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ const emit = defineEmits(["update:tracks", "update:settings", "toggle"]);
async function onSave() {
try {
if (currentVisualizationId.value) {
await visualizationsSave(props.root, currentVisualizationId.value, currentTitle.value, {
await visualizationsSave(currentVisualizationId.value, currentTitle.value, {
dataset_id: props.datasetId,
settings: props.values,
});
message.value = "Successfully saved.";
messageType.value = "success";
} else {
currentVisualizationId.value = await visualizationsCreate(props.root, props.name, currentTitle.value, {
currentVisualizationId.value = await visualizationsCreate(props.name, currentTitle.value, {
dataset_id: props.datasetId,
settings: props.values,
});
Expand Down

0 comments on commit 39586df

Please sign in to comment.