From 32d0aa26089e351912c0ecd162641398a1553884 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Mili=C4=87?= Date: Fri, 27 Sep 2024 10:58:22 +0200 Subject: [PATCH] feature/Show number of APIs at API Explorer II --- package.json | 2 +- src/components/SearchNav.vue | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 994682e..a4906f4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "api-explorer", - "version": "1.0.16", + "version": "1.0.17", "private": true, "scripts": { "dev": "vite & ts-node server/app.ts", diff --git a/src/components/SearchNav.vue b/src/components/SearchNav.vue index c5e7b24..ba375cf 100644 --- a/src/components/SearchNav.vue +++ b/src/components/SearchNav.vue @@ -96,7 +96,12 @@ onBeforeMount(async () => { setTabActive(route.params.id) let element = document.getElementById("selected-api-version") if (element !== null) { - element.textContent = selectedVersion; + const totalRows = Object.values(groups.value).reduce((acc, currentValue) => acc + currentValue.length, 0) + if(selectedTags === 'NONE') { + element.textContent = `${selectedVersion} ( ${totalRows} APIs )`; + } else { + element.textContent = `${selectedVersion} ( ${totalRows} APIs filtered by tags: ${selectedTags})`; + } } }) @@ -114,9 +119,20 @@ watch( sortedKeys.value = activeKeys.value.sort() await initializeAPICollections() routeToFirstAPI() + countApis() } ) + + +const countApis = () => { + let element = document.getElementById("selected-api-version") + if (element !== null) { + const totalRows = Object.values(groups.value).reduce((acc, currentValue) => acc + currentValue.length, 0) + element.textContent = `${selectedVersion} ( ${totalRows} APIs )`; + } +} + const routeToFirstAPI = () => { let element const elements = document.getElementsByClassName('api-router-link')