Skip to content

Commit a9d7646

Browse files
authored
Merge pull request #163 from simonredfern/develop
About page and saving space in the header
2 parents fd2d70d + d88cb7d commit a9d7646

12 files changed

Lines changed: 276 additions & 86 deletions

src/components/HeaderNav.vue

Lines changed: 7 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<script setup lang="ts">
2929
import { ref, inject, watchEffect, onMounted, onUnmounted, computed } from 'vue'
3030
import { useRoute, useRouter } from 'vue-router'
31-
import { OBP_API_DEFAULT_RESOURCE_DOC_VERSION, getCurrentUser, getOBPBanks } from '../obp'
31+
import { OBP_API_DEFAULT_RESOURCE_DOC_VERSION, getCurrentUser } from '../obp'
3232
import { getOBPAPIVersions } from '../obp/api-version'
3333
import {
3434
LOGO_URL as logoSource,
@@ -63,31 +63,12 @@ const combinedMessageDocs = computed(() => {
6363
// Help menu items (includes debug pages)
6464
const helpMenuRoutes: Record<string, string> = {
6565
'Help': '/help',
66+
'About': '/about',
6667
'Providers Status': '/debug/providers-status',
6768
'OIDC': '/debug/oidc'
6869
}
6970
const helpMenuItems = ref(Object.keys(helpMenuRoutes))
7071
71-
// Banks state
72-
const banks = ref<Array<{ bank_id: string; bank_code: string; full_name: string }>>([])
73-
const bankItems = computed(() =>
74-
[...banks.value]
75-
.sort((a, b) => (a.full_name || a.bank_id || '').localeCompare(b.full_name || b.bank_id || ''))
76-
.map(b => {
77-
const name = b.full_name || b.bank_id || ''
78-
const id = b.bank_id || ''
79-
return name !== id ? `${name} | ${id}` : id
80-
})
81-
)
82-
const selectedBankId = ref(localStorage.getItem('obp-selected-bank-id') || '')
83-
const banksDropdownLabel = computed(() => {
84-
if (selectedBankId.value) {
85-
const bank = banks.value.find(b => b.bank_id === selectedBankId.value)
86-
return bank ? (bank.full_name || bank.bank_id) : 'Banks'
87-
}
88-
return 'Banks'
89-
})
90-
9172
// Split versions into main and other
9273
const mainVersions = ['BGv1.3', 'BGv2', 'OBPv5.1.0', 'OBPv6.0.0', 'UKv3.1', 'dynamic-endpoints', 'dynamic-entities', 'OBPdynamic-endpoint', 'OBPdynamic-entity']
9374
const sortedVersions = computed(() => {
@@ -264,28 +245,7 @@ const handleMore = (command: string, source?: string) => {
264245
}
265246
}
266247
267-
const handleBankSelect = (item: string) => {
268-
// Extract bank_id from display format "full_name | bank_id" or just "bank_id"
269-
const parts = item.split(' | ')
270-
const bankId = parts[parts.length - 1]
271-
const bank = banks.value.find(b => b.bank_id === bankId)
272-
if (bank) {
273-
selectedBankId.value = bank.bank_id
274-
localStorage.setItem('obp-selected-bank-id', bank.bank_id)
275-
window.dispatchEvent(new CustomEvent('obp-bank-selected', { detail: bank.bank_id }))
276-
}
277-
}
278-
279248
onMounted(async () => {
280-
// Fetch banks
281-
getOBPBanks().then((data) => {
282-
if (data && data.banks && Array.isArray(data.banks)) {
283-
banks.value = data.banks
284-
}
285-
}).catch((error) => {
286-
console.error('Failed to fetch banks:', error)
287-
})
288-
289249
// Fetch available providers
290250
await fetchAvailableProviders()
291251
@@ -327,8 +287,10 @@ const getCurrentPath = () => {
327287
</script>
328288

329289
<template>
330-
<img alt="OBP logo" class="logo" v-show="logo" :src="logo" />
331-
<img alt="OBP logo" class="logo" v-show="!logo" src="@/assets/logo2x-1.png" />
290+
<a :href="obpApiHybridPost">
291+
<img alt="OBP logo" class="logo" v-show="logo" :src="logo" />
292+
<img alt="OBP logo" class="logo" v-show="!logo" src="@/assets/logo2x-1.png" />
293+
</a>
332294
<nav id="nav">
333295
<RouterView name="header">
334296
<a v-bind:href="obpApiHybridPost" class="router-link" id="header-nav-home">
@@ -348,15 +310,6 @@ const getCurrentPath = () => {
348310
:background-color="headerLinksBackgroundColor"
349311
@select="handleMore"
350312
/>
351-
<SvelteDropdown
352-
class="menu-right"
353-
id="header-nav-banks"
354-
:label="banksDropdownLabel"
355-
:items="bankItems"
356-
:hover-color="headerLinksHoverColor"
357-
:background-color="headerLinksBackgroundColor"
358-
@select="handleBankSelect"
359-
/>
360313
<a v-if="showObpApiManagerButton && hasObpApiManagerHost" v-bind:href="obpApiManagerHost" class="router-link" id="header-nav-api-manager">
361314
{{ $t('header.api_manager') }}
362315
</a>
@@ -582,8 +535,7 @@ button.login-button-disabled {
582535
/* Custom dropdown containers */
583536
#header-nav-versions,
584537
#header-nav-message-docs,
585-
#header-nav-help,
586-
#header-nav-banks {
538+
#header-nav-help {
587539
display: inline-block;
588540
vertical-align: middle;
589541
}

src/components/Menu.vue

Lines changed: 66 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,63 @@
2828
<script setup lang="ts">
2929
import { ArrowDown } from '@element-plus/icons-vue'
3030
import { SEARCH_LINKS_COLOR as searchLinksColorSetting } from '../obp/style-setting'
31-
import { inject, ref } from 'vue'
32-
import { updateServerStatus, clearCacheByName } from '@/obp/common-functions';
33-
import { obpApiHostKey } from '@/obp/keys';
31+
import {
32+
HEADER_LINKS_HOVER_COLOR as headerLinksHoverColorSetting,
33+
HEADER_LINKS_BACKGROUND_COLOR as headerLinksBackgroundColorSetting
34+
} from '../obp/style-setting'
35+
import { inject, ref, computed, onMounted } from 'vue'
36+
import { getOBPBanks } from '../obp'
37+
import SvelteDropdown from './SvelteDropdown.vue'
3438
35-
const APP_VERSION = ref(__APP_VERSION__)
3639
const i18n = inject('i18n')
37-
const OBP_API_HOST = inject(obpApiHostKey)
3840
const searchLinksColor = ref(searchLinksColorSetting)
41+
const headerLinksHoverColor = ref(headerLinksHoverColorSetting)
42+
const headerLinksBackgroundColor = ref(headerLinksBackgroundColorSetting)
43+
44+
// Banks state
45+
const banks = ref<Array<{ bank_id: string; bank_code: string; full_name: string }>>([])
46+
const bankItems = computed(() =>
47+
[...banks.value]
48+
.sort((a, b) => (a.full_name || a.bank_id || '').localeCompare(b.full_name || b.bank_id || ''))
49+
.map(b => {
50+
const name = b.full_name || b.bank_id || ''
51+
const id = b.bank_id || ''
52+
return name !== id ? `${name} | ${id}` : id
53+
})
54+
)
55+
const selectedBankId = ref(localStorage.getItem('obp-selected-bank-id') || '')
56+
const banksDropdownLabel = computed(() => {
57+
if (selectedBankId.value) {
58+
const bank = banks.value.find(b => b.bank_id === selectedBankId.value)
59+
return bank ? (bank.full_name || bank.bank_id) : 'Banks'
60+
}
61+
return 'Banks'
62+
})
63+
64+
const handleBankSelect = (item: string) => {
65+
const parts = item.split(' | ')
66+
const bankId = parts[parts.length - 1]
67+
const bank = banks.value.find(b => b.bank_id === bankId)
68+
if (bank) {
69+
selectedBankId.value = bank.bank_id
70+
localStorage.setItem('obp-selected-bank-id', bank.bank_id)
71+
window.dispatchEvent(new CustomEvent('obp-bank-selected', { detail: bank.bank_id }))
72+
}
73+
}
74+
75+
onMounted(() => {
76+
getOBPBanks().then((data) => {
77+
if (data && data.banks && Array.isArray(data.banks)) {
78+
banks.value = data.banks
79+
}
80+
}).catch((error) => {
81+
console.error('Failed to fetch banks:', error)
82+
})
83+
})
84+
3985
const handleLocale = (command: string) => {
4086
i18n.global.locale.value = command
4187
}
42-
const updateStatus = (event: any) => {
43-
updateServerStatus()
44-
}
45-
const clearCacheStorage = (event: any) => {
46-
clearCacheByName('obp-message-docs-cache')
47-
clearCacheByName('obp-resource-docs-cache')
48-
}
4988
</script>
5089

5190
<template>
@@ -56,13 +95,15 @@ const clearCacheStorage = (event: any) => {
5695
<span id="selected-endpoint-tags" class="endpoint-tags"></span>
5796
</el-col>
5897
<el-col :span="14" class="menu-right">
59-
<span class="host" id="cache-storage-status" @click="clearCacheStorage">App Version: {{ APP_VERSION }}</span>
60-
&nbsp;&nbsp;
61-
<span class="host"><span id="backend-status" @click="updateStatus">API Host: </span>
62-
<a :href="OBP_API_HOST">
63-
{{ OBP_API_HOST }}
64-
</a>
65-
</span>
98+
<SvelteDropdown
99+
class="menu-right bank-selector"
100+
id="menu-nav-banks"
101+
:label="banksDropdownLabel"
102+
:items="bankItems"
103+
:hover-color="headerLinksHoverColor"
104+
:background-color="headerLinksBackgroundColor"
105+
@select="handleBankSelect"
106+
/>
66107
&nbsp;&nbsp;
67108
<el-dropdown class="menu-right" @command="handleLocale">
68109
<span class="el-dropdown-link">
@@ -134,4 +175,10 @@ a:hover {
134175
color: #66b1ff;
135176
text-decoration: underline;
136177
}
178+
179+
.bank-selector {
180+
display: inline-block;
181+
vertical-align: middle;
182+
margin-right: 10px;
183+
}
137184
</style>

src/components/MessageDocsJsonSchemaSearchNav.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ import { reactive, ref, onBeforeMount, inject, watch } from 'vue'
3030
import { Search } from '@element-plus/icons-vue'
3131
import { useRoute } from 'vue-router'
3232
import { SEARCH_LINKS_COLOR as searchLinksColorSetting } from '../obp/style-setting'
33-
import { connectors } from '../obp/message-docs'
3433
import { obpGroupedMessageDocsJsonSchemaKey } from '@/obp/keys'
3534
36-
let connector = connectors[0]
3735
const route = useRoute()
3836
const groupedMessageDocsJsonSchema = ref(inject(obpGroupedMessageDocsJsonSchemaKey) || {})
37+
const connectors = Object.keys(groupedMessageDocsJsonSchema.value)
38+
let connector = connectors[0]
3939
const docs = ref({})
4040
const groups = ref({})
4141
const sortedKeys = ref([])

src/components/MessageDocsSearchNav.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ import { reactive, ref, onBeforeMount, inject, watch } from 'vue'
3030
import { Search } from '@element-plus/icons-vue'
3131
import { useRoute } from 'vue-router'
3232
import { SEARCH_LINKS_COLOR as searchLinksColorSetting } from '../obp/style-setting'
33-
import { connectors } from '../obp/message-docs'
3433
import { obpGroupedMessageDocsKey } from '@/obp/keys'
3534
36-
let connector = connectors[0]
3735
const route = useRoute()
3836
const groupedMessageDocs = ref(inject(obpGroupedMessageDocsKey) || {})
37+
const connectors = Object.keys(groupedMessageDocs.value)
38+
let connector = connectors[0]
3939
const docs = ref({})
4040
const groups = ref({})
4141
const sortedKeys = ref([])

src/language/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"header": {
3-
"portal_home": "Portal Home",
3+
"portal_home": "Portal",
44
"api_explorer": "API Explorer",
55
"api_manager": "API Manager",
66
"glossary": "Glossary",

src/language/es.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"header": {
3-
"portal_home": "Portal de inicio",
3+
"portal_home": "Portal",
44
"api_explorer": "Explorador de API",
55
"api_manager": "Administrador de API",
66
"glossary": "Glosario",

src/language/ro.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"header": {
3-
"portal_home": "Portal Acasă",
3+
"portal_home": "Portal",
44
"api_explorer": "Explorator API",
55
"api_manager": "Administrator API",
66
"glossary": "Glosar",

src/obp/message-docs.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,34 @@
2828
import { OBP_API_VERSION, get, isServerUp } from '../obp'
2929
import { updateLoadingInfoMessage } from './common-functions'
3030

31-
export const connectors = [
31+
// Connectors to exclude from message docs display
32+
const excludedConnectors = ['mapped', 'star', 'proxy', 'internal', 'cardano', 'ethereum']
33+
34+
// Fallback list in case the API endpoint is unavailable
35+
const fallbackConnectors = [
3236
'akka_vDec2018',
3337
'rest_vMar2019',
3438
'stored_procedure_vDec2019',
3539
'rabbitmq_vOct2024'
3640
]
3741

42+
// Fetch available connectors dynamically from the API
43+
export async function getConnectors(): Promise<string[]> {
44+
try {
45+
const data = await get('obp/v6.0.0/system/connectors')
46+
if (data && data.connectors && Array.isArray(data.connectors)) {
47+
const connectorNames = data.connectors
48+
.map((c: any) => c.connector_name)
49+
.filter((name: string) => !excludedConnectors.some(exc => name === exc || name.startsWith(exc + '_')))
50+
console.log('Fetched connectors from API:', connectorNames)
51+
return connectorNames
52+
}
53+
} catch (error) {
54+
console.warn('Failed to fetch connectors from API, using fallback list:', error)
55+
}
56+
return fallbackConnectors
57+
}
58+
3859
// Get Message Docs
3960
export async function getOBPMessageDocs(item: string): Promise<any> {
4061
const logMessage = `Loading message docs { connector: ${item} }`
@@ -131,6 +152,7 @@ export function getGroupedMessageDocsJsonSchema(docs: any): any {
131152
}
132153

133154
export async function cacheDoc(cacheStorageOfMessageDocs: any): Promise<any> {
155+
const connectors = await getConnectors()
134156
const messageDocs = await connectors.reduce(async (agroup: any, connector: any) => {
135157
const logMessage = `Caching message docs { connector: ${connector} }`
136158
console.log(logMessage)
@@ -151,6 +173,7 @@ async function getCacheDoc(cacheStorageOfMessageDocs: any): Promise<any> {
151173
}
152174

153175
export async function cacheDocJsonSchema(cacheStorageOfMessageDocsJsonSchema: any): Promise<any> {
176+
const connectors = await getConnectors()
154177
const messageDocsJsonSchema = await connectors.reduce(async (agroup: any, connector: any) => {
155178
const logMessage = `Caching message docs JSON schema { connector: ${connector} }`
156179
console.log(logMessage)

src/router/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import { isServerUp, OBP_API_DEFAULT_RESOURCE_DOC_VERSION } from '../obp'
4444
import MessageDocsContent from '@/components/CodeBlock.vue'
4545
import ProvidersStatusView from '../views/ProvidersStatusView.vue'
4646
import OIDCDebugView from '../views/OIDCDebugView.vue'
47+
import AboutView from '../views/AboutView.vue'
4748

4849
export default async function router(): Promise<any> {
4950
const isServerActive = await isServerUp()
@@ -79,6 +80,11 @@ export default async function router(): Promise<any> {
7980
name: 'help',
8081
component: isServerActive ? HelpView : InternalServerErrorView
8182
},
83+
{
84+
path: '/about',
85+
name: 'about',
86+
component: AboutView
87+
},
8288
{
8389
path: '/message-docs',
8490
name: 'message-docs-list',

0 commit comments

Comments
 (0)