-
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 pull request #125 from DiSSCo/RefactorProfilePage
Refactor profile page
- Loading branch information
Showing
20 changed files
with
659 additions
and
112 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* Import Dependencies */ | ||
import axios from 'axios'; | ||
import KeycloakService from 'app/Keycloak'; | ||
|
||
/* Import Types */ | ||
import { Annotation } from 'app/types/Annotation'; | ||
import { JSONResultArray } from 'app/Types'; | ||
|
||
/* Import Exceptions */ | ||
import { NotFoundException } from 'app/Exceptions'; | ||
|
||
|
||
/** | ||
* Function for fetching a the logged in user's annotations | ||
* @returns Array of Annotations | ||
*/ | ||
const GetCreatorAnnotations = async () => { | ||
let creatorAnnotations: Annotation[] = []; | ||
|
||
const token = KeycloakService.GetToken(); | ||
|
||
if (token) { | ||
try { | ||
const result = await axios({ | ||
method: 'get', | ||
url: `annotation/creator`, | ||
responseType: 'json', | ||
headers: { | ||
'Content-type': 'application/json', | ||
'Authorization': `Bearer ${token}` | ||
} | ||
}); | ||
|
||
/* Get result data from JSON */ | ||
const data: JSONResultArray = result.data; | ||
|
||
/* Set creator annotation items */ | ||
data.data.forEach(dataRow => { | ||
creatorAnnotations.push(dataRow.attributes as Annotation); | ||
}); | ||
} catch (error: any) { | ||
throw (NotFoundException('Creator Annotations', error.request.responseURL)); | ||
}; | ||
} | ||
|
||
return creatorAnnotations; | ||
}; | ||
|
||
export default GetCreatorAnnotations; |
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,48 @@ | ||
/* Import Dependencies */ | ||
import axios from 'axios'; | ||
import KeycloakService from 'app/Keycloak'; | ||
|
||
/* Import Types */ | ||
import { MasJobRecord, JSONResultArray } from 'app/Types'; | ||
|
||
/* Import Exceptions */ | ||
import { NotFoundException } from 'app/Exceptions'; | ||
|
||
|
||
/** | ||
* Function for fetching a the logged in user's MAS job records | ||
* @returns Array of MAS job records | ||
*/ | ||
const GetCreatorMasJobRecords = async () => { | ||
let creatorMasJobRecords: MasJobRecord[] = []; | ||
|
||
const token = KeycloakService.GetToken(); | ||
|
||
if (token) { | ||
try { | ||
const result = await axios({ | ||
method: 'get', | ||
url: `mjr/creator/${KeycloakService.GetParsedToken()?.orcid}`, | ||
responseType: 'json', | ||
headers: { | ||
'Content-type': 'application/json', | ||
'Authorization': `Bearer ${token}` | ||
} | ||
}); | ||
|
||
/* Get result data from JSON */ | ||
const data: JSONResultArray = result.data; | ||
|
||
/* Set creator MAS job record items */ | ||
data.data.forEach(dataRow => { | ||
creatorMasJobRecords.push(dataRow.attributes as MasJobRecord); | ||
}); | ||
} catch (error: any) { | ||
throw (NotFoundException('Creator MAS job records', error.request.responseURL)); | ||
}; | ||
} | ||
|
||
return creatorMasJobRecords; | ||
}; | ||
|
||
export default GetCreatorMasJobRecords; |
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,52 @@ | ||
/* Import Dependencies */ | ||
import { createColumnHelper } from '@tanstack/react-table'; | ||
|
||
/* Import Utilities */ | ||
import { MakeJsonPathReadableString } from 'app/utilities/SchemaUtilities'; | ||
|
||
|
||
/** | ||
* Config function that sets up the basic table column template for the user annotation records table on the profile page | ||
* @returns Table columns | ||
*/ | ||
const UserAnnotationRecordsTableConfig = () => { | ||
/* User annotation record type */ | ||
type UserAnnotationRecord = { | ||
jsonPath: string, | ||
motivation: string, | ||
value: string | number | boolean | ||
}; | ||
|
||
/* Base variables */ | ||
const columnHelper = createColumnHelper<UserAnnotationRecord>(); | ||
|
||
/* Table columns */ | ||
const columns = [ | ||
columnHelper.accessor('jsonPath', { | ||
header: 'Target', | ||
cell: info => MakeJsonPathReadableString(info.getValue()), | ||
meta: { | ||
widthInRem: 10, | ||
pinned: true | ||
} | ||
}), | ||
columnHelper.accessor('motivation', { | ||
header: 'Motivation', | ||
meta: { | ||
widthInRem: 10, | ||
pinned: true | ||
} | ||
}), | ||
columnHelper.accessor('value', { | ||
header: 'Annotation value', | ||
meta: { | ||
widthInRem: 10, | ||
pinned: true | ||
} | ||
}) | ||
]; | ||
|
||
return { columns }; | ||
}; | ||
|
||
export default UserAnnotationRecordsTableConfig; |
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,61 @@ | ||
/* Import Dependencies */ | ||
import { createColumnHelper } from '@tanstack/react-table'; | ||
import { format } from 'date-fns'; | ||
|
||
|
||
/** | ||
* Config function that sets up the basic table column template for the user MAS job records table on the profile page | ||
* @returns Table columns | ||
*/ | ||
const UserMasJobRecordsTableConfig = () => { | ||
/* User annotation record type */ | ||
type UserMasJobRecord = { | ||
targetId: string, | ||
scheduled: string, | ||
completed: string, | ||
state: string | ||
}; | ||
|
||
/* Base variables */ | ||
const columnHelper = createColumnHelper<UserMasJobRecord>(); | ||
|
||
|
||
|
||
/* Table columns */ | ||
const columns = [ | ||
columnHelper.accessor('targetId', { | ||
header: 'Target ID', | ||
meta: { | ||
widthInRem: 10, | ||
pinned: true | ||
} | ||
}), | ||
columnHelper.accessor('scheduled', { | ||
header: 'Scheduled', | ||
cell: (info) => format(info.getValue(), 'MMMM dd - yyyy'), | ||
meta: { | ||
widthInRem: 10, | ||
pinned: true | ||
} | ||
}), | ||
columnHelper.accessor('completed', { | ||
header: 'Completed', | ||
cell: (info) => format(info.getValue(), 'MMMM dd - yyyy'), | ||
meta: { | ||
widthInRem: 10, | ||
pinned: true | ||
} | ||
}), | ||
columnHelper.accessor('state', { | ||
header: 'State', | ||
meta: { | ||
widthInRem: 10, | ||
pinned: true | ||
} | ||
}) | ||
]; | ||
|
||
return { columns }; | ||
}; | ||
|
||
export default UserMasJobRecordsTableConfig; |
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
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.