From 4898b84e06c1bb21dd062ba020bc95bd5a7ad001 Mon Sep 17 00:00:00 2001 From: Alex Zaw Date: Thu, 14 Aug 2025 11:01:18 -0700 Subject: [PATCH] Initial commit --- .env | 6 + README.md | 5 + excelApp.zip | Bin 0 -> 12710 bytes index.html | 14 ++ package.json | 21 ++ src/App.vue | 182 ++++++++++++++++ src/components/DataTable.vue | 159 ++++++++++++++ src/components/FileUpload.vue | 168 ++++++++++++++ src/components/MetaData.vue | 398 ++++++++++++++++++++++++++++++++++ src/components/Navigation.vue | 82 +++++++ src/env.d.ts | 12 + src/main.js | 7 + src/services/ApiClient.ts | 63 ++++++ src/utils/sqlUtils.ts | 37 ++++ vite.config.js | 7 + 15 files changed, 1161 insertions(+) create mode 100644 .env create mode 100644 README.md create mode 100644 excelApp.zip create mode 100644 index.html create mode 100644 package.json create mode 100644 src/App.vue create mode 100644 src/components/DataTable.vue create mode 100644 src/components/FileUpload.vue create mode 100644 src/components/MetaData.vue create mode 100644 src/components/Navigation.vue create mode 100644 src/env.d.ts create mode 100644 src/main.js create mode 100644 src/services/ApiClient.ts create mode 100644 src/utils/sqlUtils.ts create mode 100644 vite.config.js diff --git a/.env b/.env new file mode 100644 index 0000000..f231c23 --- /dev/null +++ b/.env @@ -0,0 +1,6 @@ +VITE_APP_API_URL=https://mcl2000.minicircuits.com +VITE_APP_API_TOKEN=TGlua1Rlc3Q6NDI1YTVkNzYtMjIwMC00MzgwLWFlNDMtNmM0ODg5ZDliNDlj +VITE_APP_API_ENDPOINT_FETCH=/FetchAPI/FetchAPIServlet +VITE_APP_API_ENDPOINT_FILE_UTILS=/FileUtils/IFSUtilsServlet +VITE_APP_API_MAPICS_ENV=QQ +VITE_APP_API_ENV=DEV \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..1511959 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# Vue 3 + Vite + +This template should help get you started developing with Vue 3 in Vite. The template uses Vue 3 ` + + \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..881ef3d --- /dev/null +++ b/package.json @@ -0,0 +1,21 @@ +{ + "name": "my-data-table", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "vite build", + "preview": "vite preview" + }, + "dependencies": { + "@easytable/vue": "^0.0.6", + "naive-ui": "^2.41.0", + "vue": "^3.5.13", + "xlsx": "^0.18.5" + }, + "devDependencies": { + "@vitejs/plugin-vue": "^5.2.1", + "vite": "^6.2.0" + } +} diff --git a/src/App.vue b/src/App.vue new file mode 100644 index 0000000..f579114 --- /dev/null +++ b/src/App.vue @@ -0,0 +1,182 @@ + + + + + \ No newline at end of file diff --git a/src/components/DataTable.vue b/src/components/DataTable.vue new file mode 100644 index 0000000..17eaea6 --- /dev/null +++ b/src/components/DataTable.vue @@ -0,0 +1,159 @@ + + + + + diff --git a/src/components/FileUpload.vue b/src/components/FileUpload.vue new file mode 100644 index 0000000..8828379 --- /dev/null +++ b/src/components/FileUpload.vue @@ -0,0 +1,168 @@ + + + + + diff --git a/src/components/MetaData.vue b/src/components/MetaData.vue new file mode 100644 index 0000000..a4fe890 --- /dev/null +++ b/src/components/MetaData.vue @@ -0,0 +1,398 @@ + + + + + \ No newline at end of file diff --git a/src/components/Navigation.vue b/src/components/Navigation.vue new file mode 100644 index 0000000..70c576a --- /dev/null +++ b/src/components/Navigation.vue @@ -0,0 +1,82 @@ + + + + + \ No newline at end of file diff --git a/src/env.d.ts b/src/env.d.ts new file mode 100644 index 0000000..3105b83 --- /dev/null +++ b/src/env.d.ts @@ -0,0 +1,12 @@ +/// + +interface ImportMetaEnv { + readonly VITE_APP_API_URL: string + readonly VITE_APP_API_ENDPOINT_FETCH: string + readonly VITE_APP_API_ENDPOINT_FILE_UTILS: string + readonly VITE_APP_API_ENV: string +} + +interface ImportMeta { + readonly env: ImportMetaEnv +} \ No newline at end of file diff --git a/src/main.js b/src/main.js new file mode 100644 index 0000000..68ab63e --- /dev/null +++ b/src/main.js @@ -0,0 +1,7 @@ +import { createApp } from 'vue' +import App from './App.vue' +import naive from 'naive-ui' + +const app = createApp(App) +app.use(naive) +app.mount('#app') \ No newline at end of file diff --git a/src/services/ApiClient.ts b/src/services/ApiClient.ts new file mode 100644 index 0000000..00d51f6 --- /dev/null +++ b/src/services/ApiClient.ts @@ -0,0 +1,63 @@ +class ApiClient { + private static instance: ApiClient; + private baseUrl: string; + private apiEndpoints: { + FETCH: string; + FILE_UTILS: string; + }; + private isDev: boolean; + + private constructor() { + // Force to uppercase for comparison + this.isDev = import.meta.env.VITE_APP_API_ENV?.toUpperCase() === 'DEV'; + console.log('API Client Mode:', this.isDev ? 'Development' : 'Production'); + this.baseUrl = import.meta.env.VITE_APP_API_URL; + this.apiEndpoints = { + FETCH: import.meta.env.VITE_APP_API_ENDPOINT_FETCH, + FILE_UTILS: import.meta.env.VITE_APP_API_ENDPOINT_FILE_UTILS + }; + } + + public static getInstance(): ApiClient { + if (!ApiClient.instance) { + ApiClient.instance = new ApiClient(); + } + return ApiClient.instance; + } + + private async executeSQL(sql: string): Promise { + if (this.isDev) { + return {} as T; // Return empty success in dev mode + } + + const response = await fetch(`${this.baseUrl}${this.apiEndpoints.FETCH}`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ sql }) + }); + + const data = await response.json(); + if (data.error) { + throw new Error(data.error); + } + return data; + } + + public async getToken(): Promise { + if (this.isDev) { + return `DEV_TABLE_${Date.now().toString().slice(-6)}`; + } + const result = await this.executeSQL(`Values getMCLTken('RMZ')`); + return result[0]['00001']; + } + + public async createTable(sql: string): Promise { + if (!this.isDev) { + await this.executeSQL(sql); + } + } +} + +export const apiClient = ApiClient.getInstance(); \ No newline at end of file diff --git a/src/utils/sqlUtils.ts b/src/utils/sqlUtils.ts new file mode 100644 index 0000000..d0a4752 --- /dev/null +++ b/src/utils/sqlUtils.ts @@ -0,0 +1,37 @@ +export const generateSQLAttribute = (type: string, length: number, scale: number): string => { + switch (type) { + case 'Number': + return `Num(${length}, ${scale})`; + case 'Date': + return 'Date'; + default: + // For string type, if converting from number, account for decimal point and scale + const adjustedLength = scale > 0 ? length + scale + 1 : length; + return `Varchar(${adjustedLength})`; + } +}; + +export const generateSQLDefault = (type: string): string => { + switch (type) { + case 'Number': + return 'Not Null Default 0'; + case 'Date': + return `Not Null Default '1980-01-01'`; + default: + return `CCSID 37 Not Null Default ' '`; + } +}; + +export const sanitizeColumnName = (name: string): string => { + return name.replace(/[^a-zA-Z0-9_]/g, '_').toUpperCase(); +}; + +export const getExcelColumn = (index: number): string => { + let column = ''; + let num = index; + while (num >= 0) { + column = String.fromCharCode(65 + (num % 26)) + column; + num = Math.floor(num / 26) - 1; + } + return column; +}; \ No newline at end of file diff --git a/vite.config.js b/vite.config.js new file mode 100644 index 0000000..bbcf80c --- /dev/null +++ b/vite.config.js @@ -0,0 +1,7 @@ +import { defineConfig } from 'vite' +import vue from '@vitejs/plugin-vue' + +// https://vite.dev/config/ +export default defineConfig({ + plugins: [vue()], +})