WIP: API-Explorer-II

This commit is contained in:
ma-silva 2023-03-29 23:22:33 +08:00
parent 36559867f6
commit 1f6c3dbe91
41 changed files with 10393 additions and 0 deletions

16
.eslintrc.cjs Normal file
View File

@ -0,0 +1,16 @@
/* eslint-env node */
require('@rushstack/eslint-patch/modern-module-resolution')
module.exports = {
root: true,
'extends': [
'plugin:vue/vue3-essential',
'eslint:recommended',
'@vue/eslint-config-typescript',
'@vue/eslint-config-prettier/skip-formatting'
],
parserOptions: {
ecmaVersion: 'latest'
},
rules: { 'vue/multi-word-component-names': 0 }
}

28
.gitignore vendored Normal file
View File

@ -0,0 +1,28 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
.DS_Store
dist
dist-ssr
coverage
*.local
/cypress/videos/
/cypress/screenshots/
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

8
.prettierrc.json Normal file
View File

@ -0,0 +1,8 @@
{
"$schema": "https://json.schemastore.org/prettierrc",
"semi": false,
"tabWidth": 2,
"singleQuote": true,
"printWidth": 100,
"trailingComma": "none"
}

3
.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"recommendations": ["Vue.volar", "Vue.vscode-typescript-vue-plugin"]
}

View File

@ -6,7 +6,39 @@ Welcome to the OBP API Explorer II
This application is used to explore OBP APIs and interact with the data and services in the context of the logged in user.
## Project Setup
```sh
npm install
```
### Compile and Hot-Reload for Development
```sh
npm run dev
```
### Type-Check, Compile and Minify for Production
```sh
npm run build
```
### Run Unit Tests with [Vitest](https://vitest.dev/)
```sh
npm run test:unit
```
### Lint with [ESLint](https://eslint.org/)
```sh
npm run lint
```
# LICENSE
This project is licensed under the AGPL V3 (see NOTICE) and a commercial license from TESOBE.

8
auto-imports.d.ts vendored Normal file
View File

@ -0,0 +1,8 @@
/* eslint-disable */
/* prettier-ignore */
// @ts-nocheck
// Generated by unplugin-auto-import
export {}
declare global {
}

56
components.d.ts vendored Normal file
View File

@ -0,0 +1,56 @@
/* eslint-disable */
/* prettier-ignore */
// @ts-nocheck
// Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399
import '@vue/runtime-core'
export {}
declare module '@vue/runtime-core' {
export interface GlobalComponents {
Body: typeof import('./src/components/Body.vue')['default']
Content: typeof import('./src/components/Content.vue')['default']
ElAside: typeof import('element-plus/es')['ElAside']
ElCol: typeof import('element-plus/es')['ElCol']
ElCollapse: typeof import('element-plus/es')['ElCollapse']
ElCollapseItem: typeof import('element-plus/es')['ElCollapseItem']
ElContainer: typeof import('element-plus/es')['ElContainer']
ElDatePicker: typeof import('element-plus/es')['ElDatePicker']
ElDropdown: typeof import('element-plus/es')['ElDropdown']
ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem']
ElDropdownMenu: typeof import('element-plus/es')['ElDropdownMenu']
ElFooter: typeof import('element-plus/es')['ElFooter']
ElForm: typeof import('element-plus/es')['ElForm']
ElHeader: typeof import('element-plus/es')['ElHeader']
ElIcon: typeof import('element-plus/es')['ElIcon']
ElInput: typeof import('element-plus/es')['ElInput']
ElLink: typeof import('element-plus/es')['ElLink']
ElMain: typeof import('element-plus/es')['ElMain']
ElMenu: typeof import('element-plus/es')['ElMenu']
ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
ElMenuItemGroup: typeof import('element-plus/es')['ElMenuItemGroup']
ElRow: typeof import('element-plus/es')['ElRow']
ElScrollbar: typeof import('element-plus/es')['ElScrollbar']
ElSubMenu: typeof import('element-plus/es')['ElSubMenu']
ElTable: typeof import('element-plus/es')['ElTable']
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
ElTabPane: typeof import('element-plus/es')['ElTabPane']
ElTabs: typeof import('element-plus/es')['ElTabs']
ElText: typeof import('element-plus/es')['ElText']
Header: typeof import('./src/components/Header.vue')['default']
HeaderNav: typeof import('./src/components/HeaderNav.vue')['default']
HelloWorld: typeof import('./src/components/HelloWorld.vue')['default']
IconCommunity: typeof import('./src/components/icons/IconCommunity.vue')['default']
IconDocumentation: typeof import('./src/components/icons/IconDocumentation.vue')['default']
IconEcosystem: typeof import('./src/components/icons/IconEcosystem.vue')['default']
IconSupport: typeof import('./src/components/icons/IconSupport.vue')['default']
IconTooling: typeof import('./src/components/icons/IconTooling.vue')['default']
Menu: typeof import('./src/components/Menu.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
SearchNav: typeof import('./src/components/SearchNav.vue')['default']
TheWelcome: typeof import('./src/components/TheWelcome.vue')['default']
WelcomeItem: typeof import('./src/components/WelcomeItem.vue')['default']
}
}

1
env.d.ts vendored Normal file
View File

@ -0,0 +1 @@
/// <reference types="vite/client" />

14
index.html Normal file
View File

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>API Explorer</title>
<link href='https://fonts.googleapis.com/css?family=Roboto' rel='stylesheet'>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>

6108
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

44
package.json Normal file
View File

@ -0,0 +1,44 @@
{
"name": "api-explorer",
"version": "0.0.0",
"private": true,
"scripts": {
"dev": "vite",
"build": "run-p type-check build-only",
"preview": "vite preview",
"test:unit": "vitest",
"build-only": "vite build",
"type-check": "vue-tsc --noEmit -p tsconfig.vitest.json --composite false",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
"format": "prettier --write src/"
},
"dependencies": {
"@element-plus/icons-vue": "^2.1.0",
"element-plus": "^2.3.0",
"pinia": "^2.0.32",
"vue": "^3.2.47",
"vue-router": "^4.1.6"
},
"devDependencies": {
"@rushstack/eslint-patch": "^1.2.0",
"@types/jsdom": "^21.1.0",
"@types/node": "^18.14.2",
"@vitejs/plugin-vue": "^4.0.0",
"@vitejs/plugin-vue-jsx": "^3.0.0",
"@vue/eslint-config-prettier": "^7.1.0",
"@vue/eslint-config-typescript": "^11.0.2",
"@vue/test-utils": "^2.3.0",
"@vue/tsconfig": "^0.1.3",
"eslint": "^8.34.0",
"eslint-plugin-vue": "^9.9.0",
"jsdom": "^21.1.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.8.4",
"typescript": "~4.8.4",
"unplugin-auto-import": "^0.15.1",
"unplugin-vue-components": "^0.24.1",
"vite": "^4.1.4",
"vitest": "^0.29.1",
"vue-tsc": "^1.2.0"
}
}

BIN
public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

19
src/App.vue Normal file
View File

@ -0,0 +1,19 @@
<script setup lang="ts">
import HeaderNav from './components/HeaderNav.vue'
import BodyView from './views/BodyView.vue'
</script>
<template>
<div class="common-layout" style="height: inherit">
<el-container style="height: 100%">
<el-header class="header">
<!--Header-->
<HeaderNav />
</el-header>
<BodyView />
<el-footer>Footer</el-footer>
</el-container>
</div>
</template>
<style scoped></style>

4
src/assets/base.css Normal file
View File

@ -0,0 +1,4 @@
body {
margin: 0;
padding: 0;
}

View File

@ -0,0 +1,20 @@
.el-collapse-item__header {
border-bottom: none !important;
}
.el-collapse-item__wrap {
border-bottom: none !important;
}
.el-main {
--el-main-padding: padding 0px !important;
}
.el-collapse-item__header {
background-color: transparent !important;
}
.el-collapse {
border-bottom: none !important;
--el-collapse-content-bg-color: transparent !important;
}

47
src/assets/header.css Normal file
View File

@ -0,0 +1,47 @@
nav {
text-align: right;
display: table-cell;
vertical-align: middle;
}
.logo {
display: table-cell;
vertical-align: middle;
transform: translateY(-50%);
top: 50%;
}
.header {
position: relative;
display: table;
}
.header::after {
content: '';
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 1px;
background-color: var(--el-border-color-light);
z-index: var(--el-index-normal);
}
.router-link {
padding: 9px;
color: #39455f;
font-family: 'Roboto';
font-size: 14px;
text-decoration: none;
border-radius: 8px;
}
.router-link:hover {
background-color: #eef0f4;
}
.logo {
height: 40px;
position: absolute;
cursor: pointer;
}

BIN
src/assets/logo2x-1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

29
src/assets/main.css Normal file
View File

@ -0,0 +1,29 @@
@import './base.css';
@import './header.css';
@import './search-nav.css';
@import './preview.css';
@import './element-plus-override.css';
#app {
height: 100vh;
}
.main {
height: 100%;
}
.menu {
height: 40px;
line-height: 40px;
display: table;
border-bottom: solid 1px var(--el-menu-border-color);
}
.menu-left {
vertical-align: middle;
}
.menu-right {
vertical-align: middle;
text-align: right;
}

4
src/assets/preview.css Normal file
View File

@ -0,0 +1,4 @@
.preview {
color: white;
background-color: #151d30;
}

View File

@ -0,0 +1,5 @@
.search-nav {
background-color: #f8f9fb;
padding: 10px;
border-right: solid 1px var(--el-menu-border-color);
}

7
src/components/Body.vue Normal file
View File

@ -0,0 +1,7 @@
<script setup lang="ts"></script>
<template>
<div>
<h1></h1>
</div>
</template>

View File

@ -0,0 +1,26 @@
<script setup lang="ts">
import { ArrowDown } from '@element-plus/icons-vue'
</script>
<template>
<img alt="OBP logo" class="logo" src="@/assets/logo2x-1.png" />
<nav>
<RouterLink class="router-link" to="/">Portal Home</RouterLink>
<RouterLink class="router-link" to="/api">API Explorer</RouterLink>
<RouterLink class="router-link" to="/">Glossary</RouterLink>
<RouterLink class="router-link" to="/">API Manager</RouterLink>
<span class="el-dropdown-link">
<RouterLink class="router-link" to="/">More</RouterLink>
<el-icon class="el-icon--right">
<arrow-down />
</el-icon>
</span>
<span class="el-dropdown-link">
<RouterLink class="router-link" to="/">Spaces</RouterLink>
<el-icon class="el-icon--right">
<arrow-down />
</el-icon>
</span>
<RouterLink class="router-link" to="/login">Login</RouterLink>
</nav>
</template>

8
src/components/Menu.vue Normal file
View File

@ -0,0 +1,8 @@
<script setup lang="ts"></script>
<template>
<el-row>
<el-col :span="12" class="menu-left">Menu left</el-col>
<el-col :span="12" class="menu-right">Menu right</el-col>
</el-row>
</template>

View File

@ -0,0 +1,34 @@
<script setup lang="ts">
import { reactive, ref } from 'vue'
import { Search } from '@element-plus/icons-vue'
//import { getResourceDocs } from "../obp/client"
const activeNames = ref(['2'])
const form = reactive({
search: ''
})
//const resourceDocs = (async ()=>{
// console.log(await getResourceDocs());
//})()
</script>
<template>
<el-form :model="form" label-width="120px">
<el-input v-model="form.search" class="w-50 m-1" placeholder="Search" :prefix-icon="Search" />
</el-form>
<el-collapse v-model="activeNames">
<el-collapse-item title="My Collections" name="1"> </el-collapse-item>
<el-collapse-item title="API" name="2">
<div class="el-tabs--right">
<div class="el-tabs__nav-wrap is-right">
<div v-for="i in 4" :key="i">
<RouterLink :to="{ name: 'api', params: { id: 'API Item ' + i } }">{{
'API Item ' + i
}}</RouterLink>
</div>
</div>
</div>
</el-collapse-item>
</el-collapse>
</template>

15
src/main.ts Normal file
View File

@ -0,0 +1,15 @@
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from './App.vue'
import router from './router'
import 'element-plus/dist/index.css'
import './assets/main.css'
const app = createApp(App)
app.use(createPinia())
app.use(router)
app.mount('#app')

View File

20
src/obp/client.ts Normal file
View File

@ -0,0 +1,20 @@
import { Version, API, get } from "obp-typescript/src/api/client";
import type { APIClientConfig, DirectLoginAuthentication } from "obp-typescript/src/api/client";
import { Any, GetAny } from "obp-typescript/src/api/any";
const directLogin: DirectLoginAuthentication = {
username: process.env.OBP_USERNAME,
password: process.env.OBP_PASSWORD,
consumerKey: process.env.OBP_CONSUMER_KEY,
};
const clientConfig: APIClientConfig = {
baseUri: "https://obp-apisandbox.joinfincubator.com",
version: Version.v510,
authentication: directLogin,
};
// Get Resource Docs
export async function getResourceDocs(): Promise<any> {
return await get<API.Any>(clientConfig, Any)(GetAny)("/resource-docs/v5.1.0/obp?tags=Account");
}

33
src/router/index.ts Normal file
View File

@ -0,0 +1,33 @@
import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
import LoginView from '../views/LoginView.vue'
import APIView from '../views/APIView.vue'
import PreviewView from '../views/PreviewView.vue'
import NotFoundView from '../views/NotFoundView.vue'
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
{
path: '/',
name: 'home',
component: HomeView
},
{
path: '/login',
name: 'login',
component: LoginView
},
{
path: '/api/:id',
name: 'api',
components: {
default: APIView,
preview: PreviewView
}
},
{ path: '/:pathMatch(.*)*', name: 'notFound', component: NotFoundView },
]
})
export default router

7
src/views/APIView.vue Normal file
View File

@ -0,0 +1,7 @@
<script setup lang="ts"></script>
<template>
<main>
{{ $route.params.id }}
</main>
</template>

31
src/views/BodyView.vue Normal file
View File

@ -0,0 +1,31 @@
<script setup lang="ts">
import SearchNav from '../components/SearchNav.vue'
import Menu from '../components/Menu.vue'
</script>
<template>
<el-container>
<el-aside class="search-nav" width="15%">
<!--Left-->
<SearchNav />
</el-aside>
<el-main>
<el-container class="main">
<el-header class="menu">
<Menu />
</el-header>
<el-container>
<el-aside width="50%">
Middle
<RouterView />
</el-aside>
<el-aside class="preview" width="50%">
<!--Right -->
Right
<RouterView class="" name="preview" />
</el-aside>
</el-container>
</el-container>
</el-main>
</el-container>
</template>

6
src/views/HomeView.vue Normal file
View File

@ -0,0 +1,6 @@
<script setup lang="ts">
</script>
<template>
<main>Home</main>
</template>

7
src/views/LoginView.vue Normal file
View File

@ -0,0 +1,7 @@
<template>
<div class="login">
<h1>This is a login page</h1>
</div>
</template>
<style></style>

View File

@ -0,0 +1,6 @@
<script setup lang="ts">
</script>
<template>
<main>Home</main>
</template>

View File

@ -0,0 +1,7 @@
<script setup lang="ts"></script>
<template>
<main>
{{ $route.params.id }}
</main>
</template>

12
tsconfig.app.json Normal file
View File

@ -0,0 +1,12 @@
{
"extends": "@vue/tsconfig/tsconfig.web.json",
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
"exclude": ["src/**/__tests__/*"],
"compilerOptions": {
"composite": true,
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
}
}

14
tsconfig.json Normal file
View File

@ -0,0 +1,14 @@
{
"files": [],
"references": [
{
"path": "./tsconfig.node.json"
},
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.vitest.json"
}
]
}

8
tsconfig.node.json Normal file
View File

@ -0,0 +1,8 @@
{
"extends": "@vue/tsconfig/tsconfig.node.json",
"include": ["vite.config.*", "vitest.config.*", "cypress.config.*", "playwright.config.*"],
"compilerOptions": {
"composite": true,
"types": ["node"]
}
}

9
tsconfig.vitest.json Normal file
View File

@ -0,0 +1,9 @@
{
"extends": "./tsconfig.app.json",
"exclude": [],
"compilerOptions": {
"composite": true,
"lib": [],
"types": ["node", "jsdom"]
}
}

30
vite.config.ts Normal file
View File

@ -0,0 +1,30 @@
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(), vueJsx(),
AutoImport({
resolvers: [ElementPlusResolver()],
}),
Components({
resolvers: [ElementPlusResolver()],
}),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
define: {
'process.env': process.env
}
})

15
vitest.config.ts Normal file
View File

@ -0,0 +1,15 @@
import { fileURLToPath } from 'node:url'
import { mergeConfig } from 'vite'
import { configDefaults, defineConfig } from 'vitest/config'
import viteConfig from './vite.config'
export default mergeConfig(
viteConfig,
defineConfig({
test: {
environment: 'jsdom',
exclude: [...configDefaults.exclude, 'e2e/*'],
root: fileURLToPath(new URL('./', import.meta.url))
}
})
)

3652
yarn.lock Normal file

File diff suppressed because it is too large Load Diff