Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Commit with Static baseURL in vue project #125

Merged
merged 6 commits into from Nov 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: './'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means that ./ will always be the default. Shouldn't this be just /?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will always be relative to the current base and since its a SPA that will be where ever it is served from. / would be absolute so we would have to do some trickery of setting the conditional root and I am lazy :)

})

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 @@ -173,9 +173,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 @@ -185,15 +188,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 @@ -204,7 +209,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 @@ -102,7 +102,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