Skip to content

Commit

Permalink
Merge pull request #74 from constantine2nd/develop
Browse files Browse the repository at this point in the history
Remove automatic copying of text on from API Explorer
  • Loading branch information
simonredfern authored Dec 18, 2024
2 parents 9cc299a + 6b73282 commit 793f5a0
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 20 deletions.
2 changes: 1 addition & 1 deletion components.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* eslint-disable */
/* prettier-ignore */
// @ts-nocheck
// Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399
export {}

/* prettier-ignore */
declare module 'vue' {
export interface GlobalComponents {
ChatWidget: typeof import('./src/components/ChatWidget.vue')['default']
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "api-explorer",
"version": "1.0.26",
"version": "1.0.29",
"private": true,
"scripts": {
"dev": "vite & ts-node server/app.ts",
Expand Down
16 changes: 15 additions & 1 deletion server/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import express, { Application } from 'express'
import { useExpressServer, useContainer } from 'routing-controllers'
import { Container } from 'typedi'
import path from 'path'
import { execSync } from 'child_process';

const port = 8085
const app: Application = express()
Expand Down Expand Up @@ -108,7 +109,6 @@ useContainer(Container)
const routePrefix = '/api'

const server = useExpressServer(app, {
//routePrefix: '/api/v1',
routePrefix: routePrefix,
controllers: [path.join(__dirname + '/controllers/*.*s')],
middlewares: [path.join(__dirname + '/middlewares/*.*s')]
Expand All @@ -120,4 +120,18 @@ console.log(
`Backend is running. You can check a status at http://localhost:${port}${routePrefix}/status`
)

// Get commit ID
export const commitId = execSync('git rev-parse HEAD').toString().trim();
console.log('Current Commit ID:', commitId);

// Error Handling to Shut Down the App
server.on('error', (err) => {
if (err.code === 'EADDRINUSE') {
console.error(`Port ${port} is already in use.`);
process.exit(1); // Shut down the app
} else {
console.error('An error occurred:', err);
}
});

export default app
4 changes: 3 additions & 1 deletion server/controllers/StatusController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import OBPClientService from '../services/OBPClientService'
import OauthInjectedService from '../services/OauthInjectedService'
import { Service } from 'typedi'
import { OAuthConfig } from 'obp-typescript'
import { commitId } from '../app'

@Service()
@Controller('/status')
Expand Down Expand Up @@ -64,7 +65,8 @@ export class StatusController {
apiVersions,
messageDocs,
resourceDocs,
currentUser
currentUser,
commitId
})
}

Expand Down
8 changes: 5 additions & 3 deletions src/components/Preview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,9 @@ const copyToClipboard = () => {
<input type="text" v-show="exampleRequestBody" v-model="exampleRequestBody" />
</div>
<div v-show="successResponseBody">
<pre>
{{ responseHeaderTitle }}:
<pre><span>{{ responseHeaderTitle }}:</span>
<code>
<div @click="copyToClipboard" id="code" v-html="successResponseBody"></div>
<div id="code" v-html="successResponseBody"></div>
</code>
</pre>
</div>
Expand Down Expand Up @@ -370,6 +369,9 @@ pre {
font-family: 'Roboto';
font-weight: normal;
}
pre span {
all: unset; /* Reset all default styles */
}
input[type='text'] {
color: #ffffff;
font-size: 14px;
Expand Down
13 changes: 7 additions & 6 deletions src/obp/common-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,24 @@ export function updateLoadingInfoMessage(logMessage: string) {
}

export function updateServerStatus() {
const oElem = document.getElementById('backend-status')
const oElem = document.getElementById('backend-status');
serverStatus()
.then((body) => {
if (oElem) {
Object.values(body).every((i) => i === true)
body.status === true
? (oElem.className = 'server-is-online')
: (oElem.className = 'server-is-offline')
: (oElem.className = 'server-is-offline');
}
})
.catch((error) => {
console.log(error)
console.error(error);
if (oElem) {
oElem.className = 'server-is-offline'
oElem.className = 'server-is-offline';
}
})
});
}


export async function getCacheStorageInfo() {
const message = await navigator.storage.estimate().then((estimate) => {
const percent = ((estimate.usage / estimate.quota) * 100).toFixed(2)
Expand Down
7 changes: 4 additions & 3 deletions src/views/APIServerStatusView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ onBeforeMount(async () => {
<template>
<main>
<div class="content">
<div v-for="(value, name, index) in status">
<div v-for="(value, name, index) in status" :key="index" v-if="name !== 'commitId'">
<div v-if="name === 'status'" class="status">
<el-icon v-if="value === true" style="vertical-align: middle; color: green; width: auto"
><SuccessFilled
/></el-icon>
<el-icon v-else style="vertical-align: middle; color: red"><RemoveFilled /></el-icon>
<span class="main-status-label">{{ name }}</span>
</div>
<div v-else class="sub-status">
<div v-else-if="name !== 'commitId'" class="sub-status">
<span class="status-label">{{ name }}</span>
&nbsp;&nbsp;&nbsp;<el-divider />&nbsp;&nbsp;&nbsp;
<el-icon
Expand All @@ -60,7 +60,8 @@ onBeforeMount(async () => {
</div>
</div>
</main>
<span>Version: {{ version }}</span>
<span>App Version: {{ version }}</span>
<span>Commit ID: {{ status.commitId }}</span>
</template>

<style scoped>
Expand Down
6 changes: 2 additions & 4 deletions src/views/GlossaryView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,13 @@ a {
color: #39455f;
}
.content :deep(a) {
text-decoration: none;
color: #ffffff;
text-decoration: underline;
font-family: 'Roboto';
font-size: 14px;
border-radius: 3px;
background-color: #52b165;
padding: 1px;
}
.content :deep(a):hover {
background-color: #39455f;
background-color: #a4b2ce;
}
</style>

0 comments on commit 793f5a0

Please # to comment.