diff --git a/src/breeding-insight/dao/JobDAO.ts b/src/breeding-insight/dao/JobDAO.ts new file mode 100644 index 000000000..a5e64b8fa --- /dev/null +++ b/src/breeding-insight/dao/JobDAO.ts @@ -0,0 +1,31 @@ +/* + * 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 * as api from '@/util/api'; +import { BiResponse, Response } from '@/breeding-insight/model/BiResponse'; + +export class JobDAO { + + static async getProgramJobs(programId: string) { + const {data} = await api.call({ + url: `${process.env.VUE_APP_BI_API_V1_PATH}/programs/${programId}/jobs`, + method: 'get' + }) as Response; + + return new BiResponse(data); + } +} diff --git a/src/breeding-insight/model/import/ImportResponse.ts b/src/breeding-insight/model/import/ImportResponse.ts index b766033be..82c0f3e9c 100644 --- a/src/breeding-insight/model/import/ImportResponse.ts +++ b/src/breeding-insight/model/import/ImportResponse.ts @@ -17,15 +17,33 @@ import {ImportProgress} from "@/breeding-insight/model/import/ImportProgress"; import {ImportPreview} from "@/breeding-insight/model/import/ImportPreview"; +import { User } from '@/breeding-insight/model/User'; +import { JobDetail } from '@/breeding-insight/model/job/JobDetail'; -export class ImportResponse { +export class ImportResponse extends JobDetail{ importId?: string; progress?: ImportProgress; preview?: ImportPreview; + uploadFileName?: string; + importMappingName?:string; + importType?:string; + createdByUser?: User; + updatedByUser?: User; + createdAt?: Date; + updatedAt?: Date; - constructor({importId, progress, preview}: ImportResponse) { + constructor({importId, progress, preview, uploadFileName, importMappingName, importType, createdByUser, updatedByUser, createdAt, updatedAt, jobType}: ImportResponse) { + super(); this.importId = importId; this.progress = progress; this.preview = preview; + this.uploadFileName = uploadFileName; + this.importMappingName = importMappingName; + this.importType = importType; + this.createdByUser = createdByUser; + this.updatedByUser = updatedByUser; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.jobType = jobType; } } \ No newline at end of file diff --git a/src/breeding-insight/model/job/Job.ts b/src/breeding-insight/model/job/Job.ts new file mode 100644 index 000000000..efa3897f1 --- /dev/null +++ b/src/breeding-insight/model/job/Job.ts @@ -0,0 +1,39 @@ +/* + * 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 { User } from '@/breeding-insight/model/User'; +import { JobDetail } from '@/breeding-insight/model/job/JobDetail'; + +export class Job { + statuscode?: number; + statusMessage?: string; + jobType?: string; + createdAt?: Date; + updatedAt?: Date; + createdByUser?: User; + jobDetail?: JobDetail; + + constructor ({statuscode, statusMessage, jobType, createdAt, updatedAt, createdByUser, jobDetail}: Job) { + this.statuscode = statuscode; + this.statusMessage = statusMessage; + this.jobType = jobType; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.createdByUser = createdByUser; + this.jobDetail = jobDetail; + } +} \ No newline at end of file diff --git a/src/breeding-insight/model/job/JobDetail.ts b/src/breeding-insight/model/job/JobDetail.ts new file mode 100644 index 000000000..f9f078f15 --- /dev/null +++ b/src/breeding-insight/model/job/JobDetail.ts @@ -0,0 +1,20 @@ +/* + * 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. + */ + +export class JobDetail { + jobType?: string; +} \ No newline at end of file diff --git a/src/breeding-insight/service/JobService.ts b/src/breeding-insight/service/JobService.ts new file mode 100644 index 000000000..8b1452e55 --- /dev/null +++ b/src/breeding-insight/service/JobService.ts @@ -0,0 +1,48 @@ +/* + * 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 { BiResponse } from '@/breeding-insight/model/BiResponse'; +import { Job } from '@/breeding-insight/model/job/Job'; +import { JobDAO } from '@/breeding-insight/dao/JobDAO'; + +export class JobService { + static getJobsUnknown: string = 'An unknown error occurred while retrieving job statuses'; + + static async getProgramJobs(programId: string): Promise { + if (!programId) { + throw 'Program ID not provided'; + } + + try { + const response: BiResponse = await JobDAO.getProgramJobs(programId); + const data: any = response.result.data; + if(data) { + return data.map((response: Job) => new Job(response)); + } else { + return []; + } + } catch (e) { + if (e.response && e.response.statusText) { + e.errorMessage = e.response.statusText; + } else { + e.errorMessage = this.getJobsUnknown; + } + throw e; + } + + } +} \ No newline at end of file diff --git a/src/components/layouts/UserSideBarLayout.vue b/src/components/layouts/UserSideBarLayout.vue index 7467bb633..ac99c2a71 100644 --- a/src/components/layouts/UserSideBarLayout.vue +++ b/src/components/layouts/UserSideBarLayout.vue @@ -128,11 +128,19 @@ BrAPI +
  • + + Jobs + +
  • - Trials and Studies - Beta + Trials and Studies Beta
  • @@ -202,6 +210,7 @@ private importFileMenuId: string = "usersidebarlayout-import-file-menu"; private ontologyMenuId: string = "usersidebarlayout-ontology-menu"; private programManagementMenuId: string = "usersidebarlayout-program-management-menu"; + private jobManagementMenuId: string = "usersidebarlayout-job-management-menu"; private brAPIMenuId: string = "usersidebarlayout-brapi-menu"; private germplasmMenuId: string = "usersidebarlayout-germplasm-menu"; diff --git a/src/components/tables/expandableTable/ExpandableTable.vue b/src/components/tables/expandableTable/ExpandableTable.vue index 092868095..4712aec6d 100644 --- a/src/components/tables/expandableTable/ExpandableTable.vue +++ b/src/components/tables/expandableTable/ExpandableTable.vue @@ -43,22 +43,24 @@ > - + - Edit + Edit + Details + + + + + + + - - - - - - + +