Newer
Older
<template>
<div class="mainContent">
<slot :response="response" :loading="loading"></slot>
</div>
</template>
<script>
// require modules
/* eslint-disable no-unused-vars */
const _ = require('lodash');
let host = require('./js/const').host;
export default {
name: "Search",
data() {
return {
response: null,
loading: false,
isDev: process.env.NODE_ENV === 'development'
}
},
methods: {
fetchProteinList(keyword, taxId, page) {
const vm = this
// /* eslint-disable no-console */
// console.log(vm.incDesc);
vm.loading = true
// let url = `http://${host}/proteins?query=${keyword}&species_tax_id=${taxId}&page=${page}`;
if(vm.isDev) {
host = require('./js/const').devHost;
}
let url = taxId === 'all' ? `${host}/proteins?query=${keyword}&size=100000`:
`${host}/proteins?query=${keyword}&species_tax_id=${taxId}&size=100000`;
if (keyword && !_.isEmpty(keyword)) {
fetch(url)
.then(response => response.json())
.then((response) => {
// /* eslint-disable no-console */
// console.log(response);
setTimeout(() => {
vm.loading = false;
vm.response = response
// console.log(response);
// if (response && !_.isEmpty(response)) {
// this.response = _.flatMap(response, (n) => [{ text: n.name, style: 'background-color: ' + n.color }]);
// }
}, 10);
});
} else {
url = taxId === 'all' ? `${host}/proteins?fields=ensembl_gene_id,ensembl_id,functional_type,gene_name,name,species_name,species_tax_id,uniprot_id,uniprot_readable_idz&size=100000`:
`${host}/proteins?species_tax_id=${taxId}&fields=ensembl_gene_id,ensembl_id,functional_type,gene_name,name,species_name,species_tax_id,uniprot_id,uniprot_readable_id&size=100000`;
fetch(url)
.then(response => response.json())
.then((response) => {
// /* eslint-disable no-console */
// console.log(response);
setTimeout(() => {
vm.loading = false;
vm.response = response
// console.log(response);
// if (response && !_.isEmpty(response)) {
// this.response = _.flatMap(response, (n) => [{ text: n.name, style: 'background-color: ' + n.color }]);
// }
}, 10);
});
}
},
fetchCondensateList(keyword, taxId, page) {
const vm = this
// /* eslint-disable no-console */
// console.log(vm.incDesc);
vm.loading = true
if(vm.isDev) {
host = require('./js/const').devHost;
}
// let url = `http://${host}/condensates?query=${keyword}&species_tax_id=${taxId}&page=${page}`;
// fields=biomarkers,canonical_id,description,is_experimental,name,protein_count,proteins,species_name,species_tax_id,synonyms
let url = taxId === 'all' ? `${host}/condensates?query=${keyword}&size=10000`
:`${host}/condensates?query=${keyword}&species_tax_id=${taxId}&size=10000`;
// if(vm.isDev) {
// url = `/json/condensateList.json`;
// }
if (keyword && !_.isEmpty(keyword)) {
fetch(url)
.then(response => response.json())
.then((response) => {
// /* eslint-disable no-console */
// console.log(response);
setTimeout(() => {
vm.loading = false;
vm.response = response
// console.log(response);
// if (response && !_.isEmpty(response)) {
// this.response = _.flatMap(response, (n) => [{ text: n.name, style: 'background-color: ' + n.color }]);
// }
}, 10);
});
} else {
url = taxId === 'all' ? `${host}/condensates?fields=biomarkers,canonical_id,description,is_experimental,name,protein_count,proteins,species_name,species_tax_id,synonyms,protein_confidence_score&size=10000`
:`${host}/condensates?species_tax_id=${taxId}&fields=biomarkers,canonical_id,description,is_experimental,name,protein_count,proteins,species_name,species_tax_id,synonyms,protein_confidence_score&size=10000`;
fetch(url)
.then(response => response.json())
.then((response) => {
// /* eslint-disable no-console */
// console.log(response);
setTimeout(() => {
vm.loading = false;
vm.response = response
// console.log(response);
// if (response && !_.isEmpty(response)) {
// this.response = _.flatMap(response, (n) => [{ text: n.name, style: 'background-color: ' + n.color }]);
// }
}, 10);
});