DmitrMakeev
commited on
Commit
•
86486e4
1
Parent(s):
63c6283
Create upl_csv_b.html
Browse files- upl_csv_b.html +128 -0
upl_csv_b.html
ADDED
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>CSV Upload</title>
|
7 |
+
<!-- Подключение стилей Notyf -->
|
8 |
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/notyf/notyf.min.css">
|
9 |
+
<style>
|
10 |
+
body {
|
11 |
+
font-family: Arial, sans-serif;
|
12 |
+
text-align: center;
|
13 |
+
background-color: #f0f0f0;
|
14 |
+
margin: 0;
|
15 |
+
padding: 0;
|
16 |
+
}
|
17 |
+
h1 {
|
18 |
+
background-color: #4CAF50;
|
19 |
+
color: white;
|
20 |
+
padding: 20px;
|
21 |
+
margin: 0;
|
22 |
+
border-bottom: 2px solid #388E3C;
|
23 |
+
}
|
24 |
+
.input-row {
|
25 |
+
display: flex;
|
26 |
+
justify-content: center;
|
27 |
+
gap: 10px;
|
28 |
+
margin-top: 20px;
|
29 |
+
}
|
30 |
+
.input-row input[type="file"] {
|
31 |
+
padding: 10px;
|
32 |
+
font-size: 16px;
|
33 |
+
border: 1px solid #ccc;
|
34 |
+
border-radius: 5px;
|
35 |
+
}
|
36 |
+
.input-row input[type="checkbox"] {
|
37 |
+
margin-top: 5px;
|
38 |
+
}
|
39 |
+
.input-row label {
|
40 |
+
display: flex;
|
41 |
+
align-items: center;
|
42 |
+
color: #4CAF50;
|
43 |
+
font-size: 16px;
|
44 |
+
}
|
45 |
+
#uploadButton {
|
46 |
+
color: white;
|
47 |
+
background-color: #4CAF50;
|
48 |
+
border: none;
|
49 |
+
cursor: pointer;
|
50 |
+
padding: 10px 20px;
|
51 |
+
font-size: 16px;
|
52 |
+
border-radius: 5px;
|
53 |
+
margin-top: 20px;
|
54 |
+
}
|
55 |
+
#uploadButton:hover {
|
56 |
+
background-color: #388E3C;
|
57 |
+
}
|
58 |
+
</style>
|
59 |
+
</head>
|
60 |
+
<body>
|
61 |
+
<h1>Upload CSV File</h1>
|
62 |
+
<form id="uploadForm" enctype="multipart/form-data" method="post">
|
63 |
+
<div class="input-row">
|
64 |
+
<input type="file" name="file" accept=".csv">
|
65 |
+
</div>
|
66 |
+
<div class="input-row">
|
67 |
+
<label>
|
68 |
+
<input type="checkbox" name="verify_phone" value="1"> Verify Phone
|
69 |
+
</label>
|
70 |
+
<label>
|
71 |
+
<input type="checkbox" name="add_curator" value="1"> Add Curator
|
72 |
+
</label>
|
73 |
+
</div>
|
74 |
+
<input id="uploadButton" type="submit" value="Upload">
|
75 |
+
</form>
|
76 |
+
<div id="result"></div>
|
77 |
+
|
78 |
+
<!-- Подключение скрипта Notyf -->
|
79 |
+
<script src="https://cdn.jsdelivr.net/npm/notyf/notyf.min.js"></script>
|
80 |
+
<script>
|
81 |
+
document.getElementById('uploadForm').addEventListener('submit', function(event) {
|
82 |
+
event.preventDefault();
|
83 |
+
const form = new FormData(this);
|
84 |
+
// Показываем сообщение "Загрузка началась, пожалуйста, подождите"
|
85 |
+
const notyf = new Notyf({
|
86 |
+
duration: 5000, // Длительность показа уведомления
|
87 |
+
position: {
|
88 |
+
x: 'right',
|
89 |
+
y: 'top'
|
90 |
+
},
|
91 |
+
types: [
|
92 |
+
{
|
93 |
+
type: 'info',
|
94 |
+
background: 'green',
|
95 |
+
icon: {
|
96 |
+
className: 'notyf__icon--info',
|
97 |
+
tagName: 'span',
|
98 |
+
text: ''
|
99 |
+
}
|
100 |
+
}
|
101 |
+
]
|
102 |
+
});
|
103 |
+
notyf.open({
|
104 |
+
type: 'info',
|
105 |
+
message: 'Загрузка началась, пожалуйста, подождите'
|
106 |
+
});
|
107 |
+
fetch('/upload_csv', {
|
108 |
+
method: 'POST',
|
109 |
+
body: form
|
110 |
+
})
|
111 |
+
.then(response => response.json())
|
112 |
+
.then(data => {
|
113 |
+
notyf.open({
|
114 |
+
type: 'success',
|
115 |
+
message: data.message
|
116 |
+
});
|
117 |
+
})
|
118 |
+
.catch(error => {
|
119 |
+
console.error('Error:', error);
|
120 |
+
notyf.open({
|
121 |
+
type: 'error',
|
122 |
+
message: 'An error occurred while uploading the file.'
|
123 |
+
});
|
124 |
+
});
|
125 |
+
});
|
126 |
+
</script>
|
127 |
+
</body>
|
128 |
+
</html>
|