-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into UseHTMLLabelInIDCard
- Loading branch information
Showing
25 changed files
with
1,311 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* Import Dependencies */ | ||
import axios from 'axios'; | ||
|
||
/* Import Types */ | ||
import { MachineAnnotationService } from 'app/types/MachineAnnotationService'; | ||
import { JSONResultArray, Dict } from 'app/Types'; | ||
|
||
/* Import Exceptions */ | ||
import { NotFoundException } from 'app/Exceptions'; | ||
|
||
|
||
/** | ||
* Function for fetching a digital specimen's potential MASs to be run | ||
* @param handle The identifier of the digital specimen | ||
* @returns List of | ||
*/ | ||
const GetDigitalSpecimenMASs = async ({ handle }: { handle: string }) => { | ||
const digitalSpecimenMASs: MachineAnnotationService[] = []; | ||
|
||
if (handle) { | ||
const endPoint: string = `/digital-specimen/${handle}/mas`; | ||
|
||
try { | ||
const result = await axios({ | ||
method: 'get', | ||
url: endPoint, | ||
responseType: 'json' | ||
}); | ||
|
||
/* Get result data from JSON */ | ||
const data: JSONResultArray = result.data; | ||
|
||
/* Set MASs */ | ||
data.data.forEach((dataRow: Dict) => { | ||
digitalSpecimenMASs.push(dataRow.attributes); | ||
}); | ||
} catch (error: any) { | ||
throw (NotFoundException('Digital Specimen MASs', error.request.responseURL)); | ||
}; | ||
}; | ||
|
||
return digitalSpecimenMASs; | ||
}; | ||
|
||
export default GetDigitalSpecimenMASs; |
57 changes: 57 additions & 0 deletions
57
src/api/digitalSpecimen/GetDigitalSpecimenMASJobRecords.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* Import Dependencies */ | ||
import axios from 'axios'; | ||
|
||
/* Import Types */ | ||
import { JSONResultArray, Dict } from 'app/Types'; | ||
|
||
/* Import Exceptions */ | ||
import { NotFoundException } from 'app/Exceptions'; | ||
|
||
|
||
/** | ||
* Function for fetching a digital specimen's machine annotation service (MAS) job records | ||
* @param handle The identifier of the digital specimen | ||
* @param version The version of the digital specimen | ||
* @returns Object of Digital Specimen | ||
*/ | ||
const GetDigitalSpecimenMASJobRecords = async ({ handle, pageSize, pageNumber, state }: { handle: string, pageSize?: number, pageNumber: number, state?: string }) => { | ||
let returnData: { | ||
MASJobRecords: Dict[], | ||
links?: Dict | ||
} = { | ||
MASJobRecords: [] | ||
}; | ||
|
||
if (handle) { | ||
const endPoint: string = `/digital-specimen/${handle.replace(import.meta.env.VITE_DOI_URL, '')}/mjr`; | ||
|
||
try { | ||
const result = await axios({ | ||
method: 'get', | ||
url: endPoint, | ||
params: { | ||
pageSize: pageSize, | ||
pageNumber: pageNumber ?? 1, | ||
...(state && { state }) | ||
}, | ||
responseType: 'json' | ||
}); | ||
|
||
/* Get result data from JSON */ | ||
const data: JSONResultArray = result.data; | ||
|
||
data.data.forEach(dataFragment => { | ||
returnData.MASJobRecords.push(dataFragment.attributes); | ||
}); | ||
|
||
/* Set return data */ | ||
returnData.links = data.links; | ||
} catch (error: any) { | ||
console.error(NotFoundException('Digital Specimen MAS Job Records', error.request.responseURL)); | ||
}; | ||
}; | ||
|
||
return returnData; | ||
}; | ||
|
||
export default GetDigitalSpecimenMASJobRecords; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* Import Dependencies */ | ||
import axios from 'axios'; | ||
import KeycloakService from 'app/Keycloak'; | ||
|
||
/* Import Exceptions */ | ||
import { PostException } from 'app/Exceptions'; | ||
|
||
/* Import Types */ | ||
import { JSONResultArray, Dict } from 'app/Types'; | ||
|
||
|
||
/** | ||
* Function for posting a scheduling job for scheduling MASs for the digital specimen | ||
* @param digitalSpecimenId The identifier of the digital specimen to schedule MASs for | ||
* @param masList A list of MASs to be scheduled | ||
* @returns Array of scheduled MASs | ||
*/ | ||
const ScheduleDigitalSpecimenMAS = async ({ digitalSpecimenId, masList }: { digitalSpecimenId: string, masList: { masId: string }[] }) => { | ||
let digitalSpecimenMAS: Dict = {}; | ||
|
||
if (digitalSpecimenId) { | ||
const token = KeycloakService.GetToken(); | ||
|
||
const masRecord: { | ||
data: { | ||
type: 'MasRequest', | ||
attributes: { | ||
mass: { | ||
masId: string | ||
}[] | ||
} | ||
} | ||
} = { | ||
data: { | ||
type: 'MasRequest', | ||
attributes: { | ||
mass: masList | ||
} | ||
} | ||
}; | ||
|
||
try { | ||
const result = await axios({ | ||
method: 'post', | ||
url: `digital-specimen/${digitalSpecimenId.replace(import.meta.env.VITE_DOI_URL, '')}/mas`, | ||
responseType: 'json', | ||
data: masRecord, | ||
headers: { | ||
'Content-type': 'application/json', | ||
'Authorization': `Bearer ${token}` | ||
} | ||
}); | ||
|
||
/* Set Specimen MAS */ | ||
const data: JSONResultArray = result.data; | ||
|
||
digitalSpecimenMAS = data.data[0].attributes; | ||
} catch (error: any) { | ||
throw PostException('Machine Annotation Services', error.request.responseURL); | ||
}; | ||
}; | ||
|
||
return digitalSpecimenMAS; | ||
}; | ||
|
||
export default ScheduleDigitalSpecimenMAS; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.