2017-06-24 19:54:31 +00:00
|
|
|
<template lang="pug">
|
2017-07-04 04:52:37 +00:00
|
|
|
.container.is-fluid
|
|
|
|
.columns.is-gapless
|
|
|
|
|
|
|
|
.column.is-narrow.is-hidden-touch.sidebar
|
|
|
|
aside.stickyscroll
|
|
|
|
.sidebar-label
|
2017-07-06 04:10:41 +00:00
|
|
|
span {{ $t('history.pastversions') }}
|
2017-07-04 04:52:37 +00:00
|
|
|
ul.sidebar-menu
|
|
|
|
li(v-for='item in versions')
|
2017-07-06 04:10:41 +00:00
|
|
|
a.is-multiline(:title='item.dateFull', @click='changeCommit(item)', :class='{ "is-active": item.commit === current.commit }')
|
2017-07-04 04:52:37 +00:00
|
|
|
span {{ item.dateCalendar }}
|
|
|
|
span.is-small {{ item.commitAbbr }}
|
|
|
|
|
|
|
|
.column
|
|
|
|
.history
|
|
|
|
.history-title {{ currentPath }}
|
|
|
|
.history-info
|
|
|
|
.columns
|
|
|
|
.column.history-info-meta
|
|
|
|
p
|
|
|
|
i.nc-icon-outline.ui-1_calendar-check-62
|
2017-07-06 04:10:41 +00:00
|
|
|
span {{ $t('history.timestamp') }}: #[strong {{ current.dateFull }}]
|
2017-07-04 04:52:37 +00:00
|
|
|
p
|
|
|
|
i.nc-icon-outline.i.nc-icon-outline.users_man-23
|
2017-07-06 04:10:41 +00:00
|
|
|
span {{ $t('history.author') }}: #[strong {{ current.name }} <{{ current.email }}>]
|
2017-07-04 04:52:37 +00:00
|
|
|
p
|
|
|
|
i.nc-icon-outline.media-1_flash-21
|
2017-07-06 04:10:41 +00:00
|
|
|
span {{ $t('history.commit') }}: #[strong {{ current.commit }}]
|
2017-07-04 04:52:37 +00:00
|
|
|
.column.history-info-actions
|
|
|
|
.button-group
|
|
|
|
button.button.is-blue-grey()
|
|
|
|
i.nc-icon-outline.design_path-intersect
|
2017-07-06 04:10:41 +00:00
|
|
|
span {{ $t('history.comparewith') }}
|
2017-07-04 04:52:37 +00:00
|
|
|
button.button.is-blue-grey()
|
|
|
|
i.nc-icon-outline.ui-1_eye-17
|
2017-07-06 04:10:41 +00:00
|
|
|
span {{ $t('history.view') }}
|
2017-07-04 04:52:37 +00:00
|
|
|
button.button.is-blue-grey()
|
|
|
|
i.nc-icon-outline.arrows-4_undo-29
|
2017-07-06 04:10:41 +00:00
|
|
|
span {{ $t('history.reverttoversion') }}
|
|
|
|
toggle.is-dark(v-model='sidebyside', :desc='$t("history.sidebyside")')
|
2017-07-04 04:52:37 +00:00
|
|
|
.history-diff#diff
|
2017-07-02 22:15:05 +00:00
|
|
|
|
2017-06-24 19:54:31 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2017-07-02 22:15:05 +00:00
|
|
|
let diffui
|
2017-07-06 04:10:41 +00:00
|
|
|
let diffuiIsReady = false
|
2017-06-24 19:54:31 +00:00
|
|
|
export default {
|
|
|
|
name: 'history',
|
2017-07-04 04:52:37 +00:00
|
|
|
props: ['currentPath', 'historyData'],
|
2017-06-24 19:54:31 +00:00
|
|
|
data() {
|
|
|
|
return {
|
2017-07-04 04:52:37 +00:00
|
|
|
versions: [],
|
2017-07-06 04:10:41 +00:00
|
|
|
current: {},
|
2017-07-02 22:15:05 +00:00
|
|
|
diffui: {},
|
|
|
|
sidebyside: true
|
2017-06-24 19:54:31 +00:00
|
|
|
}
|
|
|
|
},
|
2017-07-04 04:52:37 +00:00
|
|
|
watch: {
|
|
|
|
sidebyside() {
|
|
|
|
this.draw()
|
|
|
|
}
|
|
|
|
},
|
2017-06-24 19:54:31 +00:00
|
|
|
methods: {
|
2017-07-02 22:15:05 +00:00
|
|
|
draw() {
|
2017-07-06 04:10:41 +00:00
|
|
|
if (diffuiIsReady) {
|
|
|
|
diffui.draw('#diff', {
|
|
|
|
inputFormat: 'diff',
|
|
|
|
outputFormat: this.sidebyside ? 'side-by-side' : 'line-by-line',
|
|
|
|
matching: 'words',
|
|
|
|
synchronisedScroll: true
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
changeCommit(cm) {
|
|
|
|
let self = this
|
|
|
|
diffuiIsReady = false
|
|
|
|
self.current = cm
|
|
|
|
self.$http.post(siteRoot + '/hist', {
|
|
|
|
path: self.currentPath,
|
|
|
|
commit: cm.commit
|
|
|
|
}).then(resp => {
|
|
|
|
return resp.json()
|
|
|
|
}).then(resp => {
|
|
|
|
diffui = new Diff2HtmlUI({ diff: resp.diff })
|
|
|
|
diffuiIsReady = true
|
|
|
|
self.draw()
|
|
|
|
}).catch(err => {
|
|
|
|
console.log(err)
|
|
|
|
self.$store.dispatch('alert', {
|
|
|
|
style: 'red',
|
|
|
|
icon: 'square-cross',
|
|
|
|
msg: 'Error: ' + err.body.error
|
|
|
|
})
|
2017-06-24 19:54:31 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
2017-07-04 04:52:37 +00:00
|
|
|
this.versions = JSON.parse(this.historyData)
|
2017-07-06 04:10:41 +00:00
|
|
|
this.changeCommit(this.versions[0])
|
2017-06-24 19:54:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|