Skip to content

Commit

Permalink
First layout for jobs logs frontend view has been implemented. Connec…
Browse files Browse the repository at this point in the history
…tion to backend is missing
  • Loading branch information
michelvocks committed Mar 16, 2018
1 parent 7ad6f9e commit 28cb3bd
Show file tree
Hide file tree
Showing 10 changed files with 149 additions and 24 deletions.
1 change: 1 addition & 0 deletions frontend/client/components/layout/Navbar.vue
Expand Up @@ -84,6 +84,7 @@ export default {
logout () {
this.$router.push('/')
this.$store.commit('clearIntervals')
auth.logout(this)
},
Expand Down
16 changes: 7 additions & 9 deletions frontend/client/router/index.js
Expand Up @@ -18,21 +18,19 @@ export default new Router({
name: 'Pipeline Detail',
path: '/pipelines/detail',
component: lazyLoading('pipelines/detail')
},
{
name: 'Job Log',
path: '/jobs/log',
component: lazyLoading('jobs/log')
}
]
})

// Menu should have 2 levels.
// Menu should have 1 level.
function generateRoutesFromMenu (menu = [], routes = []) {
for (let i = 0, l = menu.length; i < l; i++) {
let item = menu[i]
if (item.path && item.subroute) {
for (let x = 0, y = item.subroute.length; x < y; x++) {
routes.push(item.subroute[x])
}
} else if (item.path) {
routes.push(item)
}
routes.push(menu[i])
}
return routes
}
4 changes: 3 additions & 1 deletion frontend/client/store/getters.js
Expand Up @@ -8,6 +8,7 @@ const componententry = state => {
return state.menu.items.filter(c => c.meta && c.meta.label === 'Components')[0]
}
const session = state => state.session
const intervals = state => state.intervals

export {
pkg,
Expand All @@ -17,5 +18,6 @@ export {
effect,
menuitems,
componententry,
session
session,
intervals
}
17 changes: 17 additions & 0 deletions frontend/client/store/mutations.js
Expand Up @@ -5,3 +5,20 @@ export const setSession = (state, session) => {
export const clearSession = (state) => {
state.session = null
}

export const appendInterval = (state, interval) => {
if (!state.intervals) {
state.intervals = []
}

state.intervals.push(interval)
}

export const clearIntervals = (state) => {
if (state.intervals) {
for (let i = 0, l = state.intervals.length; i < l; i++) {
clearInterval(state.intervals[i])
}
state.intervals = null
}
}
95 changes: 95 additions & 0 deletions frontend/client/views/jobs/log.vue
@@ -0,0 +1,95 @@
<template>
<div class="job-log-view">
<message :direction="'down'" :message="'This is a cool test and test and test and test and test and test'" :duration="0"></message>
<div class="job-loading" v-if="jobRunning"></div>
</div>
</template>

<script>
import Message from 'vue-bulma-message'
export default {
data () {
return {
job: null,
jobRunning: true,
runID: null,
pipelineID: null
}
},
mounted () {
// Fetch data from backend
this.fetchData()
// periodically update dashboard
this.intervalID = setInterval(function () {
this.fetchData()
}.bind(this), 3000)
},
watch: {
'$route': 'fetchData'
},
components: {
Message
},
methods: {
fetchData () {
// look up url parameters
this.pipelineID = this.$route.query.pipelineid
this.runID = this.$route.query.runid
if (!this.runID || !this.pipelineID) {
return
}
this.$http
.get('/api/v1/pipelines', { showProgressBar: false })
.then(response => {
if (response.data) {
this.pipelines = response.data
}
})
.catch((error) => {
clearInterval(this.intervalID)
this.$onError(error)
})
}
}
}
</script>

<style lang="scss">
.job-log-view {
width: 100%;
}
.message-header {
background-color: #4da2fc;
}
.message-body {
background-color: black;
border: none;
color: whitesmoke;
}
.job-loading {
margin-top: 20px;
border: 5px solid #f3f3f3; /* Light grey */
border-top: 5px solid #3498db; /* Blue */
border-radius: 50%;
width: 70px;
height: 70px;
animation: spin 2s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
</style>
12 changes: 7 additions & 5 deletions frontend/client/views/overview/index.vue
Expand Up @@ -31,8 +31,7 @@
export default {
data () {
return {
pipelines: [],
intervalID: null
pipelines: []
}
},
Expand All @@ -41,9 +40,12 @@ export default {
this.fetchData()
// periodically update dashboard
this.intervalID = setInterval(function () {
var intervalID = setInterval(function () {
this.fetchData()
}.bind(this), 3000)
// Append interval id to store
this.$store.commit('appendInterval', intervalID)
},
watch: {
Expand All @@ -60,7 +62,7 @@ export default {
}
})
.catch((error) => {
clearInterval(this.intervalID)
this.$store.commit('clearIntervals')
this.$onError(error)
})
},
Expand All @@ -75,7 +77,7 @@ export default {
}
})
.catch((error) => {
clearInterval(this.intervalID)
this.$store.commit('clearIntervals')
this.$onError(error)
})
},
Expand Down
10 changes: 6 additions & 4 deletions frontend/client/views/pipelines/create.vue
Expand Up @@ -244,8 +244,7 @@ export default {
field: 'errmsg'
}
],
historyRows: [],
intervalID: null
historyRows: []
}
},
Expand All @@ -261,9 +260,12 @@ export default {
this.fetchData()
// periodically update history dashboard
this.intervalID = setInterval(function () {
var intervalID = setInterval(function () {
this.fetchData()
}.bind(this), 3000)
// Append interval id to store
this.$store.commit('appendInterval', intervalID)
},
watch: {
Expand All @@ -280,7 +282,7 @@ export default {
}
})
.catch((error) => {
clearInterval(this.intervalID)
this.$store.commit('clearIntervals')
this.$onError(error)
})
},
Expand Down
12 changes: 7 additions & 5 deletions frontend/client/views/pipelines/detail.vue
Expand Up @@ -104,8 +104,7 @@ export default {
},
arrows: {to: true}
}
},
intervalID: null
}
}
},
Expand All @@ -115,9 +114,12 @@ export default {
// periodically update view
this.fetchData()
this.intervalID = setInterval(function () {
var intervalID = setInterval(function () {
this.fetchData()
}.bind(this), 3000)
// Append interval id to store
this.$store.commit('appendInterval', intervalID)
},
watch: {
Expand Down Expand Up @@ -160,7 +162,7 @@ export default {
this.runsRows = pipelineRuns.data
}.bind(this)))
.catch((error) => {
clearInterval(this.intervalID)
this.$store.commit('clearIntervals')
this.$onError(error)
})
} else {
Expand All @@ -174,7 +176,7 @@ export default {
this.runsRows = pipelineRuns.data
}.bind(this)))
.catch((error) => {
clearInterval(this.intervalID)
this.$store.commit('clearIntervals')
this.$onError(error)
})
}
Expand Down
5 changes: 5 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Expand Up @@ -49,6 +49,7 @@
"vue-bulma-collapse": "1.0.3",
"vue-bulma-datepicker": "^1.3.0",
"vue-bulma-expanding": "^0.0.1",
"vue-bulma-message": "^1.1.1",
"vue-bulma-modal": "1.0.1",
"vue-bulma-notification-fixed": "^1.1.0",
"vue-bulma-progress-bar": "^1.0.2",
Expand Down

0 comments on commit 28cb3bd

Please sign in to comment.