add simple split and merge option
This commit is contained in:
parent
b8a34dd2a7
commit
53c7cb1db3
14 changed files with 264 additions and 232 deletions
84
static/js/merge.js
Normal file
84
static/js/merge.js
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
/* eslint-disable new-cap */
|
||||
/* eslint-disable camelcase */
|
||||
/* eslint-disable no-console */
|
||||
|
||||
let uuid;
|
||||
let pdf_uploaded = false;
|
||||
import('./pdf_api_wrapper.js');
|
||||
|
||||
// eslint-disable-next-line no-undef, no-unused-vars
|
||||
const vueInstance = new Vue({
|
||||
el: '#app',
|
||||
data() {
|
||||
return {
|
||||
pdf_file: null,
|
||||
project_uuid: null,
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
window.addEventListener('load', () => this.side_loaded());
|
||||
},
|
||||
methods: {
|
||||
move_page(from_page, to_page) {
|
||||
console.debug('trying to move page: ', from_page, to_page);
|
||||
fetch(`/move_page/${this.project_uuid}/${from_page}/${to_page}`, {
|
||||
method: 'GET',
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
console.debug('data from Backend: ', data);
|
||||
if (data.status === 200) {
|
||||
this.display_pages();
|
||||
console.info('Page was moved');
|
||||
} else {
|
||||
console.error('Page could not be moved');
|
||||
}
|
||||
})
|
||||
.catch((error) => console.error(error));
|
||||
},
|
||||
side_loaded() {
|
||||
document.getElementById('btn_download_complete').addEventListener('click', () => new pdf_api_wrapper(`${uuid}`).download_pdf());
|
||||
|
||||
fetch('/init_project/', {
|
||||
method: 'GET',
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
console.debug('data from Backend: ', data);
|
||||
if (data.status === 200) {
|
||||
this.project_uuid = data.project_uuid;
|
||||
uuid = data.project_uuid;
|
||||
} else {
|
||||
this.project_uuid = null;
|
||||
console.error('Project could not be created');
|
||||
}
|
||||
})
|
||||
.catch((error) => console.error(error));
|
||||
|
||||
// Dropzone has been added as a global variable.
|
||||
// eslint-disable-next-line no-undef
|
||||
const dropzone = new Dropzone('div#pdf-dropzone', {
|
||||
url: '/add_pdf_to_project/',
|
||||
paramName: 'pdf',
|
||||
});
|
||||
|
||||
dropzone.on('addedfile', (file) => {
|
||||
console.log('A file has been added');
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
file.previewElement.innerHTML = '';
|
||||
console.debug('Suppress file.previewElement');
|
||||
console.debug('PDF Project UUID: ', this.project_uuid);
|
||||
});
|
||||
|
||||
dropzone.on('sending', (file, xhr, formData) => {
|
||||
formData.append('uuid', uuid);
|
||||
});
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
dropzone.on('complete', (file, xhr, formData) => {
|
||||
pdf_uploaded = true;
|
||||
document.getElementById('btn-group-download').style.display = 'flex';
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
let uuid;
|
||||
let pdf_uploaded = false;
|
||||
import('./pdf_api_wrapper');
|
||||
import('./pdf_api_wrapper.js');
|
||||
|
||||
// eslint-disable-next-line no-undef, no-unused-vars
|
||||
const vueInstance = new Vue({
|
||||
|
|
|
|||
84
static/js/split.js
Normal file
84
static/js/split.js
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
/* eslint-disable new-cap */
|
||||
/* eslint-disable camelcase */
|
||||
/* eslint-disable no-console */
|
||||
|
||||
let uuid;
|
||||
let pdf_uploaded = false;
|
||||
import('./pdf_api_wrapper.js');
|
||||
|
||||
// eslint-disable-next-line no-undef, no-unused-vars
|
||||
const vueInstance = new Vue({
|
||||
el: '#app',
|
||||
data() {
|
||||
return {
|
||||
pdf_file: null,
|
||||
project_uuid: null,
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
window.addEventListener('load', () => this.side_loaded());
|
||||
},
|
||||
methods: {
|
||||
move_page(from_page, to_page) {
|
||||
console.debug('trying to move page: ', from_page, to_page);
|
||||
fetch(`/move_page/${this.project_uuid}/${from_page}/${to_page}`, {
|
||||
method: 'GET',
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
console.debug('data from Backend: ', data);
|
||||
if (data.status === 200) {
|
||||
this.display_pages();
|
||||
console.info('Page was moved');
|
||||
} else {
|
||||
console.error('Page could not be moved');
|
||||
}
|
||||
})
|
||||
.catch((error) => console.error(error));
|
||||
},
|
||||
side_loaded() {
|
||||
document.getElementById('btn_download_singel_pages').addEventListener('click', () => new pdf_api_wrapper(`${uuid}`).download_split_pdf());
|
||||
|
||||
fetch('/init_project/', {
|
||||
method: 'GET',
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
console.debug('data from Backend: ', data);
|
||||
if (data.status === 200) {
|
||||
this.project_uuid = data.project_uuid;
|
||||
uuid = data.project_uuid;
|
||||
} else {
|
||||
this.project_uuid = null;
|
||||
console.error('Project could not be created');
|
||||
}
|
||||
})
|
||||
.catch((error) => console.error(error));
|
||||
|
||||
// Dropzone has been added as a global variable.
|
||||
// eslint-disable-next-line no-undef
|
||||
const dropzone = new Dropzone('div#pdf-dropzone', {
|
||||
url: '/add_pdf_to_project/',
|
||||
paramName: 'pdf',
|
||||
});
|
||||
|
||||
dropzone.on('addedfile', (file) => {
|
||||
console.log('A file has been added');
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
file.previewElement.innerHTML = '';
|
||||
console.debug('Suppress file.previewElement');
|
||||
console.debug('PDF Project UUID: ', this.project_uuid);
|
||||
});
|
||||
|
||||
dropzone.on('sending', (file, xhr, formData) => {
|
||||
formData.append('uuid', uuid);
|
||||
});
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
dropzone.on('complete', (file, xhr, formData) => {
|
||||
pdf_uploaded = true;
|
||||
document.getElementById('btn-group-download').style.display = 'flex';
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue