File size: 4,115 Bytes
5586a08 9c86df2 5bd6539 cb10cfb 5bd6539 5586a08 d6901d9 5586a08 9c86df2 5586a08 d481e21 5586a08 d481e21 9c86df2 5586a08 d481e21 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 |
<!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">
<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;
}
</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>
<!-- Подключение скрипта Notyf -->
<script src="https://cdn.jsdelivr.net/npm/notyf/notyf.min.js"></script>
<script>
document.getElementById('uploadForm').addEventListener('submit', function(event) {
event.preventDefault();
const form = new FormData(this);
// Показываем сообщение "Загрузка началась, пожалуйста, подождите"
const notyf = new Notyf({
duration: 5000, // Длительность показа уведомления
position: {
x: 'right',
y: 'top'
},
types: [
{
type: 'info',
background: 'green',
icon: {
className: 'notyf__icon--info',
tagName: 'span',
text: ''
}
}
]
});
notyf.open({
type: 'info',
message: 'Загрузка началась, пожалуйста, подождите'
});
fetch('/upload_csv', {
method: 'POST',
body: form
})
.then(response => response.json())
.then(data => {
notyf.open({
type: 'success',
message: data.message
});
})
.catch(error => {
console.error('Error:', error);
notyf.open({
type: 'error',
message: 'An error occurred while uploading the file.'
});
});
});
</script>
</body>
</html> |