Merge pull request #40 from constantine2nd/develop

Remove Vuetify UI library; Add coments; Tweak variable names
This commit is contained in:
Simon Redfern 2024-02-22 13:54:23 +01:00 committed by GitHub
commit 8891573b46
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 58 additions and 100 deletions

1
components.d.ts vendored
View File

@ -9,7 +9,6 @@ export {}
declare module '@vue/runtime-core' {
export interface GlobalComponents {
Collections: typeof import('./src/components/Collections.vue')['default']
Content: typeof import('./src/components/Content.vue')['default']
ElAlert: typeof import('element-plus/es')['ElAlert']
ElAside: typeof import('element-plus/es')['ElAside']

View File

@ -1,6 +1,6 @@
{
"name": "api-explorer",
"version": "1.0.6",
"version": "1.0.8",
"private": true,
"scripts": {
"dev": "vite & ts-node server/app.ts",
@ -17,7 +17,6 @@
"@element-plus/icons-vue": "^2.1.0",
"@fontsource/roboto": "^4.5.8",
"@highlightjs/vue-plugin": "^2.1.0",
"@vueuse/core": "^10.7.2",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
"dotenv": "^16.0.3",
@ -33,11 +32,9 @@
"typedi": "^0.10.0",
"vue": "^3.2.47",
"vue-i18n": "^9.2.2",
"vue-router": "^4.1.6",
"vuetify": "^3.5.4"
"vue-router": "^4.1.6"
},
"devDependencies": {
"@mdi/font": "^7.4.47",
"@rushstack/eslint-patch": "^1.2.0",
"@types/jsdom": "^21.1.0",
"@types/node": "^18.14.2",

View File

@ -23,16 +23,14 @@ const updateStatus = (event: any) => {
<span id="selected-api-version" class="host">OBPv5.1.0</span>
</el-col>
<el-col :span="14" class="menu-right">
<span class="host"><v-chip>App Version: {{ version }}</v-chip></span>
<span class="host">App Version: {{ version }}</span>
&nbsp;&nbsp;
<v-chip>
<span class="host"
<span class="host"
><span id="backend-status" @click="updateStatus" >API Host: </span>
<a :href="host">
{{ host }}
</a>
</span>
</v-chip>
&nbsp;&nbsp;
<el-dropdown class="menu-right" @command="handleLocale">
<span class="el-dropdown-link">

View File

@ -17,20 +17,6 @@ import './assets/main.css'
import '@fontsource/roboto/300.css'
import '@fontsource/roboto/400.css'
import '@fontsource/roboto/700.css'
// Vuetify
import 'vuetify/styles'
import { createVuetify } from 'vuetify'
import * as components from 'vuetify/components'
import * as directives from 'vuetify/directives'
import '@mdi/font/css/materialdesignicons.css' // Ensure you are using css-loader
const vuetify = createVuetify({
components,
directives,
})
;(async () => {
const app = createApp(App)
const router = await appRouter()
@ -50,7 +36,7 @@ const vuetify = createVuetify({
app.use(i18n)
app.use(createPinia())
app.use(router)
app.use(vuetify)
app.mount('#app')
if (!isDataSetup) router.replace({ path: 'api-server-error' })
@ -66,30 +52,38 @@ const vuetify = createVuetify({
async function setupData(app: App<Element>, worker: Worker) {
try {
const resourceDocsCache = await caches.open('obp-resource-docs-cache')
const resourceDocsCacheResponse = await resourceDocsCache.match('/')
const messageDocsCache = await caches.open('obp-message-docs-cache')
const messageDocsCacheResponse = await messageDocsCache.match('/')
// 'open': Returns a Promise that resolves to the Cache object matching the cacheName(obp-resource-docs-cache) (a new cache is created if it doesn't already exist.)
const cacheStorageOfResourceDocs = await caches.open('obp-resource-docs-cache') // Please note: The global 'caches' read-only property returns the 'CacheStorage' object associated with the current context.
// 'match': Checks if a given Request is a key in any of the Cache objects that the CacheStorage object tracks, and returns a Promise that resolves to that match.
const cachedResponseOfResourceDocs = await cacheStorageOfResourceDocs.match('/')
// 'open': Returns a Promise that resolves to the Cache object matching the cacheName(obp-message-docs-cache) (a new cache is created if it doesn't already exist.)
const cacheStorageOfMessageDocs = await caches.open('obp-message-docs-cache') // Please note: The global 'caches' read-only property returns the 'CacheStorage' object associated with the current context.
// 'match': Checks if a given Request is a key in any of the Cache objects that the CacheStorage object tracks, and returns a Promise that resolves to that match.
const cachedResponseOfMessageDocs = await cacheStorageOfMessageDocs.match('/')
//Listen to Web worker
// Listen to Web worker
worker.onmessage = async (event) => {
//Update cache docs data in the background
// Update cache docs data in the background
if (event.data === 'update-resource-docs') {
await cacheResourceDocsDoc(resourceDocsCache)
await cacheResourceDocsDoc(cacheStorageOfResourceDocs)
console.log('Resource Docs cache was updated.')
}
if (event.data === 'update-message-docs') {
await cacheMessageDocsDoc(messageDocsCache)
await cacheMessageDocsDoc(cacheStorageOfMessageDocs)
console.log('Message Docs cache was updated.')
}
}
const { resourceDocs, groupedDocs } = await cacheResourceDocs(
resourceDocsCache,
resourceDocsCacheResponse,
cacheStorageOfResourceDocs,
cachedResponseOfResourceDocs,
worker
)
const messageDocs = await cacheMessageDocs(
cacheStorageOfMessageDocs,
cachedResponseOfMessageDocs,
worker
)
const messageDocs = await cacheMessageDocs(messageDocsCache, messageDocsCacheResponse, worker)
app.provide('OBP-ResourceDocs', resourceDocs)
app.provide('OBP-APIActiveVersions', Object.keys(resourceDocs).sort())

View File

@ -20,7 +20,9 @@ export function updateServerStatus() {
serverStatus()
.then((body) => {
if (oElem) {
Object.values(body).every(i => i === true) ? (oElem.className = 'server-is-online') : (oElem.className = 'server-is-offline')
Object.values(body).every((i) => i === true)
? (oElem.className = 'server-is-online')
: (oElem.className = 'server-is-offline')
}
})
.catch((error) => {
@ -29,4 +31,14 @@ export function updateServerStatus() {
oElem.className = 'server-is-offline'
}
})
updateCacheSizeStatus()
}
export function updateCacheSizeStatus() {
navigator.storage.estimate().then((estimate) => {
const percent = ((estimate.usage / estimate.quota) * 100).toFixed(2)
const quota = (estimate.quota / 1024 / 1024).toFixed(2) + 'MB'
const message = `You're currently using about ${percent}% of your estimated storage quota ${quota}`
console.log(message)
})
}

View File

@ -24,7 +24,7 @@ export function getGroupedMessageDocs(docs: any): Promise<any> {
}, {})
}
export async function cacheDoc(messageDocsCache: any): Promise<any> {
export async function cacheDoc(cacheStorageOfMessageDocs: any): Promise<any> {
const messageDocs = await connectors.reduce(async (agroup: any, connector: any) => {
const logMessage = `Caching message docs { connector: ${connector} }`
console.log(logMessage)
@ -36,27 +36,27 @@ export async function cacheDoc(messageDocsCache: any): Promise<any> {
}
return group
}, Promise.resolve({}))
await messageDocsCache.put('/', new Response(JSON.stringify(messageDocs)))
await cacheStorageOfMessageDocs.put('/', new Response(JSON.stringify(messageDocs)))
return messageDocs
}
async function getCacheDoc(messageDocsCache: any): Promise<any> {
return await cacheDoc(messageDocsCache)
async function getCacheDoc(cacheStorageOfMessageDocs: any): Promise<any> {
return await cacheDoc(cacheStorageOfMessageDocs)
}
export async function cache(
messageDocsCache: any,
messageDocsCacheResponse: any,
cacheStorage: any,
cachedResponse: any,
worker: any
): Promise<any> {
try {
worker.postMessage('update-message-docs')
return await messageDocsCacheResponse.json()
return await cachedResponse.json()
} catch (error) {
console.warn('No message docs cache or malformed cache.')
console.log('Caching message docs...')
const isServerActive = await isServerUp()
if (!isServerActive) throw new Error('API Server is not responding.')
return await getCacheDoc(messageDocsCache)
return await getCacheDoc(cacheStorage)
}
}

View File

@ -4,7 +4,7 @@ import { updateLoadingInfoMessage } from './common-functions'
// Get Resource Docs
export async function getOBPResourceDocs(version: string): Promise<any> {
const logMessage = `Loading API { standard: ${configVersion}, version: ${version} }`
const logMessage = `Loading API ${version}`
console.log(logMessage)
updateLoadingInfoMessage(logMessage)
return await get(`/obp/${configVersion}/resource-docs/${version}/obp`)
@ -24,7 +24,7 @@ export function getOperationDetails(version: string, operation_id: string, docs:
return docs[version].resource_docs.filter((doc: any) => doc.operation_id === operation_id)[0]
}
export async function cacheDoc(resourceDocsCache: any): Promise<any> {
export async function cacheDoc(cacheStorageOfResourceDocs: any): Promise<any> {
const apiVersions = await getOBPAPIVersions()
if (apiVersions) {
const scannedAPIVersions = apiVersions.scanned_api_versions
@ -40,35 +40,35 @@ export async function cacheDoc(resourceDocsCache: any): Promise<any> {
}
updateLoadingInfoMessage(logMessage)
}
await resourceDocsCache.put('/', new Response(JSON.stringify(resourceDocsMapping)))
await cacheStorageOfResourceDocs.put('/', new Response(JSON.stringify(resourceDocsMapping)))
return resourceDocsMapping
} else {
const resourceDocs = { ['OBP' + configVersion]: await getOBPResourceDocs(configVersion) }
await resourceDocsCache.put('/', new Response(JSON.stringify(resourceDocs)))
await cacheStorageOfResourceDocs.put('/', new Response(JSON.stringify(resourceDocs)))
return resourceDocs
}
}
async function getCacheDoc(resourceDocsCache: any): Promise<any> {
return await cacheDoc(resourceDocsCache)
async function getCacheDoc(cacheStorageOfResourceDocs: any): Promise<any> {
return await cacheDoc(cacheStorageOfResourceDocs)
}
export async function cache(
resourceDocsCache: any,
resourceDocsCacheResponse: any,
cachedStorage: any,
cachedResponse: any,
worker: any
): Promise<any> {
try {
worker.postMessage('update-resource-docs')
const resourceDocs = await resourceDocsCacheResponse.json()
const groupedDocs = getGroupedResourceDocs('OBP' + configVersion, resourceDocs)
return { resourceDocs, groupedDocs }
const resourceDocs = await cachedResponse.json()
const groupedResourceDocs = getGroupedResourceDocs('OBP' + configVersion, resourceDocs)
return { resourceDocs, groupedDocs: groupedResourceDocs }
} catch (error) {
console.warn('No resource docs cache or malformed cache.')
console.log('Caching resource docs...')
const isServerActive = await isServerUp()
if (!isServerActive) throw new Error('API Server is not responding.')
const resourceDocs = await getCacheDoc(resourceDocsCache)
const resourceDocs = await getCacheDoc(cachedStorage)
const groupedDocs = getGroupedResourceDocs('OBP' + configVersion, resourceDocs)
return { resourceDocs, groupedDocs }
}

View File

@ -621,11 +621,6 @@
methods "^1.1.2"
path-to-regexp "^6.2.1"
"@mdi/font@^7.4.47":
version "7.4.47"
resolved "https://registry.yarnpkg.com/@mdi/font/-/font-7.4.47.tgz#2ae522867da3a5c88b738d54b403eb91471903af"
integrity sha512-43MtGpd585SNzHZPcYowu/84Vz2a2g31TvPMTm9uTiCSWzaheQySUcSyUH/46fPnuPQWof2yd0pGBtzee/IQWw==
"@nodelib/fs.scandir@2.1.5":
version "2.1.5"
resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5"
@ -778,11 +773,6 @@
resolved "https://registry.yarnpkg.com/@types/web-bluetooth/-/web-bluetooth-0.0.16.tgz#1d12873a8e49567371f2a75fe3e7f7edca6662d8"
integrity sha512-oh8q2Zc32S6gd/j50GowEjKLoOVOwHP/bWVjKJInBwQqdOYMdPrf1oVlelTlyfFK3CKxL1uahMDAr+vy8T7yMQ==
"@types/web-bluetooth@^0.0.20":
version "0.0.20"
resolved "https://registry.yarnpkg.com/@types/web-bluetooth/-/web-bluetooth-0.0.20.tgz#f066abfcd1cbe66267cdbbf0de010d8a41b41597"
integrity sha512-g9gZnnXVq7gM7v3tJCWV/qw7w+KeOlSHAhgF9RytFyifW6AF61hdT2ucrYhPq9hLs5JIryeupHV3qGk95dH9ow==
"@typescript-eslint/eslint-plugin@^5.59.1":
version "5.59.8"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.59.8.tgz#1e7a3e5318ece22251dfbc5c9c6feeb4793cc509"
@ -1107,16 +1097,6 @@
resolved "https://registry.yarnpkg.com/@vue/tsconfig/-/tsconfig-0.1.3.tgz#4a61dbd29783d01ddab504276dcf0c2b6988654f"
integrity sha512-kQVsh8yyWPvHpb8gIc9l/HIDiiVUy1amynLNpCy8p+FoCiZXCo6fQos5/097MmnNZc9AtseDsCrfkhqCrJ8Olg==
"@vueuse/core@^10.7.2":
version "10.7.2"
resolved "https://registry.yarnpkg.com/@vueuse/core/-/core-10.7.2.tgz#78917803a29a0bca1803a6521fdf7ff873f6e72c"
integrity sha512-AOyAL2rK0By62Hm+iqQn6Rbu8bfmbgaIMXcE3TSr7BdQ42wnSFlwIdPjInO62onYsEMK/yDMU8C6oGfDAtZ2qQ==
dependencies:
"@types/web-bluetooth" "^0.0.20"
"@vueuse/metadata" "10.7.2"
"@vueuse/shared" "10.7.2"
vue-demi ">=0.14.6"
"@vueuse/core@^9.1.0":
version "9.13.0"
resolved "https://registry.yarnpkg.com/@vueuse/core/-/core-9.13.0.tgz#2f69e66d1905c1e4eebc249a01759cf88ea00cf4"
@ -1127,23 +1107,11 @@
"@vueuse/shared" "9.13.0"
vue-demi "*"
"@vueuse/metadata@10.7.2":
version "10.7.2"
resolved "https://registry.yarnpkg.com/@vueuse/metadata/-/metadata-10.7.2.tgz#ba0187ce138c287fd80301afc5b0d6a97e563633"
integrity sha512-kCWPb4J2KGrwLtn1eJwaJD742u1k5h6v/St5wFe8Quih90+k2a0JP8BS4Zp34XUuJqS2AxFYMb1wjUL8HfhWsQ==
"@vueuse/metadata@9.13.0":
version "9.13.0"
resolved "https://registry.yarnpkg.com/@vueuse/metadata/-/metadata-9.13.0.tgz#bc25a6cdad1b1a93c36ce30191124da6520539ff"
integrity sha512-gdU7TKNAUVlXXLbaF+ZCfte8BjRJQWPCa2J55+7/h+yDtzw3vOoGQDRXzI6pyKyo6bXFT5/QoPE4hAknExjRLQ==
"@vueuse/shared@10.7.2":
version "10.7.2"
resolved "https://registry.yarnpkg.com/@vueuse/shared/-/shared-10.7.2.tgz#746441fbc08072371dd600a55883422c83fd0cab"
integrity sha512-qFbXoxS44pi2FkgFjPvF4h7c9oMDutpyBdcJdMYIMg9XyXli2meFMuaKn+UMgsClo//Th6+beeCgqweT/79BVA==
dependencies:
vue-demi ">=0.14.6"
"@vueuse/shared@9.13.0":
version "9.13.0"
resolved "https://registry.yarnpkg.com/@vueuse/shared/-/shared-9.13.0.tgz#089ff4cc4e2e7a4015e57a8f32e4b39d096353b9"
@ -5182,12 +5150,7 @@ vm-browserify@^1.0.1:
resolved "https://registry.yarnpkg.com/vm-browserify/-/vm-browserify-1.1.2.tgz#78641c488b8e6ca91a75f511e7a3b32a86e5dda0"
integrity sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ==
vue-demi@*, vue-demi@>=0.14.6:
version "0.14.7"
resolved "https://registry.yarnpkg.com/vue-demi/-/vue-demi-0.14.7.tgz#8317536b3ef74c5b09f268f7782e70194567d8f2"
integrity sha512-EOG8KXDQNwkJILkx/gPcoL/7vH+hORoBaKgGe+6W7VFMvCYJfmF2dGbvgDroVnI8LU7/kTu8mbjRZGBU1z9NTA==
vue-demi@>=0.14.5:
vue-demi@*, vue-demi@>=0.14.5:
version "0.14.5"
resolved "https://registry.yarnpkg.com/vue-demi/-/vue-demi-0.14.5.tgz#676d0463d1a1266d5ab5cba932e043d8f5f2fbd9"
integrity sha512-o9NUVpl/YlsGJ7t+xuqJKx8EBGf1quRhCiT6D/J0pfwmk9zUwYkC7yrF4SZCe6fETvSM3UNL2edcbYrSyc4QHA==
@ -5250,11 +5213,6 @@ vue@^3.2.47:
"@vue/server-renderer" "3.3.4"
"@vue/shared" "3.3.4"
vuetify@^3.5.4:
version "3.5.4"
resolved "https://registry.yarnpkg.com/vuetify/-/vuetify-3.5.4.tgz#f919c5194995a123815c277a95812bc230e33464"
integrity sha512-fHgfWMI7+z/UtbVPOezX+O1MNBOOMBW9HnKejcBIyQQ7jFRnTHbDQmbINf25FK0wrg/zkjfzyOmWWREKW39eXg==
w3c-xmlserializer@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/w3c-xmlserializer/-/w3c-xmlserializer-4.0.0.tgz#aebdc84920d806222936e3cdce408e32488a3073"