Publication on Hook step 2

This commit is contained in:
Kristian Polso 2018-06-25 10:29:06 +03:00
parent 543b9102ad
commit 03577c5938
4 changed files with 24 additions and 54 deletions

View file

@ -23,57 +23,23 @@
<Step2 v-if="activeStep == 2"></Step2>
<Step3 v-if="activeStep == 3"></Step3>
<aside class="modal" v-model="uploadDialog" v-if="uploadDialog !== false">
<div class="modal-wrap">
<template v-if="confirmed">
<h3>Your image has been published!</h3>
<p>Check out your content on <a v-bind:href="`https://explorer.lbry.io/tx/${txhash}`" target="_blank" rel="noopener noreferrer">the LBRY blockchain explorer</a>.</p>
<a href="#" class="__button-black" style="display: inline-block;" v-on:click.prevent="uploadDialog = false">Dismiss this dialog</a>
</template>
<template v-else>
<h3><span class="loader tiny" style="display: inline-block;"></span>&nbsp;Waiting for confirmation...</h3>
<p>Your image was uploaded to the LBRY network but we are currently waiting for the first confirmation. This should take just a few minutes. In the meantime, go ahead and try the other steps!</p>
</template>
</div>
</aside>
</div>
</template>
<script>
import EventBus from "../event-bus";
import Vue from "vue";
import EventBus from "../event-bus";
export default {
data () {
return {
activeStep: 1,
confirmed: false,
txhash: "",
uploadDialog: false
}
},
watch: {
uploadDialog: function () {
const component = this;
if (this.uploadDialog) {
setTimeout(() => {
component.confirmed = true; // Simulate confirmation
}, 10000);
}
activeStep: 1
}
},
created () {
const component = this;
EventBus.$on("HookFileUploaded", txhash => {
component.txhash = txhash;
component.uploadDialog = true;
});
EventBus.$on("HookStepUpdate", step => {
component.activeStep = step;
});

View file

@ -104,7 +104,7 @@
component.isLoading = true;
component.exampleCode = `
# Example code using the daemon
curl "http://localhost:5279" --data "{ "method": "resolve", "params": { "uri": "${this.address}" } }"
curl "http://localhost:5279" --data "{ 'method': 'resolve', 'params': { 'uri': '${this.address}' } }"
`;
component.$http.post("https://lbry.tech/forward", {

View file

@ -46,15 +46,15 @@
<fieldset>
<label for="meme-language">Language</label>
<select name="meme-language" id="meme-language" v-model="language">
<option value="AR">Arabic</option>
<option value="ZH">Chinese (Mandarin)</option>
<option value="EN">English</option>
<option value="FR">French</option>
<option value="DE">German</option>
<option value="IT">Italian</option>
<option value="JP">Japanese</option>
<option value="RU">Russian</option>
<option value="ES">Spanish</option>
<option value="ar">Arabic</option>
<option value="zh">Chinese (Mandarin)</option>
<option value="en">English</option>
<option value="fr">French</option>
<option value="de">German</option>
<option value="it">Italian</option>
<option value="jp">Japanese</option>
<option value="ru">Russian</option>
<option value="es">Spanish</option>
<option value="">Not specified</option>
</select>
</fieldset>
@ -88,7 +88,10 @@
<div class="loader" v-if="isLoading"></div>
<div v-if="jsonData">
<p style="text-align: center;">Success! Here is the response:</p>
<p style="text-align: center;">Success!<br/>
<a class="__button-black" v-bind:href="'http://explorer.lbry.io/tx/'+txid">See the transaction on explorer.lbry.io</a>
</p>
<p style="text-align: center;">Here is the raw response:</p>
<pre><code class="json"><span v-html="highlight('json', jsonData)"></span></code></pre>
</div>
</div>
@ -96,7 +99,6 @@
</template>
<script>
import EventBus from "../event-bus";
import hljs from "highlight.js";
import imagesLoaded from "vue-images-loaded";
@ -129,7 +131,7 @@
images: images,
isLoading: false,
jsonData: "",
language: "EN",
language: "en",
license: "Public Domain",
loadingMessage: "",
nsfw: false,
@ -139,6 +141,7 @@
title: "",
topLine: "This is an example meme",
valid: false,
txid: ""
}
},
@ -177,7 +180,7 @@
component.exampleCode = `
# Example code using the daemon
curl "http://localhost:5279" --data "{ "method": "publish", "params": { "name": "${component.title}", "bid": 0.001, "file_path": "/path/to/your/file.jpg", "title": "${component.title}", "description": "${component.description}", "language": "${component.language}", "license": "${component.license}", "nsfw": "${component.nsfw}" } }"
curl "http://localhost:5279" --data "{ 'method': 'publish', 'params': { 'name': '${component.title}', 'bid': 0.001, 'file_path': '/path/to/your/file.jpg', 'title': '${component.title}', 'description': '${component.description}', 'language': '${component.language}', 'license': '${component.license}', 'nsfw': '${component.nsfw}' } }"
`;
component.$http.post("https://lbry.tech/upload-image", document.getElementById("meme-canvas").toDataURL("image/jpeg", 0.6), {
@ -185,7 +188,8 @@ curl "http://localhost:5279" --data "{ "method": "publish", "params": { "name":
"Content-Type": "text/plain"
}
}).then(uploadResponse => {
if (uploadResponse.status === "error") {
if (uploadResponse.body.status === "error") {
component.isLoading = false;
component.exampleCode = "";
return;
@ -194,7 +198,7 @@ curl "http://localhost:5279" --data "{ "method": "publish", "params": { "name":
component.$http.post("https://lbry.tech/forward", {
bid: 0.001,
description: component.description,
file_path: uploadResponse.filename,
file_path: uploadResponse.body.filename,
language: component.language,
license: component.license,
method: "publish",
@ -204,7 +208,7 @@ curl "http://localhost:5279" --data "{ "method": "publish", "params": { "name":
}).then(response => {
component.isLoading = false;
component.jsonData = JSON.stringify(response.body, null, " ");
EventBus.$emit("HookFileUploaded", response.body.txid);
component.txid = response.body.result.txid;
}).catch(error => {
component.isLoading = false;
component.jsonData = JSON.stringify(error, null, " ");

View file

@ -102,7 +102,7 @@
component.exampleCode = `
# Example code using the daemon
curl "http://localhost:5279" --data "{ "method": "wallet_send", "params": { "claim_id": "${this.address}", "amount": "${this.amount}" } }"
curl "http://localhost:5279" --data "{ 'method': 'wallet_send', 'params': { 'claim_id': '${this.address}', 'amount': '${this.amount}' } }"
`;
component.$http.post("https://lbry.tech/forward", {