From cd3ef481c9f8e5fcbe11bb3f8d1ace683ac0e88c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Blanco?= <ablanco@siu.edu.ar> Date: Wed, 8 May 2019 14:36:48 -0300 Subject: [PATCH] =?UTF-8?q?se=20parametriza=20la=20url=20a=20trav=C3=A9s?= =?UTF-8?q?=20de=20una=20prop=20en=20el=20html=20para=20hacer=20m=C3=A1s?= =?UTF-8?q?=20f=C3=A1cil=20el=20embedding?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/package.json | 4 ++-- ui/public/index.html | 2 +- ui/src/App.vue | 2 ++ ui/src/components/DropFile.vue | 7 +++---- ui/src/main.js | 8 +++++++- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/ui/package.json b/ui/package.json index 6081ef8..8b20bd3 100644 --- a/ui/package.json +++ b/ui/package.json @@ -1,10 +1,10 @@ -{ +{ "name": "ui", "version": "0.1.0", "private": true, "scripts": { "serve": "vue-cli-service serve", - "build": "vue-cli-service build --modern", + "build": "vue-cli-service build", "lint": "vue-cli-service lint" }, "dependencies": { diff --git a/ui/public/index.html b/ui/public/index.html index f4ad665..3f03321 100644 --- a/ui/public/index.html +++ b/ui/public/index.html @@ -11,7 +11,7 @@ <noscript> <strong>We're sorry but ui doesn't work properly without JavaScript enabled. Please enable it to continue.</strong> </noscript> - <div id="app"></div> + <div id="app" apiurl="http://localhost:3000"></div> <!-- built files will be auto injected --> </body> </html> diff --git a/ui/src/App.vue b/ui/src/App.vue index 2df95a5..3a5ded5 100644 --- a/ui/src/App.vue +++ b/ui/src/App.vue @@ -2,6 +2,7 @@ <div id="app"> <div class="drop-file-wrapper"> <DropFile + :apiurl="apiurl" v-if="state == 'visible-drop'" v-on:stamp="onStamp()" v-on:failed-stamp="onFailedStamp()" @@ -37,6 +38,7 @@ export default { name: 'app', + props: ['apiurl'], data: function() { return { state: 'visible-drop', diff --git a/ui/src/components/DropFile.vue b/ui/src/components/DropFile.vue index 4d694ae..fd24551 100644 --- a/ui/src/components/DropFile.vue +++ b/ui/src/components/DropFile.vue @@ -47,6 +47,7 @@ import axios from "axios" export default { name: 'DropFile', + props: ['apiurl'], data: function() { return { loading: false, @@ -68,9 +69,8 @@ export default { verify() { var self = this; - let baseUrl = process.env.VUE_APP_API_URL let hash = self.uploadedFiles[0].hash - let verifyUrl = `${baseUrl}/verify/${hash}` + let verifyUrl = `${this.apiurl}/verify/${hash}` self.loading = true axios.get(verifyUrl).then((res) => { console.log(res.data) @@ -87,8 +87,7 @@ export default { stamp() { var self = this; - let baseUrl = process.env.VUE_APP_API_URL - let stampUrl = `${baseUrl}/stamp` + let stampUrl = `${this.apiurl}/stamp` self.loading = true axios.post(stampUrl, { hashes: [self.uploadedFiles[0].hash] diff --git a/ui/src/main.js b/ui/src/main.js index 3b03b9f..14905af 100644 --- a/ui/src/main.js +++ b/ui/src/main.js @@ -4,5 +4,11 @@ import App from './App.vue' Vue.config.productionTip = false new Vue({ - render: h => h(App), + render(h) { + return h(App, { + props: { + apiurl: this.$el.attributes.apiurl.value + } + }) + } }).$mount('#app') \ No newline at end of file -- GitLab