Skip to content

Commit

Permalink
fix minor bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
emiliorighi committed Oct 7, 2024
1 parent 9d252fa commit 20f69ee
Show file tree
Hide file tree
Showing 11 changed files with 108 additions and 139 deletions.
44 changes: 0 additions & 44 deletions biogenome-client/src/components/blocks/FiltersBlock.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
</div>
<div class="flex">
<VaMenu>
<VaMenuItem icon="article" v-if="isGoaTActive" @selected="downloadGoatReport">
GoaT
</VaMenuItem>
<VaMenuItem icon="article" @selected="itemStore.showTsvModal = !itemStore.showTsvModal">
Report
</VaMenuItem>
Expand Down Expand Up @@ -44,8 +41,6 @@ import { useItemStore } from '../../stores/items-store'
import { useI18n } from 'vue-i18n'
import ExportTSV from '../modals/ExportTSV.vue'
import CreateChart from '../modals/CreateChart.vue'
import general from '../../../configs/general.json'
import GoaTService from '../../services/clients/GoaTService'
const { t } = useI18n()
Expand All @@ -70,52 +65,13 @@ const model = computed(() => {
return itemStore.currentModel
})
const isGoaTActive = computed(() => {
return model.value === 'organisms' && general.goat
})
const isFiltering = computed(() => !!itemStore.stores[model.value].searchForm.filter)
const total = computed(() => itemStore.stores[model.value].total)
const modelFilterEntries = computed(() => Object.entries(itemStore.stores[model.value].searchForm)
.filter(([k, v]) => !staticColumns.includes(k)))
const activeFilters = computed(() => modelFilterEntries.value
.filter(([k, v]) => (v || v === false))
)
async function downloadGoatReport() {
try {
const response = await GoaTService.getGoatReport()
const data = response.data
const href = URL.createObjectURL(data);
const filename = response.headers['content-disposition']
const match = filename.match(/filename=([^;]+)/);
let name = ''
if (match && match[1]) {
name = match[1];
} else {
name = 'file.tsv'
console.log("Filename not found in the string.");
}
// create "a" HTML element with href to file & click
const link = document.createElement('a');
link.href = href;
link.setAttribute('download', name); //or any other extension
document.body.appendChild(link);
link.click();
// clean up "a" element & remove ObjectURL
document.body.removeChild(link);
URL.revokeObjectURL(href);
} catch (err) {
console.error(err)
itemStore.toast({ message: 'Error downloading Goat Report', color: 'danger' })
}
}
</script>
<style>
Expand Down
7 changes: 5 additions & 2 deletions biogenome-client/src/components/blocks/TableBlock.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@
</va-avatar>
</template>
<template #cell(gff_gz_location)="{ rowData }">
<VaChip :href="rowData.gff_gz_location" outline size="small">{{ t('buttons.download') }}</VaChip>
<VaChip @click.stop :href="rowData.gff_gz_location" outline size="small">{{
t('buttons.download') }}
</VaChip>
</template>
<template #cell(tab_index_location)="{ rowData }">
<VaChip :href="rowData.tab_index_location" outline size="small">{{ t('buttons.download')
<VaChip @click.stop :href="rowData.tab_index_location" outline size="small">{{
t('buttons.download')
}}</VaChip>
</template>
</VaDataTable>
Expand Down
2 changes: 1 addition & 1 deletion biogenome-client/src/components/maps/LeafletMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</div>
<div v-if="showSampleTypeSelect" class="flex">
<va-select preset="bordered" inner-label v-model="sampleType" label="Sample Type"
:options="['local_sample', 'biosamples']" />
:options="['local_sample', 'biosample']" />
</div>
<div class="flex">
<va-button :loading="isLoading" :disabled="isSubmitDisabled" :round="false" @click="search">
Expand Down
43 changes: 43 additions & 0 deletions biogenome-client/src/components/sidebar/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
</VaSidebarItemTitle>
</VaSidebarItemContent>
</VaSidebarItem>
<VaSidebarItem v-if="general.goat" @click="downloadGoatReport">
<VaSidebarItemContent>
<VaSidebarItemTitle>
GoaT Report
</VaSidebarItemTitle>
</VaSidebarItemContent>
</VaSidebarItem>
<VaSidebarItem @click="globalStore.isSidebarVisible = !globalStore.isSidebarVisible"
v-if="globalStore.isAuthenticated" :to="{ name: 'cms-organisms' }">
<VaSidebarItemContent>
Expand Down Expand Up @@ -51,6 +58,11 @@ import general from '../../../configs/general.json'
import { useGlobalStore } from '../../stores/global-store'
import { useRoute, useRouter } from 'vue-router'
import { useI18n } from 'vue-i18n'
import GoaTService from '../../services/clients/GoaTService'
import { useToast } from 'vuestic-ui/web-components'
const { init } = useToast()
const { t } = useI18n()
const route = useRoute()
Expand All @@ -70,6 +82,37 @@ async function logout() {
await globalStore.logout()
router.push({ name: 'dashboard' })
}
async function downloadGoatReport() {
try {
const response = await GoaTService.getGoatReport()
const data = response.data
const href = URL.createObjectURL(data);
const filename = response.headers['content-disposition']
const match = filename.match(/filename=([^;]+)/);
let name = ''
if (match && match[1]) {
name = match[1];
} else {
name = 'file.tsv'
console.log("Filename not found in the string.");
}
// create "a" HTML element with href to file & click
const link = document.createElement('a');
link.href = href;
link.setAttribute('download', name); //or any other extension
document.body.appendChild(link);
link.click();
// clean up "a" element & remove ObjectURL
document.body.removeChild(link);
URL.revokeObjectURL(href);
} catch (err) {
console.error(err)
init({ message: 'Error downloading Goat Report', color: 'danger' })
}
}
</script>

<style lang="scss">
Expand Down
14 changes: 10 additions & 4 deletions biogenome-client/src/components/tables/RelatedDataTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
{{ key.split('.').length ? key.split('.')[key.split('.').length - 1] : key }}
</template>
<template #cell(gff_gz_location)="{ rowData }">
<VaChip :href="rowData.gff_gz_location" outline size="small">{{ t('buttons.download') }}</VaChip>
<VaChip @click.stop :href="rowData.gff_gz_location" outline size="small">{{
t('buttons.download') }}
</VaChip>
</template>
<template #cell(tab_index_location)="{ rowData }">
<VaChip :href="rowData.tab_index_location" outline size="small">{{ t('buttons.download')
}}</VaChip>
<VaChip @click.stop :href="rowData.tab_index_location" outline size="small">{{
t('buttons.download')
}}</VaChip>
</template>
</VaDataTable>
</template>
Expand Down Expand Up @@ -41,9 +44,12 @@ const columns = computed(() => {
} else {
return []
}
})
const handleLinkClick = (event: MouseEvent) => {
event.stopPropagation(); // Prevent event from bubbling to the row
};
const handleClick = (event: any) => {
const { item } = event
const routeMap: Record<string, any> = {
Expand Down
4 changes: 2 additions & 2 deletions biogenome-client/src/pages/cms/assembly/Assemblies.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
<va-icon color="danger" name="delete" @click="deleteConfirmation(rowData)" />
</template>
<template #cell(chromosome_aliases)="{ rowData }">
<div class="row justify-space-between">
<div class="row">
<div v-if="rowData.has_chromosomes_aliases" class="flex">
<va-button size="small" :href="`${baseURL}/assemblies/${rowData.accession}/chr_aliases`"
icon="download"></va-button>
</div>
<div v-if="rowData.metadata.assembly_info.assembly_level === 'Chromosome'" class="flex">
<div v-if="rowData.metadata && rowData.metadata.assembly_info.assembly_level === 'Chromosome'" class="flex">
<va-button :to="{ name: 'chr-aliases', params: { accession: rowData.accession } }" size="small"
icon="add" />
</div>
Expand Down
12 changes: 8 additions & 4 deletions biogenome-client/src/pages/cms/uploads/ChrAliasesForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ import { ref } from 'vue';
import AuthService from '../../../services/clients/AuthService';
import { useToast } from 'vuestic-ui/web-components';
import { AxiosError } from 'axios';
import { useRouter } from 'vue-router';
const {init} = useToast()
const router = useRouter()
const { init } = useToast()
const props = defineProps<{
accession: string,
}>()
Expand All @@ -39,11 +42,12 @@ async function handleSubmit() {
const formData = new FormData()
formData.append('chr_aliases', refName.value)
const { data } = await AuthService.uploadRefNameAliases(props.accession, formData)
init({message: data as string, color:'success'})
init({ message: data as string, color: 'success' })
router.push({ name: 'cms-assemblies' })
} catch (error) {
const axiosError = error as AxiosError
if(axiosError.response && axiosError.response.data){
init({message:axiosError.response.data as string,color:'danger'})
if (axiosError.response && axiosError.response.data) {
init({ message: axiosError.response.data as string, color: 'danger' })
}
console.log(error)
} finally {
Expand Down
71 changes: 33 additions & 38 deletions biogenome-client/src/stores/items-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,32 @@ export const useItemStore = defineStore('item', {
const model = this.currentModel
this.stores[model].searchForm[field] = null
},
catchError(error: any) {
console.error(error)
const axiosError = error as AxiosError<ErrorResponseData>
let message
if (axiosError.response && axiosError.response.data && axiosError.response.data.message) {
message = axiosError.response.data.message

} else {
message = axiosError.message
}
this.toast({ message: message, color: 'danger' })
},
downloadFile(data: any) {
const href = URL.createObjectURL(data);

const filename = `${this.currentModel}_report.tsv`
// create "a" HTML element with href to file & click
const link = document.createElement('a');
link.href = href;
link.setAttribute('download', filename); //or any other extension
document.body.appendChild(link);
link.click();
// clean up "a" element & remove ObjectURL
document.body.removeChild(link);
URL.revokeObjectURL(href);
},
//incoming model may not correspond to currentModel
async getStats(model: string, field: string) {
try {
Expand All @@ -101,20 +127,12 @@ export const useItemStore = defineStore('item', {
const { data } = await StatisticsService.getModelFieldStats(model, field, query)
return data
} catch (err) {
const axiosError = err as AxiosError<ErrorResponseData>
let message
if (axiosError.response && axiosError.response.data && axiosError.response.data.message) {
message = axiosError.response.data.message

} else {
message = axiosError.message
}
this.toast({ message: message, color: 'danger' })
this.catchError(err)
}
},
async fetchItems() {
const model = this.currentModel
this.stores[model].isLoading = true
this.isTableLoading = true
const { searchForm, pagination } = this.stores[model]

// Build the query params
Expand All @@ -127,23 +145,14 @@ export const useItemStore = defineStore('item', {
if (this.parentTaxon) {
params['taxon_lineage'] = this.parentTaxon
}

try {
const { data } = await CommonService.getItems(`/${model}`, params)
this.stores[model].items = [...data.data]
this.stores[model].total = data.total
} catch (err) {
const axiosError = err as AxiosError<ErrorResponseData>
let message
if (axiosError.response && axiosError.response.data && axiosError.response.data.message) {
message = axiosError.response.data.message

} else {
message = axiosError.message
}
this.toast({ message: message, color: 'danger' })
this.catchError(err)
} finally {
this.stores[model].isLoading = false
this.isTableLoading = false
}
},
async downloadData(fields: string[], applyFilters: boolean) {
Expand All @@ -158,25 +167,11 @@ export const useItemStore = defineStore('item', {
if (this.parentTaxon) {
requestData['taxon_lineage'] = this.parentTaxon
}
const { data } = await CommonService.getTsv(`/${model}`, requestData)
this.downloadFile(data)

const response = await CommonService.getTsv(`/${model}`, requestData)
const data = response.data
const href = URL.createObjectURL(data);

const filename = `${model}_report.tsv`
// create "a" HTML element with href to file & click
const link = document.createElement('a');
link.href = href;
link.setAttribute('download', filename); //or any other extension
document.body.appendChild(link);
link.click();
// clean up "a" element & remove ObjectURL
document.body.removeChild(link);
URL.revokeObjectURL(href);
} catch (e) {
console.log(e)
const axiosError = e as AxiosError
this.toast({ message: axiosError.message, color: 'danger' })
this.catchError(e)
} finally {
this.isTSVLoading = false
}
Expand Down
42 changes: 0 additions & 42 deletions docker-compose.yml

This file was deleted.

Loading

0 comments on commit 20f69ee

Please sign in to comment.