Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work around weird scoping issue #76

Open
wants to merge 9 commits into
base: manage_dependencies
Choose a base branch
from
26 changes: 9 additions & 17 deletions client/galaxy/scripts/components/Toolshed/services.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import axios from "axios";
import { getAppRoot } from "onload/loadConfig";
import { getGalaxyInstance } from "app";
import { rethrowSimple } from "utils/simple-error";

/** Request repositories, categories etc from toolshed server **/
export class Services {
Expand All @@ -11,7 +12,7 @@ export class Services {
const response = await axios.get(url);
return response.data;
} catch (e) {
this._errorMessage(e);
rethrowSimple(e);
}
}
async getRepositories(params) {
Expand All @@ -28,7 +29,7 @@ export class Services {
});
return incoming;
} catch (e) {
this._errorMessage(e);
rethrowSimple(e);
}
}
async getRepository(toolshedUrl, repositoryId) {
Expand All @@ -52,7 +53,7 @@ export class Services {
});
return table;
} catch (e) {
this._errorMessage(e);
rethrowSimple(e);
}
}
async getRepositoryByName(toolshedUrl, repositoryName, repositoryOwner) {
Expand All @@ -69,7 +70,7 @@ export class Services {
throw "Repository details not found.";
}
} catch (e) {
this._errorMessage(e);
rethrowSimple(e);
}
}
async getInstalledRepositories(options = {}) {
Expand All @@ -81,7 +82,7 @@ export class Services {
this._fixToolshedUrls(repositories, Galaxy.config.tool_shed_urls);
return repositories;
} catch (e) {
this._errorMessage(e);
rethrowSimple(e);
}
}
async getInstalledRepositoriesByName(repositoryName, repositoryOwner) {
Expand All @@ -100,7 +101,7 @@ export class Services {
});
return result;
} catch (e) {
this._errorMessage(e);
rethrowSimple(e);
}
}
async installRepository(payload) {
Expand All @@ -109,7 +110,7 @@ export class Services {
const response = await axios.post(url, payload);
return response.data;
} catch (e) {
this._errorMessage(e);
rethrowSimple(e);
}
}
async uninstallRepository(params) {
Expand All @@ -121,7 +122,7 @@ export class Services {
const response = await axios.delete(url);
return response.data;
} catch (e) {
this._errorMessage(e);
rethrowSimple(e);
}
}
_groupByNameOwner(incoming, filter) {
Expand Down Expand Up @@ -152,15 +153,6 @@ export class Services {
if (value > 1000) return `>${Math.floor(value / 1000)}k`;
return value;
}
_errorMessage(e) {
let message = "Request failed.";
if (e.response) {
message = e.response.data.err_msg || `${e.response.statusText} (${e.response.status})`;
} else if (typeof e == "string") {
message = e;
}
throw message;
}
_getParamsString(params) {
if (params) {
return Object.keys(params).reduce(function(previous, key) {
Expand Down
17 changes: 5 additions & 12 deletions client/galaxy/scripts/components/Workflow/services.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import axios from "axios";
import { getGalaxyInstance } from "app";
import { rethrowSimple } from "utils/simple-error";

/** Workflow data request helper **/
export class Services {
Expand All @@ -25,7 +26,7 @@ export class Services {
this._addAttributes(createWorkflow);
return createWorkflow;
} catch (e) {
this._errorMessage(e);
rethrowSimple(e);
}
}

Expand All @@ -35,7 +36,7 @@ export class Services {
const response = await axios.delete(url);
return response.data;
} catch (e) {
this._errorMessage(e);
rethrowSimple(e);
}
}

Expand All @@ -49,7 +50,7 @@ export class Services {
});
return workflows;
} catch (e) {
this._errorMessage(e);
rethrowSimple(e);
}
}

Expand All @@ -59,7 +60,7 @@ export class Services {
const response = await axios.put(url, data);
return response.data;
} catch (e) {
this._errorMessage(e);
rethrowSimple(e);
}
}

Expand All @@ -74,12 +75,4 @@ export class Services {
}
}
}

_errorMessage(e) {
let message = "Request failed.";
if (e.response) {
message = e.response.data.err_msg || `${e.response.statusText} (${e.response.status})`;
}
throw message;
}
}
79 changes: 79 additions & 0 deletions client/galaxy/scripts/components/admin/AdminServices.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { getAppRoot } from "onload/loadConfig";
import axios from "axios";
import { rethrowSimple } from "utils/simple-error";

export function getErrorStack() {
const url = `${getAppRoot()}api/tools/error_stack`;
Expand Down Expand Up @@ -31,3 +32,81 @@ export function resetRepositoryMetadata(repository_ids) {
const url = `${getAppRoot()}api/tool_shed_repositories/reset_metadata_on_selected_installed_repositories?repository_ids=${repository_ids}`;
return axios.post(url);
}

export async function getDependencyUnusedPaths() {
const params = {};
const url = `${getAppRoot()}api/dependency_resolvers/unused_paths`;
try {
const response = await axios.get(url, { params: params });
return response.data;
} catch (e) {
rethrowSimple(e);
}
}

export async function deletedUnusedPaths(paths) {
const url = `${getAppRoot()}api/dependency_resolvers/unused_paths`;
try {
await axios.put(url, { paths: paths });
} catch (e) {
rethrowSimple(e);
}
}

export async function getToolboxDependencies(params_) {
const params = params_ || {};
const url = `${getAppRoot()}api/dependency_resolvers/toolbox`;
try {
const response = await axios.get(url, { params: params });
return response.data;
} catch (e) {
rethrowSimple(e);
}
}

export async function installDependencies(toolIds, resolutionOptions) {
const postData = { ...resolutionOptions, tool_ids: toolIds };
const url = `${getAppRoot()}api/dependency_resolvers/toolbox/install`;
try {
const response = await axios.post(url, postData);
return response.data;
} catch (e) {
rethrowSimple(e);
}
}

export async function uninstallDependencies(toolIds, resolutionOptions) {
const postData = { ...resolutionOptions, tool_ids: toolIds };
const url = `${getAppRoot()}api/dependency_resolvers/toolbox/uninstall`;
try {
const response = await axios.post(url, postData);
return response.data;
} catch (e) {
rethrowSimple(e);
}
}

export async function getContainerResolutionToolbox(params_) {
const params = params_ || {};
const url = `${getAppRoot()}api/container_resolvers/toolbox`;
try {
const response = await axios.get(url, { params: params });
return response.data;
} catch (e) {
rethrowSimple(e);
}
}

export async function resolveContainersWithInstall(toolIds, params_) {
const data = params_ || {};
const url = `${getAppRoot()}api/container_resolvers/toolbox/install`;
if (toolIds && toolIds.length > 0) {
data.tool_ids = toolIds || [];
}
try {
const response = await axios.post(url, data);
return response.data;
} catch (e) {
rethrowSimple(e);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<template>
<span class="container-description">
<span v-if="containerDescription" :title="title">
<a v-if="externalUrl" class="icon-btn" :href="externalUrl"><span class="fa fa-link"></span></a>
{{ containerDescription.identifier }}
<span v-if="!compact">
<i>{{ description }}</i>
</span>
</span>
<span v-else>
<i>no container resolved</i>
</span>
</span>
</template>
<script>
export default {
props: {
containerDescription: {
type: Object
},
compact: {
type: Boolean,
default: true
}
},
computed: {
title: function() {
return this.compact ? this.description : "";
},
description: function() {
return `This is a ${this.containerDescription.type} container. ${this.shellDescription}`;
},
shellDescription: function() {
return `This container uses shell [${this.containerDescription.shell}].`;
},
identifier: function() {
return this.containerDescription && this.containerDescription.identifier;
},
externalUrl: function() {
const identifier = this.identifier;
if (identifier) {
if (identifier.startsWith("quay.io")) {
return "http://" + identifier;
}
}
return null;
}
}
};
</script>
Loading