Make the api url for development configurable via env file (#33)

Make the api url for development configurable via env file

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
Florian Symanowski 2019-09-10 02:16:30 +02:00 committed by Rohit Yadav
parent c30cbbe3d3
commit 791013a86e
6 changed files with 14 additions and 9 deletions

1
ui/.env.local Normal file
View File

@ -0,0 +1 @@
API_URL=http://localhost:8080/client/api

View File

@ -34,6 +34,10 @@ Fix issues and vulnerabilities:
npm audit
Override the default CloudStack API URL:
Change the `API_URL` in the `.env.local` file
## History
The project was created by Rohit Yadav over several weekends during late 2018.

View File

@ -280,7 +280,6 @@ import DataView from '@/components/widgets/DataView'
import InstanceView from '@/components/widgets/InstanceView'
import Status from '@/components/widgets/Status'
import { mixinDevice } from '@/utils/mixin.js'
import { constants } from 'crypto';
export default {
name: 'Resource',
@ -558,7 +557,7 @@ export default {
if (obj.includes('response')) {
for (const res in json[obj]) {
if (res === 'jobid') {
this.$store.dispatch('AddAsyncJob', { 'title': this.currentAction.label, 'jobid': json[obj][res], 'description': this.resource.name, 'status': 'progress'})
this.$store.dispatch('AddAsyncJob', { 'title': this.currentAction.label, 'jobid': json[obj][res], 'description': this.resource.name, 'status': 'progress' })
break
}
}

View File

@ -34,7 +34,6 @@
<script>
import { api } from '@/api'
import store from '@/store'
import { constants } from 'crypto';
export default {
name: 'HeaderNotice',
@ -60,7 +59,7 @@ export default {
this.jobs = []
this.$store.commit('SET_ASYNC_JOB_IDS', [])
},
startPolling() {
startPolling () {
this.poller = setInterval(() => {
this.pollJobs()
}, 2500)
@ -69,7 +68,7 @@ export default {
var hasUpdated = false
for (var i in this.jobs) {
if (this.jobs[i].status === 'progress') {
await api('queryAsyncJobResult', {'jobid': this.jobs[i].jobid}).then(json => {
await api('queryAsyncJobResult', { 'jobid': this.jobs[i].jobid }).then(json => {
var result = json.queryasyncjobresultresponse
if (result.jobstatus === 1 && this.jobs[i].status !== 'done') {
hasUpdated = true
@ -100,10 +99,10 @@ export default {
}
},
beforeDestroy () {
clearInterval(this.poller)
clearInterval(this.poller)
},
created () {
this.startPolling()
this.startPolling()
},
mounted () {
this.jobs = store.getters.asyncJobIds.reverse()

View File

@ -45,6 +45,7 @@ import plPL from 'ant-design-vue/lib/locale-provider/pl_PL'
import ptBR from 'ant-design-vue/lib/locale-provider/pt_BR'
import ruRU from 'ant-design-vue/lib/locale-provider/ru_RU'
import zhCN from 'ant-design-vue/lib/locale-provider/zh_CN'
import hi from 'ant-design-vue/lib/locale-provider/he_IL'
import moment from 'moment'
import 'moment/locale/zh-cn'
@ -76,7 +77,8 @@ export default {
plPL,
ptBR,
ruRU,
zhCN
zhCN,
hi
}
},
methods: {

View File

@ -87,7 +87,7 @@ module.exports = {
port: 5050,
proxy: {
'/client/api': {
target: 'http://localhost:8080/client/api',
target: process.env.API_URL || 'http://localhost:8080/client/api',
ws: false,
changeOrigin: true
}