33 Commits

Author SHA1 Message Date
Sirttas 42c7e59d63 balance endpoint 2026-06-01 17:39:14 +02:00
Sirttas 192cf7d9cb ledger view page structure 2026-06-01 16:24:35 +02:00
Sirttas 3235cf21ba transaction list display 2026-05-31 23:10:50 +02:00
Sirttas 47ee14319d transaction list api 2026-05-31 21:54:56 +02:00
Sirttas 457d2a5161 cleanup rules 2026-05-31 18:57:10 +02:00
Sirttas 1358aaa705 cleanup routes names 2026-05-31 18:33:35 +02:00
Sirttas d7bae268da character rule book front 2026-05-31 18:20:46 +02:00
Sirttas 9310397320 character rule book front 2026-05-31 18:19:45 +02:00
Sirttas ba81d7b6a8 rule book front 2026-05-31 17:00:49 +02:00
Sirttas 676ff961ed rename rule set to rule 2026-05-28 13:15:15 +02:00
Sirttas b40b58f866 rename rule to rule clause 2026-05-28 11:37:09 +02:00
Sirttas 9acbc101e1 post processing call from front 2026-05-26 22:32:43 +02:00
Sirttas ccc6b827f0 upate dependancies 2026-05-25 18:37:12 +02:00
Sirttas 0a2894b378 sortable 2026-05-25 18:36:18 +02:00
Sirttas 2d6930d38d from to at 2026-05-24 17:04:02 +02:00
Sirttas 11fbe847f2 pretyness 2026-05-24 17:00:34 +02:00
Sirttas 72933ada6e fix rules bugs 2026-05-24 16:22:39 +02:00
Sirttas e10d58d231 rule book ui 2026-05-24 14:28:12 +02:00
Sirttas 4b39d491d2 rule book ui 2026-05-24 13:39:35 +02:00
Sirttas a1dbe41b6c character rules 2026-05-23 23:47:06 +02:00
Sirttas e233e609e6 character endpoint 2026-05-23 23:19:45 +02:00
Sirttas d64b718573 character endpoint 2026-05-23 21:33:23 +02:00
Sirttas 153dff6bc7 rules endpoint 2026-05-23 16:03:48 +02:00
Sirttas 4fbced2c70 ledger balance 2026-05-23 14:29:25 +02:00
Sophie-Gaëlle CALLOCH 2970f48e65 rename combining ledger to combined 2026-05-22 14:53:33 +02:00
Sirttas e137bec8dd ledger uuid 2026-05-20 00:18:27 +02:00
Sirttas 3ca0cf23f1 edit ledger 2026-05-18 21:19:01 +02:00
Sirttas 02466eea14 ledger empty name 2026-05-17 21:26:23 +02:00
Sirttas f4b590bc3b rename leger label 2026-05-17 21:14:04 +02:00
Sirttas 65bb13aa3b ledger list clean + fix 2026-05-17 21:03:56 +02:00
Sirttas 2332ad2216 ledger list and modal 2026-05-17 19:53:55 +02:00
Sirttas 8005e7a45b ledger list and modal 2026-05-17 19:19:01 +02:00
Sirttas f9ae0d142a ledger gemory draft 2026-05-17 12:42:25 +02:00
72 changed files with 5870 additions and 2913 deletions
+2
View File
@@ -23,3 +23,5 @@ docker-compose.yml
*.njsproj
*.sln
*.sw?
generated/mammon/
+720
View File
@@ -0,0 +1,720 @@
openapi: 3.1.0
info:
title: OpenAPI definition
version: v0
servers:
- url: http://localhost:8080
description: Generated server url
paths:
/rule-books/{ruleBookId}:
get:
tags:
- rule-book
operationId: findRuleBookById
parameters:
- name: ruleBookId
in: path
required: true
schema:
type: string
format: uuid
responses:
"404":
description: Not Found
"400":
description: Bad Request
"200":
description: OK
content:
'*/*':
schema:
$ref: "#/components/schemas/RuleBookResponse"
put:
tags:
- rule-book
operationId: updateRuleBook
parameters:
- name: ruleBookId
in: path
required: true
schema:
type: string
format: uuid
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/UpdateRuleBookRequest"
required: true
responses:
"404":
description: Not Found
"400":
description: Bad Request
"200":
description: OK
content:
'*/*':
schema:
$ref: "#/components/schemas/RuleBookResponse"
/ledgers/main/{ledgerId}:
put:
tags:
- ledger
operationId: updateMainLedger
parameters:
- name: ledgerId
in: path
required: true
schema:
type: string
format: uuid
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/UpdateMainLedgerRequest"
required: true
responses:
"404":
description: Not Found
"400":
description: Bad Request
"200":
description: OK
content:
'*/*':
schema:
$ref: "#/components/schemas/MainLedgerResponse"
/ledgers/combined/{ledgerId}:
put:
tags:
- ledger
operationId: updateCombinedLedger
parameters:
- name: ledgerId
in: path
required: true
schema:
type: string
format: uuid
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/UpdateCombinedLedgerRequest"
required: true
responses:
"404":
description: Not Found
"400":
description: Bad Request
"200":
description: OK
content:
'*/*':
schema:
$ref: "#/components/schemas/CombinedLedgerResponse"
/characters/{characterId}/rule-book:
get:
tags:
- character-rule-book
operationId: findCharacterRuleBookByCharacterId
parameters:
- name: characterId
in: path
required: true
schema:
type: integer
format: int64
responses:
"404":
description: Not Found
"400":
description: Bad Request
"200":
description: OK
content:
'*/*':
schema:
$ref: "#/components/schemas/CharacterRuleBookResponse"
put:
tags:
- character-rule-book
operationId: setCharacterRuleBookForCharacter
parameters:
- name: characterId
in: path
required: true
schema:
type: integer
format: int64
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/SetCharacterRuleBookRequest"
required: true
responses:
"404":
description: Not Found
"400":
description: Bad Request
"200":
description: OK
content:
'*/*':
schema:
$ref: "#/components/schemas/CharacterRuleBookResponse"
/rule-books:
get:
tags:
- rule-book
operationId: findAllRuleBooks
responses:
"404":
description: Not Found
"400":
description: Bad Request
"200":
description: OK
content:
'*/*':
schema:
type: array
items:
$ref: "#/components/schemas/RuleBookResponse"
post:
tags:
- rule-book
operationId: createRuleBook
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/CreateRuleBookRequest"
required: true
responses:
"404":
description: Not Found
"400":
description: Bad Request
"200":
description: OK
content:
'*/*':
schema:
$ref: "#/components/schemas/RuleBookResponse"
/process-activities:
post:
tags:
- processing
operationId: processNewActivities
responses:
"404":
description: Not Found
"400":
description: Bad Request
"200":
description: OK
/ledgers/main:
post:
tags:
- ledger
operationId: createMainLedger
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/CreateMainLedgerRequest"
required: true
responses:
"404":
description: Not Found
"400":
description: Bad Request
"200":
description: OK
content:
'*/*':
schema:
$ref: "#/components/schemas/MainLedgerResponse"
/ledgers/combined:
post:
tags:
- ledger
operationId: createCombinedLedger
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/CreateCombinedLedgerRequest"
required: true
responses:
"404":
description: Not Found
"400":
description: Bad Request
"200":
description: OK
content:
'*/*':
schema:
$ref: "#/components/schemas/CombinedLedgerResponse"
/activity/fetch/{characterId}:
post:
tags:
- activity
operationId: fetchNewActivitiesForCharacter
parameters:
- name: characterId
in: path
required: true
schema:
type: integer
format: int64
responses:
"404":
description: Not Found
"400":
description: Bad Request
"200":
description: OK
/ledgers:
get:
tags:
- ledger
operationId: findAllLedgers
responses:
"404":
description: Not Found
"400":
description: Bad Request
"200":
description: OK
content:
'*/*':
schema:
type: array
items:
oneOf:
- $ref: "#/components/schemas/CombinedLedgerResponse"
- $ref: "#/components/schemas/MainLedgerResponse"
/ledgers/{ledgerId}:
get:
tags:
- ledger
operationId: findLedgerById
parameters:
- name: ledgerId
in: path
required: true
schema:
type: string
format: uuid
responses:
"404":
description: Not Found
"400":
description: Bad Request
"200":
description: OK
content:
'*/*':
schema:
oneOf:
- $ref: "#/components/schemas/CombinedLedgerResponse"
- $ref: "#/components/schemas/MainLedgerResponse"
/ledgers/{ledgerId}/transactions:
get:
tags:
- transaction
operationId: finAllTransactionsInLedger
parameters:
- name: ledgerId
in: path
required: true
schema:
type: string
format: uuid
responses:
"404":
description: Not Found
"400":
description: Bad Request
"200":
description: OK
content:
'*/*':
schema:
type: array
items:
$ref: "#/components/schemas/TransactionResponse"
/ledgers/{ledgerId}/balance:
get:
tags:
- ledger
operationId: findBalanceByLedgerId
parameters:
- name: ledgerId
in: path
required: true
schema:
type: string
format: uuid
responses:
"404":
description: Not Found
"400":
description: Bad Request
"200":
description: OK
content:
'*/*':
schema:
$ref: "#/components/schemas/BalanceResponse"
/characters:
get:
tags:
- character
operationId: findAllCharacters
responses:
"404":
description: Not Found
"400":
description: Bad Request
"200":
description: OK
content:
'*/*':
schema:
type: array
items:
$ref: "#/components/schemas/CharacterResponse"
components:
schemas:
RuleClauseResponse:
type: object
properties:
rate:
type: string
enum:
- NONE
- VALUE
- JITA_BUY
- JITA_SELL
- EVE_ESTIMATE
fromLedgerRef:
type: string
toLedgerRef:
type: string
required:
- fromLedgerRef
- rate
- toLedgerRef
RuleResponse:
type: object
properties:
clauses:
type: array
items:
$ref: "#/components/schemas/RuleClauseResponse"
required:
- clauses
UpdateRuleBookRequest:
type: object
properties:
name:
type: string
ledgerRefs:
type: array
items:
type: string
rules:
type: object
additionalProperties:
$ref: "#/components/schemas/RuleResponse"
required:
- ledgerRefs
- name
- rules
RuleBookResponse:
type: object
properties:
ruleBookId:
type: string
format: uuid
name:
type: string
ledgerRefs:
type: array
items:
type: string
rules:
type: object
additionalProperties:
$ref: "#/components/schemas/RuleResponse"
required:
- ledgerRefs
- name
- ruleBookId
- rules
UpdateMainLedgerRequest:
type: object
properties:
name:
type: string
required:
- name
MainLedgerResponse:
allOf:
- $ref: "#/components/schemas/LedgerResponse"
- type: object
properties:
ledgerId:
type: string
format: uuid
name:
type: string
balance:
type: number
type:
type: string
enum:
- MAIN
required:
- balance
- ledgerId
- name
UpdateCombinedLedgerRequest:
type: object
properties:
name:
type: string
memberLedgerIds:
type: array
items:
type: string
format: uuid
required:
- memberLedgerIds
- name
CombinedLedgerResponse:
allOf:
- $ref: "#/components/schemas/LedgerResponse"
- type: object
properties:
ledgerId:
type: string
format: uuid
name:
type: string
balance:
type: number
memberLedgerIds:
type: array
items:
type: string
format: uuid
type:
type: string
enum:
- COMBINED
required:
- balance
- ledgerId
- memberLedgerIds
- name
SetCharacterRuleBookRequest:
type: object
properties:
ruleBookId:
type: string
format: uuid
bindings:
type: object
additionalProperties:
type: string
format: uuid
required:
- bindings
- ruleBookId
CharacterRuleBookResponse:
type: object
properties:
characterId:
type: integer
format: int64
ruleBookId:
type: string
format: uuid
bindings:
type: object
additionalProperties:
type: string
format: uuid
required:
- bindings
- characterId
- ruleBookId
CreateRuleBookRequest:
type: object
properties:
name:
type: string
ledgerRefs:
type: array
items:
type: string
rules:
type: object
additionalProperties:
$ref: "#/components/schemas/RuleResponse"
required:
- ledgerRefs
- name
- rules
CreateMainLedgerRequest:
type: object
properties:
name:
type: string
required:
- name
CreateCombinedLedgerRequest:
type: object
properties:
name:
type: string
memberLedgerIds:
type: array
items:
type: string
format: uuid
required:
- memberLedgerIds
- name
LedgerResponse:
type: object
discriminator:
propertyName: type
properties:
type:
type: string
enum:
- MAIN
- COMBINED
IskTransferResponse:
allOf:
- $ref: "#/components/schemas/TransferResponse"
- type: object
properties:
fromLedgerId:
type: string
format: uuid
toLedgerId:
type: string
format: uuid
amount:
type: number
type:
type: string
enum:
- ISK
required:
- amount
- fromLedgerId
- toLedgerId
ItemTransferResponse:
allOf:
- $ref: "#/components/schemas/TransferResponse"
- type: object
properties:
fromLedgerId:
type: string
format: uuid
toLedgerId:
type: string
format: uuid
marketTypeId:
type: integer
format: int64
quantity:
type: integer
format: int64
type:
type: string
enum:
- ITEM
required:
- fromLedgerId
- marketTypeId
- quantity
- toLedgerId
TransactionResponse:
type: object
properties:
transactionId:
type: string
format: uuid
datetime:
type: string
format: date-time
description:
type: string
transfers:
type: array
items:
oneOf:
- $ref: "#/components/schemas/IskTransferResponse"
- $ref: "#/components/schemas/ItemTransferResponse"
required:
- datetime
- description
- transactionId
- transfers
TransferResponse:
type: object
discriminator:
propertyName: type
properties:
type:
type: string
enum:
- ISK
- ITEM
BalanceResponse:
type: object
properties:
iskBalance:
type: number
itemBalances:
type: array
items:
$ref: "#/components/schemas/ItemBalanceResponse"
required:
- iskBalance
- itemBalances
ItemBalanceResponse:
type: object
properties:
typeId:
type: integer
format: int64
quantity:
type: integer
format: int64
required:
- quantity
- typeId
CharacterResponse:
type: object
properties:
characterId:
type: integer
format: int64
name:
type: string
required:
- characterId
- name
+1927 -2515
View File
File diff suppressed because it is too large Load Diff
+16 -16
View File
@@ -11,29 +11,29 @@
},
"dependencies": {
"@heroicons/vue": "^2.0.18",
"@vueuse/components": "^10.5.0",
"@vueuse/core": "^10.2.1",
"@vueuse/integrations": "^10.2.1",
"@vueuse/components": "^14.3.0",
"@vueuse/core": "^14.3.0",
"@vueuse/integrations": "^14.3.0",
"@vueuse/router": "^14.3.0",
"axios": "^1.4.0",
"axios-rate-limit": "^1.3.1",
"gemory": "file:",
"loglevel": "^1.8.1",
"loglevel-plugin-prefix": "^0.8.4",
"oidc-client-ts": "^3.0.1",
"pinia": "^2.1.6",
"pinia": "^3.0.4",
"sortablejs": "^1.15.7",
"vue": "^3.3.4",
"vue-router": "^4.2.4"
"vue-router": "^5.0.7"
},
"devDependencies": {
"@types/node": "^20.4.5",
"@vitejs/plugin-vue": "^5.0.4",
"autoprefixer": "^10.4.14",
"postcss": "^8.4.27",
"tailwindcss": "^3.3.3",
"typescript": "^5.0.2",
"vite": "^6.3.5",
"vite-plugin-runtime-env": "^0.1.1",
"vitest": "^3.1.3",
"vue-tsc": "^2.0.18"
"@tailwindcss/vite": "^4.3.0",
"@types/node": "^25.8.0",
"@vitejs/plugin-vue": "^6.0.7",
"tailwindcss": "^4.3.0",
"typescript": "^6.0.3",
"vite": "^8.0.13",
"vite-plugin-runtime-env": "^1.0.0",
"vitest": "^4.1.6",
"vue-tsc": "^3.2.9"
}
}
-8
View File
@@ -1,8 +0,0 @@
export default {
plugins: {
'postcss-import': {},
'tailwindcss/nesting': {},
tailwindcss: {},
autoprefixer: {},
},
}
+5 -4
View File
@@ -1,14 +1,13 @@
<script setup lang="ts">
import { useAuthStore } from '@/auth';
import { computed } from 'vue';
import { RouterView, useRoute } from 'vue-router';
import { Sidebar } from './sidebar';
import { routeNames } from '@/routes';
const route = useRoute();
const authStore = useAuthStore();
const hideSidebar = computed(() => {
return !authStore.isLoggedIn || route.name === 'callback' || route.name === 'about';
return route.name === routeNames.callback || route.name === routeNames.about;
});
</script>
@@ -24,7 +23,9 @@ const hideSidebar = computed(() => {
</template>
</template>
<style scoped lang="postcss">
<style scoped>
@reference "tailwindcss";
div.main-container {
@apply px-4 sm:ml-64;
}
-49
View File
@@ -1,49 +0,0 @@
import log from "loglevel";
import { Log, User, UserManager, WebStorageStateStore } from "oidc-client-ts";
import { defineStore } from "pinia";
import { computed, ref } from "vue";
Log.setLogger(log);
export const useAuthStore = defineStore('auth', () => {
const userManager = new UserManager({
authority: import.meta.env.VITE_AUTH_AUTHORITY,
client_id: import.meta.env.VITE_AUTH_CLIENT_ID,
client_secret: import.meta.env.VITE_AUTH_CLIENT_SECRET,
redirect_uri: import.meta.env.VITE_AUTH_REDIRECT_URI,
scope: import.meta.env.VITE_AUTH_SCOPE,
stateStore: new WebStorageStateStore({ store: window.localStorage }),
userStore: new WebStorageStateStore({ store: window.localStorage })
});
const user = ref<User>();
const isLoggedIn = computed(() => user.value?.expired === false);
const accessToken = computed(() => user.value?.access_token);
const username = computed(() => user.value?.profile.name ?? "");
const userId = computed(() => user.value?.profile.sub ?? "");
const redirect = async () => {
await userManager.signinRedirect();
log.info("Redirecting to login page");
}
const login = async () => {
await userManager.signinCallback();
log.debug("Logged in");
}
const logout = async () => {
await userManager.signoutRedirect();
log.debug("Logged out");
}
const setUser = (u?: User | null) => {
if (u) {
user.value = u;
log.debug("User loaded", u.profile.name);
} else {
user.value = undefined;
}
}
userManager.events.addUserLoaded(setUser);
userManager.getUser().then(setUser);
return { redirect, login, logout, isLoggedIn, accessToken, username, userId };
});
+20
View File
@@ -0,0 +1,20 @@
<script setup lang="ts">
import {Character} from "./chartacters.ts";
interface Props {
character: Character;
size?: number;
}
const props = withDefaults(defineProps<Props>(), {
size: 32
})
</script>
<template>
<div class="flex">
<img class="me-2" :src="`https://images.evetech.net/characters/${character.characterId}/portrait?size=${size}`" />
<span>{{ character.name }}</span>
</div>
</template>
+28
View File
@@ -0,0 +1,28 @@
import {activityApi, characterApi} from "@/mammon";
import {defineStore} from "pinia";
import {ref} from "vue";
import {CharacterResponse} from "@/generated/mammon";
export type Character = CharacterResponse
export const useCharactersStore = defineStore('characters', () => {
const characters = ref<Character[]>([]);
const findById = async (characterId: number): Promise<Character | undefined> => {
let character = characters.value.find(c => c.characterId === characterId);
if (!character) {
await refresh(); // TODO call api instead of refresh
character = characters.value.find(c => c.characterId === characterId);
}
return character;
}
const reloadActivities = (characterId: number): Promise<void> => activityApi.fetchNewActivitiesForCharacter(characterId) as Promise<void>;
const refresh = () => characterApi.findAllCharacters().then(response => characters.value = response.data);
refresh();
return {characters, findById, reloadActivities, refresh};
})
+3
View File
@@ -0,0 +1,3 @@
export * from './chartacters.ts'
export {default as CharacterLabel} from './CharacterLabel.vue';
+41 -31
View File
@@ -1,30 +1,57 @@
<script setup lang="ts">
import { ChevronDownIcon, ChevronUpIcon } from '@heroicons/vue/24/outline';
import { vOnClickOutside } from '@vueuse/components';
import { useEventListener } from '@vueuse/core';
import { ref } from 'vue';
import {ChevronDownIcon, ChevronUpIcon} from '@heroicons/vue/24/outline';
import {vOnClickOutside} from '@vueuse/components';
import {useEventListener} from '@vueuse/core';
import {ref} from 'vue';
interface Props {
inline?: boolean;
autoClose?: boolean;
}
const props = withDefaults(defineProps<Props>(), {
inline: false,
autoClose: true
})
const isOpen = ref(false);
const doAutoClose = () => {
if (props.autoClose) {
isOpen.value = false;
}
}
useEventListener('keyup', e => {
if (e.key === 'Escape') {
isOpen.value = false;
doAutoClose();
}
});
</script>
<template>
<div class="dropdown" :class="{'dropdown-open': isOpen, 'dropdown-close': !isOpen}" v-on-click-outside="() => isOpen = false">
<div class="dropdown" :class="{'dropdown-open': isOpen, 'dropdown-close': !isOpen}" v-on-click-outside="doAutoClose">
<button @click="isOpen = !isOpen">
<slot name="button" />
<Transition name="flip">
<Transition
enter-active-class="transition-transform"
enter-from-class="rotate-180"
leave-active-class="hidden"
leave-to-class="rotate-180">
<ChevronDownIcon v-if="!isOpen" class="chevron" />
<ChevronUpIcon v-else class="chevron" />
</Transition>
<slot name="button" />
</button>
<Transition name="fade">
<div v-if="isOpen" class="relative">
<Transition
enter-active-class="transition-opacity"
enter-from-class="opacity-0"
leave-from-class="transition-opacity"
leave-to-class="opacity-0">
<div v-if="inline && isOpen">
<slot />
</div>
<div v-else-if="isOpen" class="relative">
<div class="z-10 divide-y rounded-b-md absolute">
<slot />
</div>
@@ -33,27 +60,10 @@ useEventListener('keyup', e => {
</div>
</template>
<style scoped lang="postcss">
<style scoped>
@reference "tailwindcss";
.chevron {
@apply w-4 h-4 ms-1;
}
.fade-enter-from, .fade-leave-to {
opacity: 0;
}
.fade-enter-active, .fade-leave-active {
@apply transition-opacity;
}
.flip-enter-from, .flip-leave-to {
transform: rotate(180deg);
}
.flip-enter-active {
@apply transition-transform;
}
.flip-leave-active {
display: none;
@apply w-4 h-4 me-1;
}
</style>
+2 -1
View File
@@ -34,7 +34,8 @@ useEventListener('keyup', e => {
</Transition>
</template>
<style scoped lang="postcss">
<style scoped>
@reference "tailwindcss";
.fade-enter-from, .fade-leave-to {
@apply opacity-0;
}
+71
View File
@@ -0,0 +1,71 @@
<script setup lang="ts" generic="T">
import {vOnClickOutside} from '@vueuse/components';
import {useVirtualList} from '@vueuse/core';
import {computed, ref} from 'vue';
interface Props {
items: T[];
itemHeight?: number;
}
const props = withDefaults(defineProps<Props>(), {
itemHeight: 24,
});
const modelValue = defineModel<T>();
const isOpen = ref(false);
const currentIndex = ref(-1);
const {list, scrollTo, containerProps, wrapperProps} = useVirtualList(computed(() => props.items), {
itemHeight: () => props.itemHeight,
overscan: 3,
});
const moveDown = () => {
currentIndex.value = currentIndex.value >= props.items.length - 1 ? 0 : currentIndex.value + 1;
scrollTo(currentIndex.value);
};
const moveUp = () => {
currentIndex.value = currentIndex.value <= 0 ? props.items.length - 1 : currentIndex.value - 1;
scrollTo(currentIndex.value);
};
const select = (item?: T) => {
modelValue.value = item;
currentIndex.value = -1;
isOpen.value = false;
};
const submit = () => {
if (currentIndex.value >= 0 && currentIndex.value < props.items.length) {
select(props.items[currentIndex.value]);
} else if (modelValue.value === undefined && props.items.length > 0) {
select(props.items[0]);
}
};
</script>
<template>
<div @click="isOpen = true" v-on-click-outside="() => isOpen = false">
<div class="fake-input" @keyup.enter="submit" @keyup.down="moveDown" @keyup.up="moveUp">
<slot name="input" :value="modelValue" />
</div>
<div v-if="isOpen && items.length" class="z-20 absolute">
<div v-bind="containerProps" class="rounded-b" style="height: 300px">
<div v-bind="wrapperProps">
<div v-for="s in list" :key="s.index"
class="hover:bg-slate-700 cursor-pointer"
:class="s.index === currentIndex ? 'bg-emerald-500' : 'bg-slate-500'"
@click.stop="select(s.data)">
<slot name="item" :item="s.data" />
</div>
</div>
</div>
</div>
</div>
</template>
<style scoped>
@reference "tailwindcss";
.fake-input {
@apply flex border bg-slate-500 rounded px-1 py-0.5;
}
</style>
+2 -1
View File
@@ -10,7 +10,8 @@ const modelValue = defineModel({ default: false });
</label>
</template>
<style scoped lang="postcss">
<style scoped>
@reference "tailwindcss";
input:checked ~ span:last-child {
--tw-translate-x: 1.25rem;
}
+1
View File
@@ -3,6 +3,7 @@ export { default as Dropdown } from './Dropdown.vue';
export { default as LoadingSpinner } from './LoadingSpinner.vue';
export { default as Modal } from './Modal.vue';
export { default as ProgressBar } from './ProgressBar.vue';
export { default as SelectInput } from './SelectInput.vue';
export { default as SliderCheckbox } from './SliderCheckbox.vue';
export { default as Tooltip } from './tooltip/Tooltip.vue';
+2 -1
View File
@@ -32,7 +32,8 @@ const emit = defineEmits<Emit>();
</component>
</template>
<style scoped lang="postcss">
<style scoped>
@reference "tailwindcss";
.sort-header {
@apply relative h-8 pe-3;
}
+2 -1
View File
@@ -67,7 +67,8 @@ const itemHeightStyle = computed(() => {
<slot v-else name="empty" />
</template>
<style scoped lang="postcss">
<style scoped>
@reference "tailwindcss";
div.table-container {
@apply bg-slate-600;
max-height: calc(100vh - v-bind(ypx));
-1
View File
@@ -11,7 +11,6 @@ export const percentFormater = new Intl.NumberFormat("en-US", {
maximumFractionDigits: 0
});
const timeFormat = new Intl.NumberFormat("en-US", {
minimumFractionDigits: 0,
maximumFractionDigits: 0,
File diff suppressed because it is too large Load Diff
+62
View File
@@ -0,0 +1,62 @@
/* tslint:disable */
/* eslint-disable */
/**
* OpenAPI definition
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: v0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import type { Configuration } from './configuration';
// Some imports not used depending on template conditions
// @ts-ignore
import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
import globalAxios from 'axios';
export const BASE_PATH = "http://localhost:8080".replace(/\/+$/, "");
export const COLLECTION_FORMATS = {
csv: ",",
ssv: " ",
tsv: "\t",
pipes: "|",
};
export interface RequestArgs {
url: string;
options: RawAxiosRequestConfig;
}
export class BaseAPI {
protected configuration: Configuration | undefined;
constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) {
if (configuration) {
this.configuration = configuration;
this.basePath = configuration.basePath ?? basePath;
}
}
};
export class RequiredError extends Error {
constructor(public field: string, msg?: string) {
super(msg);
this.name = "RequiredError"
}
}
interface ServerMap {
[key: string]: {
url: string,
description: string,
}[];
}
export const operationServerMap: ServerMap = {
}
+127
View File
@@ -0,0 +1,127 @@
/* tslint:disable */
/* eslint-disable */
/**
* OpenAPI definition
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: v0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import type { Configuration } from "./configuration";
import type { RequestArgs } from "./base";
import type { AxiosInstance, AxiosResponse } from 'axios';
import { RequiredError } from "./base";
export const DUMMY_BASE_URL = 'https://example.com'
/**
*
* @throws {RequiredError}
*/
export const assertParamExists = function (functionName: string, paramName: string, paramValue: unknown) {
if (paramValue === null || paramValue === undefined) {
throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`);
}
}
export const setApiKeyToObject = async function (object: any, keyParamName: string, configuration?: Configuration) {
if (configuration && configuration.apiKey) {
const localVarApiKeyValue = typeof configuration.apiKey === 'function'
? await configuration.apiKey(keyParamName)
: await configuration.apiKey;
object[keyParamName] = localVarApiKeyValue;
}
}
export const setBasicAuthToObject = function (object: any, configuration?: Configuration) {
if (configuration && (configuration.username || configuration.password)) {
object["auth"] = { username: configuration.username, password: configuration.password };
}
}
export const setBearerAuthToObject = async function (object: any, configuration?: Configuration) {
if (configuration && configuration.accessToken) {
const accessToken = typeof configuration.accessToken === 'function'
? await configuration.accessToken()
: await configuration.accessToken;
object["Authorization"] = "Bearer " + accessToken;
}
}
export const setOAuthToObject = async function (object: any, name: string, scopes: string[], configuration?: Configuration) {
if (configuration && configuration.accessToken) {
const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
? await configuration.accessToken(name, scopes)
: await configuration.accessToken;
object["Authorization"] = "Bearer " + localVarAccessTokenValue;
}
}
function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void {
if (parameter == null) return;
if (typeof parameter === "object") {
if (Array.isArray(parameter) || parameter instanceof Set) {
(parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key));
}
else {
Object.keys(parameter).forEach(currentKey =>
setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== '' ? '.' : ''}${currentKey}`)
);
}
}
else {
if (urlSearchParams.has(key)) {
urlSearchParams.append(key, parameter);
}
else {
urlSearchParams.set(key, parameter);
}
}
}
export const setSearchParams = function (url: URL, ...objects: any[]) {
const searchParams = new URLSearchParams(url.search);
setFlattenedQueryParams(searchParams, objects);
url.search = searchParams.toString();
}
/**
* JSON serialization helper function which replaces instances of unserializable types with serializable ones.
* This function will run for every key-value pair encountered by JSON.stringify while traversing an object.
* Converting a set to a string will return an empty object, so an intermediate conversion to an array is required.
*/
// @ts-ignore
export const replaceWithSerializableTypeIfNeeded = function(key: string, value: any) {
if (value instanceof Set) {
return Array.from(value);
} else {
return value;
}
}
export const serializeDataIfNeeded = function (value: any, requestOptions: any, configuration?: Configuration) {
const nonString = typeof value !== 'string';
const needsSerialization = nonString && configuration && configuration.isJsonMime
? configuration.isJsonMime(requestOptions.headers['Content-Type'])
: nonString;
return needsSerialization
? JSON.stringify(value !== undefined ? value : {}, replaceWithSerializableTypeIfNeeded)
: (value || "");
}
export const toPathString = function (url: URL) {
return url.pathname + url.search + url.hash
}
export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) {
return <T = unknown, R = AxiosResponse<T>>(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
const axiosRequestArgs = {...axiosArgs.options, url: (axios.defaults.baseURL ? '' : configuration?.basePath ?? basePath) + axiosArgs.url};
return axios.request<T, R>(axiosRequestArgs);
};
}
+121
View File
@@ -0,0 +1,121 @@
/* tslint:disable */
/**
* OpenAPI definition
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: v0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
interface AWSv4Configuration {
options?: {
region?: string
service?: string
}
credentials?: {
accessKeyId?: string
secretAccessKey?: string,
sessionToken?: string
}
}
export interface ConfigurationParameters {
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
username?: string;
password?: string;
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
awsv4?: AWSv4Configuration;
basePath?: string;
serverIndex?: number;
baseOptions?: any;
formDataCtor?: new () => any;
}
export class Configuration {
/**
* parameter for apiKey security
* @param name security name
*/
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
/**
* parameter for basic security
*/
username?: string;
/**
* parameter for basic security
*/
password?: string;
/**
* parameter for oauth2 security
* @param name security name
* @param scopes oauth2 scope
*/
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
/**
* parameter for aws4 signature security
* @param {Object} AWS4Signature - AWS4 Signature security
* @param {string} options.region - aws region
* @param {string} options.service - name of the service.
* @param {string} credentials.accessKeyId - aws access key id
* @param {string} credentials.secretAccessKey - aws access key
* @param {string} credentials.sessionToken - aws session token
* @memberof Configuration
*/
awsv4?: AWSv4Configuration;
/**
* override base path
*/
basePath?: string;
/**
* override server index
*/
serverIndex?: number;
/**
* base options for axios calls
*/
baseOptions?: any;
/**
* The FormData constructor that will be used to create multipart form data
* requests. You can inject this here so that execution environments that
* do not support the FormData class can still run the generated client.
*
* @type {new () => FormData}
*/
formDataCtor?: new () => any;
constructor(param: ConfigurationParameters = {}) {
this.apiKey = param.apiKey;
this.username = param.username;
this.password = param.password;
this.accessToken = param.accessToken;
this.awsv4 = param.awsv4;
this.basePath = param.basePath;
this.serverIndex = param.serverIndex;
this.baseOptions = {
...param.baseOptions,
headers: {
...param.baseOptions?.headers,
},
};
this.formDataCtor = param.formDataCtor;
}
/**
* Check if the given MIME is a JSON MIME.
* JSON MIME examples:
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
* application/vnd.company+json
* @param mime - MIME (Multipurpose Internet Mail Extensions)
* @return True if the given MIME is JSON, false otherwise.
*/
public isJsonMime(mime: string): boolean {
const jsonMime: RegExp = /^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$/i;
return mime !== null && jsonMime.test(mime);
}
}
+18
View File
@@ -0,0 +1,18 @@
/* tslint:disable */
/* eslint-disable */
/**
* OpenAPI definition
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: v0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
export * from "./api";
export * from "./configuration";
+147
View File
@@ -0,0 +1,147 @@
<script setup lang="ts">
import {computed, ref} from "vue";
import {storeToRefs} from "pinia";
import {isCombined, Ledger, LedgerType, LedgerTypes, useLedgersStore} from "./ledger";
import {Modal} from "@/components";
import LedgerLabel from "./LedgerLabel.vue";
import {PlusIcon, TrashIcon} from '@heroicons/vue/24/outline';
import LedgerSelect from "@/ledger/LedgerSelect.vue";
interface Props {
ledgerId?: string;
}
const props = defineProps<Props>();
const ledgersStore = useLedgersStore();
const {ledgers} = storeToRefs(ledgersStore);
const {findById, findAllById, createMain, createCombined, updateMain, updateCombined} = ledgersStore;
const modalOpen = ref<boolean>(false);
const type = ref<LedgerType>(LedgerTypes.Main);
const name = ref("");
const members = ref<Ledger[]>([]);
const selectedLedger = ref<Ledger>();
const availableLedgers = computed(() => ledgers.value
.filter((ledger) => selectedLedger.value === ledger)
.filter(l => !members.value.includes(l)));
const addMember = () => {
if (selectedLedger.value && !members.value.includes(selectedLedger.value)) {
members.value = [...members.value, selectedLedger.value];
selectedLedger.value = undefined;
}
}
const open = () => {
const ledger = isCreating.value ? undefined : findById(props.ledgerId);
if (ledger) {
type.value = ledger.type;
name.value = ledger.name;
members.value = isCombined(ledger) ? findAllById(ledger.memberLedgerIds) : [];
} else {
type.value = LedgerTypes.Main;
name.value = "";
members.value = [];
}
modalOpen.value = true;
}
const canSave = computed(() => name.value.trim().length > 0);
const isCreating = computed(() => props.ledgerId === undefined || props.ledgerId.length === 0);
const title = computed(() => {
if (isCreating.value) {
return `Creating ${type.value === LedgerTypes.Main ? 'Main' : 'Combined'} Ledger`
}
return `Updating ${name.value}`
})
const create = () => {
if (type.value === LedgerTypes.Main) {
createMain({name: name.value})
} else {
createCombined({name: name.value, memberLedgerIds: members.value.map(l => l.ledgerId)})
}
}
const update = () => {
if (type.value === LedgerTypes.Main) {
updateMain(props.ledgerId, {name: name.value})
} else {
updateCombined(props.ledgerId, {name: name.value, memberLedgerIds: members.value.map(l => l.ledgerId)})
}
}
const save = () => {
if (!canSave.value) {
return;
}
if (isCreating.value) {
create();
} else {
update();
}
modalOpen.value = false;
}
defineExpose({ open });
</script>
<template>
<Modal v-model:open="modalOpen">
<div class="bg-slate-800 rounded pb-4 w-96">
<span class="m-2">{{ title }}</span>
<hr />
<div class="mt-4">
<div class="flex justify-center">
<div class="flex bg-slate-600 rounded-s-md p-1">
<button class="switch" :class="{active: type === LedgerTypes.Main}" @click="type = LedgerTypes.Main">Main</button>
</div>
<div class="switch flex bg-slate-600 rounded-e-md p-1">
<button class="switch" :class="{active: type === LedgerTypes.Combined}" @click="type = LedgerTypes.Combined">Combined</button>
</div>
</div>
<div class="m-4">
Name:
<div class="flex">
<input type="text" class="flex grow" v-model="name" />
</div>
</div>
</div>
<div v-if="type === LedgerTypes.Combined" class="ms-4 mb-4">
Member Ledgers:
<div v-for="ledger in members" :key="ledger.ledgerId" class="flex">
<LedgerLabel class="flex grow mb-2" :ledger="ledger" />
<div class="flex justify-end me-4 ms-2">
<button class="btn-icon" @click="members = members.filter(m => m !== ledger)"><TrashIcon /></button>
</div>
</div>
<div v-if="availableLedgers.length" class="flex">
<LedgerSelect v-model="selectedLedger" class="grow" :ledgers="availableLedgers" />
<div class="flex justify-end me-4 ms-2">
<button class="btn-icon" @click="addMember"><PlusIcon /></button>
</div>
</div>
</div>
<div class="flex justify-end">
<button class="me-4" @click="save" :disabled="!canSave">Save</button>
</div>
</div>
</Modal>
</template>
<style scoped>
@reference "tailwindcss";
button.switch {
@apply flex items-center px-4 rounded-md bg-slate-600;
&.active {
@apply bg-emerald-500;
}
}
</style>
+23
View File
@@ -0,0 +1,23 @@
<script setup lang="ts">
import {isCombined, Ledger} from "@/ledger/ledger.ts";
import {FolderOpenIcon} from '@heroicons/vue/24/outline';
import {RouterLink} from "vue-router";
import {routeNames} from "@/routes";
interface Props {
ledger: Ledger;
link?: boolean;
}
const props = defineProps<Props>();
</script>
<template>
<div class="flex">
<FolderOpenIcon v-if="isCombined(ledger)" class="w-4 me-1" />
<div v-else class="w-4 me-1"/>
<RouterLink v-if="link" :to="{name: routeNames.viewLedger, params: {ledgerId: ledger.ledgerId}}">{{ ledger.name }}</RouterLink>
<span v-else>{{ ledger.name }}</span>
</div>
</template>
+34
View File
@@ -0,0 +1,34 @@
<script setup lang="ts">
import {Ledger, systemLedger, useLedgersStore} from "@/ledger/ledger.ts";
import {storeToRefs} from "pinia";
import {computed} from "vue";
interface Props {
ledgers?: Ledger[];
}
const props = defineProps<Props>()
const ledger = defineModel<Ledger>();
const {ledgers: allLedgers} = storeToRefs(useLedgersStore());
const ledgersToUse = computed(() => props.ledgers || allLedgers);
const ledgerId = computed({
get: () => ledger.value?.ledgerId,
set: value => ledger.value = ledgersToUse.value.find(l => l.ledgerId === value)
})
</script>
<template>
<select v-model="ledgerId" :class="{'system-ledger': ledger === systemLedger}">
<option v-for="l in ledgersToUse" :key="l.ledgerId" :value="l.ledgerId" :class="{'system-ledger': l === systemLedger}">{{ l.name }}</option>
</select>
</template>
<style scoped>
@reference "tailwindcss";
.system-ledger {
@apply text-emerald-400;
}
</style>
+5
View File
@@ -0,0 +1,5 @@
export * from './ledger';
export {default as LedgerLabel} from './LedgerLabel.vue';
export {default as LedgerSelect} from './LedgerSelect.vue';
export {default as EditLedgerModal} from './EditLedgerModal.vue';
+86
View File
@@ -0,0 +1,86 @@
import {
CombinedLedgerResponse,
CombinedLedgerResponseTypeEnum,
CreateCombinedLedgerRequest,
CreateMainLedgerRequest,
LedgerResponseTypeEnum,
MainLedgerResponse,
MainLedgerResponseTypeEnum,
TransactionResponse,
TransferResponseTypeEnum,
UpdateCombinedLedgerRequest,
UpdateMainLedgerRequest
} from "@/generated/mammon";
import {defineStore} from "pinia";
import {computed, ref, triggerRef} from "vue";
import {ledgerApi, transactionApi} from "@/mammon";
import {useRouteParams} from "@vueuse/router";
export const LedgerTypes = LedgerResponseTypeEnum;
export type LedgerType = LedgerResponseTypeEnum;
export type MainLedger = MainLedgerResponse & {type: MainLedgerResponseTypeEnum}
export type CombinedLedger = CombinedLedgerResponse & {type: CombinedLedgerResponseTypeEnum}
export type Ledger = MainLedger | CombinedLedger;
export const TransferTypes = TransferResponseTypeEnum;
export const systemLedgerRef = 'system';
export const systemLedger = {
type: LedgerTypes.Main,
ledgerId: "",
name: "Eve Economy",
balance: 0,
_system: true
} as MainLedger;
export const isMain = (ledger: Ledger): ledger is MainLedger => {
return ledger.type === LedgerTypes.Main;
}
export const isCombined = (ledger: Ledger): ledger is CombinedLedger => {
return ledger.type === LedgerTypes.Combined;
}
export const useLedgersStore = defineStore('ledgers', () => {
const ledgers = ref<Ledger[]>([]);
const addLedger = (ledger: Ledger) => {
ledgers.value.push(ledger);
triggerRef(ledgers);
return ledger;
};
const replaceLedger = (ledger: Ledger) => {
const index = ledgers.value.findIndex(l => l.ledgerId === ledger.ledgerId);
if (index !== -1) {
ledgers.value[index] = ledger;
}
triggerRef(ledgers);
return ledger;
};
const findById = (ledgerId: string): Ledger | undefined => ledgers.value.find(l => l.ledgerId === ledgerId);
const findAllById = (ledgerIds: string[]): Ledger[] => ledgerIds.map(findById).filter((x): x is Ledger => x !== undefined)
const createMain = (ledger: CreateMainLedgerRequest) => ledgerApi.createMainLedger(ledger).then(response => addLedger(response.data as Ledger));
const createCombined = (ledger: CreateCombinedLedgerRequest) => ledgerApi.createCombinedLedger(ledger).then(response => addLedger(response.data as Ledger));
const updateMain = (ledgerId: string, ledger: UpdateMainLedgerRequest) => ledgerApi.updateMainLedger(ledgerId, ledger).then(response => replaceLedger(response.data as Ledger));
const updateCombined = (ledgerId: string, ledger: UpdateCombinedLedgerRequest) => ledgerApi.updateCombinedLedger(ledgerId, ledger).then(response => replaceLedger(response.data as Ledger));
const refresh = () => ledgerApi.findAllLedgers().then(response => ledgers.value = response.data as Ledger[]);
refresh();
return {ledgers, findById, findAllById, createMain, createCombined, updateMain, updateCombined, refresh};
})
export const findAllTransactionInLeger = (ledger: Ledger | string): Promise<TransactionResponse[]> => transactionApi.finAllTransactionsInLedger(typeof ledger == 'string' ? ledger : ledger.ledgerId).then(response => response.data)
export const useLedgerParam = () => {
const {findById} = useLedgersStore();
const ledgerId = useRouteParams<string, string>('ledgerId', '', { transform: v => typeof v === 'string' ? v : v[0]});
const ledger = computed(() => findById(ledgerId.value))
return {ledgerId, ledger};
}
-13
View File
@@ -1,4 +1,3 @@
import { useAuthStore } from "@/auth";
import { createPinia } from 'pinia';
import { createApp } from 'vue';
import { createRouter, createWebHistory } from 'vue-router';
@@ -17,18 +16,6 @@ const router = createRouter({
});
app.use(pinia);
const authStore = useAuthStore();
router.beforeEach(async to => {
if (to.name === 'callback') {
await authStore.login();
return { name: 'home' };
} else if (!authStore.isLoggedIn) {
await authStore.redirect();
}
});
app.use(router);
app.mount('#app');
+1
View File
@@ -0,0 +1 @@
export * from './mammonService'
+31
View File
@@ -0,0 +1,31 @@
import {logResource} from "@/service";
import axios from "axios";
import {
ActivityApi,
CharacterApi,
CharacterRuleBookApi,
LedgerApi,
ProcessingApi,
RuleBookApi,
TransactionApi
} from "@/generated/mammon";
export const mammonUrl = import.meta.env.VITE_MAMMON_URL;
export const mammonAddCharacterUrl = mammonUrl + "oauth2/authorization/esi"
const mammonAxiosInstance = axios.create({
baseURL: mammonUrl,
headers: {
'Accept': 'application/json',
"Content-Type": "application/json",
},
})
logResource(mammonAxiosInstance)
export const ledgerApi = new LedgerApi(undefined, mammonUrl, mammonAxiosInstance);
export const transactionApi = new TransactionApi(undefined, mammonUrl, mammonAxiosInstance);
export const characterApi = new CharacterApi(undefined, mammonUrl, mammonAxiosInstance);
export const ruleBookApi = new RuleBookApi(undefined, mammonUrl, mammonAxiosInstance);
export const characterRuleBookApi = new CharacterRuleBookApi(undefined, mammonUrl, mammonAxiosInstance);
export const activityApi = new ActivityApi(undefined, mammonUrl, mammonAxiosInstance);
export const processingApi = new ProcessingApi(undefined, mammonUrl, mammonAxiosInstance);
-3
View File
@@ -1,3 +0,0 @@
export type MarbasObject = {
id: number;
}
-3
View File
@@ -1,3 +0,0 @@
export * from './MarbasObject';
export * from './marbasService';
-56
View File
@@ -1,56 +0,0 @@
import { useAuthStore } from "@/auth";
import { logResource } from "@/service";
import axios from "axios";
export const marbasAxiosInstance = axios.create({
baseURL: import.meta.env.VITE_MARBAS_URL,
headers: {
'Accept': 'application/json',
"Content-Type": "application/json",
},
})
const authStore = useAuthStore();
marbasAxiosInstance.interceptors.request.use(async r => {
if (!authStore.isLoggedIn) {
await authStore.redirect();
}
const accessToken = authStore.accessToken;
if (accessToken) {
r.headers.Authorization = `Bearer ${accessToken}`;
}
if (!r.params?.page_size) {
r.params = { ...r.params, page_size: 250 };
}
return r;
})
logResource(marbasAxiosInstance)
marbasAxiosInstance.interceptors.response.use(async r => {
if (r.status === 401) {
await authStore.redirect();
return marbasAxiosInstance.request(r.config);
}
let next: string = r.data?.next;
let results = r.data?.results;
if (next) {
if (!next.startsWith(import.meta.env.VITE_MARBAS_URL)) { // FIME remove once the API is fixed
next = import.meta.env.VITE_MARBAS_URL + next.replace(/http(s)?:\/\/[^/]+\//g, '');
}
results = results.concat((await marbasAxiosInstance.request({
...r.config,
url: next,
baseURL: '',
})).data);
}
if (results) {
r.data = results;
}
return r;
})
+13
View File
@@ -0,0 +1,13 @@
<script setup lang="ts">
import {formatIsk} from "@/formaters";
interface Props {
amount: number;
}
const { amount } = defineProps<Props>();
</script>
<template>
<span :class="amount >= 0 ? 'text-emerald-400' : 'text-amber-700'">{{ formatIsk(amount) }}</span>
</template>
@@ -1,10 +1,10 @@
<script setup lang="ts">
import { LoadingSpinner, Tooltip } from '@/components';
import { formatIsk } from '@/formaters';
import { getHistory, getHistoryQuartils } from '@/market';
import { ArrowTrendingDownIcon, ArrowTrendingUpIcon } from '@heroicons/vue/24/outline';
import { computedAsync } from '@vueuse/core';
import { ref, watchEffect } from 'vue';
import {LoadingSpinner, Tooltip} from '@/components';
import {formatIsk} from '@/formaters';
import {getHistory, getHistoryQuartils} from '@/market';
import {ArrowTrendingDownIcon, ArrowTrendingUpIcon} from '@heroicons/vue/24/outline';
import {computedAsync} from '@vueuse/core';
import {ref, watchEffect} from 'vue';
const trendingScale = 3;
@@ -74,7 +74,9 @@ watchEffect(async () => {
</Tooltip>
</template>
<style scoped lang="postcss">
<style scoped>
@reference "tailwindcss";
.tooltip {
@apply ms-auto;
>:deep(div.header) {
@@ -245,7 +245,8 @@ const total = computed(() => {
</VirtualScrollTable>
</template>
<style scoped lang="postcss">
<style scoped>
@reference "tailwindcss";
div.end {
@apply justify-self-end ms-2;
}
+5 -6
View File
@@ -1,10 +1,9 @@
<script setup lang="ts">
import { Modal } from '@/components';
import { formatIsk } from '@/formaters';
import { MarketType, MarketTypeLabel } from '@/market';
import { ref } from 'vue';
import { useAcquiredTypesStore } from './acquisition';
import {Modal} from '@/components';
import {formatIsk} from '@/formaters';
import {MarketType, MarketTypeLabel} from '@/market';
import {ref} from 'vue';
import {useAcquiredTypesStore} from './acquisition';
const acquiredTypesStore = useAcquiredTypesStore();
+3 -37
View File
@@ -1,48 +1,16 @@
import { marbasAxiosInstance, MarbasObject } from "@/marbas";
import { AxiosResponse } from "axios";
import log from "loglevel";
import { defineStore } from "pinia";
import { computed, ref } from "vue";
export type AcquiredTypeSource = 'bo' | 'so' | 'prod' | 'misc';
export type MarbasAcquiredType = MarbasObject & {
type: number;
quantity: number;
remaining: number;
price: number;
date: Date;
source: AcquiredTypeSource;
}
type RawMarbasAcquiredType = Omit<MarbasAcquiredType, 'date'> & {
date: string;
}
type InsertableRawMarbasAcquiredType = Omit<MarbasAcquiredType, 'id' | 'date'>;
const mapRawMarbasAcquiredType = (raw: RawMarbasAcquiredType): MarbasAcquiredType => ({
...raw,
date: raw.date ? new Date(raw.date) : new Date()
});
const endpoint = '/api/acquisitions/';
export const useAcquiredTypesStore = defineStore('market-acquisition', () => {
const acquiredTypes = ref<MarbasAcquiredType[]>([]);
const acquiredTypes = ref<any[]>([]); // TODO
const types = computed(() => acquiredTypes.value.filter(item => item.remaining > 0));
const addAcquiredType = async (type: number, quantity: number, price: number, source?: AcquiredTypeSource) => {
const newItem = mapRawMarbasAcquiredType((await marbasAxiosInstance.post<RawMarbasAcquiredType, AxiosResponse<RawMarbasAcquiredType>, InsertableRawMarbasAcquiredType>(endpoint, {
type: type,
quantity: quantity,
remaining: quantity,
price: price,
source: source ?? 'misc',
})).data);
const newItem = [];
acquiredTypes.value = [...acquiredTypes.value, newItem];
log.info(`Acquired type ${newItem.id} with quantity ${newItem.quantity} and price ${newItem.price}`, newItem);
};
const removeAcquiredType = async (id: number, quantity: number) => {
const found = acquiredTypes.value.find(t => t.id === id);
@@ -63,11 +31,9 @@ export const useAcquiredTypesStore = defineStore('market-acquisition', () => {
return i;
}
});
await marbasAxiosInstance.put(`${endpoint}${item.id}/`, item);
log.info(`Acquired type ${item.id} remaining: ${item.remaining}`, item);
};
const refresh = () => marbasAxiosInstance.get<RawMarbasAcquiredType[]>(endpoint).then(res => acquiredTypes.value = res.data.map(mapRawMarbasAcquiredType));
const refresh = () => {}
refresh();
+2
View File
@@ -6,3 +6,5 @@ export * from './type';
export * from './appraisal';
export * from './market';
export { default as IskLabel } from './IskLabel.vue';
+2 -1
View File
@@ -17,7 +17,8 @@ const { brokerFee, scc } = storeToRefs(useMarketTaxStore());
</div>
</template>
<style scoped lang="postcss">
<style scoped>
@reference "tailwindcss";
div.end {
@apply justify-self-end ms-2;
}
+2 -1
View File
@@ -167,7 +167,8 @@ const getLineColor = (result: Result) => {
</VirtualScrollTable>
</template>
<style scoped lang="postcss">
<style scoped>
@reference "tailwindcss";
div.end {
@apply justify-self-end ms-2;
}
+1 -11
View File
@@ -1,4 +1,3 @@
import { marbasAxiosInstance, MarbasObject } from "@/marbas";
import { EsiMarketOrderHistory, getHistory, MarketType, MarketTypePrice } from "@/market";
import log from "loglevel";
import { defineStore } from "pinia";
@@ -12,21 +11,16 @@ export type TrackingResult = {
orderCount: number,
}
export type MarbasTrackedType = MarbasObject & {
type: number
};
const endpoint = '/api/types_tracking/';
export const useMarketTrackingStore = defineStore('marketTracking', () => {
const trackedTypes = ref<MarbasTrackedType[]>([]);
const trackedTypes = ref<any[]>([]); // TODO
const types = computed(() => trackedTypes.value.map(item => item.type) ?? []);
const addType = async (type: number) => {
const found = trackedTypes.value.find(item => item.type === type);
if (!found) {
trackedTypes.value = [...trackedTypes.value, (await marbasAxiosInstance.post<MarbasTrackedType>(endpoint, { type })).data];
log.info(`Tracking type ${type}`);
}
}
@@ -38,12 +32,8 @@ export const useMarketTrackingStore = defineStore('marketTracking', () => {
}
trackedTypes.value = trackedTypes.value.filter(t => t.id !== found.id);
await marbasAxiosInstance.delete(`${endpoint}${found.id}`);
log.info(`Stopped tracking type ${type}`);
}
marbasAxiosInstance.get<MarbasTrackedType[]>(endpoint).then(res => trackedTypes.value = res.data);
return { types, addType, removeType };
});
+21 -20
View File
@@ -1,35 +1,40 @@
import { marbasAxiosInstance } from "@/marbas";
import {esiAxiosInstance} from '@/service';
export type MarketType = {
id: number;
type_id: number;
group_id: number;
marketgroup_id: number;
market_group_id: number;
name: string;
published: boolean;
description: string;
basePrice: number;
base_price: number;
icon_id: number;
volume: number;
portionSize: number;
portion_size: number;
}
const cache = new Map<number, MarketType>(); // TODO move to pinia store
const fetchType = (id: number): Promise<MarketType> => {
if (cache.has(id)) {
return Promise.resolve(cache.get(id)!);
}
return esiAxiosInstance.get<MarketType>(`/universe/types/${id}/`).then(r => {
cache.set(id, r.data);
return r.data;
});
};
export const getMarketType = async (type: string | number): Promise<MarketType> => (await getMarketTypes([type]))[0];
export const getMarketTypes = async (types: (string | number)[]): Promise<MarketType[]> => {
if (types.length === 0) {
return [];
} else if (types.length === 1 && typeof types[0] === "number") {
return [(await marbasAxiosInstance.get<MarketType>(`/sde/types/${types[0]}/`)).data];
}
return (await marbasAxiosInstance.post<MarketType[]>("/api/types/search", types.map(t => {
if (typeof t === "number") {
return { id: t };
} else {
return { name: t };
}
}))).data;
const ids = types.filter((t): t is number => typeof t === 'number');
return Promise.all(ids.map(fetchType));
}
const blueprintMarketGrous = [ // TODO add all groups
const blueprintMarketGroups = [ // TODO add all groups
2,
2157,
2159,
@@ -49,9 +54,5 @@ const blueprintMarketGrous = [ // TODO add all groups
]
export const searchMarketTypes = async (search: string): Promise<MarketType[]> => {
return (await marbasAxiosInstance.post<MarketType[]>("/api/types/search", [{
name__icontains: search,
marketgroup_id___not: null,
marketgroup_id__in___not: blueprintMarketGrous,
}])).data;
return []
}
+2 -1
View File
@@ -104,7 +104,8 @@ watchEffect(async () => {
</div>
</template>
<style scoped lang="postcss">
<style scoped>
@reference "tailwindcss";
.fake-input {
@apply w-96 flex border bg-slate-500 rounded px-1 py-0.5;
+4 -2
View File
@@ -1,6 +1,7 @@
<script setup lang="ts">
import { ClipboardButton } from '@/components';
import { InformationCircleIcon } from '@heroicons/vue/24/outline';
import { routeNames } from '@/routes';
interface Props {
@@ -21,7 +22,7 @@ withDefaults(defineProps<Props>(), {
<img v-if="id" :src="`https://images.evetech.net/types/${id}/icon?size=32`" class="inline-block w-5 h-5 me-1 mt-1" alt="" />
<template v-if="name">
{{ name }}
<RouterLink v-if="id" :to="{ name: 'market-types', params: { type: id } }" class="button btn-icon ms-1 me-1 mt-1" title="Show item info">
<RouterLink v-if="id" :to="{ name: routeNames.marketTypes, params: { type: id } }" class="button btn-icon ms-1 me-1 mt-1" title="Show item info">
<InformationCircleIcon />
</RouterLink>
<ClipboardButton v-if="!hideCopy" :value="name" />
@@ -29,7 +30,8 @@ withDefaults(defineProps<Props>(), {
</div>
</template>
<style scoped lang="postcss">
<style scoped>
@reference "tailwindcss";
button:deep(>svg), .button:deep(>svg) {
@apply !w-4 !h-4;
}
+18 -2
View File
@@ -1,11 +1,27 @@
<script setup lang="ts">
import {mammonAddCharacterUrl} from "@/mammon";
import {storeToRefs} from "pinia";
import {CharacterLabel, useCharactersStore} from "@/characters";
import {ArrowPathIcon} from '@heroicons/vue/24/outline';
const charactersStore = useCharactersStore()
const {characters} = storeToRefs(charactersStore);
const {reloadActivities} = charactersStore;
const addCharacter = () => {
// TODO
window.location.replace(mammonAddCharacterUrl);
}
</script>
<template>
<div class="grid mb-2 mt-4">
<button class="justify-self-end" @click="addCharacter">Add chacarcter</button>
<div class="mb-4 border-b-1 flex justify-end">
<button class="mb-2" @click="addCharacter">Add chacarcter</button>
</div>
<div v-for="character in characters" :key="character.characterId" class="flex items-center mb-2">
<CharacterLabel class="grow" :character="character" />
<button class="btn-icon" @click="reloadActivities(character.characterId)"><ArrowPathIcon /></button>
</div>
</div>
</template>
+26
View File
@@ -0,0 +1,26 @@
<script setup lang="ts">
import {RouterView} from 'vue-router';
import {EditLedgerModal, useLedgersStore} from "@/ledger";
import {ref} from "vue";
import {processingApi} from "@/mammon";
const {refresh} = useLedgersStore();
const editLedgerModal = ref<typeof EditLedgerModal>();
const processActivities = async () => {
await processingApi.processNewActivities();
await refresh();
}
</script>
<template>
<div class="mt-4">
<div class="mb-4 border-b-1 flex justify-end">
<button class="mb-2 ms-2" @click="processActivities">Process Activities</button>
<button class="mb-2 ms-2" @click="editLedgerModal?.open()">New Ledger</button>
</div>
<EditLedgerModal ref="editLedgerModal" />
<RouterView />
</div>
</template>
+4 -13
View File
@@ -1,12 +1,12 @@
<script setup lang="ts">
import { RouterLink, RouterView } from 'vue-router';
import {RouterLink, RouterView} from 'vue-router';
import {routeNames} from '@/routes';
</script>
<template>
<div class="mt-4">
<div class="flex border-b-2 border-emerald-500">
<RouterLink :to="{name: 'market-types'}" class="tab">
<RouterLink :to="{name: routeNames.marketTypes}" class="tab">
<span>Item Info</span>
</RouterLink>
<RouterLink to="/market/tracking" class="tab">
@@ -18,13 +18,4 @@ import { RouterLink, RouterView } from 'vue-router';
</div>
<RouterView />
</div>
</template>
<style scoped lang="postcss">
a.tab {
@apply flex items-center px-4 me-2 rounded-t-md bg-slate-600 hover:bg-slate-700;
&.router-link-active {
@apply bg-emerald-500 hover:bg-emerald-700;
}
}
</style>
</template>
+18
View File
@@ -0,0 +1,18 @@
<script setup lang="ts">
import {RouterLink, RouterView} from "vue-router";
import {routeNames} from '@/routes';
</script>
<template>
<div class="mt-4">
<div class="flex border-b-2 border-emerald-500">
<RouterLink :to="{ name: routeNames.listRuleBooks }" class="tab">
<span>Rule Books</span>
</RouterLink>
<RouterLink to="/characters/rules" class="tab">
<span>Characters Rules</span>
</RouterLink>
</div>
<RouterView />
</div>
</template>
@@ -0,0 +1,46 @@
<script setup lang="ts">
import {findAllTransactionInLeger, TransferTypes, useLedgerParam} from "@/ledger";
import {computedAsync} from "@vueuse/core";
import {TransactionResponse} from "@/generated/mammon";
import {formatEveDate} from "@/formaters.ts";
import {IskLabel} from "@/market";
const {ledgerId, ledger} = useLedgerParam();
const transactions = computedAsync<TransactionResponse[]>(async () => {
if (ledgerId.value) {
return await findAllTransactionInLeger(ledgerId.value);
}
return [];
}, []);
const getIskBalance = (transaction: TransactionResponse) => {
if (!ledgerId.value) {
return 0;
}
let balance = 0;
for (const transfer of transaction.transfers) {
if (transfer.type === TransferTypes.Isk) {
if (transfer.toLedgerId === ledgerId.value) {
balance += transfer.amount;
} else if (transfer.fromLedgerId === ledgerId.value) {
balance -= transfer.amount;
}
}
}
return balance;
}
</script>
<template>
<div class="mt-4">
<div class="flex items-end gap-2 mt-2" v-for="transaction in transactions" :key="transaction.transactionId">
<span>{{formatEveDate(new Date(transaction.datetime))}}</span>
<IskLabel :amount="getIskBalance(transaction)" />
<span>{{transaction.description}}</span>
</div>
</div>
</template>
+33
View File
@@ -0,0 +1,33 @@
<script setup lang="ts">
import {EditLedgerModal, LedgerLabel, useLedgersStore} from "@/ledger";
import {storeToRefs} from "pinia";
import {nextTick, ref} from "vue";
import {PencilSquareIcon} from "@heroicons/vue/24/outline";
import {IskLabel} from "@/market";
const {ledgers} = storeToRefs(useLedgersStore());
const editModal = ref<typeof EditLedgerModal>();
const editingLedgerId = ref("");
const openEdit = async (ledgerId: string) => {
editingLedgerId.value = ledgerId;
await nextTick();
editModal.value?.open();
};
</script>
<template>
<div class="mt-4">
<div v-for="ledger in ledgers" :key="ledger.ledgerId" class="flex items-center mb-2">
<LedgerLabel :ledger="ledger" :link="true" />
<div class="flex grow">
<IskLabel class="ms-2" :amount="ledger.balance" />
</div>
<button class="btn-icon ms-2" @click="openEdit(ledger.ledgerId)"><PencilSquareIcon /></button>
</div>
</div>
<EditLedgerModal ref="editModal" :ledger-id="editingLedgerId" />
</template>
+22
View File
@@ -0,0 +1,22 @@
<script setup lang="ts">
import {RouterLink, RouterView} from 'vue-router';
import {isMain, useLedgerParam} from "@/ledger";
import {routeNames} from "@/routes.ts";
const {ledgerId, ledger} = useLedgerParam();
</script>
<template>
<div v-if="ledger" class="mt-4">
<div class="flex border-b-2 border-emerald-500">
<RouterLink :to="{name: routeNames.viewLedgerBalance}" class="tab">
<span>Balance</span>
</RouterLink>
<RouterLink v-if="isMain(ledger)" :to="{name: routeNames.listLedgerTransactions}" class="tab">
<span>Transactions</span>
</RouterLink>
</div>
<RouterView />
</div>
</template>
+11
View File
@@ -0,0 +1,11 @@
<script setup lang="ts">
import {useLedgerParam} from "@/ledger";
const {ledgerId, ledger} = useLedgerParam();
</script>
<template>
<div class="mt-4">
</div>
</template>
+13 -10
View File
@@ -1,13 +1,14 @@
<script setup lang="ts">
import { ClipboardButton } from '@/components';
import { MarketType, MarketTypeInput, getMarketType, useApraisalStore } from "@/market";
import { AcquisitionResultTable, BuyModal, useAcquiredTypesStore } from '@/market/acquisition';
import { TrackingResultTable, createResult, useMarketTrackingStore } from '@/market/tracking';
import { BookmarkIcon, BookmarkSlashIcon, ShoppingCartIcon } from '@heroicons/vue/24/outline';
import { computedAsync } from '@vueuse/core/index.cjs';
import {ClipboardButton} from '@/components';
import {getMarketType, MarketType, MarketTypeInput, useApraisalStore} from "@/market";
import {AcquisitionResultTable, BuyModal, useAcquiredTypesStore} from '@/market/acquisition';
import {createResult, TrackingResultTable, useMarketTrackingStore} from '@/market/tracking';
import {BookmarkIcon, BookmarkSlashIcon, ShoppingCartIcon} from '@heroicons/vue/24/outline';
import log from "loglevel";
import { computed, ref, watch } from "vue";
import { useRoute, useRouter } from "vue-router";
import {computed, ref, watch} from "vue";
import {useRoute, useRouter} from "vue-router";
import {routeNames} from "@/routes";
import {computedAsync} from "@vueuse/core";
const buyModal = ref<typeof BuyModal>();
@@ -52,7 +53,7 @@ const view = () => {
}
router.push({
name: 'market-types',
name: routeNames.marketTypes,
params: {
type: inputItem.value.id
}
@@ -113,7 +114,9 @@ watch(useRoute(), async route => {
<BuyModal ref="buyModal" />
</template>
<style scoped lang="postcss">
<style scoped>
@reference "tailwindcss";
img.type-image {
width: 64px;
height: 64px;
+95
View File
@@ -0,0 +1,95 @@
<script setup lang="ts">
import {Character, CharacterLabel, useCharactersStore} from "@/characters";
import {useRoute} from "vue-router";
import {computed, ref, watch, watchEffect} from "vue";
import log from "loglevel";
import {
findCharacterRuleBookByCharacterId,
RuleBook,
setCharacterRuleBookForCharacter,
useRuleBooksStore
} from "@/rules";
import {storeToRefs} from "pinia";
import {isMain, Ledger, LedgerSelect, systemLedger, useLedgersStore} from "@/ledger";
type Bindings = { [key: string]: Ledger; };
const ruleBookStore = useRuleBooksStore();
const {findById: findCharacterRuleBookById} = ruleBookStore;
const {ruleBooks} = storeToRefs(ruleBookStore);
const {findById: findCharacterById} = useCharactersStore();
const {ledgers} = storeToRefs(useLedgersStore());
const ledgersToUse = computed(() => [systemLedger, ...ledgers.value.filter(isMain)]);
const character = ref<Character>();
const ruleBook = ref<RuleBook>();
const bindings = ref<Bindings>({});
watchEffect(async () => {
const characterId = character.value?.characterId;
if (characterId) {
const characterRuleBook = await findCharacterRuleBookByCharacterId(characterId);
ruleBook.value = findCharacterRuleBookById(characterRuleBook.ruleBookId);
bindings.value = Object.fromEntries(
Object.entries(characterRuleBook.bindings)
.map(([key, id]) => [key, ledgersToUse.value.find(l => l.ledgerId === id) ?? systemLedger])
);
}
});
const save = () => {
const characterId = character.value?.characterId;
const ruleBookId = ruleBook.value?.ruleBookId;
if (characterId && ruleBookId) {
setCharacterRuleBookForCharacter(characterId, {
ruleBookId,
bindings: Object.fromEntries(
Object.entries(bindings.value)
.map(([key, ledger]) => [key, ledger.ledgerId])
)
})
}
}
watch(useRoute(), async route => {
if (route.params.characterId) {
const id = parseInt(typeof route.params.characterId === 'string' ? route.params.characterId : route.params.characterId[0]);
character.value = await findCharacterById(id);
log.info('Loaded character:', character.value);
} else {
character.value = undefined;
log.info('No character to load');
}
}, { immediate: true })
</script>
<template>
<div v-if="character" class="grid mb-2 mt-4">
<div class="mb-2 border-b-1 flex">
<CharacterLabel class="flex grow mb-2" :character="character" :size="64" />
<div>
<button @click="save">Save</button>
</div>
</div>
<div class="flex-col border-b-1">
Rule Book:
<select class="me-2 mb-2 w-50" v-model="ruleBook">
<option v-for="rb in ruleBooks" :key="rb.ruleBookId" :value="rb">{{ rb.name }}</option>
</select>
</div>
<div class="flex-col border-b-1">
Ledger Bindings:
<div class="flex flex-wrap items-center mb-2 mt-2">
<div class="me-2" v-for="ref in ruleBook.ledgerRefs" :ref="ref">
<span class="me-1">{{ref}}:</span>
<LedgerSelect :ledgers="ledgersToUse" :modelValue="bindings[ref] ?? systemLedger" @update:modelValue="value => bindings[ref] = value" />
</div>
</div>
</div>
</div>
</template>
+120
View File
@@ -0,0 +1,120 @@
<script setup lang="ts">
import {useRoute, useRouter} from "vue-router";
import {ref, watch} from "vue";
import {useDebounceFn} from "@vueuse/core";
import log from "loglevel";
import {activityTypes, RuleInput, Rules, useRuleBooksStore} from "@/rules";
import {PlusIcon, TrashIcon} from "@heroicons/vue/24/outline";
import {routeNames} from "@/routes";
import {Dropdown} from "@/components";
const ruleBookId = ref<string>();
const name = ref<string>('');
const ledgerRefs = ref<string[]>([]);
const rules = ref<Rules>({});
const {findById, create, update, refresh} = useRuleBooksStore();
const router = useRouter();
const save = async () => {
if (!ruleBookId.value) {
const created = await create({
name: name.value,
ledgerRefs: ledgerRefs.value,
rules: rules.value
})
await router.push({ name: routeNames.editRuleBook, params: {ruleBookId: created.ruleBookId}})
} else {
await update(ruleBookId.value, {
name: name.value,
ledgerRefs: ledgerRefs.value,
rules: rules.value
})
}
}
const addLedgerRef = () => {
ledgerRefs.value = [...ledgerRefs.value, '']
}
const updateLedgerRef = useDebounceFn((index: number, value: string) => {
ledgerRefs.value[index] = value;
}, 500);
const removeLedgerRef = (index: number) => {
ledgerRefs.value = ledgerRefs.value.toSpliced(index, 1)
}
watch(useRoute(), async route => {
if (route.params.ruleBookId) {
const promise = refresh(); // FIXME don't call refresh
const id = typeof route.params.ruleBookId === 'string' ? route.params.ruleBookId : route.params.ruleBookId[0];
await promise;
const ruleBook = findById(id);
ruleBookId.value = id;
name.value = ruleBook?.name ?? '';
ledgerRefs.value = [...ruleBook?.ledgerRefs];
rules.value = {...ruleBook?.rules}; // TODO fully clone rules
log.info('Loaded rule book:', ruleBook);
} else {
ruleBookId.value = undefined;
name.value = '';
ledgerRefs.value = [];
rules.value = {};
log.info('No rule book to load');
}
}, { immediate: true })
</script>
<template>
<div class="grid mb-2 mt-4">
<div class="flex flex-col">
<div class="flex grow border-b-1">
Name:
<input class="mb-2 ms-2" type="text" v-model="name" />
</div>
<div class="border-b-1">
Ledgers References:
<div class="flex flex-wrap items-center">
<div class="flex items-center mb-2" v-for="(ledgerRef, index) in ledgerRefs" :key="index">
<input class="me-1" type="text" :value="ledgerRefs[index]" @input="updateLedgerRef(index, ($event.target as HTMLInputElement).value)" />
<button class="btn-icon me-2" @click="addLedgerRef"><TrashIcon /></button>
</div>
<div class="flex items-center mb-2">
<button class="btn-icon" @click="removeLedgerRef(index)"><PlusIcon /></button>
</div>
</div>
</div>
<div class="flex flex-col grow border-b-1" v-for="activityType in activityTypes" :key="activityType.key">
<Dropdown :inline="true" :autoClose="false" class="rule-dropdown">
<template #button>
<span>{{ activityType.name }}</span>
</template>
<RuleInput :ledgerRefs="ledgerRefs" v-model="rules[activityType.key]" />
</Dropdown>
</div>
</div>
<div class="mt-2 justify-end flex">
<div>
<button @click="save">Save</button>
</div>
</div>
</div>
</template>
<style scoped>
@reference "tailwindcss";
.rule-dropdown :deep(>button) {
@apply bg-slate-800 hover:bg-slate-800 border-none flex items-center w-full;
}
.rule-dropdown.dropdown-open :deep(>button) {
@apply bg-slate-800 rounded-b-none;
}
</style>
@@ -0,0 +1,18 @@
<script setup lang="ts">
import {storeToRefs} from "pinia";
import {CharacterLabel, useCharactersStore} from "@/characters";
import {PencilSquareIcon} from "@heroicons/vue/24/outline";
import {routeNames} from "@/routes";
const {characters} = storeToRefs(useCharactersStore());
</script>
<template>
<div class="grid mb-2 mt-4">
<div v-for="character in characters" :key="character.characterId" class="flex items-center mb-2">
<CharacterLabel class="flex grow" :character="character" />
<RouterLink class="btn-icon ms-2" :to="{ name: routeNames.editCharacterRulebook, params: { characterId: character.characterId } }"><PencilSquareIcon /></RouterLink>
</div>
</div>
</template>
+22
View File
@@ -0,0 +1,22 @@
<script setup lang="ts">
import {storeToRefs} from "pinia";
import {PencilSquareIcon, TrashIcon} from "@heroicons/vue/24/outline";
import {useRuleBooksStore} from "@/rules";
import {routeNames} from "@/routes";
const {ruleBooks} = storeToRefs(useRuleBooksStore());
</script>
<template>
<div class="grid mb-2 mt-4">
<div class="flex justify-end border-b-1">
<RouterLink class="button mb-2 ms-2" :to="{ name: routeNames.newRuleBook}">New Rule Book</RouterLink>
</div>
<div v-for="ruleBook in ruleBooks" :key="ruleBook.ruleBookId" class="flex items-center mt-2">
<span class="flex grow me-2">{{ruleBook.name}}</span>
<RouterLink class="btn-icon me-1" :to="{ name: routeNames.editRuleBook, params: { ruleBookId: ruleBook.ruleBookId } }"><PencilSquareIcon /></RouterLink>
<button class="btn-icon"><TrashIcon /></button>
</div>
</div>
</template>
+2 -1
View File
@@ -12,7 +12,8 @@ const modelValue = defineModel({ default: false });
</label>
</template>
<style scoped lang="postcss">
<style scoped>
@reference "tailwindcss";
input:checked ~ span:last-child {
--tw-translate-x: 1.75rem;
}
+1 -5
View File
@@ -1,5 +1,3 @@
import { marbasAxiosInstance } from "@/marbas";
export type ReprocessItemValues = {
typeID: number;
name: string;
@@ -22,7 +20,5 @@ export const reprocess = async (items: string, minerals: string, efficiency?: nu
};
const source = JSON.stringify(sourceJson);
const response = await marbasAxiosInstance.post('/reprocess/', source, {params: {efficiency: efficiency ?? 0.55}});
return response.data;
return []
};
+54 -14
View File
@@ -1,16 +1,56 @@
import { RouteRecordRaw } from 'vue-router';
import {RouteRecordRaw} from 'vue-router';
export const routeNames = {
home: 'home',
callback: 'callback',
viewLedger: 'view-ledger',
viewLedgerBalance: 'view-ledger-balance',
listLedgerTransactions: 'list-ledger-transactions',
listRuleBooks: 'list-rule-books',
newRuleBook: 'new-rule-book',
editRuleBook: 'edit-rule-book',
editCharacterRulebook: 'edit-character-rule-book',
marketTypes: 'market-types',
about: 'about',
} as const;
export const routes: RouteRecordRaw[] = [
{ path: '/', name: 'home', component: () => import('@/pages/Index.vue') },
{ path: '/callback', name: 'callback', component: () => import('@/pages/Index.vue') },
{ path: '/reprocess', component: () => import('@/pages/Reprocess.vue') },
{ path: '/market', component: () => import('@/pages/Market.vue'), children: [
{ path: '', redirect: '/market/types' },
{ path: 'types/:type?', name: 'market-types', component: () => import('@/pages/market/TypeInfo.vue') },
{ path: 'tracking', component: () => import('@/pages/market/Tracking.vue') },
{ path: 'acquisitions', component: () => import('@/pages/market/Acquisitions.vue') },
] },
{ path: '/tools', component: () => import('@/pages/Tools.vue') },
{ path: '/characters', component: () => import('@/pages/Characters.vue') },
{ path: '/about', name: 'about', component: () => import('@/pages/About.vue') },
];
{path: '/', name: routeNames.home, component: () => import('@/pages/Index.vue')},
{path: '/callback', name: routeNames.callback, component: () => import('@/pages/Index.vue')},
{path: '/ledgers', component: () => import('@/pages/Ledgers.vue'), children: [
{path: '', component: () => import('@/pages/ledger/ListLedgers.vue')},
{path: ':ledgerId', component: () => import('./pages/ledger/ViewLedger.vue'), children: [
{path: '', name: routeNames.viewLedger, redirect: {name: routeNames.viewLedgerBalance}},
{path: 'balance', name: routeNames.viewLedgerBalance, component: () => import('@/pages/ledger/ViewLedgerBalance.vue')},
{path: 'transactions', name: routeNames.listLedgerTransactions, component: () => import('@/pages/ledger/ListLedgerTransactions.vue')},
]},
]},
{path: '/rules', component: () => import('@/pages/Rules.vue'), children: [
{path: '', redirect: {name: routeNames.listRuleBooks}},
{path: '/rule-books', children: [
{path: '', name: routeNames.listRuleBooks, component: () => import('@/pages/rules/ListRuleBooks.vue')},
{path: 'new', name: routeNames.newRuleBook, component: () => import('@/pages/rules/EditRuleBook.vue')},
{path: ':ruleBookId', name: routeNames.editRuleBook, component: () => import('@/pages/rules/EditRuleBook.vue')},
]},
{path: '/characters/rules', children: [
{path: '', component: () => import('@/pages/rules/ListCharacterRuleBooks.vue')},
{path: '/characters/:characterId/rules', name: routeNames.editCharacterRulebook, component: () => import('@/pages/rules/EditCharacterRuleBook.vue')},
]}
]},
{path: '/market', component: () => import('@/pages/Market.vue'), children: [
{path: '', redirect: {name: routeNames.marketTypes}},
{path: 'types/:type?', name: routeNames.marketTypes, component: () => import('@/pages/market/TypeInfo.vue')},
{path: 'tracking', component: () => import('@/pages/market/Tracking.vue')},
{path: 'acquisitions', component: () => import('@/pages/market/Acquisitions.vue')},
]},
{path: '/reprocess', component: () => import('@/pages/Reprocess.vue')},
{path: '/tools', component: () => import('@/pages/Tools.vue')},
{path: '/characters', component: () => import('@/pages/Characters.vue')},
{path: '/about', name: routeNames.about, component: () => import('@/pages/About.vue')},
] as const;
+57
View File
@@ -0,0 +1,57 @@
<script setup lang="ts">
import {RuleClauseResponse} from "@/generated/mammon";
import {computed, watch} from "vue";
import {systemLedgerRef} from "@/ledger";
import {ratesTypes} from "@/rules/rules.ts";
interface Props {
ledgerRefs: string[];
}
const props = defineProps<Props>()
const rule = defineModel<RuleClauseResponse>({ default: {
rate: ratesTypes.None,
fromLedgerRef: systemLedgerRef,
toLedgerRef: systemLedgerRef,
}});
const ledgerRefsWithSystem = computed<string[]>(() => [systemLedgerRef, ...props.ledgerRefs])
watch(ledgerRefsWithSystem, (newVal, oldVal) => {
if (newVal.length !== oldVal.length) {
return;
}
if (rule.value.fromLedgerRef && rule.value.fromLedgerRef !== systemLedgerRef) {
rule.value.fromLedgerRef = newVal[oldVal.findIndex(v => v === rule.value.fromLedgerRef)]
}
if (rule.value.toLedgerRef && rule.value.toLedgerRef !== systemLedgerRef) {
rule.value.toLedgerRef = newVal[oldVal.findIndex(v => v === rule.value.toLedgerRef)]
}
})
</script>
<template>
From:
<select class="me-2 grow" v-model="rule.fromLedgerRef" :class="{'system-ledger': rule.fromLedgerRef === systemLedgerRef}">
<option v-for="l in ledgerRefsWithSystem" :key="l" :value="l" :class="{'system-ledger': l === systemLedgerRef}">{{ l }}</option>
</select>
To:
<select class="me-2 grow" v-model="rule.toLedgerRef" :class="{'system-ledger': rule.toLedgerRef === systemLedgerRef}">
<option v-for="l in ledgerRefsWithSystem" :key="l" :value="l" :class="{'system-ledger': l === systemLedgerRef}">{{ l }}</option>
</select>
At:
<select class="me-2 grow" v-model="rule.rate">
<option v-for="rateType in ratesTypes" :key="rateType.key" :value="rateType.key">{{ rateType.name }}</option>
</select>
</template>
<style scoped>
@reference "tailwindcss";
.system-ledger {
@apply text-emerald-400;
}
</style>
+76
View File
@@ -0,0 +1,76 @@
<script setup lang="ts">
import {RuleClauseResponse, RuleClauseResponseRateEnum, RuleResponse} from "@/generated/mammon";
import RuleClauseInput from "@/rules/RuleClauseInput.vue";
import {computed, useTemplateRef} from "vue";
import {Bars4Icon, PlusIcon, TrashIcon} from '@heroicons/vue/24/outline';
import {useSortable} from "@vueuse/integrations/useSortable";
import {systemLedgerRef} from "@/ledger";
interface Props {
ledgerRefs: string[];
}
const props = defineProps<Props>()
const rule = defineModel<RuleResponse>({default: {clauses:[]}});
const clauses = computed<RuleClauseResponse[]>({
get: () => rule.value && rule.value.clauses ? rule.value.clauses : [],
set: value => rule.value = {clauses: value}
})
const addClause = () => {
clauses.value = [...clauses.value, {
rate: RuleClauseResponseRateEnum.None,
fromLedgerRef: systemLedgerRef,
toLedgerRef: systemLedgerRef
}]
}
const setClause = (index: number, clause?: RuleClauseResponse) => {
if (!clause) {
return;
}
clauses.value = clauses.value.with(index, clause)
}
const removeClause = (index: number) => {
clauses.value = clauses.value.toSpliced(index, 1)
}
const sortableContainer = useTemplateRef('sortable-container')
useSortable(sortableContainer, clauses, { handle: '.sortable-handle'});
</script>
<template>
<div class="flex-col">
<div ref="sortable-container" class="flex-col">
<div class="flex items-end gap-2 mt-2" v-for="(clause, index) in clauses" :key="index">
<span class="sortable-handle flex">
<Bars4Icon class="w-6"/>
</span>
<RuleClauseInput :ledgerRefs="ledgerRefs" :modelValue="clause" @update:modelValue="v => setClause(index, v)" />
<button class="btn-icon" @click="removeClause(index)"><TrashIcon /></button>
</div>
</div>
<div class="flex justify-end mb-2 mt-2">
<button class="btn-icon" @click="addClause"><PlusIcon /></button>
</div>
</div>
</template>
<style scoped>
@reference "tailwindcss";
.sortable-handle {
@apply cursor-grab;
}
.sortable-chosen {
@apply cursor-grabbing;
}
.sortable-chosen .sortable-handle {
@apply cursor-grabbing;
}
</style>
+3
View File
@@ -0,0 +1,3 @@
export * from "./rules";
export {default as RuleInput} from './RuleInput.vue';
+72
View File
@@ -0,0 +1,72 @@
import {characterRuleBookApi, ruleBookApi} from "@/mammon";
import {
CharacterRuleBookResponse,
CreateRuleBookRequest,
RuleBookResponse,
RuleClauseResponseRateEnum,
RuleResponse,
SetCharacterRuleBookRequest
} from "@/generated/mammon";
import {defineStore} from "pinia";
import {ref, triggerRef} from "vue";
export const activityTypes = {
itemBought: {key: "ITEM_BOUGHT", name: "Item Bought"},
itemSold: {key: "ITEM_SOLD", name: "Item Sold"},
itemAcquiredManually: {key: "ITEM_ACQUIRED_MANUALLY", name: "Item Acquired Manually"},
itemConsumedManually: {key: "ITEM_CONSUME_MANUALLY", name: "Item Consumed Manually"},
// bountyEarned: {id: "BOUNTY_EARNED", name: "Bounty Earned"},
// itemManufactured: {id: "ITEM_MANUFACTURED", name: "Item Manufactured"}
} as const;
export type Activity = { key: ActivityType, name: string }
export type ActivityType = typeof activityTypes[keyof typeof activityTypes]['key'];
export type Rules = { [key: ActivityType]: RuleResponse; };
export type RuleBook = RuleBookResponse & { rules: Rules }
export const ratesTypes = {
None: {key: "NONE", name: "0 ISK"},
Value: {key: "VALUE", name: "Value"},
JitaBuy: {key: "JITA_BUY", name: "Jita Buy Order"},
JitaSell: {key: "JITA_SELL", name: "Jita Sell Order"},
EveEstimate: {key: "EVE_ESTIMATE", name: "Eve Estimate"},
} as const;
export type Rate = { key: RuleClauseResponseRateEnum, name: string }
export const useRuleBooksStore = defineStore('rule-books', () => {
const ruleBooks = ref<RuleBook[]>([]);
const addRuleBook = (ruleBook: RuleBook) => {
ruleBooks.value.push(ruleBook);
triggerRef(ruleBooks);
return ruleBook;
};
const replaceRuleBook = (ruleBook: RuleBook) => {
const index = ruleBooks.value.findIndex(rb => rb.ruleBookId === ruleBook.ruleBookId);
if (index !== -1) {
ruleBooks.value[index] = ruleBook;
}
triggerRef(ruleBooks);
return ruleBook;
};
const findById = (ruleBookId: string): RuleBook | undefined => ruleBooks.value.find(rb => rb.ruleBookId === ruleBookId);
const create = (ruleBook: CreateRuleBookRequest) => ruleBookApi.createRuleBook(ruleBook).then(response => addRuleBook(response.data));
const update = (ruleBookId: string, ruleBook: CreateRuleBookRequest) => ruleBookApi.updateRuleBook(ruleBookId, ruleBook).then(response => replaceRuleBook(response.data));
const refresh = () => ruleBookApi.findAllRuleBooks().then(response => ruleBooks.value = response.data as RuleBook[]);
refresh();
return {ruleBooks, findById, create, update, refresh};
})
export const findCharacterRuleBookByCharacterId = (characterId: number): Promise<CharacterRuleBookResponse> => characterRuleBookApi.findCharacterRuleBookByCharacterId(characterId)
.then(response => response.data)
.catch(() => ({characterId, rules: {}}));
export const setCharacterRuleBookForCharacter = (characterId: number, ruleBook: SetCharacterRuleBookRequest): Promise<CharacterRuleBookResponse> => characterRuleBookApi.setCharacterRuleBookForCharacter(characterId, ruleBook)
.then(response => response.data);
+61 -53
View File
@@ -1,73 +1,81 @@
<script setup lang="ts">
import { useAuthStore } from '@/auth';
import { Dropdown } from '@/components';
import { RouterLink } from 'vue-router';
import {Dropdown} from '@/components';
import {RouterLink} from 'vue-router';
import {routeNames} from '@/routes';
const links = [
{ name: "Market", path: "/market" },
{ name: "Reprocess", path: "/reprocess" },
{ name: "Tools", path: "/tools" }
{name: "Ledger", path: "/ledgers"},
{name: "Rules", path: "/rules"},
{name: "Market", path: "/market"},
{name: "Reprocess", path: "/reprocess"},
{name: "Tools", path: "/tools"}
];
const authStore = useAuthStore();
const logout = async () => {
await authStore.logout();
}
</script>
<template>
<aside class="fixed top-0 left-0 w-64 h-screen transition-transform -translate-x-full sm:translate-x-0">
<div class="h-full px-3 py-4 overflow-y-auto bg-slate-700 flex flex-col">
<div class="mb-2 border-b-2 border-emerald-500">
<Dropdown class="mb-2 user-dropdown">
<template #button>
<span>{{ authStore.username }}</span>
</template>
<ul>
<li>
<RouterLink class="sidebar-button py-0.5 px-2" to="/characters">Characters</RouterLink>
</li>
<li>
<RouterLink class="sidebar-button py-0.5 px-2" :to="{name: 'about'}">About EVE Online</RouterLink>
</li>
<li>
<a class="sidebar-button py-0.5 px-2 text-amber-700" @click="logout">Logout</a>
</li>
</ul>
</Dropdown>
</div>
<ul class="space-y-2 font-medium">
<li v-for="link in links" :key="link.name">
<RouterLink :to="link.path" class="sidebar-button p-2">
<span>{{ link.name }}</span>
</RouterLink>
</li>
</ul>
</div>
</aside>
<aside class="fixed top-0 left-0 w-64 h-screen transition-transform -translate-x-full sm:translate-x-0">
<div class="h-full px-3 py-4 overflow-y-auto bg-slate-700 flex flex-col">
<div class="mb-2 border-b-2 border-emerald-500">
<Dropdown class="mb-2 user-dropdown">
<template #button>
<span>NAME</span>
</template>
<ul>
<li>
<RouterLink class="sidebar-button py-0.5 px-2" to="/characters">Characters</RouterLink>
</li>
<li>
<RouterLink class="sidebar-button py-0.5 px-2" :to="{name: routeNames.about}">About EVE Online</RouterLink>
</li>
<li>
<a class="sidebar-button py-0.5 px-2 text-amber-700" @click="logout">Logout</a>
</li>
</ul>
</Dropdown>
</div>
<ul class="space-y-2 font-medium">
<li v-for="link in links" :key="link.name">
<RouterLink :to="link.path" class="sidebar-button p-2">
<span>{{ link.name }}</span>
</RouterLink>
</li>
</ul>
</div>
</aside>
</template>
<style scoped lang="postcss">
<style scoped>
@reference "tailwindcss";
.sidebar-button {
@apply flex items-center rounded-md hover:bg-slate-800 cursor-pointer;
@apply flex items-center rounded-md hover:bg-slate-800 cursor-pointer;
}
.router-link-active {
@apply bg-emerald-500 hover:bg-emerald-700;
@apply bg-emerald-500 hover:bg-emerald-700;
}
.user-dropdown {
@apply w-full;
:deep(>div) {
@apply w-full;
>div {
@apply w-full bg-slate-800;
}
}
:deep(>button) {
@apply bg-slate-700 hover:bg-slate-800 border-none flex items-center w-full;
}
&.dropdown-open:deep(>button) {
@apply bg-slate-800 rounded-b-none;
}
@apply w-full;
}
.user-dropdown :deep(>div) {
@apply w-full;
> div {
@apply w-full bg-slate-800;
}
}
.user-dropdown :deep(>button) {
@apply bg-slate-700 hover:bg-slate-800 border-none flex items-center w-full;
}
.user-dropdown.dropdown-open :deep(>button) {
@apply bg-slate-800 rounded-b-none;
}
</style>
+18 -7
View File
@@ -1,9 +1,9 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
@import "tailwindcss";
@custom-variant search-cancel (&::-webkit-search-cancel-button);
@layer base {
span, table, input, th, tr, td, button, div, hr {
span, table, input, th, tr, td, button, a.button, div, hr {
@apply border-slate-600 text-slate-100 placeholder-slate-400;
}
@@ -11,12 +11,15 @@
@apply bg-slate-800;
}
button {
button, a.button {
@apply py-0.5 px-2 border rounded bg-slate-600 hover:bg-slate-700;
}
input {
input, select {
@apply border bg-slate-500 rounded px-1;
}
option {
@apply bg-slate-500;
}
textarea {
@apply border rounded bg-slate-500 w-full;
}
@@ -69,9 +72,17 @@
}
.btn-icon {
@apply p-0 border-none bg-transparent hover:text-slate-400 hover:bg-transparent;
@apply p-0 border-none bg-transparent hover:text-slate-400 hover:bg-transparent cursor-pointer;
> svg {
@apply w-6 h-6;
}
}
a.tab {
@apply flex items-center px-4 me-2 rounded-t-md bg-slate-600 hover:bg-slate-700;
&.router-link-active {
@apply bg-emerald-500 hover:bg-emerald-700;
}
}
}
+1 -1
View File
@@ -1 +1 @@
export const copyToClipboard = (s: string) => navigator.clipboard.writeText(s);
export const copyToClipboard = (s: string) => navigator.clipboard.writeText(s);
-16
View File
@@ -1,16 +0,0 @@
/** @type {import('tailwindcss').Config} */
export default {
content: [
"./index.html",
"./src/**/*.{vue,js,ts,jsx,tsx}",
],
theme: {
extend: {},
},
plugins: [
require('tailwindcss/plugin')(({ addVariant }) => {
addVariant('search-cancel', '&::-webkit-search-cancel-button');
}),
],
}
+2 -1
View File
@@ -26,7 +26,8 @@
"src/*": [
"./src/*"
]
}
},
"allowSyntheticDefaultImports": true
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
"references": [{ "path": "./tsconfig.node.json" }]
+2
View File
@@ -2,11 +2,13 @@ import vue from '@vitejs/plugin-vue';
import * as path from "path";
import { defineConfig } from 'vite';
import runtimeEnv from 'vite-plugin-runtime-env';
import tailwindcss from '@tailwindcss/vite'
export default defineConfig({
plugins: [
runtimeEnv(),
vue(),
tailwindcss(),
],
resolve: {
alias: {