Skip to content

Commit

Permalink
Initial Commit with Static baseURL in vue project (#125)
Browse files Browse the repository at this point in the history
* Initial Commit with Static baseURL in vue project

* Fix Test Cases

* revert lockfile

* Removed hardcoded baseUrl and made it relative

* revert handler changes and baseurl

* Fix Vue Axios all and spread
  • Loading branch information
KThornley authored and Skarlso committed Nov 7, 2018
1 parent 3e78a92 commit c3b84a9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
11 changes: 7 additions & 4 deletions frontend/client/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,24 @@ import auth from './auth'
import lodash from 'lodash'
import VueLodash from 'vue-lodash'

Vue.prototype.$http = axios
Vue.axios = axios
const axiosInstance = axios.create({
baseURL: './'
})

Vue.prototype.$http = axiosInstance
Vue.axios = axiosInstance
Vue.router = router
Vue.use(NProgress)
Vue.use(VueLodash, lodash)

// Auth interceptors
axios.interceptors.request.use(function (request) {
axiosInstance.interceptors.request.use(function (request) {
request.headers['Authorization'] = 'Bearer ' + auth.getToken()
return request
})

// Enable devtools
Vue.config.devtools = true

sync(store, router)

const nprogress = new NProgress({ parent: '.nprogress-container' })
Expand Down
17 changes: 11 additions & 6 deletions frontend/client/views/pipeline/detail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,12 @@ export default {
this.runID = runID
// Run ID specified. Do concurrent request
this.$http.all([this.getPipeline(pipelineID), this.getPipelineRun(pipelineID, runID), this.getPipelineRuns(pipelineID)])
.then(this.$http.spread(function (pipeline, pipelineRun, pipelineRuns) {
Promise.all([this.getPipeline(pipelineID), this.getPipelineRun(pipelineID, runID), this.getPipelineRuns(pipelineID)])
.then(values => {
// We only redraw the pipeline if pipeline is running
var pipeline = values[0]
var pipelineRun = values[1]
var pipelineRuns = values[2]
if (pipelineRun.data.status !== 'running' && !this.lastRedraw) {
this.drawPipelineDetail(pipeline.data, pipelineRun.data)
this.lastRedraw = true
Expand All @@ -220,15 +223,17 @@ export default {
}
this.runsRows = pipelineRuns.data
this.pipeline = pipeline.data
}.bind(this)))
})
.catch((error) => {
this.$store.commit('clearIntervals')
this.$onError(error)
})
} else {
// Do concurrent request
this.$http.all([this.getPipeline(pipelineID), this.getPipelineRuns(pipelineID)])
.then(this.$http.spread(function (pipeline, pipelineRuns) {
Promise.all([this.getPipeline(pipelineID), this.getPipelineRuns(pipelineID)])
.then(values => {
var pipeline = values[0]
var pipelineRuns = values[1]
if (!this.lastRedraw) {
this.drawPipelineDetail(pipeline.data, null)
this.lastRedraw = true
Expand All @@ -239,7 +244,7 @@ export default {
this.runsRows = pipelineRuns.data
}
this.pipeline = pipeline.data
}.bind(this)))
})
.catch((error) => {
this.$store.commit('clearIntervals')
this.$onError(error)
Expand Down
2 changes: 1 addition & 1 deletion frontend/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = {
index: path.resolve(__dirname, '../dist/index.html'),
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'assets',
assetsPublicPath: '/',
assetsPublicPath: './',
productionSourceMap: true,
// Gzip off by default as many popular static hosts such as
// Surge or Netlify already gzip all static assets for you.
Expand Down
2 changes: 1 addition & 1 deletion handlers/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func InitHandlers(e *echo.Echo) error {
e.GET("/favicon.ico", echo.WrapHandler(assetHandler))
e.GET("/assets/css/*", echo.WrapHandler(http.StripPrefix("/", assetHandler)))
e.GET("/assets/js/*", echo.WrapHandler(http.StripPrefix("/", assetHandler)))
e.GET("/assets/fonts/*", echo.WrapHandler(http.StripPrefix("/", assetHandler)))
e.GET("/assets/css/assets/fonts/*", echo.WrapHandler(http.StripPrefix("/assets/css/", assetHandler)))
e.GET("/assets/img/*", echo.WrapHandler(http.StripPrefix("/", assetHandler)))
}

Expand Down

0 comments on commit c3b84a9

Please sign in to comment.