add simple split and merge option
This commit is contained in:
parent
b8a34dd2a7
commit
53c7cb1db3
14 changed files with 264 additions and 232 deletions
|
|
@ -1,36 +0,0 @@
|
|||
div {
|
||||
/* border: 2px solid yellowgreen; */
|
||||
}
|
||||
|
||||
|
||||
.div_float_clear {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
|
||||
/* The snackbar - position it at the bottom and in the middle of the screen */
|
||||
#snackbar {
|
||||
visibility: hidden; /* Hidden by default. Visible on click */
|
||||
min-width: 800px; /* Set a default minimum width */
|
||||
margin-left: -400px; /* Divide value of min-width by 2 */
|
||||
background-color: #333; /* Black background color */
|
||||
color: #fff; /* White text color */
|
||||
text-align: center; /* Centered text */
|
||||
border-radius: 2px; /* Rounded borders */
|
||||
padding: 16px; /* Padding */
|
||||
position: fixed; /* Sit on top of the screen */
|
||||
z-index: 1; /* Add a z-index if needed */
|
||||
left: 50%; /* Center the snackbar */
|
||||
bottom: 30px; /* 30px from the bottom */
|
||||
}
|
||||
|
||||
/* Show the snackbar when clicking on a button (class added with JavaScript) */
|
||||
#snackbar.show {
|
||||
visibility: visible; /* Show the snackbar */
|
||||
/* Add animation: Take 0.5 seconds to fade in and out the snackbar.
|
||||
However, delay the fade out process for 2.5 seconds */
|
||||
/*
|
||||
-webkit-animation: fadein 0.5s, fadeout 0.5s 2.5s;
|
||||
animation: fadein 0.5s, fadeout 0.5s 2.5s;
|
||||
*/
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
.div_float_clear {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
/* The snackbar - position it at the bottom and in the middle of the screen */
|
||||
#snackbar {
|
||||
visibility: hidden; /* Hidden by default. Visible on click */
|
||||
min-width: 800px; /* Set a default minimum width */
|
||||
margin-left: -400px; /* Divide value of min-width by 2 */
|
||||
background-color: #333; /* Black background color */
|
||||
color: #fff; /* White text color */
|
||||
text-align: center; /* Centered text */
|
||||
border-radius: 2px; /* Rounded borders */
|
||||
padding: 16px; /* Padding */
|
||||
position: fixed; /* Sit on top of the screen */
|
||||
z-index: 1; /* Add a z-index if needed */
|
||||
left: 50%; /* Center the snackbar */
|
||||
bottom: 30px; /* 30px from the bottom */
|
||||
}
|
||||
|
||||
/* Show the snackbar when clicking on a button (class added with JavaScript) */
|
||||
#snackbar.show {
|
||||
visibility: visible; /* Show the snackbar */
|
||||
/* Add animation: Take 0.5 seconds to fade in and out the snackbar.
|
||||
However, delay the fade out process for 2.5 seconds */
|
||||
/*
|
||||
-webkit-animation: fadein 0.5s, fadeout 0.5s 2.5s;
|
||||
animation: fadein 0.5s, fadeout 0.5s 2.5s;
|
||||
*/
|
||||
}
|
||||
|
||||
@media (min-width: 992px) {
|
||||
.nav-item.active {
|
||||
border-bottom: 1px solid var(--bs-nav-link-color);
|
||||
}
|
||||
}
|
||||
9
static/css/merge.css
Normal file
9
static/css/merge.css
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
#btn-group-download {
|
||||
width: 100%;
|
||||
margin-top: 1em;
|
||||
display: none;
|
||||
}
|
||||
#btn_download_complete {
|
||||
width: 100%;
|
||||
}
|
||||
|
|
@ -17,9 +17,6 @@
|
|||
width: 500px;
|
||||
text-align: center;
|
||||
}
|
||||
.pdf-interact-buttons {
|
||||
padding-left: 1em;
|
||||
}
|
||||
|
||||
#btn-group-download {
|
||||
width: 100%;
|
||||
|
|
|
|||
9
static/css/split.css
Normal file
9
static/css/split.css
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
#btn-group-download {
|
||||
width: 100%;
|
||||
margin-top: 1em;
|
||||
display: none;
|
||||
}
|
||||
#btn_download_singel_pages {
|
||||
width: 100%;
|
||||
}
|
||||
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