get orders

This commit is contained in:
2023-09-16 13:02:24 +02:00
parent 3de8f53e0f
commit c1f00da176
5 changed files with 46 additions and 11 deletions

View File

@@ -1,4 +1,5 @@
<script setup lang="ts">
import { evepraisalAxiosInstance } from '@/service';
import { useStorage } from '@vueuse/core';
import { onMounted, ref, watch } from 'vue';
import { MarketOrderHistory, MarketResult, getHistory, jitaId } from ".";
@@ -15,8 +16,16 @@ const itemsStorage = useStorage<MarketItemStorage[]>('market-items', []);
const items = ref<MarketResult[]>([]);
const addOrRelaod = async (type: MarketType) => {
const typeID = type.id;
const history = await getHistory(jitaId, typeID);
const item = { type, history };
const [history, price] = await Promise.all([
getHistory(jitaId, typeID),
evepraisalAxiosInstance.post('/appraisal.json?market=jita&persist=no', type.name)
]);
const item = {
type,
history,
buy: price.data.appraisal.items[0].prices.buy.max,
sell: price.data.appraisal.items[0].prices.sell.min
};
if (items.value.some(i => i.type.id === typeID)) {
items.value = items.value.map(i => i.type.id === typeID ? item : i);
@@ -37,9 +46,20 @@ const addItem = async () => {
watch(items, itms => itemsStorage.value = itms.map(i => ({ typeID: i.type.id, history: i.history })));
onMounted(async () => {
const types = await getMarketTypes(itemsStorage.value.map(i => i.typeID));
const prices: any = (await evepraisalAxiosInstance.post(`/appraisal.json?market=jita&persist=no&raw_textarea=${types.map(t => t.name).join("%0A")}`)).data;
items.value = itemsStorage.value.map(i => ({ ...i, type: types.find(t => t.id === i.typeID) as MarketType }));
})
items.value = itemsStorage.value.map(i => {
const type = types.find(t => t.id === i.typeID) as MarketType;
const price = prices.appraisal.items.find((p: any) => p.typeID === i.typeID);
return {
...i,
type: type,
buy: price.prices.buy.max,
sell: price.prices.sell.min
};
});
});
</script>
<template>

View File

@@ -33,6 +33,8 @@ const { sortedArray, headerProps } = useSort(computed(() => props.items
type: r.type,
typeID: r.type.id,
name: r.type.name,
buy: r.buy,
sell: r.sell,
q1: quartils.q1,
mmedian: quartils.median,
q3: quartils.q3,
@@ -47,15 +49,15 @@ const { sortedArray, headerProps } = useSort(computed(() => props.items
<template>
<div class="flex">
<div class="flex justify-self-end mb-2 mt-4 ms-auto">
<div class="justify-self-end ms-2">
<div class="end">
<span>Days: </span>
<input type="number" min="1" max="365" step="1" v-model="days" />
</div>
<div class="justify-self-end ms-2">
<div class="end">
<span>Filter: </span>
<input type="text" class="w-96" v-model="filter" >
</div>
<div class="justify-self-end ms-2">
<div class="end">
<button class="flex" @click="$emit('relaodAll')"><ArrowPathIcon class="h-6 w-6 me-2" />Reload all</button>
</div>
</div>
@@ -64,6 +66,8 @@ const { sortedArray, headerProps } = useSort(computed(() => props.items
<thead>
<tr>
<SortableHeader v-bind="headerProps" sortKey="name">Item</SortableHeader>
<SortableHeader v-bind="headerProps" sortKey="buy">Buy</SortableHeader>
<SortableHeader v-bind="headerProps" sortKey="sell">Sell</SortableHeader>
<SortableHeader v-bind="headerProps" sortKey="q1">Q1</SortableHeader>
<SortableHeader v-bind="headerProps" sortKey="median">Median</SortableHeader>
<SortableHeader v-bind="headerProps" sortKey="q3">Q3</SortableHeader>
@@ -72,10 +76,12 @@ const { sortedArray, headerProps } = useSort(computed(() => props.items
</tr>
</thead>
<tbody>
<tr v-for="r in sortedArray" :key="r.typeID" class="cursor-pointer" @click="copyToClipboard(r.name)">
<tr v-for="r in sortedArray" :key="r.typeID" class="cursor-pointer" :class="{'bg-emerald-500': r.buy <= r.q1 }" @click="copyToClipboard(r.name)">
<td>
<MarketTypeLabel :id="r.typeID" :name="r.name" />
</td>
<td class="text-right">{{ formatIsk(r.buy) }}</td>
<td class="text-right">{{ formatIsk(r.sell) }}</td>
<td class="text-right">{{ formatIsk(r.q1) }}</td>
<td class="text-right">{{ formatIsk(r.mmedian) }}</td>
<td class="text-right">{{ formatIsk(r.q3) }}</td>
@@ -87,3 +93,9 @@ const { sortedArray, headerProps } = useSort(computed(() => props.items
</tbody>
</table>
</template>
<style scoped>
div.end {
@apply justify-self-end ms-2;
}
</style>

View File

@@ -15,6 +15,8 @@ export type MarketOrderHistory = {
export type MarketResult = {
type: MarketType;
history: MarketOrderHistory[];
buy: number,
sell: number
}
export type HistoryQuartils = {

View File

@@ -24,6 +24,7 @@ export const esiAxiosInstance = axios.create({
baseURL: esiUrl,
headers: {
'accept': 'application/json',
"Content-Type": "application/json"
"Content-Type": "application/json",
"User-Agent": "eveal (eveal.shendai.rip calloch.gael@gmail.com)"
},
})

View File

@@ -26,7 +26,7 @@ const emit = defineEmits<Emit>();
<style scoped>
th {
@apply relative h-8;
@apply relative h-8 pe-3;
}
span.asc, span.desc {
@apply absolute end-2 cursor-pointer text-xs;