@@ -30,7 +30,7 @@ import { obpMyCollectionsEndpointKey, obpResourceDocsKey } from '@/obp/keys'
3030import { ArrowLeftBold , ArrowRightBold } from ' @element-plus/icons-vue'
3131import { ElNotification } from ' element-plus'
3232import { inject , onMounted , provide , ref } from ' vue'
33- import { onBeforeRouteUpdate , useRoute } from ' vue-router'
33+ import { onBeforeRouteUpdate , useRoute , useRouter } from ' vue-router'
3434import {
3535OBP_API_DEFAULT_RESOURCE_DOC_VERSION ,
3636createMyAPICollection ,
@@ -43,9 +43,12 @@ import { SUMMARY_PAGER_LINKS_COLOR as summaryPagerLinksColorSetting } from '../o
4343import { initializeAPICollections , setTabActive } from ' ./SearchNav.vue'
4444
4545const route = useRoute ()
46+ const router = useRouter ()
4647const obpVersion = OBP_API_DEFAULT_RESOURCE_DOC_VERSION
4748const description = ref (' ' )
4849const summary = ref (' ' )
50+ const tags = ref <string []>([])
51+ const allTags = ref <string []>([])
4952const resourceDocs = inject (obpResourceDocsKey )
5053const displayPrev = ref (true )
5154const displayNext = ref (true )
@@ -63,8 +66,20 @@ let apiCollectionsEndpoint = inject(obpMyCollectionsEndpointKey)!
6366
6467const setOperationDetails = (id : string , version : string ): void => {
6568 const operation = getOperationDetails (version , id , resourceDocs )
69+ console .log (' Operation details:' , operation )
70+ console .log (' Tags from operation:' , operation ?.tags )
6671 description .value = operation ?.description
6772 summary .value = operation ?.summary
73+ tags .value = operation ?.tags || []
74+ console .log (' Tags ref value:' , tags .value )
75+ }
76+
77+ const filterByTag = (tag : string ) => {
78+ router .push ({
79+ name: ' api' ,
80+ params: { version: version },
81+ query: { tags: tag }
82+ })
6883}
6984
7085const setPager = (id : string ): void => {
@@ -144,6 +159,17 @@ const showNotification = (message: string, type: string): void => {
144159 })
145160}
146161
162+ const getAllTags = (version : string ) => {
163+ const docs = resourceDocs [version ]?.resource_docs || []
164+ const tagSet = new Set <string >()
165+ docs .forEach ((doc : any ) => {
166+ if (doc .tags && Array .isArray (doc .tags )) {
167+ doc .tags .forEach ((tag : string ) => tagSet .add (tag ))
168+ }
169+ })
170+ return Array .from (tagSet ).sort ()
171+ }
172+
147173onMounted (async () => {
148174 routeId = route .query .operationid
149175 version = route .params .version ? route .params .version : obpVersion
@@ -153,6 +179,7 @@ onMounted(async () => {
153179 showPlaceholder .value = true
154180 placeholderVersion .value = version
155181 totalEndpoints .value = resourceDocs [version ]?.resource_docs ?.length || 0
182+ allTags .value = getAllTags (version )
156183 } else {
157184 showPlaceholder .value = false
158185 setOperationDetails (routeId , version )
@@ -165,10 +192,11 @@ onBeforeRouteUpdate(async (to) => {
165192 version = to .params .version ? to .params .version : obpVersion
166193
167194 if (! routeId ) {
168- // No operation selected, show placeholder
195+ // Version changed but no endpoint selected
169196 showPlaceholder .value = true
170197 placeholderVersion .value = version
171198 totalEndpoints .value = resourceDocs [version ]?.resource_docs ?.length || 0
199+ allTags .value = getAllTags (version )
172200 } else {
173201 showPlaceholder .value = false
174202 setOperationDetails (routeId , version )
@@ -186,6 +214,20 @@ onBeforeRouteUpdate(async (to) => {
186214 <h2 >Version {{ placeholderVersion }} Selected</h2 >
187215 <p >There are {{ totalEndpoints }} endpoints available in this version.</p >
188216 <p >Please click an endpoint on the left to view its details.</p >
217+
218+ <div v-if =" allTags.length > 0" class =" placeholder-tags" >
219+ <h3 >Filter by Tag:</h3 >
220+ <div class =" tags-grid" >
221+ <a
222+ v-for =" tag in allTags"
223+ :key =" tag"
224+ class =" tag-link"
225+ @click.prevent =" filterByTag(tag)"
226+ >
227+ {{ tag }}
228+ </a >
229+ </div >
230+ </div >
189231 </div >
190232 <div v-else >
191233 <el-row >
@@ -197,6 +239,18 @@ onBeforeRouteUpdate(async (to) => {
197239 <!-- <el-button text>★</el-button>-->
198240 </el-col >
199241 </el-row >
242+ <div class =" tags-section" >
243+ <span class =" tags-label" >Tags ({{ tags.length }}):</span >
244+ <a
245+ v-for =" tag in tags"
246+ :key =" tag"
247+ class =" tag-link"
248+ @click.prevent =" filterByTag(tag)"
249+ >
250+ {{ tag }}
251+ </a >
252+ <span v-if =" tags.length === 0" style =" color : #909399 ; font-size : 12px ;" >No tags available</span >
253+ </div >
200254 <div v-html =" description" class =" content" ></div >
201255 </div >
202256 </el-main >
@@ -236,6 +290,39 @@ span {
236290 font-size : 28px ;
237291}
238292
293+ .tags-section {
294+ margin : 15px 0 ;
295+ display : flex ;
296+ align-items : center ;
297+ gap : 8px ;
298+ flex-wrap : wrap ;
299+ }
300+
301+ .tags-label {
302+ font-size : 14px !important ;
303+ font-weight : 600 ;
304+ color : #606266 ;
305+ }
306+
307+ .tag-link {
308+ display : inline-block ;
309+ padding : 4px 12px ;
310+ font-size : 12px !important ;
311+ color : #409eff ;
312+ background-color : #ecf5ff ;
313+ border : 1px solid #d9ecff ;
314+ border-radius : 4px ;
315+ cursor : pointer ;
316+ transition : all 0.2s ease ;
317+ text-decoration : none ;
318+ }
319+
320+ .tag-link :hover {
321+ background-color : #409eff ;
322+ color : white ;
323+ border-color : #409eff ;
324+ }
325+
239326.placeholder-message {
240327 text-align : center ;
241328 padding : 60px 20px ;
@@ -254,6 +341,24 @@ span {
254341 line-height : 1.6 ;
255342}
256343
344+ .placeholder-tags {
345+ margin-top : 40px ;
346+ text-align : left ;
347+ }
348+
349+ .placeholder-tags h3 {
350+ font-size : 18px ;
351+ margin-bottom : 20px ;
352+ color : #39455f ;
353+ }
354+
355+ .tags-grid {
356+ display : flex ;
357+ flex-wrap : wrap ;
358+ gap : 10px ;
359+ justify-content : flex-start ;
360+ }
361+
257362div {
258363 font-size : 14px ;
259364}
0 commit comments