File size: 10,205 Bytes
4e1d4ee 94e14dc 65d94dd 995e423 3763d04 8c577bf b897754 8c577bf b897754 3a5b355 3763d04 94e14dc b785770 e26678d 669d47e 97438ca 669d47e 2d20cac 669d47e 2d20cac 669d47e b785770 669d47e e26678d 97438ca e26678d 757b606 e26678d 757b606 90eb70e 757b606 90eb70e e26678d 90eb70e 757b606 90eb70e 757b606 90eb70e 757b606 3763d04 995e423 41a6c80 bcd40b3 e26678d bcd40b3 995e423 41a6c80 e26678d bcd40b3 e26678d bcd40b3 a31b49e bcd40b3 41a6c80 e26678d 41a6c80 6506d29 41a6c80 ff18898 bcd40b3 3763d04 94e14dc 669d47e |
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 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>API Request</title>
<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;
font-size: 28px;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}
.container {
display: flex;
justify-content: space-around;
margin-top: 20px;
}
.block {
width: 45%;
text-align: left;
background-color: white;
padding: 20px;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
.form-group {
margin: 20px 0;
}
.form-group label {
display: block;
margin-bottom: 8px;
font-size: 16px;
}
.form-group input,
.form-group select {
width: 100%;
padding: 12px;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 5px;
box-sizing: border-box;
}
button {
display: block;
margin: 20px auto;
color: white;
background-color: #4CAF50;
border: none;
cursor: pointer;
padding: 12px 24px;
font-size: 16px;
border-radius: 5px;
transition: background-color 0.3s ease;
}
button:hover {
background-color: #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;
display: block;
margin-left: auto;
margin-right: auto;
}
#uploadButton:hover {
background-color: #388E3C;
}
/* Стили для выпадающего списка */
#dropdown-container select {
width: 100%;
padding: 12px;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 5px;
box-sizing: border-box;
background-color: white;
appearance: none; /* Убираем стандартные стили браузера */
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M7 10l5 5 5-5z"/></svg>');
background-repeat: no-repeat;
background-position: right 10px center;
background-size: 16px;
}
/* Центрирование заголовков блоков */
.block h2 {
text-align: center;
}
</style>
</head>
<body>
<h1>WhatsMasterGRM - Принудительное обновление базы</h1>
<div class="container">
<div class="block">
<h2>Тильда - Таблица CSV</h2>
<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"> Наличие WhatsApp
</label>
<label>
<input type="checkbox" name="add_curator" value="1"> Добавлять менеджера
</label>
</div>
<input id="uploadButton" type="submit" value="Загрузить пользователей">
</form>
<div id="result"></div>
</div>
<div class="block">
<h2>Бизон 365 - API</h2>
<div class="form-group">
<label for="tokenInput">API-токен администратора Бизон 365:</label>
<input type="text" id="tokenInput" placeholder="Введите токен">
</div>
<div class="form-group">
<label for="dateSelect">Выбор даты:</label>
<select id="dateSelect">
<option value="2021-01-01T00:00:00">2021-01-01</option>
<option value="2022-01-01T00:00:00">2022-01-01</option>
<option value="2023-01-01T00:00:00">2023-01-01</option>
<option value="2024-01-01T00:00:00">2024-01-01</option>
</select>
</div>
<div class="form-group">
<label for="typeSelect">Выбор формата вебинара:</label>
<select id="typeSelect">
<option value="AutoWebinars">Автовебинарные комнаты</option>
<option value="LiveWebinars">Вебинарные комнаты</option>
</select>
</div>
<button id="sendRequestButton">Получить список комнат Бизон 365</button>
<div id="dropdown-container"></div>
<button id="sendGetRequestButton">Обновить базу пользователей WhatCRM</button>
</div>
</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>
<script>
const notyf = new Notyf({
duration: 5000,
position: {
x: 'right',
y: 'top',
},
});
let requestButtonClicked = false;
document.getElementById('sendRequestButton').addEventListener('click', function() {
if (requestButtonClicked) return;
requestButtonClicked = true;
const token = document.getElementById('tokenInput').value;
const minDate = document.getElementById('dateSelect').value;
const type = document.getElementById('typeSelect').value;
const url = '/send_request';
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: 'token=' + encodeURIComponent(token) + '&minDate=' + encodeURIComponent(minDate) + '&type=' + encodeURIComponent(type)
})
.then(response => response.json())
.then(data => {
console.log('JSON Response:', data);
createDropdown(data);
})
.catch(error => {
console.error('Error:', error);
notyf.error('Error: ' + error.message);
})
.finally(() => {
requestButtonClicked = false;
});
});
function createDropdown(data) {
const container = document.getElementById('dropdown-container');
container.innerHTML = '';
const select = document.createElement('select');
select.id = 'dropdown';
select.classList.add('form-group');
data.forEach(item => {
const option = document.createElement('option');
option.value = item;
option.text = item;
select.appendChild(option);
});
container.appendChild(select);
const sendGetRequestButton = document.getElementById('sendGetRequestButton');
sendGetRequestButton.removeEventListener('click', handleGetRequest);
sendGetRequestButton.addEventListener('click', handleGetRequest);
}
function handleGetRequest() {
const selectedValue = document.getElementById('dropdown').value;
const token = document.getElementById('tokenInput').value;
const getUrl = '/send_get_request?token=' + encodeURIComponent(token) + '&webinarId=' + encodeURIComponent(selectedValue);
fetch(getUrl, {
method: 'GET'
})
.then(response => response.json())
.then(data => {
console.log('GET Response:', data);
notyf.success('Пользователи добавлены в базу данных WhatsGRM');
})
.catch(error => {
console.error('Error:', error);
notyf.error('Error: ' + error.message);
});
}
</script>
</body>
</html> |