Update upl_csv.html
Browse files- upl_csv.html +31 -36
upl_csv.html
CHANGED
|
@@ -81,53 +81,48 @@
|
|
| 81 |
document.getElementById('uploadForm').addEventListener('submit', function(event) {
|
| 82 |
event.preventDefault();
|
| 83 |
const form = new FormData(this);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
fetch('/upload_csv', {
|
| 85 |
method: 'POST',
|
| 86 |
body: form
|
| 87 |
})
|
| 88 |
.then(response => response.json())
|
| 89 |
.then(data => {
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
x: 'right',
|
| 94 |
-
y: 'bottom'
|
| 95 |
-
},
|
| 96 |
-
types: [
|
| 97 |
-
{
|
| 98 |
-
type: 'success',
|
| 99 |
-
background: 'green',
|
| 100 |
-
icon: {
|
| 101 |
-
className: 'notyf__icon--success',
|
| 102 |
-
tagName: 'span',
|
| 103 |
-
text: ''
|
| 104 |
-
}
|
| 105 |
-
}
|
| 106 |
-
]
|
| 107 |
});
|
| 108 |
-
notyf.success(data.message); // Показываем уведомление с сообщением от сервера
|
| 109 |
})
|
| 110 |
.catch(error => {
|
| 111 |
console.error('Error:', error);
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
x: 'right',
|
| 116 |
-
y: 'bottom'
|
| 117 |
-
},
|
| 118 |
-
types: [
|
| 119 |
-
{
|
| 120 |
-
type: 'error',
|
| 121 |
-
background: 'red',
|
| 122 |
-
icon: {
|
| 123 |
-
className: 'notyf__icon--error',
|
| 124 |
-
tagName: 'span',
|
| 125 |
-
text: ''
|
| 126 |
-
}
|
| 127 |
-
}
|
| 128 |
-
]
|
| 129 |
});
|
| 130 |
-
notyf.error('An error occurred while uploading the file.'); // Показываем уведомление об ошибке
|
| 131 |
});
|
| 132 |
});
|
| 133 |
</script>
|
|
|
|
| 81 |
document.getElementById('uploadForm').addEventListener('submit', function(event) {
|
| 82 |
event.preventDefault();
|
| 83 |
const form = new FormData(this);
|
| 84 |
+
|
| 85 |
+
// Показываем сообщение "Загрузка началась, пожалуйста, подождите"
|
| 86 |
+
const notyf = new Notyf({
|
| 87 |
+
duration: 5000, // Длительность показа уведомления
|
| 88 |
+
position: {
|
| 89 |
+
x: 'right',
|
| 90 |
+
y: 'top'
|
| 91 |
+
},
|
| 92 |
+
types: [
|
| 93 |
+
{
|
| 94 |
+
type: 'info',
|
| 95 |
+
background: 'green',
|
| 96 |
+
icon: {
|
| 97 |
+
className: 'notyf__icon--info',
|
| 98 |
+
tagName: 'span',
|
| 99 |
+
text: ''
|
| 100 |
+
}
|
| 101 |
+
}
|
| 102 |
+
]
|
| 103 |
+
});
|
| 104 |
+
notyf.open({
|
| 105 |
+
type: 'info',
|
| 106 |
+
message: 'Загрузка началась, пожалуйста, подождите'
|
| 107 |
+
});
|
| 108 |
+
|
| 109 |
fetch('/upload_csv', {
|
| 110 |
method: 'POST',
|
| 111 |
body: form
|
| 112 |
})
|
| 113 |
.then(response => response.json())
|
| 114 |
.then(data => {
|
| 115 |
+
notyf.open({
|
| 116 |
+
type: 'success',
|
| 117 |
+
message: data.message
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
});
|
|
|
|
| 119 |
})
|
| 120 |
.catch(error => {
|
| 121 |
console.error('Error:', error);
|
| 122 |
+
notyf.open({
|
| 123 |
+
type: 'error',
|
| 124 |
+
message: 'An error occurred while uploading the file.'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
});
|
|
|
|
| 126 |
});
|
| 127 |
});
|
| 128 |
</script>
|