Skip to content

Commit

Permalink
feat: Disable "server" buttons for anonymous users (#391) (#392)
Browse files Browse the repository at this point in the history
  • Loading branch information
gromdimon authored Jan 19, 2024
1 parent 7e377c9 commit bfabd6e
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 7 deletions.
3 changes: 0 additions & 3 deletions backend/app/api/internal/endpoints/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,6 @@ async def cnv_acmg(request: Request):
data={"chromosome": chromosome, "start": start, "end": end, "func": func, "error": 0},
)
backend_resp = await client.send(backend_req)
if backend_resp.status_code != 200:
return Response(status_code=backend_resp.status_code, content=backend_resp.content)

if backend_resp.status_code != 200:
return Response(status_code=backend_resp.status_code, content=backend_resp.content)
return JSONResponse(backend_resp.json())
Expand Down
9 changes: 9 additions & 0 deletions frontend/src/components/SeqvarDetails/ClinsigCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
import { type Seqvar } from '@/lib/genomicVars'
import { StoreState } from '@/stores/misc'
import { useSeqvarAcmgRatingStore } from '@/stores/seqvarAcmgRating'
import { useUserStore } from '@/stores/user'

/** Data type used for component's props. */
interface Props {
Expand All @@ -41,6 +42,9 @@ const emit = defineEmits<{
/** Store to use for ACMG ratings of sequence variants. */
const acmgRatingStore = useSeqvarAcmgRatingStore()

/** Store for user data. */
const userStore = useUserStore()

/** Component state: error message to display, if any. */
const errorMessage = ref<string>('')
/** Component state: whether to enable summary view. */
Expand Down Expand Up @@ -172,6 +176,7 @@ watch(

/** Fetch ACMG rating when mounted. */
onMounted(async () => {
userStore.initialize()
if (props.seqvar?.genomeBuild === 'grch37') {
const seqvar = props.seqvar // so that it is not undefined in the async function
await tryCatchEmitErrorDisplay(async () => await acmgRatingStore.fetchAcmgRating(seqvar))
Expand Down Expand Up @@ -257,6 +262,7 @@ onMounted(async () => {
<v-col cols="6">
<SummarySheet
:calculated-acmg-class="calculatedAcmgClass"
:inter-var-available="acmgRatingStore.acmgRatingIntervarLoaded"
@clear-all="() => unfetchAcmgRating()"
@reset-to-auto="() => refetchAcmgRatingInterVar()"
/>
Expand All @@ -268,6 +274,7 @@ onMounted(async () => {
variant="text"
rounded="sm"
prepend-icon="mdi-cloud-upload-outline"
:disabled="!userStore.isAuthenticated"
@click="() => saveAcmgRating()"
>
Save to Server
Expand All @@ -277,6 +284,7 @@ onMounted(async () => {
variant="text"
rounded="sm"
prepend-icon="mdi-cloud-download-outline"
:disabled="!userStore.isAuthenticated"
@click="() => refetchAcmgRatingServer()"
>
Load from Server
Expand All @@ -286,6 +294,7 @@ onMounted(async () => {
variant="text"
rounded="sm"
prepend-icon="mdi-cloud-remove-outline"
:disabled="!userStore.isAuthenticated"
@click="() => deleteAcmgRating()"
>
Delete from Server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import { classColor } from '@/lib/utils'
interface Props {
calculatedAcmgClass?: string
interVarAvailable?: boolean
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const props = withDefaults(defineProps<Props>(), {
calculatedAcmgClass: 'N/A'
calculatedAcmgClass: 'N/A',
interVaravailable: false
})
const emit = defineEmits(['clearAll', 'resetToAuto'])
Expand Down Expand Up @@ -38,6 +40,7 @@ const emit = defineEmits(['clearAll', 'resetToAuto'])
variant="text"
rounded="sm"
prepend-icon="mdi-file-restore-outline"
:disabled="!interVarAvailable"
@click="emit('resetToAuto')"
>
Reset to InterVar
Expand Down
28 changes: 25 additions & 3 deletions frontend/src/stores/seqvarAcmgRating.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { InterVarClient } from '@/api/intervar'
import {
ALL_ACMG_CRITERIA,
AcmgCriteria,
AcmgEvidenceLevel,
MultiSourceAcmgCriteriaState,
Presence,
StateSource
Expand Down Expand Up @@ -98,6 +99,9 @@ export const useSeqvarAcmgRatingStore = defineStore('seqvarAcmgRating', () => {
// Load data from InterVar via API
storeState.value = StoreState.Loading

// Set the variant
seqvar.value = seqvar$

// Fetch the ACMG rating from InterVar
try {
const client = new InterVarClient()
Expand Down Expand Up @@ -232,7 +236,7 @@ export const useSeqvarAcmgRatingStore = defineStore('seqvarAcmgRating', () => {
throw new Error('Cannot save ACMG rating without a variant.')
}
const seqvarImpl = seqvarImplFromSeqvar(seqvar.value)
const acmgRating = transformAcmgRating()
const acmgRatingServer = transformAcmgRating()

try {
const acmgSeqvarClient = new AcmgSeqVarClient()
Expand All @@ -242,9 +246,23 @@ export const useSeqvarAcmgRatingStore = defineStore('seqvarAcmgRating', () => {
acmgSeqvar.detail !== 'ACMG Sequence Variant not found' &&
acmgSeqvar.detail !== 'Not Found'
) {
await acmgSeqvarClient.updateAcmgRating(seqvarImpl, acmgRating)
await acmgSeqvarClient.updateAcmgRating(seqvarImpl, acmgRatingServer)
} else {
await acmgSeqvarClient.saveAcmgRating(seqvarImpl, acmgRating)
await acmgSeqvarClient.saveAcmgRating(seqvarImpl, acmgRatingServer)
}
// Go through the data and setPresense for each criteria
for (const criteria of acmgRatingServer.criterias) {
const criteriaKey = criteria.criteria as keyof typeof AcmgCriteria
acmgRating.value.setPresence(
StateSource.Server,
AcmgCriteria[criteriaKey],
criteria.presence as Presence
)
acmgRating.value.setEvidenceLevel(
StateSource.Server,
AcmgCriteria[criteriaKey],
criteria.evidence as AcmgEvidenceLevel
)
}
acmgRatingStatus.value = true
} catch (e) {
Expand All @@ -266,6 +284,10 @@ export const useSeqvarAcmgRatingStore = defineStore('seqvarAcmgRating', () => {
try {
const acmgSeqvarClient = new AcmgSeqVarClient()
await acmgSeqvarClient.deleteAcmgRating(seqvarImpl)
// Go through the data and setPresense for each criteria
for (const criteria of ALL_ACMG_CRITERIA) {
acmgRating.value.setPresence(StateSource.Server, criteria, Presence.Unknown)
}
acmgRatingStatus.value = false
} catch (e) {
throw new Error(`There was an error deleting the ACMG data: ${e}`)
Expand Down

0 comments on commit bfabd6e

Please sign in to comment.