update to mabras rework

This commit is contained in:
2023-10-29 18:28:05 +01:00
parent 2b59f8719a
commit 0ea65867a8
7 changed files with 69 additions and 16 deletions

View File

@@ -13,6 +13,7 @@ server {
proxy_ssl_server_name on; proxy_ssl_server_name on;
proxy_set_header Host "${API_URL}"; proxy_set_header Host "${API_URL}";
proxy_set_header X-Forwarded-Proto https; proxy_set_header X-Forwarded-Proto https;
sub_filter 'https://${API_URL}/' '/appi/';
} }
location /pocketbase/ { location /pocketbase/ {
proxy_pass https://${POCKET_BASE_URL}/; proxy_pass https://${POCKET_BASE_URL}/;

View File

@@ -4,7 +4,7 @@
"version": "0.0.0", "version": "0.0.0",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite --host",
"build": "vue-tsc && vite build", "build": "vue-tsc && vite build",
"preview": "vite preview" "preview": "vite preview"
}, },

View File

@@ -20,7 +20,7 @@ export const getMarketTypes = async (types: (string | number)[]): Promise<Market
} else if (types.length === 1 && typeof types[0] === "number") { } else if (types.length === 1 && typeof types[0] === "number") {
return [(await apiAxiosInstance.get<MarketType>(`/sde/types/${types[0]}/`)).data]; return [(await apiAxiosInstance.get<MarketType>(`/sde/types/${types[0]}/`)).data];
} }
return (await apiAxiosInstance.post<MarketType[]>("/sde/types/search", types.map(t => { return (await apiAxiosInstance.post<MarketType[]>("/api/types/search", types.map(t => {
if (typeof t === "number") { if (typeof t === "number") {
return { id: t }; return { id: t };
} else { } else {
@@ -49,9 +49,9 @@ const blueprintMarketGrous = [ // TODO add all groups
] ]
export const searchMarketTypes = async (search: string): Promise<MarketType[]> => { export const searchMarketTypes = async (search: string): Promise<MarketType[]> => {
return (await apiAxiosInstance.post<MarketType[]>("/sde/types/search", [{ return (await apiAxiosInstance.post<MarketType[]>("/api/types/search", [{
name__i: search, name__icontains: search,
marketgroup_id__not: null, marketgroup_id___not: null,
marketgroup_id__not__in: blueprintMarketGrous, marketgroup_id__in___not: blueprintMarketGrous,
}])).data; }])).data;
} }

View File

@@ -82,6 +82,7 @@ watchEffect(async () => {
suggestions.value = []; suggestions.value = [];
} else { } else {
suggestions.value = await searchMarketTypes(search); suggestions.value = await searchMarketTypes(search);
scrollTo(0);
} }
currentIndex.value = -1; currentIndex.value = -1;
}) })
@@ -94,7 +95,7 @@ watchEffect(async () => {
<input type="text" v-model="name" @keyup.enter="submit" @keyup.down="moveDown" @keyup.up="moveUp" /> <input type="text" v-model="name" @keyup.enter="submit" @keyup.down="moveDown" @keyup.up="moveUp" />
</div> </div>
<div v-if="suggestions.length > 1" class="z-10 absolute w-96"> <div v-if="suggestions.length > 1" class="z-10 absolute w-96">
<div v-bind="containerProps" style="height: 300px"> <div v-bind="containerProps" class="rounded-b" style="height: 300px">
<div v-bind="wrapperProps"> <div v-bind="wrapperProps">
<div v-for="s in list" :key="s.index" class="hover:bg-slate-700" :class="{'bg-slate-500': s.index !== currentIndex, 'bg-emerald-500': s.index === currentIndex}" @click="select(s.data)"> <div v-for="s in list" :key="s.index" class="hover:bg-slate-700" :class="{'bg-slate-500': s.index !== currentIndex, 'bg-emerald-500': s.index === currentIndex}" @click="select(s.data)">
<MarketTypeLabel :id="s.data.id" :name="s.data.name" class="whitespace-nowrap overflow-hidden cursor-pointer" hideCopy /> <MarketTypeLabel :id="s.data.id" :name="s.data.name" class="whitespace-nowrap overflow-hidden cursor-pointer" hideCopy />

View File

@@ -20,6 +20,20 @@ export const apiAxiosInstance = axios.create({
}, },
}) })
logResource(apiAxiosInstance) logResource(apiAxiosInstance)
apiAxiosInstance.interceptors.response.use(async r => {
const next = r.data?.next;
let results = r.data?.results;
if (next) {
results = results.concat((await apiAxiosInstance.request({
...r.config,
url: next,
baseURL: '',
})).data);
}
r.data = results;
return r;
})
export const evepraisalAxiosInstance = axios.create({ export const evepraisalAxiosInstance = axios.create({
baseURL: '/appraisal/', baseURL: '/appraisal/',

View File

@@ -49,7 +49,7 @@
@apply w-3; @apply w-3;
} }
::-webkit-scrollbar-track { ::-webkit-scrollbar-track {
@apply bg-slate-500; @apply bg-slate-500 rounded;
} }
::-webkit-scrollbar-thumb { ::-webkit-scrollbar-thumb {
@apply bg-slate-600 hover:bg-slate-700; @apply bg-slate-600 hover:bg-slate-700;

View File

@@ -1,6 +1,7 @@
import vue from '@vitejs/plugin-vue'; import vue from '@vitejs/plugin-vue';
import * as path from "path"; import * as path from "path";
import { defineConfig, loadEnv } from 'vite'; import { defineConfig, loadEnv } from 'vite';
import zlib from 'zlib';
export default defineConfig(({ mode }) => { export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), ''); const env = loadEnv(mode, process.cwd(), '');
@@ -17,30 +18,66 @@ export default defineConfig(({ mode }) => {
server: { server: {
port: 3000, port: 3000,
strictPort: true, strictPort: true,
watch: {
usePolling: true
},
proxy: { proxy: {
'/api/': { '/api/': {
target: `https://${env.API_URL}/`, target: env.API_URL,
changeOrigin: true, changeOrigin: true,
followRedirects: true, followRedirects: true,
rewrite: (path) => path.replace(/^\/api/, ''), rewrite: path => path.replace(/^\/api/, ''),
selfHandleResponse: true,
configure: proxy => {
proxy.on('proxyRes', (proxyRes, req, res) => {
const chunks = [];
proxyRes.on("data", (chunk) => chunks.push(chunk));
proxyRes.on("end", () => {
const buffer = Buffer.concat(chunks);
const encoding = proxyRes.headers["content-encoding"];
const relace = (b: Buffer) => {
let remoteBody = b.toString();
const modifiedBody = remoteBody.replace(env.API_URL, '/api/');
res.write(modifiedBody);
res.end();
}
if (!encoding) {
relace(buffer);
} else if (encoding === "gzip" || encoding === "deflate") {
zlib.unzip(buffer, (err, b) => {
if (!err) {
relace(b);
} else {
console.error(err);
}
});
} else {
console.error(`Unsupported encoding: ${encoding}`);
}
});
});
}
}, },
'/pocketbase/': { '/pocketbase/': {
target: `https://${env.POCKET_BASE_URL}/`, target: env.POCKET_BASE_URL,
changeOrigin: true, changeOrigin: true,
followRedirects: true, followRedirects: true,
rewrite: (path) => path.replace(/^\/pocketbase/, ''), rewrite: path => path.replace(/^\/pocketbase/, ''),
}, },
'/appraisal/': { '/appraisal/': {
target: `https://${env.EVEPRAISAL_URL}/`, target: env.EVEPRAISAL_URL,
changeOrigin: true, changeOrigin: true,
followRedirects: true, followRedirects: true,
rewrite: (path) => path.replace(/^\/appraisal/, ''), rewrite: path => path.replace(/^\/appraisal/, ''),
}, },
'/esi/': { '/esi/': {
target: `https://${env.ESI_URL}/latest/`, target: env.ESI_URL,
changeOrigin: true, changeOrigin: true,
followRedirects: true, followRedirects: true,
rewrite: (path) => path.replace(/^\/esi/, ''), rewrite: path => path.replace(/^\/esi/, ''),
headers: { headers: {
'User-Agent': env.ESI_USER_AGENT 'User-Agent': env.ESI_USER_AGENT
}, },