reprocess rework
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
|||||||
CharacterRuleBookApi,
|
CharacterRuleBookApi,
|
||||||
LedgerApi,
|
LedgerApi,
|
||||||
MarketApi,
|
MarketApi,
|
||||||
|
ReprocessingApi,
|
||||||
RuleBookApi,
|
RuleBookApi,
|
||||||
TransactionApi
|
TransactionApi
|
||||||
} from "@/generated/mammon";
|
} from "@/generated/mammon";
|
||||||
@@ -31,3 +32,4 @@ export const characterRuleBookApi = new CharacterRuleBookApi(undefined, mammonUr
|
|||||||
export const activityApi = new ActivityApi(undefined, mammonUrl, mammonAxiosInstance);
|
export const activityApi = new ActivityApi(undefined, mammonUrl, mammonAxiosInstance);
|
||||||
export const acquisitionApi = new AcquisitionApi(undefined, mammonUrl, mammonAxiosInstance);
|
export const acquisitionApi = new AcquisitionApi(undefined, mammonUrl, mammonAxiosInstance);
|
||||||
export const marketApi = new MarketApi(undefined, mammonUrl, mammonAxiosInstance);
|
export const marketApi = new MarketApi(undefined, mammonUrl, mammonAxiosInstance);
|
||||||
|
export const reprocessingApi = new ReprocessingApi(undefined, mammonUrl, mammonAxiosInstance);
|
||||||
|
|||||||
+16
-11
@@ -1,31 +1,36 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ReprocessInput, ReprocessItemValues, ReprocessResultTable, reprocess } from '@/reprocess';
|
import { useCharactersStore } from '@/characters';
|
||||||
|
import { ReprocessItemValues, ReprocessResultTable, reprocess } from '@/reprocess';
|
||||||
import { useStorage } from '@vueuse/core';
|
import { useStorage } from '@vueuse/core';
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
|
|
||||||
const items = ref("");
|
const charactersStore = useCharactersStore();
|
||||||
const materials = ref("");
|
|
||||||
const efficiency = useStorage('reprocess-efficiency', 0.55);
|
const characterId = useStorage<number | undefined>('reprocess-character', undefined);
|
||||||
|
const items = ref('');
|
||||||
|
|
||||||
const result = ref<ReprocessItemValues[]>([]);
|
const result = ref<ReprocessItemValues[]>([]);
|
||||||
|
|
||||||
const send = async () => result.value = await reprocess(items.value, materials.value, efficiency.value);
|
const send = async () => result.value = await reprocess(characterId.value, items.value);
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="grid mb-2 mt-4">
|
<div class="grid mb-2 mt-4">
|
||||||
<div class="justify-self-end">
|
<div class="justify-self-end">
|
||||||
<span>Reprocess efficiency: </span>
|
<span>Character: </span>
|
||||||
<input type="number" min="0" max="1" step="0.05" v-model="efficiency" />
|
<select v-model="characterId">
|
||||||
|
<option v-for="character in charactersStore.characters" :key="character.characterId" :value="character.characterId">{{ character.name }}</option>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-stretch">
|
<div class="flex items-stretch">
|
||||||
<ReprocessInput name="Item JSON" v-model="items" />
|
<div class="flex-1 mx-1">
|
||||||
<ReprocessInput name="Materials JSON" v-model="materials" />
|
<span>Items</span>
|
||||||
|
<textarea class="mt-1" v-model="items" placeholder="Paste an EVE inventory listing" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid my-2">
|
<div class="grid my-2">
|
||||||
<button class="justify-self-end" @click="send">Send</button>
|
<button class="justify-self-end" @click="send" :disabled="!characterId || !items.trim()">Send</button>
|
||||||
</div>
|
</div>
|
||||||
<template v-if="result.length > 0">
|
<template v-if="result.length > 0">
|
||||||
<hr />
|
<hr />
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import { evepraisalAxiosInstance } from '@/market/appraisal/evepraisal';
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
name: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
const modelValue = defineModel({ default: '' });
|
|
||||||
defineProps<Props>();
|
|
||||||
|
|
||||||
const loadFromId = async (e: Event) => {
|
|
||||||
const input = e.target as HTMLInputElement;
|
|
||||||
const id = input.value;
|
|
||||||
|
|
||||||
if (!id) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const response = await evepraisalAxiosInstance.get(`/a/${id}.json`);
|
|
||||||
|
|
||||||
if (response.status !== 200) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
modelValue.value = JSON.stringify(response.data);
|
|
||||||
input.value = '';
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div class="flex-1 mx-1">
|
|
||||||
<span>{{ name }}</span><input type="text" class="ms-2" @change="loadFromId" placeholder="id evepraisal" />
|
|
||||||
<textarea class="mt-1" v-model="modelValue" />
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
@@ -26,8 +26,8 @@ const { sortedArray, headerProps } = useSort(computed(() => props.result.map(r =
|
|||||||
|
|
||||||
return { ...r, market, materials, ratio };
|
return { ...r, market, materials, ratio };
|
||||||
})), {
|
})), {
|
||||||
defaultSortKey: 'name',
|
defaultSortKey: 'ratio',
|
||||||
defaultSortDirection: 'asc'
|
defaultSortDirection: 'desc'
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
export * from './reprocess';
|
export * from './reprocess';
|
||||||
|
|
||||||
export { default as ReprocessInput } from './ReprocessInput.vue';
|
|
||||||
export { default as ReprocessResultTable } from './ReprocessResultTable.vue';
|
export { default as ReprocessResultTable } from './ReprocessResultTable.vue';
|
||||||
|
|
||||||
|
|||||||
+16
-10
@@ -1,3 +1,6 @@
|
|||||||
|
import { reprocessingApi } from '@/mammon';
|
||||||
|
import { getMarketTypes } from '@/market';
|
||||||
|
|
||||||
export type ReprocessItemValues = {
|
export type ReprocessItemValues = {
|
||||||
typeID: number;
|
typeID: number;
|
||||||
name: string;
|
name: string;
|
||||||
@@ -7,18 +10,21 @@ export type ReprocessItemValues = {
|
|||||||
sell_reprocess: number;
|
sell_reprocess: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const reprocess = async (items: string, minerals: string, efficiency?: number): Promise<ReprocessItemValues[]> => {
|
export const reprocess = async (characterId?: number, items?: string, locationId?: number): Promise<ReprocessItemValues[]> => {
|
||||||
if (!items || !minerals || (efficiency && (efficiency < 0 || efficiency > 1))) {
|
if (!characterId || !items?.trim()) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const itemsJson = JSON.parse(items);
|
const results = await reprocessingApi.reprocessRawItems(characterId, items, locationId).then(r => r.data);
|
||||||
const mineralsJson = JSON.parse(minerals);
|
const names = await getMarketTypes(results.map(r => r.input.marketTypeId))
|
||||||
const sourceJson = {
|
.then(types => new Map(types.map(t => [t.id, t.name])));
|
||||||
"ep_items": itemsJson,
|
|
||||||
"ep_mat": mineralsJson
|
|
||||||
};
|
|
||||||
const source = JSON.stringify(sourceJson);
|
|
||||||
|
|
||||||
return []
|
return results.map(({ input, output }) => ({
|
||||||
|
typeID: input.marketTypeId,
|
||||||
|
name: names.get(input.marketTypeId) ?? '',
|
||||||
|
buy: input.buy,
|
||||||
|
sell: input.sell,
|
||||||
|
buy_reprocess: output.reduce((sum, o) => sum + o.buy, 0),
|
||||||
|
sell_reprocess: output.reduce((sum, o) => sum + o.sell, 0),
|
||||||
|
}));
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user