-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Starting with UI impl for add transaction (#244)
- Loading branch information
Showing
16 changed files
with
318 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,5 @@ mgo | |
coverage.cov | ||
money.db | ||
.DS_Store | ||
__debug* | ||
moneyd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ | |
"portfoliov", | ||
"protobuf", | ||
"protoreflect", | ||
"rgossiaux", | ||
"secmap", | ||
"secres", | ||
"steeze", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<script lang="ts"> | ||
import type { HTMLButtonAttributes } from 'svelte/elements'; | ||
let clazz: string | undefined | null = null; | ||
export { clazz as class }; | ||
interface $$Props extends HTMLButtonAttributes { | ||
class?: string | undefined | null; | ||
} | ||
</script> | ||
|
||
<button | ||
type="button" | ||
class="mt-5 rounded-md bg-indigo-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 | ||
focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600 | ||
{clazz ?? ''} | ||
" | ||
on:click | ||
{...$$restProps} | ||
> | ||
<slot /> | ||
</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<script lang="ts"> | ||
export let value: number; | ||
export let currency: string = 'EUR'; | ||
export let symbol: string = '€'; | ||
export let name: string; | ||
</script> | ||
|
||
<div class="sm:grid sm:grid-cols-3 sm:items-start sm:gap-4 sm:py-6"> | ||
<label for={name} class="block text-sm font-medium leading-6 text-gray-900 sm:pt-1.5"> | ||
<slot /> | ||
</label> | ||
<div class="relative mt-2 rounded-md shadow-sm"> | ||
<div class="pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3"> | ||
<span class="text-gray-500 sm:text-sm">{symbol}</span> | ||
</div> | ||
<input | ||
type="number" | ||
{name} | ||
id={name} | ||
bind:value | ||
class="block w-full rounded-md border-0 py-1.5 pl-7 pr-12 text-gray-900 ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 | ||
focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6" | ||
placeholder="0.00" | ||
aria-describedby="price-currency" | ||
/> | ||
<div class="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3"> | ||
<span class="text-gray-500 sm:text-sm" id="price-currency">{currency}</span> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<script lang="ts"> | ||
import type { Security } from '$lib/gen/mgo_pb'; | ||
import { Check, ChevronUpDown } from '@steeze-ui/heroicons'; | ||
import { Icon } from '@steeze-ui/svelte-icon'; | ||
import { createListbox } from 'svelte-headlessui'; | ||
import { Transition } from 'svelte-transition'; | ||
const listbox = createListbox({ label: 'Securities', selected: null }); | ||
export let securities: Security[]; | ||
export let securityName: string | undefined; | ||
$: securityName = $listbox.selected?.name ?? undefined; | ||
</script> | ||
|
||
<div class="relative mt-2"> | ||
<button | ||
use:listbox.button | ||
class=" | ||
relative w-full cursor-default rounded-md bg-white py-1.5 pl-3 pr-10 text-left text-gray-900 shadow-sm ring-1 | ||
ring-inset ring-gray-300 focus:outline-none focus:ring-2 focus:ring-indigo-500 sm:text-sm sm:leading-6" | ||
> | ||
<span class="inline-flex w-full truncate"> | ||
{#if $listbox.selected} | ||
<span class="truncate">{$listbox.selected.displayName}</span> | ||
{:else} | ||
<span class="truncate">Please select a security</span> | ||
{/if} | ||
</span> | ||
<span class="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2"> | ||
<Icon src={ChevronUpDown} class="h-5 w-5 text-gray-400" aria-hidden="true" /> | ||
</span> | ||
</button> | ||
|
||
<Transition | ||
show={$listbox.expanded} | ||
leave="transition ease-in duration-100" | ||
leaveFrom="opacity-100" | ||
leaveTo="opacity-0" | ||
> | ||
<ul | ||
use:listbox.items | ||
class=" | ||
absolute z-10 mt-1 max-h-60 w-full overflow-auto rounded-md bg-white py-1 text-base shadow-lg ring-1 | ||
ring-black ring-opacity-5 focus:outline-none sm:text-sm" | ||
> | ||
{#each securities as value (value.name)} | ||
{@const active = $listbox.active === value} | ||
{@const selected = $listbox.selected === value} | ||
<li | ||
use:listbox.item={{ value }} | ||
class="{active | ||
? 'bg-indigo-600 text-white' | ||
: 'text-gray-900'} relative cursor-default select-none py-2 pl-3 pr-9" | ||
> | ||
<div class="flex"> | ||
<span class="{selected ? 'font-semibold' : 'font-normal'} truncate"> | ||
{value.displayName} | ||
</span> | ||
</div> | ||
|
||
{#if selected} | ||
<span | ||
class="{active | ||
? 'text-white' | ||
: 'text-indigo-600'} absolute inset-y-0 right-0 flex items-center pr-4" | ||
> | ||
<Icon src={Check} class="h-5 w-5" aria-hidden="true" /> | ||
</span> | ||
{/if} | ||
</li> | ||
{/each} | ||
</ul> | ||
</Transition> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,14 @@ | ||
import 'inter-ui/inter.css'; | ||
import '../app.css'; | ||
import { securitiesClient } from '$lib/api/client'; | ||
import type { LayoutLoad } from './$types'; | ||
|
||
export const ssr = false; | ||
|
||
export const load = (async ({ fetch }) => { | ||
const client = securitiesClient(fetch); | ||
|
||
const securities = (await client.listSecurities({})).securities; | ||
|
||
return { securities }; | ||
}) satisfies LayoutLoad; |
13 changes: 6 additions & 7 deletions
13
ui/src/routes/portfolios/[...name]/+page.ts → .../portfolios/[...portfolioName]/+layout.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
import type { PageLoad } from './$types'; | ||
import type { LayoutData } from './$types'; | ||
import { error } from '@sveltejs/kit'; | ||
import type { Portfolio } from '$lib/gen/mgo_pb'; | ||
import { portfolioClient } from '$lib/api/client'; | ||
|
||
export const load = (async ({ fetch, params }) => { | ||
if (params.name == undefined) { | ||
if (params.portfolioName == undefined) { | ||
throw error(405, 'Required parameter missing'); | ||
} | ||
|
||
const client = portfolioClient(fetch); | ||
console.log(params.name); | ||
console.log(params.portfolioName); | ||
|
||
const portfolio = client.getPortfolio({ name: params.name }); | ||
const snapshot = client.getPortfolioSnapshot({ portfolioName: params.name }); | ||
const portfolio = client.getPortfolio({ name: params.portfolioName }); | ||
const snapshot = client.getPortfolioSnapshot({ portfolioName: params.portfolioName }); | ||
|
||
return { portfolio, snapshot }; | ||
}) as PageLoad; | ||
}) as LayoutData; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.