File size: 6,874 Bytes
5586a08 9c86df2 f628a8a 5bd6539 cb10cfb f628a8a 5bd6539 91f68a0 5bd6539 5586a08 d6901d9 5586a08 91f68a0 5586a08 9c86df2 f628a8a 5586a08 91f68a0 5bd6539 5586a08 5bd6539 9c86df2 5586a08 5bd6539 9c86df2 5586a08 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSV Upload</title>
<!-- Подключение стилей Notyf -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/notyf/notyf.min.css">
<!-- Подключение стилей Bootstrap -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
background-color: #f0f0f0;
margin: 0;
padding: 0;
}
h1 {
background-color: #4CAF50;
color: white;
padding: 20px;
margin: 0;
border-bottom: 2px solid #388E3C;
}
.input-row {
display: flex;
justify-content: center;
gap: 10px;
margin-top: 20px;
}
.input-row input[type="file"] {
padding: 10px;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 5px;
}
.input-row input[type="checkbox"] {
margin-top: 5px;
}
.input-row label {
display: flex;
align-items: center;
color: #4CAF50;
font-size: 16px;
}
#uploadButton {
color: white;
background-color: #4CAF50;
border: none;
cursor: pointer;
padding: 10px 20px;
font-size: 16px;
border-radius: 5px;
margin-top: 20px;
}
#uploadButton:hover {
background-color: #388E3C;
}
.center-spinner {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 1000;
}
.loader {
--b: 10px; /* border thickness */
--n: 10; /* number of dashes*/
--g: 10deg; /* gap between dashes*/
--c: green; /* the color */
width: 100px; /* size */
aspect-ratio: 1;
border-radius: 50%;
padding: 1px; /* get rid of bad outlines */
background: conic-gradient(#0000, var(--c)) content-box;
--_m: /* we use +/-1deg between colors to avoid jagged edges */
repeating-conic-gradient(#0000 0deg,
#000 1deg calc(360deg/var(--n) - var(--g) - 1deg),
#0000 calc(360deg/var(--n) - var(--g)) calc(360deg/var(--n))),
radial-gradient(farthest-side, #0000 calc(98% - var(--b)), #000 calc(100% - var(--b)));
-webkit-mask: var(--_m);
mask: var(--_m);
-webkit-mask-composite: destination-in;
mask-composite: intersect;
animation: load 1s infinite steps(var(--n));
display: none;
}
@keyframes load {
to { transform: rotate(1turn); }
}
</style>
</head>
<body>
<h1>Upload CSV File</h1>
<form id="uploadForm" enctype="multipart/form-data" method="post">
<div class="input-row">
<input type="file" name="file" accept=".csv">
</div>
<div class="input-row">
<label>
<input type="checkbox" name="verify_phone" value="1"> Verify Phone
</label>
<label>
<input type="checkbox" name="add_curator" value="1"> Add Curator
</label>
</div>
<input id="uploadButton" type="submit" value="Upload">
</form>
<div id="result"></div>
<div class="loader center-spinner"></div>
<!-- Подключение скрипта Notyf -->
<script src="https://cdn.jsdelivr.net/npm/notyf/notyf.min.js"></script>
<!-- Подключение скриптов Bootstrap -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<script>
document.getElementById('uploadForm').addEventListener('submit', function(event) {
event.preventDefault();
const form = new FormData(this);
const loader = document.querySelector('.loader');
loader.style.display = 'block'; // Показываем спиннер
fetch('/upload_csv', {
method: 'POST',
body: form
})
.then(response => response.json())
.then(data => {
loader.style.display = 'none'; // Скрываем спиннер после завершения
const notyf = new Notyf({
duration: 5000, // Длительность показа уведомления
position: {
x: 'right',
y: 'bottom'
},
types: [
{
type: 'success',
background: 'green',
icon: {
className: 'notyf__icon--success',
tagName: 'span',
text: ''
}
}
]
});
notyf.success(data.message); // Показываем уведомление с сообщением от сервера
})
.catch(error => {
console.error('Error:', error);
loader.style.display = 'none'; // Скрываем спиннер в случае ошибки
const notyf = new Notyf({
duration: 5000, // Длительность показа уведомления
position: {
x: 'right',
y: 'bottom'
},
types: [
{
type: 'error',
background: 'red',
icon: {
className: 'notyf__icon--error',
tagName: 'span',
text: ''
}
}
]
});
notyf.error('An error occurred while uploading the file.'); // Показываем уведомление об ошибке
});
});
</script>
</body>
</html> |