Skip to content

Commit 55043f7

Browse files
committedJan 31, 2020
Add url generate and error handling functionalities.
1 parent 27c51f6 commit 55043f7

File tree

5 files changed

+81
-6
lines changed

5 files changed

+81
-6
lines changed
 

‎assets/copy.svg

+1
Loading

‎nuxt.config.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,13 @@ export default {
3434
},
3535
modules: [
3636
'@nuxtjs/axios',
37-
'@nuxtjs/style-resources'
37+
'@nuxtjs/style-resources',
38+
'@nuxtjs/toast'
3839
],
40+
toast: {
41+
position: 'bottom-right',
42+
duration: 3000
43+
},
3944
axios: {
4045
},
4146
build: {

‎package-lock.json

+13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"@0xcert/wanchain-asset-ledger": "^2.0.0-beta1",
2020
"@0xcert/wanchain-http-provider": "^2.0.0-beta1",
2121
"@nuxtjs/axios": "^5.9.3",
22+
"@nuxtjs/toast": "^3.3.0",
2223
"nuxt": "^2.11.0",
2324
"vee-validate": "^3.2.3",
2425
"qrcode-with-logos": "1.0.1"

‎pages/index.vue

+60-5
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,25 @@
199199
>
200200
Generate QR code
201201
</button>
202+
<button
203+
class="button mt-1"
204+
:disabled="invalid"
205+
@click="generateURL()"
206+
>
207+
Generate URL
208+
</button>
209+
<div v-if="url" class="url mt-2">
210+
<label v-text="'URL'" />
211+
<div class="field">
212+
<img
213+
class="icon copy"
214+
src="~/assets/copy.svg"
215+
alt="Copy to clipboard"
216+
@click="copyToClipboard(url)"
217+
>
218+
<p v-text="url" />
219+
</div>
220+
</div>
202221
<div class="qr-code">
203222
<canvas ref="canvas" class="canvas" />
204223
<img
@@ -328,7 +347,8 @@ export default {
328347
url: '//gwan-ssl.wandevs.org:46891/'
329348
}
330349
],
331-
qrcode: null
350+
qrcode: null,
351+
url: ''
332352
}
333353
},
334354
computed: {
@@ -410,15 +430,16 @@ export default {
410430
}
411431
},
412432
async getAssetInfo () {
413-
const asset = await this.assetLedger.getAsset(this.formData.assetId)
414-
if (asset.uri) {
415-
try {
433+
try {
434+
const asset = await this.assetLedger.getAsset(this.formData.assetId)
435+
if (asset.uri) {
416436
const result = await this.$axios.get(asset.uri)
417437
this.formData.metadata = JSON.stringify(result.data)
418438
this.formData.schema = JSON.stringify((await this.$axios.get(result.data.$schema)).data)
419439
this.formData.evidence = JSON.stringify((await this.$axios.get(result.data.$evidence)).data)
420-
} catch {
421440
}
441+
} catch {
442+
this.$toast.error('Error fetching asset information.')
422443
}
423444
},
424445
async verifyAsset () {
@@ -427,6 +448,13 @@ export default {
427448
window.scrollTo(0, 0)
428449
this.state = 'results'
429450
},
451+
generateURL () {
452+
this.url = `https://verify.0xcert.org?assetId=${this.formData.assetId}&ledgerId=${this.formData.assetLedgerId}&network=${this.formData.network}`
453+
},
454+
copyToClipboard (text) {
455+
this.$toast.success('Coppied to clipboard.')
456+
navigator.clipboard.writeText(text)
457+
},
430458
async generateQRCode () {
431459
this.qrcode = new QrCodeWithLogo({
432460
canvas: this.$refs.canvas,
@@ -487,4 +515,31 @@ export default {
487515
margin: 0 auto;
488516
}
489517
}
518+
.url {
519+
520+
label {
521+
font-weight: bold;
522+
}
523+
}
524+
525+
.field {
526+
margin-top: 2px;
527+
background-color: #ECEFF1;
528+
border-radius: 4px;
529+
padding: 10px 30px 10px 10px;
530+
position: relative;
531+
532+
p {
533+
margin-top: 5px;
534+
}
535+
}
536+
537+
.copy {
538+
height: 15px;
539+
cursor: pointer;
540+
position: absolute;
541+
right: 8px;
542+
top: 50%;
543+
margin-top: -7px;
544+
}
490545
</style>

0 commit comments

Comments
 (0)
Please sign in to comment.