X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/30ef6aaa179aa1d18e70e2a54b1a997146328147..c48d10802d4ae95273f8b98e622e5df200cdc3a7:/src/services/common-service/common-service.ts diff --git a/src/services/common-service/common-service.ts b/src/services/common-service/common-service.ts index f66fad74..f16a2024 100644 --- a/src/services/common-service/common-service.ts +++ b/src/services/common-service/common-service.ts @@ -3,10 +3,11 @@ // SPDX-License-Identifier: AGPL-3.0 import { camelCase, isPlainObject, isArray, snakeCase } from "lodash"; -import { AxiosInstance, AxiosPromise } from "axios"; +import { AxiosInstance, AxiosPromise, AxiosRequestConfig } from "axios"; import uuid from "uuid/v4"; import { ApiActions } from "services/api/api-actions"; import QueryString from "query-string"; +import { Session } from "models/session"; interface Errors { status: number; @@ -113,11 +114,24 @@ export class CommonService { ); } - get(uuid: string, showErrors?: boolean) { + get(uuid: string, showErrors?: boolean, select?: string[], session?: Session) { this.validateUuid(uuid); + + const cfg: AxiosRequestConfig = { + params: { + select: select + ? `[${select.map(snakeCase).map(s => `"${s}"`).join(',')}]` + : undefined + } + }; + if (session) { + cfg.baseURL = session.baseUrl; + cfg.headers = { 'Authorization': 'Bearer ' + session.token }; + } + return CommonService.defaultResponse( this.serverApi - .get(`/${this.resourceType}/${uuid}`), + .get(`/${this.resourceType}/${uuid}`, cfg), this.actions, true, // mapKeys showErrors