Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Oracles details events tab 2 #196

Merged
merged 31 commits into from
May 16, 2023
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
6e937f8
add orecleEvents UI
janmichek May 2, 2023
a7c1077
add response button ui
janmichek May 2, 2023
5e0b593
add pagination
janmichek May 2, 2023
49f7291
add query panel to condensed view
janmichek May 3, 2023
e63c2fb
add button icons
janmichek May 3, 2023
bf3880f
fix conditional styling of table rows
janmichek May 3, 2023
08f10b8
replace missing walues with placeholder
janmichek May 3, 2023
2f06129
code cleanup
janmichek May 3, 2023
dcc8130
adjust query response
janmichek May 3, 2023
b3584b2
add scoped style
janmichek May 3, 2023
4834bbc
remove console.log
janmichek May 3, 2023
de0dea5
fix css order
janmichek May 3, 2023
c47bfa8
fix table markup
janmichek May 4, 2023
2d7925f
remove unneccessary prop
janmichek May 4, 2023
9f88ae8
prop fixes
janmichek May 4, 2023
9a86e5e
rewire UI to oracle endpoint
janmichek May 8, 2023
3c3ac2a
rename classname
janmichek May 8, 2023
a8c4b3e
rewire to response endpoint
janmichek May 9, 2023
ef4e556
fix code indent
janmichek May 9, 2023
3a5d97a
rename class names
janmichek May 9, 2023
5b86a63
fix open oracle detail in new tab
janmichek May 9, 2023
301e752
fix typo
janmichek May 10, 2023
9085533
remove unnecessary styling
janmichek May 10, 2023
dcb3b40
remove unused prop
janmichek May 10, 2023
c5f9b73
revert async data fetching
janmichek May 10, 2023
912a67f
fix printing query and response
janmichek May 10, 2023
d4138de
fix pagination
janmichek May 10, 2023
e23c398
fix pagination UX
janmichek May 10, 2023
7d8782f
change pagination label style
janmichek May 10, 2023
8fb54d4
Merge branch 'develop' into Oracles_details_events_tab_2
janmichek May 10, 2023
e453fa5
sanitize failed data fetching
janmichek May 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/assets/icons/minus-circle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/icons/plus-circle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
67 changes: 67 additions & 0 deletions src/components/OracleEventsPanel.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<template>
<app-panel class="oracle-events-panel">
<paginated-content
:entities="oracleEvents"
@prev-clicked="loadPrevEvents"
@next-clicked="loadNextEvents">
<oracle-events-table
v-if="oracleEvents"
:oracle-events="oracleEvents"
class="oracle-events-panel__table"/>

<oracle-events-table-condensed
v-if="oracleEvents"
:oracle-events="oracleEvents"
class="oracle-events-panel__table-condensed"/>
</paginated-content>
</app-panel>
</template>
<script setup>
import { storeToRefs } from 'pinia'
import { useOracleDetailsStore } from '@/stores/oracleDetails'
import OracleEventsTable from '@/components/OracleEventsTable'
import OracleEventsTableCondensed from '@/components/OracleEventsTableCondensed'

const oracleDetailsStore = useOracleDetailsStore()
const { oracleEvents } = storeToRefs(oracleDetailsStore)
const { fetchOracleEvents } = oracleDetailsStore

function loadPrevEvents() {
fetchOracleEvents({ queryParameters: oracleEvents.value.prev })
}

function loadNextEvents() {
fetchOracleEvents({ queryParameters: oracleEvents.value.next })
}

if (process.client) {
const limit = computed(() => isDesktop() ? 10 : 3)
await fetchOracleEvents({
limit: limit.value,
})
}
</script>

<style scoped>
.oracle-events-panel {
padding: var(--space-3) var(--space-1) var(--space-4);
margin-top: var(--space-2);

@media (--desktop) {
padding: var(--space-2) var(--space-4) var(--space-4);
}

&__table {
display: none;
@media (--desktop) {
display: revert;
}
}

&__table-condensed {
@media (--desktop) {
display: none;
}
}
}
</style>
51 changes: 51 additions & 0 deletions src/components/OracleEventsQueryPanel.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<template>
<app-panel class="oracle-events-query-panel">
<div class="oracle-events-query-panel__heading">
QueryDetails
michele-franchi marked this conversation as resolved.
Show resolved Hide resolved
</div>
<dl>
<dt>Query ID:</dt>
<dd>{{ event.queryId }}</dd>
<dt>Query Fee:</dt>
<dd>{{ formatAePrice(event.queryFee) }}</dd>
<dt>
Query:
</dt>
<dd>
{{ event.query }}
</dd>
<dt>Response TTL:</dt>
<dd>{{ event.responseTtl }}</dd>
<dt>
Response:
</dt>
<dd>
{{ event.response }}
</dd>
</dl>
</app-panel>
</template>

<script setup>
defineProps({
event: {
type: Object,
required: true,
},
})
</script>

<style scoped>
.oracle-events-query-panel {
padding: var(--space-3);
background: var(--color-snow) !important;
michele-franchi marked this conversation as resolved.
Show resolved Hide resolved
font-size: 11px;
line-height: 16px;

&__heading {
font-weight: 700;
letter-spacing: 0.015em;
margin-bottom: var(--space-1);
}
}
</style>
83 changes: 83 additions & 0 deletions src/components/OracleEventsTable.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<template>
<table>
<thead>
<tr>
lukeromanowicz marked this conversation as resolved.
Show resolved Hide resolved
<th>Query Tx</th>
<th>Status</th>
<th>Queried at</th>
<th>Respond Tx</th>
<th>Respond at</th>
</tr>
</thead>
<tbody>
<template
v-for="(event, index) in oracleEvents.data"
:key="event.respondTx">
<tr>
<td :class="[{'oracle-events-table__opened': isOpened.includes(index)}]">
<hash-symbol>th</hash-symbol>
<value-hash-ellipsed
:hash="event.queryTx"
:link-to="`/transactions/${event.queryTx}`"/>
</td>
<td :class="[{'oracle-events-table__opened': isOpened.includes(index)}]">
<response-button
:status="event.status"
:is-collapsed="!isOpened.includes(index)"
@click="toggle(index)"/>
</td>
<td :class="[{'oracle-events-table__opened': isOpened.includes(index)}]">
<div>
{{ event.queriedAtHeight }}
</div>
<datetime-label :datetime="event.queriedAtTime"/>
</td>
<td :class="[{'oracle-events-table__opened': isOpened.includes(index)}]">
N/A
</td>
<td :class="[{'oracle-events-table__opened': isOpened.includes(index)}]">
N/A
</td>
</tr>
<tr v-if="isOpened.includes(index)">
<td
colspan="5"
class="oracle-events-table__query">
<oracle-events-query-panel :event="event"/>
</td>
</tr>
</template>
</tbody>
</table>
</template>

<script setup>
defineProps({
oracleEvents: {
type: Array,
required: true,
},
})
const isOpened = ref([])

function toggle(id) {
const index = isOpened.value.indexOf(id)
if (index > -1) {
isOpened.value.splice(index, 1)
} else {
isOpened.value.push(id)
}
}
</script>

<style scoped>
.oracle-events-table {
&__opened {
border-bottom: 0;
}

&__query {
border-top: 0;
}
}
</style>
127 changes: 127 additions & 0 deletions src/components/OracleEventsTableCondensed.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
<template>
<div class="oracle-events-table-condensed">
<table
v-for="event in oracleEvents.data"
:key="event.respondTx"
class="oracle-events-table-condensed__table">
<tbody>
<tr class="oracle-events-table-condensed__row">
<th class="oracle-events-table-condensed__header">
Query Tx
</th>
<td class="oracle-events-table-condensed__data">
<value-hash-ellipsed
:hash="event.queryTx"
:link-to="`/transactions/${event.callTxHash}`"/>
</td>
</tr>
<tr class="oracle-events-table-condensed__row">
<th class="oracle-events-table-condensed__header">
Status
</th>
<td class="oracle-events-table-condensed__data">
<response-button
:status="event.status"
:is-collapsed="!isOpened.includes(index)"
@click="toggle(index)"/>
</td>
</tr>
<tr class="oracle-events-table-condensed__row">
<th class="oracle-events-table-condensed__header">
Queried at
</th>
<td class="oracle-events-table-condensed__data">
<div>
{{ event.queriedAtHeight }}
</div>
<datetime-label :datetime="event.queriedAtTime"/>
</td>
</tr>
<tr class="oracle-events-table-condensed__row">
<th class="oracle-events-table-condensed__header">
Respond Tx
</th>
<td class="oracle-events-table-condensed__data">
N/A
</td>
</tr>
<tr class="oracle-events-table-condensed__row">
<th
:class="[
'oracle-events-table-condensed__header',
{'oracle-events-table-condensed__header--opened': isOpened.includes(index)}]">
Respond at
</th>
<td
:class="[
'oracle-events-table-condensed__data',
{'oracle-events-table-condensed__data--opened': isOpened.includes(index)}]">
N/A
</td>
</tr>
<tr
v-if="isOpened.includes(index)"
class="oracle-events-table-condensed__row">
<td colspan="5">
<oracle-events-query-panel :event="event"/>
</td>
</tr>
</tbody>
</table>
</div>
</template>

<script setup>
defineProps({
oracleEvents: {
type: Array,
required: true,
},
})
const isOpened = ref([])

function toggle(id) {
const index = isOpened.value.indexOf(id)
if (index > -1) {
isOpened.value.splice(index, 1)
} else {
isOpened.value.push(id)
}
}
</script>

<style scoped>
.oracle-events-table-condensed {
&__table {
background: var(--color-white);
padding: 0 var(--space-1) var(--space-7);
margin-bottom: var(--space-5);

&:last-of-type {
margin-bottom: var(--space-2);
}
}

&__header {
vertical-align: top;
border-bottom: 1px solid var(--color-midnight-15);
padding-right: var(--space-4);

&--opened {
border-bottom: 0;
}
}

&__row:last-of-type &__header {
border-bottom: 0;
}

&__data {
text-align: right;

&--opened {
border-bottom: 0;
}
}
}
</style>
39 changes: 39 additions & 0 deletions src/components/ResponseButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<template>
<div>
<app-chip :class="['response-button', {'response-button--activated': !isCollapsed}]">
Response available
<app-icon
class="response-button__icon"
:name="isCollapsed ? 'plus-circle' : 'minus-circle' "/>
</app-chip>
</div>
</template>

<script setup>
defineProps({
status: {
type: String,
required: true,
},
isCollapsed: {
type: Boolean,
default: true,
},
})
</script>

<style scoped>
.response-button {
cursor: pointer;
color: var(--color-midnight);

&__icon {
margin-left: var(--space-1);
}

&--activated {
color: var(--color-white);
background-color: var(--color-midnight-55);
}
}
</style>
Loading