lighter type info

This commit is contained in:
2024-05-19 16:22:02 +02:00
parent 3a3711b713
commit d82f6b6965
3 changed files with 33 additions and 19 deletions

View File

@@ -26,6 +26,7 @@ interface Props {
items?: AcquiredType[];
infoOnly?: boolean;
showAll?: boolean;
ignoredColums?: string[] | string;
}
interface Emits {
@@ -36,15 +37,25 @@ interface Emits {
const props = withDefaults(defineProps<Props>(), {
items: () => [],
infoOnly: false,
showAll: false
showAll: false,
ignoredColums: () => []
});
defineEmits<Emits>();
const columnsToIgnore = computed(() => {
const ic = typeof props.ignoredColums === 'string' ? [props.ignoredColums] : props.ignoredColums;
if (props.infoOnly && !ic.includes('buttons')) {
return [...ic, 'buttons'];
}
return ic;
});
const marketTaxStore = useMarketTaxStore();
const threshold = useStorage('market-acquisition-threshold', 10);
const filter = ref("");
const { sortedArray, headerProps } = useSort<Result>(computed(() => {
const { sortedArray, headerProps, showColumn } = useSort<Result>(computed(() => {
const filteredItems = props.items.filter(r => r.type.name.toLowerCase().includes(filter.value.toLowerCase()));
if (props.showAll) {
@@ -99,7 +110,8 @@ const { sortedArray, headerProps } = useSort<Result>(computed(() => {
return list;
}), {
defaultSortKey: 'precentProfit',
defaultSortDirection: 'desc'
defaultSortDirection: 'desc',
ignoredColums: columnsToIgnore
})
const getLineColor = (result: Result) => {
if (result.precentProfit >= (threshold.value / 100)) {
@@ -135,24 +147,24 @@ const getLineColor = (result: Result) => {
<SortableHeader v-bind="headerProps" sortKey="remaining">Remaining Amount</SortableHeader>
<SortableHeader v-bind="headerProps" sortKey="precentProfit">Profit (%)</SortableHeader>
<SortableHeader v-bind="headerProps" sortKey="iskProfit">Profit (ISK)</SortableHeader>
<th v-if="!infoOnly" />
<SortableHeader v-bind="headerProps" sortKey="buttons" unsortable />
</tr>
</thead>
<tbody>
<tr v-for="r in sortedArray" :key="r.id" :class="getLineColor(r)">
<td>
<td v-if="showColumn('name')">
<div class="flex">
<MarketTypeLabel :id="r.type.id" :name="r.name" />
<AcquisitionQuantilsTooltip :id="r.type.id" :buy="r.buy" :sell="r.sell" />
</div>
</td>
<td class="text-right">{{ formatIsk(r.buy) }}</td>
<td class="text-right">{{ formatIsk(r.sell) }}</td>
<td class="text-right">{{ formatIsk(r.price) }}</td>
<td class="text-right">{{ r.remaining }}/{{ r.quantity }}</td>
<td class="text-right">{{ percentFormater.format(r.precentProfit) }}</td>
<td class="text-right">{{ formatIsk(r.iskProfit) }}</td>
<td class="text-right" v-if="!infoOnly">
<td v-if="showColumn('buy')" class="text-right">{{ formatIsk(r.buy) }}</td>
<td v-if="showColumn('sell')" class="text-right">{{ formatIsk(r.sell) }}</td>
<td v-if="showColumn('price')" class="text-right">{{ formatIsk(r.price) }}</td>
<td v-if="showColumn('remaining')" class="text-right">{{ r.remaining }}/{{ r.quantity }}</td>
<td v-if="showColumn('precentProfit')" class="text-right">{{ percentFormater.format(r.precentProfit) }}</td>
<td v-if="showColumn('iskProfit')" class="text-right">{{ formatIsk(r.iskProfit) }}</td>
<td v-if="showColumn('buttons')" class="text-right">
<button class="btn-icon me-1" @click="$emit('buy', r.acquisitions, r.price, r.buy, r.sell)"><PlusIcon /></button>
<button class="btn-icon me-1" @click="$emit('sell', r.acquisitions)"><MinusIcon /></button>
</td>

View File

@@ -24,7 +24,7 @@ type Result = {
interface Props {
items?: TrackingResult[];
infoOnly?: boolean;
ignoredColums?: string[];
ignoredColums?: string[] | string;
}
interface Emits {
@@ -50,10 +50,12 @@ const threshold = useStorage('market-tracking-threshold', 10);
const filter = ref("");
const onlyCheap = ref(false);
const columnsToIgnore = computed(() => {
if (props.infoOnly && !props.ignoredColums.includes('buttons')) {
return [...props.ignoredColums, 'buttons'];
const ic = typeof props.ignoredColums === 'string' ? [props.ignoredColums] : props.ignoredColums;
if (props.infoOnly && !ic.includes('buttons')) {
return [...ic, 'buttons'];
}
return props.ignoredColums;
return ic;
});
const { sortedArray, headerProps, showColumn } = useSort<Result>(computed(() => props.items
.filter(r => r.type.name.toLowerCase().includes(filter.value.toLowerCase()))
@@ -125,7 +127,7 @@ const getLineColor = (result: Result) => {
<SortableHeader v-bind="headerProps" sortKey="q3">Q3</SortableHeader>
<SortableHeader v-bind="headerProps" sortKey="profit">Profit</SortableHeader>
<SortableHeader v-bind="headerProps" sortKey="score">Score</SortableHeader>
<SortableHeader v-bind="headerProps" sortKey="buttons" unsortable></SortableHeader>
<SortableHeader v-bind="headerProps" sortKey="buttons" unsortable />
</tr>
</thead>
<tbody>

View File

@@ -103,11 +103,11 @@ watch(useRoute(), async route => {
</div>
<div v-if="result" class="mb-4">
<span>Market Info:</span>
<TrackingResultTable :items="[result]" infoOnly />
<TrackingResultTable :items="[result]" infoOnly ignoredColums="name" />
</div>
<div v-if="acquisitions && acquisitions.length > 0">
<span>Acquisitions:</span>
<AcquisitionResultTable :items="acquisitions" infoOnly showAll />
<AcquisitionResultTable :items="acquisitions" infoOnly showAll :ignoredColums="['name', 'buy', 'sell']" />
</div>
</template>
<BuyModal ref="buyModal" />