mirror of
https://github.com/MarcZierle/photo-log-frontend.git
synced 2025-04-07 21:14:37 +00:00
add generate button
This commit is contained in:
parent
11cda03429
commit
3b060df6ca
@ -49,3 +49,7 @@ export function getPhotoGroups() {
|
|||||||
export function getPhotosByGroup(group_id) {
|
export function getPhotosByGroup(group_id) {
|
||||||
return apiClient.get('/photos/?photogroup='+group_id)
|
return apiClient.get('/photos/?photogroup='+group_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getPhotoLogPDF(id) {
|
||||||
|
return apiClient.get('/generatephotolog/'+id+'/')
|
||||||
|
}
|
@ -1,8 +1,15 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<n-space justify="space-between">
|
<n-space justify="space-around">
|
||||||
<h1>Create Log</h1>
|
<h1>Create Log</h1>
|
||||||
<n-button type="primary">Generate</n-button>
|
<n-button
|
||||||
|
type="primary" style="margin: 1em;"
|
||||||
|
@click="getPDF"
|
||||||
|
:disabled="!isValidId"
|
||||||
|
:loading="isGeneratingPDF"
|
||||||
|
>
|
||||||
|
Save & Generate
|
||||||
|
</n-button>
|
||||||
</n-space>
|
</n-space>
|
||||||
|
|
||||||
<n-space justify="space-around">
|
<n-space justify="space-around">
|
||||||
@ -86,7 +93,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<n-image-group>
|
<n-image-group>
|
||||||
<n-space>
|
|
||||||
<draggable
|
<draggable
|
||||||
:list="slide"
|
:list="slide"
|
||||||
item-key="id"
|
item-key="id"
|
||||||
@ -100,7 +106,6 @@
|
|||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</draggable>
|
</draggable>
|
||||||
</n-space>
|
|
||||||
</n-image-group>
|
</n-image-group>
|
||||||
</n-card>
|
</n-card>
|
||||||
|
|
||||||
@ -188,6 +193,8 @@ import SaveFilled from '@vicons/material/SaveFilled'
|
|||||||
|
|
||||||
import PhotoSelectModal from '@/components/PhotoSelectModal'
|
import PhotoSelectModal from '@/components/PhotoSelectModal'
|
||||||
|
|
||||||
|
import { getPhotoLogPDF } from '@/api'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'CreateLog',
|
name: 'CreateLog',
|
||||||
components: {
|
components: {
|
||||||
@ -223,6 +230,7 @@ export default {
|
|||||||
isLoadingData: false,
|
isLoadingData: false,
|
||||||
isCreateLoading: false,
|
isCreateLoading: false,
|
||||||
isSavingServer: false,
|
isSavingServer: false,
|
||||||
|
isGeneratingPDF: false,
|
||||||
|
|
||||||
showPreventLeaveModal: false,
|
showPreventLeaveModal: false,
|
||||||
leaving_to_page: null,
|
leaving_to_page: null,
|
||||||
@ -285,10 +293,16 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
saveChanges() {
|
saveChanges() {
|
||||||
|
return new Promise((reject, resolve) => {
|
||||||
this.currently_saving = true
|
this.currently_saving = true
|
||||||
this.updateServerData()
|
this.updateServerData().catch(() => {
|
||||||
|
reject()
|
||||||
|
}).finally(() => {
|
||||||
this.currently_saving = false
|
this.currently_saving = false
|
||||||
this.unsaved_changes = false
|
this.unsaved_changes = false
|
||||||
|
resolve()
|
||||||
|
})
|
||||||
|
})
|
||||||
},
|
},
|
||||||
selectPhotosForSlide(slide_index) {
|
selectPhotosForSlide(slide_index) {
|
||||||
this.selectedSlide = slide_index
|
this.selectedSlide = slide_index
|
||||||
@ -401,7 +415,21 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
getPDF() {
|
||||||
|
this.saveChanges().then(() => {
|
||||||
|
this.isGeneratingPDF = true
|
||||||
|
getPhotoLogPDF(this.id).then((response) => {
|
||||||
|
let url = response.data.pdf
|
||||||
|
window.open(url, '_blank')
|
||||||
|
}).catch((error) => {
|
||||||
|
this.message.error('Cannot generate PDF file: ' + error)
|
||||||
|
}).finally(() => {
|
||||||
|
this.isGeneratingPDF = false
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
updateServerData() {
|
updateServerData() {
|
||||||
|
return new Promise((reject, resolve) => {
|
||||||
this.isSavingServer = true
|
this.isSavingServer = true
|
||||||
|
|
||||||
let server_slides = [...this.slides]
|
let server_slides = [...this.slides]
|
||||||
@ -424,8 +452,11 @@ export default {
|
|||||||
this.message.success('Changes saved')
|
this.message.success('Changes saved')
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
this.message.error('There was a problem saving the changes: '+error.message)
|
this.message.error('There was a problem saving the changes: '+error.message)
|
||||||
|
reject()
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
this.isSavingServer = false
|
this.isSavingServer = false
|
||||||
|
resolve()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
continueLeavePage() {
|
continueLeavePage() {
|
||||||
@ -458,6 +489,10 @@ export default {
|
|||||||
min-width: 25em;
|
min-width: 25em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.n-card .n-image {
|
||||||
|
margin-right: 2em;
|
||||||
|
}
|
||||||
|
|
||||||
.add-slide-between-button, .add-slide-between-button * {
|
.add-slide-between-button, .add-slide-between-button * {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user