2017-05-26 06:56:54 -04:00
|
|
|
import Vue from 'vue';
|
2017-10-02 08:32:53 -04:00
|
|
|
import Flash from '../flash';
|
2017-05-26 06:56:54 -04:00
|
|
|
import PipelinesMediator from './pipeline_details_mediatior';
|
|
|
|
import pipelineGraph from './components/graph/graph_component.vue';
|
2017-06-02 09:24:42 -04:00
|
|
|
import pipelineHeader from './components/header_component.vue';
|
|
|
|
import eventHub from './event_hub';
|
2017-05-26 06:56:54 -04:00
|
|
|
|
|
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
|
|
const dataset = document.querySelector('.js-pipeline-details-vue').dataset;
|
|
|
|
|
|
|
|
const mediator = new PipelinesMediator({ endpoint: dataset.endpoint });
|
|
|
|
|
|
|
|
mediator.fetchPipeline();
|
|
|
|
|
2017-06-02 09:24:42 -04:00
|
|
|
// eslint-disable-next-line
|
|
|
|
new Vue({
|
2017-05-26 06:56:54 -04:00
|
|
|
el: '#js-pipeline-graph-vue',
|
2017-05-26 10:05:43 -04:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
mediator,
|
|
|
|
};
|
2017-05-26 06:56:54 -04:00
|
|
|
},
|
|
|
|
components: {
|
|
|
|
pipelineGraph,
|
|
|
|
},
|
|
|
|
render(createElement) {
|
|
|
|
return createElement('pipeline-graph', {
|
|
|
|
props: {
|
|
|
|
isLoading: this.mediator.state.isLoading,
|
|
|
|
pipeline: this.mediator.store.state.pipeline,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2017-06-02 09:24:42 -04:00
|
|
|
// eslint-disable-next-line
|
|
|
|
new Vue({
|
|
|
|
el: '#js-pipeline-header-vue',
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
mediator,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
components: {
|
|
|
|
pipelineHeader,
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
eventHub.$on('headerPostAction', this.postAction);
|
|
|
|
},
|
|
|
|
beforeDestroy() {
|
|
|
|
eventHub.$off('headerPostAction', this.postAction);
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
postAction(action) {
|
|
|
|
this.mediator.service.postAction(action.path)
|
|
|
|
.then(() => this.mediator.refreshPipeline())
|
|
|
|
.catch(() => new Flash('An error occurred while making the request.'));
|
|
|
|
},
|
|
|
|
},
|
|
|
|
render(createElement) {
|
|
|
|
return createElement('pipeline-header', {
|
|
|
|
props: {
|
|
|
|
isLoading: this.mediator.state.isLoading,
|
|
|
|
pipeline: this.mediator.store.state.pipeline,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
2017-05-26 06:56:54 -04:00
|
|
|
});
|