Skip to content

Commit

Permalink
Merge pull request #17 from celenium-io/dusk-11
Browse files Browse the repository at this point in the history
Dusk 11
  • Loading branch information
GusevPM authored Oct 19, 2024
2 parents ce6d184 + 6e525ac commit 8cf2858
Show file tree
Hide file tree
Showing 13 changed files with 363 additions and 43 deletions.
20 changes: 3 additions & 17 deletions components/SearchField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ const handleSaveToHistory = (target) => {
}
const getResultPath = (result) => {
if (!result) return
switch (result.type) {
case "address":
return `/account/${result.body.hash}`
Expand All @@ -133,29 +135,13 @@ const getResultPath = (result) => {
}
}
const getItemLink = (item) => {
switch (item.type) {
case "address":
return `/account/${result.body.hash}`
case "block":
return `/block/${result.body.height}`
case "validator":
return `/validator/${result.body.id}`
case "bridge":
return `/account/${result.body.address}`
default:
return `/${item.type === 'address' ? 'account' : item.type}/${item.body.hash}`
}
}
const onKeydown = (e) => {
if (e.code === "Escape") {
show.value = false
inputEl.value.blur()
}
if (e.code === "Enter") {
if (e.code === "Enter" && results.value.length) {
const target = results.value[0]
router.push(getResultPath(target))
Expand Down
35 changes: 35 additions & 0 deletions components/modules/account/AccountDeposits.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<script setup>
import EmptyHolder from "~/components/shared/EmptyHolder.vue"
import LoadingHolder from "@/components/shared/LoadingHolder.vue"
import DepositsTable from "~/components/tables/DepositsTable.vue"
const props = defineProps({
deposits: {
type: Array,
},
isLoading: {
type: Boolean,
}
})
</script>

<template>
<Flex direction="column" :class="$style.wrapper">
<LoadingHolder v-if="isLoading" title="Loading bridge deposits.." />

<DepositsTable v-if="deposits.length > 0" :isLoading="isLoading" :deposits="deposits" />

<EmptyHolder v-else-if="!isLoading" title=" This account did not receive any deposits" />
</Flex>
</template>

<style module>
.wrapper {
position: relative;
border-radius: 8px;
box-shadow: inset 0 0 0 1px var(--op-5);
background: var(--op-3);
/* padding: 8px 0 8px 0; */
}
</style>
35 changes: 35 additions & 0 deletions components/modules/rollup/RollupDeposits.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<script setup>
import EmptyHolder from "~/components/shared/EmptyHolder.vue"
import LoadingHolder from "@/components/shared/LoadingHolder.vue"
import DepositsTable from "~/components/tables/DepositsTable.vue"
const props = defineProps({
deposits: {
type: Array,
},
isLoading: {
type: Boolean,
}
})
</script>

<template>
<Flex direction="column" :class="$style.wrapper">
<LoadingHolder v-if="isLoading" title="Loading deposits.." />

<DepositsTable v-if="deposits.length > 0" :isLoading="isLoading" :deposits="deposits" />

<EmptyHolder v-else-if="!isLoading" title=" This rollup did not wire any deposits" />
</Flex>
</template>

<style module>
.wrapper {
position: relative;
border-radius: 8px;
box-shadow: inset 0 0 0 1px var(--op-5);
background: var(--op-3);
/* padding: 8px 0 8px 0; */
}
</style>
2 changes: 1 addition & 1 deletion components/tables/AccountsTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const props = defineProps({
<Flex align="center" gap="8">
<Text size="12" weight="500" color="secondary">
<Text color="tertiary">Balance</Text>
{{ `${spaces(account.balances[0]?.value)}${account.balances.length ? account.balances[0]?.currency.toUpperCase() : ''}` }}
{{ `${spaces(account.balances[0]?.value)}${account.balances.length ? ' ' + account.balances[0]?.currency.toUpperCase() : ''}` }}
</Text>
<div :class="$style.dot" />
Expand Down
4 changes: 2 additions & 2 deletions components/tables/ActionsTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const handleOpenTx = async (action) => {
</Text>
</Flex>

<Flex v-if="act.type === 'sequence'" gap="4" :class="$style.description">
<Flex v-if="act.type === 'rollup_data_submission'" gap="4" :class="$style.description">
<Text size="13" weight="500" color="secondary">
{{ `Pushed ${getActionDataLength(act)} to` }}
</Text>
Expand Down Expand Up @@ -297,7 +297,7 @@ const handleOpenTx = async (action) => {
<Flex align="center" gap="8">
<Text size="12" color="tertiary">Block</Text>

<LinkToEntity :entity="{ title: spaces(act.height), type: 'block', id: act.height }" :class="$style.link" />
<LinkToEntity :entity="{ title: spaces(act.height), type: 'block', id: act.height }" color="secondary" :class="$style.link" />

<div :class="$style.dot" />

Expand Down
185 changes: 185 additions & 0 deletions components/tables/DepositsTable.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
<script setup>
/** Vendor */
import { DateTime } from "luxon"
/** UI */
import Tooltip from "@/components/ui/Tooltip.vue"
/** Components */
import LinkToEntity from "@/components/shared/LinkToEntity.vue"
/** Services */
import { capitalize, formatBytes, midHash, spaces } from "@/services/utils"
import { getRollupHashSafeURL } from "~/services/utils/rollups"
/** API */
import { fetchTxByHash } from "~/services/api/tx"
/** Store */
import { useSidebarsStore } from "@/store/sidebars"
const sidebarsStore = useSidebarsStore()
const props = defineProps({
deposits: {
type: Array,
},
})
const handleOpenTx = async (deposit) => {
const { data } = await fetchTxByHash(deposit.tx_hash)
if (data.value) {
sidebarsStore.open("tx", data.value)
}
}
</script>

<template>
<Flex direction="column" :class="$style.wrapper">
<Flex
v-if="deposits"
v-for="d in deposits"
@click="handleOpenTx(d)"
justify="between"
align="center"
:class="[$style.row, isLoading && $style.disabled]"
>
<Flex direction="column" gap="8">
<Flex align="center" gap="6">
<Icon name="role" size="16" color="secondary" />

<Flex v-if="d.bridge" gap="4">
<Text size="13" weight="500" color="primary">
{{ `Wired deposit of ${spaces(d.amount)} ${(d.asset).toUpperCase()} to` }}
</Text>

<LinkToEntity
:entity="{ title: midHash(d.bridge), type: 'account', id: d.bridge }"
color="primary"
size="13"
:class="$style.link"
/>
</Flex>

<Text v-else size="13" weight="500" color="primary">
{{ `Received deposit of ${spaces(d.amount)} ${(d.asset).toUpperCase()}` }}
</Text>
</Flex>

<Flex align="center" gap="8">
<Text size="12" color="tertiary">Block</Text>

<LinkToEntity :entity="{ title: spaces(d.height), type: 'block', id: d.height }" color="secondary" :class="$style.link" />

<div :class="$style.dot" />

<Text size="12" color="tertiary"> {{ DateTime.fromISO(d.time).setLocale("en").toFormat("tt, LLL d, y") }} </Text>
</Flex>
</Flex>

<Tooltip>
<!-- <Flex align="center" gap="4">
<Text size="13" weight="600" color="primary"> {{ spaces(rollup.actions_count) }} </Text>
<Icon name="action" size="13" color="tertiary" />
</Flex>
<template #content>
<Text size="12" color="tertiary">Actions count</Text>
</template> -->
</Tooltip>
</Flex>
</Flex>
</template>

<style module>
.wrapper {
position: relative;
}
.loading {
position: absolute;
top: 50%;
left: 50%;
transform: translateY(-50%) translateX(-50%);
}
.row {
height: 60px;
border-top: 1px solid var(--op-5);
cursor: pointer;
padding: 0 16px;
transition: all 0.2s ease;
&:hover {
background: var(--op-5);
}
&:first-child {
border-top-left-radius: 8px;
border-top-right-radius: 8px;
border-top: none;
}
&:last-child {
border-bottom-left-radius: 8px;
border-bottom-right-radius: 8px;
}
&:active {
background: var(--op-10);
}
&.disabled {
pointer-events: none;
opacity: 0.2;
}
}
.row_general_list {
height: 60px;
border-top: 1px solid var(--op-5);
cursor: pointer;
padding: 0 16px;
transition: all 0.2s ease;
&:hover {
background: var(--op-5);
}
&:last-child {
border-bottom-left-radius: 8px;
border-bottom-right-radius: 8px;
}
&:active {
background: var(--op-10);
}
&.disabled {
pointer-events: none;
opacity: 0.2;
}
}
.dot {
width: 4px;
height: 4px;
border-radius: 50%;
background: var(--op-10);
}
.link {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
</style>
Loading

0 comments on commit 8cf2858

Please sign in to comment.