Library/frontend/src/components/PublisherOverview.vue

119 lines
3.3 KiB
Vue
Raw Normal View History

2017-11-21 12:38:20 +00:00
<template>
<div v-if="user.authenticated">
2017-11-29 15:23:19 +00:00
<h1>{{ publisher.name }}</h1>
2017-11-21 12:38:20 +00:00
2018-01-16 09:38:36 +00:00
<div class="fullscreen-loader-wrapper" v-if="loading">
<div class="half-circle-spinner">
<div class="circle circle-1"></div>
<div class="circle circle-2"></div>
</div>
2017-11-21 12:38:20 +00:00
</div>
<div v-if="!loading">
2017-11-21 12:38:20 +00:00
<router-link :to="{ name: 'publisher-edit', params: { id: publisherID} }" class="ui teal labeled icon button" style="float: right;">
<i class="edit icon"></i>
2017-11-22 14:28:55 +00:00
<span v-lang.general.edit></span>
2017-11-21 12:38:20 +00:00
</router-link>
2017-11-24 10:54:52 +00:00
<list :infos="publisherList"/>
2017-11-30 14:26:28 +00:00
<p class="grey">
<span v-lang.general.created="this.createdTime"></span><br/>
<span v-if="this.publisher.created !== this.publisher.updated" v-lang.general.lastEdit="this.editedTime"></span>
</p>
2017-11-21 12:38:20 +00:00
</div>
</div>
</template>
<script>
import auth from '../auth'
import {HTTP} from '../http-common'
export default {
name: 'Publisher',
data () {
return {
user: auth.user,
publisher: {},
2017-11-24 10:54:52 +00:00
publisherID: this.$route.params.id,
2017-11-30 14:26:28 +00:00
publisherList: [],
createdTime: {
date: '',
time: ''
},
editedTime: {
date: '',
time: ''
}
2017-11-21 12:38:20 +00:00
}
},
created () {
this.loadPublisher()
2017-12-05 14:55:56 +00:00
// Set the title
document.title = this.translate('nav').publishers
2017-11-21 12:38:20 +00:00
},
watch: {
// call again the method if the route changes
'$route': 'loadPublisher'
},
2017-12-05 14:55:56 +00:00
computed: {
langGeneral () {
return this.translate('general')
}
},
2017-11-21 12:38:20 +00:00
methods: {
loadPublisher () {
this.loading = true
this.publisher = {}
HTTP.get(`publishers/` + this.publisherID)
.then(response => {
this.publisher = response.data
2017-11-24 10:54:52 +00:00
// Make a list
this.publisherList = [
{
header: this.translate('general').name,
2017-11-29 15:23:19 +00:00
content: this.publisher.name
2017-11-24 10:54:52 +00:00
}
]
2017-11-30 14:26:28 +00:00
// Beautify the date
let c = new Date(this.publisher.created * 1000)
// c.setSeconds()
this.createdTime = {
date: ('0' + c.getDate()).slice(-2) + '.' + ('0' + (c.getMonth() + 1)).slice(-2) + '.' + c.getFullYear(),
time: ('0' + c.getHours()).slice(-2) + ':' + ('0' + c.getMinutes()).slice(-2)
}
let e = new Date(this.publisher.updated * 1000)
// e.setSeconds()
this.editedTime = {
date: ('0' + e.getDate()).slice(-2) + '.' + ('0' + (e.getMonth() + 1)).slice(-2) + '.' + e.getFullYear(),
time: ('0' + e.getHours()).slice(-2) + ':' + ('0' + e.getMinutes()).slice(-2)
}
2017-12-05 14:55:56 +00:00
// Set the title
document.title = this.publisher.name + ' | ' + this.translate('nav').publishers
2017-11-21 12:38:20 +00:00
this.loading = false
})
.catch(e => {
this.loading = false
// Build the notification text from error response
let err = e.message
if (e.response.data.message) {
err += '<br/>' + e.response.data.message
}
// Fire a notification
this.$notify({
type: 'error',
title: this.langGeneral.error,
text: err
})
2017-11-21 12:38:20 +00:00
})
}
}
}
</script>