From dc1ade8786db463f0d4a7366e4d82b0e86cebc9e Mon Sep 17 00:00:00 2001 From: OganM Date: Wed, 18 Sep 2024 18:00:10 -0700 Subject: [PATCH] always show code snippets. closes #113 --- src/components/CodeSnippet.vue | 32 +++++++++++++++++++++----------- src/views/Browser.vue | 3 +-- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/components/CodeSnippet.vue b/src/components/CodeSnippet.vue index a507332..a137ecf 100644 --- a/src/components/CodeSnippet.vue +++ b/src/components/CodeSnippet.vue @@ -147,31 +147,40 @@ export default { `api = gemmapy.GemmaPy()\n` + `data = api.get_all_pages(api.get_datasets,`); queryGemmapy.push(`)\n`) + } else { + queryGemmapy.push(`import gemmapy\n` + + `api = gemmapy.GemmaPy()\n` + + `data = api.get_all_pages(api.get_datasets)` + ) } tabs[0].content = queryGemmapy.join(""); // Gemma.R snippet let queryGemmaR = []; - if (query !== undefined) { + queryGemmaR.push(`BiocManager::install("gemma.R")\n` + + `library(gemma.R)\n`+ + `library(dplyr)\n` + + `data <- get_datasets(`); + + if (query !== undefined){ queryGemmaR.push(`query = ${this.escapeRString(query)}`); } if (filter !== undefined && filter.length > 0) { - if (queryGemmaR.length > 0) { + if (queryGemmaR.length > 1){ queryGemmaR.push(`, `); } queryGemmaR.push(`filter = ${this.escapeRString(filter)}`); } - if (queryGemmaR.length > 0) { - if (sort !== undefined) { - queryGemmaR.push(`, sort = ${this.escapeRString(sort)}`); + if (sort !== undefined){ + if (queryGemmaR.length > 1){ + queryGemmaR.push(`, `); } - queryGemmaR.unshift(`BiocManager::install("gemma.R")\n` + - `library(gemma.R)\n` + - `library(dplyr)\n` + - `data <- get_datasets(`); - queryGemmaR.push(`) %>% \n` + - `\tgemma.R:::get_all_pages()`); + queryGemmaR.push(`sort = ${this.escapeRString(sort)}`) } + + queryGemmaR.push(`) %>% \n` + + `\tgemma.R:::get_all_pages()`); + tabs[1].content = queryGemmaR.join(""); // curl snippet @@ -181,6 +190,7 @@ export default { const parsedBaseUrl = new URL(this.compressedUrl); tabs[3].content = `GET ${parsedBaseUrl.pathname}${parsedBaseUrl.search} HTTP/1.1\nHost: ${parsedBaseUrl.hostname}\nAccept: application/json`; + return tabs; } }, diff --git a/src/views/Browser.vue b/src/views/Browser.vue index 6825778..72bd0e5 100644 --- a/src/views/Browser.vue +++ b/src/views/Browser.vue @@ -131,8 +131,7 @@ Collapse all datasets - +