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

Advanced search #412

Merged
merged 10 commits into from
Jul 7, 2022
Merged
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
Add cards
aopoltorzhicky committed Jun 16, 2022
commit 209c7e1c4bb06e0391d4ce250ee359e259cc24b4
61 changes: 30 additions & 31 deletions src/components/Tags.vue
Original file line number Diff line number Diff line change
@@ -1,46 +1,45 @@
<template>
<div>
<v-list-item-action v-if="tags">
<v-list-item-action-text>
<v-chip
small
class="caption"
target="_blank"
>{{ tags.text }}</v-chip
>
</v-list-item-action-text>
</v-list-item-action>
</div>
<v-chip-group v-if="this.tags" active-class="primary--text" column>
<v-chip small class="caption" v-for="(tag) in readable" :key="tag">{{ tag }}</v-chip>
</v-chip-group>
</template>

<script>
const standards = {
'fa2': "FA2",
'fa1-2': "FA1.2",
'fa1': "FA1",
'delegator': "Delegator",
'multisig': "Multisig",
'sapling': "Sapling",
'ledger': "Ledger",
'CREATE_CONTRACT': "Contract factory",
'SET_DELEGATE': "Delegatable",
'upgradable': "Upgradable",
'CHAIN_ID': "",
'CHECK_SIGNATURE': "",
'view_address': "",
'view_balance_of': "",
'view_nat': ""
};

export default {
name: "Tags",
props: {
contract: Object,
tags: Array,
},
computed: {
tags() {
const standards = {
fa2: "FA2",
fa12: "FA1.2",
fa1: "FA1",
delegator: "Delegator",
multisig: "Multisig",
};
if (this.contract && this.contract.tags) {
for (var tag in standards) {
if (this.contract.tags.includes(tag)) {
return { tag, text: standards[tag] };
}
}
readable() {
if (this.tags) {
let result = [];
this.tags.forEach(tag => {
let text = standards[tag];
if (text) result.push(text)
})
return result;
}
return null;
}
}
}
</script>

<style scoped>

</style>
4 changes: 2 additions & 2 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ import VueMeta from 'vue-meta'
import * as Sentry from "@sentry/vue";
import { BrowserTracing } from "@sentry/tracing";

import { shortcut, formatDatetime, formatDate, plural, urlExtractBase58, checkAddress, round } from "@/utils/tz.js";
import { shortcut, shortcutOnly, formatDatetime, formatDate, plural, urlExtractBase58, checkAddress, round } from "@/utils/tz.js";
import { BetterCallApi } from "@/api/bcd.js";
import { NodeRPC } from "@/api/rpc.js";
import { Bookmarks } from "@/utils/bookmarks.js";
@@ -133,7 +133,7 @@ api.getConfig().then(response => {
window.config = config;

let rpc = new NodeRPC(config.rpc_endpoints);
let helpers = { shortcut, formatDatetime, formatDate, plural, checkAddress, round }
let helpers = { shortcut, shortcutOnly, formatDatetime, formatDate, plural, checkAddress, round }

Vue.mixin({
data() {
4 changes: 1 addition & 3 deletions src/views/contract/Contract.vue
Original file line number Diff line number Diff line change
@@ -7,9 +7,7 @@
divider="/"
:items="breadcrumbsItems"
/>
<Tags
:contract="contract"
/>
<Tags :tags="contract.tags"/>
</v-col>
<v-col cols="3" class="d-flex justify-end pr-7">
<div class="d-flex align-center justify-start pa-2 px-4">
77 changes: 51 additions & 26 deletions src/views/extended_search/ExtendedSearch.vue
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@
</v-row>
</div>
<template v-slot:extension>
<v-tabs v-model="tab" style="margin-left: 228px;">
<v-tabs v-model="tab" class="ml-10">
<v-tab>
<v-icon left small>mdi-auto-fix</v-icon>Everywhere
</v-tab>
@@ -53,32 +53,41 @@
</template>
</v-app-bar>

<v-container fluid class="canvas fill-canvas pa-8">
<div style="width: 800px; margin-left: 228px">
<template v-if="total > 0">
<v-overlay :value="loading" color="data" style="z-index:4" absolute></v-overlay>
<span
class="text--secondary caption ml-4"
>Found {{ total == 10000 ? `more than ${total}` : total }} documents ({{ elasticTime }} ms)</span>
<template v-for="(item, idx) in suggests">
<Account :item="item" :words="getSearchWords()" :key="idx" v-if="item.type === 'account'"/>
<BigMapKey :item="item" :words="getSearchWords()" :key="idx" v-if="item.type === 'bigmapkey'"/>
<Operation :item="item" :words="getSearchWords()" :key="idx" v-if="item.type === 'operation'"/>
<Token :item="item" :words="getSearchWords()" :key="idx" v-if="item.type === 'token'"/>
<v-container fluid class="canvas fill-canvas px-10 pt-8">
<v-row>
<v-col cols="8" class="pl-8">
<template v-if="total > 0">
<v-overlay :value="loading" color="data" style="z-index:4" absolute></v-overlay>
<span
class="text--secondary caption ml-4"
>Found {{ total == 10000 ? `more than ${total}` : total }} documents ({{ elasticTime }} ms)</span>
<template v-for="(item, idx) in suggests">
<Account :item="item" :words="getSearchWords()" :key="idx" v-if="item.type === 'account'"/>
<BigMapKey :item="item" :words="getSearchWords()" :key="idx" v-if="item.type === 'bigmapkey'"/>
<Operation :item="item" :words="getSearchWords()" :key="idx" v-if="item.type === 'operation'"/>
<Token :item="item" :words="getSearchWords()" :key="idx" v-if="item.type === 'token'"/>
</template>
<span v-intersect="onDownloadPage" v-if="!completed && !loading"></span>
</template>
<span v-intersect="onDownloadPage" v-if="!completed && !loading"></span>
</template>
<template v-else-if="!cold">
<EmptyState
icon="mdi-code-brackets"
title="Nothing found"
text="Empty set is also a result, otherwise try a broader query"
/>
</template>
<v-overlay v-else-if="loading" :value="cold" color="data" absolute>
<v-progress-circular indeterminate size="64" color="primary"></v-progress-circular>
</v-overlay>
</div>
<template v-else-if="!cold">
<EmptyState
icon="mdi-code-brackets"
title="Nothing found"
text="Empty set is also a result, otherwise try a broader query"
/>
</template>
<v-overlay v-else-if="loading" :value="cold" color="data" absolute>
<v-progress-circular indeterminate size="64" color="primary"></v-progress-circular>
</v-overlay>
</v-col>
<v-col cols="4" v-if="first" class="pt-10 mt-2 pr-8">
<AccountCard :item="first" v-if="first.type === 'account' && !first.body.IsContract"/>
<ContractCard :item="first" v-if="first.type === 'account' && first.body.IsContract"/>
<BigMapKeyCard :item="first" v-if="first.type === 'bigmapkey'"/>
<OperationCard :item="first" v-if="first.type === 'operation'"/>
<TokenCard :item="first" v-if="first.type === 'token'"/>
</v-col>
</v-row>
</v-container>
</div>
</template>
@@ -91,14 +100,24 @@ import Account from "./result/Account.vue";
import BigMapKey from "./result/BigMapKey.vue";
import Operation from "./result/Operation.vue";
import Token from "./result/Token.vue";
import AccountCard from "./cards/Account.vue";
import ContractCard from "./cards/Contract.vue";
import BigMapKeyCard from "./cards/BigMapKey.vue";
import OperationCard from "./cards/Operation.vue";
import TokenCard from "./cards/Token.vue";

export default {
name: "ExtendedSearch",
components: {
Account,
AccountCard,
ContractCard,
BigMapKey,
BigMapKeyCard,
Operation,
OperationCard,
Token,
TokenCard,
EmptyState,
},
data: () => ({
@@ -129,6 +148,12 @@ export default {
}
return ["accounts", "operations", "big-maps", "tokens"];
},
first() {
if (this.suggests.length > 0) {
return this.suggests[0];
}
return undefined;
}
},
mounted() {
this.networks = [...this.config.networks.keys()];
79 changes: 77 additions & 2 deletions src/views/extended_search/cards/Account.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,72 @@
<template>
<v-card>

<v-card class="mx-auto" outlined :loading="loading">
<v-card-title class="sidebar py-2" primary-title>Top result</v-card-title>
<v-card-text>
<v-list>
<v-list-item two-line class="pl-3">
<v-list-item-avatar size="50">
<v-icon size="50">mdi-wallet-outline</v-icon>
</v-list-item-avatar>
<v-list-item-content>
<v-list-item-title>
<span class="text-h4 text--primary">{{ alias ? alias : info.address }}</span>
</v-list-item-title>
<v-list-item-subtitle>
<span class="secondary--text overline">{{ item.body.Network }}</span>
</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>

<v-list-item two-line v-if="alias">
<v-list-item-content>
<v-list-item-title>
<span class="overline">Address</span>
</v-list-item-title>
<v-list-item-subtitle>
<span class="hash">{{ item.body.Address }}</span>
</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>

<v-list-item two-line>
<v-list-item-content>
<v-list-item-title>
<span class="overline">Balance</span>
</v-list-item-title>
<v-list-item-subtitle>
<span class="hash">{{ info.balance | uxtz }}</span>
</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>

<v-list-item two-line>
<v-list-item-content>
<v-list-item-title>
<span class="overline">Operations count</span>
</v-list-item-title>
<v-list-item-subtitle>
<span class="hash">{{ info.tx_count }}</span>
</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>

<v-list-item two-line>
<v-list-item-content>
<v-list-item-title>
<span class="overline">Last action</span>
</v-list-item-title>
<v-list-item-subtitle>
<span class="hash">{{ info.last_action | fromNow }}</span>
</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
</v-list>
</v-card-text>
<v-card-actions class="pl-8 mb-4">
<v-btn color="primary" outlined small :to="`/${item.body.Network}/${info.address}`">
Account page
</v-btn>
</v-card-actions>
</v-card>
</template>

@@ -14,6 +80,15 @@ export default {
loading: false,
info: {}
}),
computed: {
alias() {
if (this.item.body.TzKT) return this.item.body.TzKT.Name;
if (this.item.body.Profiles) return this.item.body.Profiles.Name;
if (this.item.body.Domains) return this.item.Domains.body.Name;
if (this.item.body.TZIP) return this.item.body.TZIP.Name;
return this.info.alias;
}
},
created() {
this.getAccountInfo();
},
72 changes: 72 additions & 0 deletions src/views/extended_search/cards/BigMapKey.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<template>
<v-card class="mx-auto" outlined :loading="loading">
<v-card-title class="sidebar py-2" primary-title>Top result</v-card-title>
<v-card-text>
<v-list>
<v-list-item two-line class="pl-3">
<v-list-item-avatar size="50">
<v-icon size="50">mdi-database</v-icon>
</v-list-item-avatar>
<v-list-item-content>
<v-list-item-title>
<span class="text-h4 text--primary">{{ helpers.shortcutOnly(item.body.KeyHash) }}</span>
</v-list-item-title>
<v-list-item-subtitle>
<span class="secondary--text overline">{{ item.body.Network }}</span>
</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>

<v-list-item two-line>
<v-list-item-content>
<v-list-item-title>
<span class="overline">Pointer</span>
</v-list-item-title>
<v-list-item-subtitle>
<span class="hash">{{ item.body.BigMapID }}</span>
</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>

<v-list-item two-line>
<v-list-item-content>
<v-list-item-title>
<span class="overline">Key hash</span>
</v-list-item-title>
<v-list-item-subtitle>
<span class="hash">{{ item.body.KeyHash }}</span>
</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>

<v-list-item two-line>
<v-list-item-content>
<v-list-item-title>
<span class="overline">Status</span>
</v-list-item-title>
<v-list-item-subtitle>
<span class="hash">{{ item.body.IsActive ? 'Active' : 'Removed' }}</span>
</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
</v-list>
</v-card-text>
<v-card-actions class="pl-8 mb-4">
<v-btn color="primary" outlined small :to="`/${item.body.Network}/big_map/${item.body.BigMapID}/${item.body.KeyHash}`">
Key page
</v-btn>
</v-card-actions>
</v-card>
</template>

<script>
export default {
name: "BigMapKeyCard",
props: {
item: Object
},
data: () => ({
loading: false
})
}
</script>
Loading