diff --git a/.env.development b/.env.development index cbfcd9af4..9fabf4eb6 100644 --- a/.env.development +++ b/.env.development @@ -13,3 +13,5 @@ VUE_APP_BI_API_ROOT=${API_BASE_URL} # The level of logging for our logger VUE_APP_LOG_LEVEL=${WEB_LOG_LEVEL} +# The reference source +VUE_APP_BI_REFERENCE_SOURCE=breedinginsight.org diff --git a/src/breeding-insight/dao/GermplasmDAO.ts b/src/breeding-insight/dao/GermplasmDAO.ts index bcb1ce26c..151777ffe 100644 --- a/src/breeding-insight/dao/GermplasmDAO.ts +++ b/src/breeding-insight/dao/GermplasmDAO.ts @@ -15,9 +15,11 @@ * limitations under the License. */ -import {BiResponse} from "@/breeding-insight/model/BiResponse"; +import {BiResponse, Response} from "@/breeding-insight/model/BiResponse"; import * as api from "@/util/api"; import {PaginationQuery} from "@/breeding-insight/model/PaginationQuery"; +import {Result, ResultGenerator} from "@/breeding-insight/model/Result"; +import {Germplasm} from "@/breeding-insight/brapi/model/germplasm"; export class GermplasmDAO { @@ -41,4 +43,21 @@ export class GermplasmDAO { }) })) } + + static async getSingleGermplasm(programId: string, germplasmId: string): Promise> { + const config: any = {}; + config.url = `${process.env.VUE_APP_BI_API_V1_PATH}/programs/${programId}/brapi/v2/germplasm/${germplasmId}`; + config.method = 'get'; + config.programId = programId; + config.germplasmId = germplasmId; + config.params = {}; + + try { + const res = await api.call(config) as Response; + let { result } = res.data; + return ResultGenerator.success(result); + } catch (error) { + return ResultGenerator.err(error); + } + } } diff --git a/src/breeding-insight/service/GermplasmService.ts b/src/breeding-insight/service/GermplasmService.ts index 3953f0a78..fc1933721 100644 --- a/src/breeding-insight/service/GermplasmService.ts +++ b/src/breeding-insight/service/GermplasmService.ts @@ -20,6 +20,8 @@ import {BiResponse, Metadata} from "@/breeding-insight/model/BiResponse"; import {PaginationQuery} from "@/breeding-insight/model/PaginationQuery"; import {PaginationController} from "@/breeding-insight/model/view_models/PaginationController"; import {GermplasmDAO} from "@/breeding-insight/dao/GermplasmDAO"; +import {Germplasm} from "@/breeding-insight/brapi/model/germplasm"; +import {Result, ResultGenerator} from "@/breeding-insight/model/Result"; export class GermplasmService { @@ -48,4 +50,14 @@ export class GermplasmService { })); } + static async getSingleGermplasm(programId: string, germplasmId: string): Promise> { + try { + if (!programId) throw new Error('Missing or invalid program id'); + let response: Result = await GermplasmDAO.getSingleGermplasm(programId, germplasmId); + return response; + } catch(error) { + return ResultGenerator.err(error); + } + } + } diff --git a/src/breeding-insight/utils/GermplasmUtils.ts b/src/breeding-insight/utils/GermplasmUtils.ts new file mode 100644 index 000000000..1fd51735c --- /dev/null +++ b/src/breeding-insight/utils/GermplasmUtils.ts @@ -0,0 +1,46 @@ +/* + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import moment from "moment"; +import {Germplasm} from "@/breeding-insight/brapi/model/germplasm"; +import {ExternalReferences} from "@/breeding-insight/brapi/model/externalReferences"; + +export class GermplasmUtils { + static getExternalUID(germplasm: Germplasm): string | undefined { + let val; + if (germplasm.externalReferences && germplasm.seedSource) { + val = germplasm.externalReferences!.filter(ref => ref.referenceSource == germplasm.seedSource!) + .map(ref => ref.referenceID); + return val ? val[0]: ""; + } + return ""; + } + + static getCreatedDate(germplasm: Germplasm): string | undefined { + if (germplasm.additionalInfo && germplasm.additionalInfo.createdDate) { + let dateTime = moment(germplasm.additionalInfo!.createdDate!, "DD/MM/YYYY h:mm:ss"); + return dateTime.format("DD/MM/YYYY"); + } + return ""; + } + + static getGermplasmUUID(references: ExternalReferences): string | undefined { + let val = references.find(ref => ref.referenceSource === process.env.VUE_APP_BI_REFERENCE_SOURCE); + return val ? val.referenceID : ""; + } + +} \ No newline at end of file diff --git a/src/router/index.ts b/src/router/index.ts index e8076a244..61a01bb99 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -66,6 +66,7 @@ import OntologyArchivedTable from "@/components/ontology/OntologyArchivedTable.v import PageNotFound from "@/views/PageNotFound.vue"; import Germplasm from "@/views/germplasm/Germplasm.vue"; import GermplasmLists from "@/views/germplasm/GermplasmLists.vue"; +import GermplasmDetails from "@/views/germplasm/GermplasmDetails.vue"; import ProgramConfiguration from "@/views/program/ProgramConfiguration.vue"; Vue.use(VueRouter); @@ -303,6 +304,16 @@ const routes = [ } ] }, + { + path: '/programs/:programId/germplasm/:germplasmId', + name: 'germplasm-details', + component: GermplasmDetails, + meta: { + title: 'Germplasm Details', + layout: layouts.userSideBar + }, + beforeEnter: processProgramNavigation + }, { path: '/programs/:programId/traits', name: 'traits', diff --git a/src/views/germplasm/GermplasmDetails.vue b/src/views/germplasm/GermplasmDetails.vue new file mode 100644 index 000000000..cc65b6bd5 --- /dev/null +++ b/src/views/germplasm/GermplasmDetails.vue @@ -0,0 +1,134 @@ + + + + + \ No newline at end of file diff --git a/src/views/germplasm/GermplasmTable.vue b/src/views/germplasm/GermplasmTable.vue index e2f71a2d2..8c7d0f771 100644 --- a/src/views/germplasm/GermplasmTable.vue +++ b/src/views/germplasm/GermplasmTable.vue @@ -37,6 +37,11 @@ {{ props.row.data.additionalInfo.createdBy.userName }} + + + Show Details + +