DmitrMakeev commited on
Commit
e0b0269
1 Parent(s): a5d5813

Update data_gc_tab.html

Browse files
Files changed (1) hide show
  1. data_gc_tab.html +135 -112
data_gc_tab.html CHANGED
@@ -208,119 +208,142 @@
208
  </div>
209
  <div id="example-table"></div>
210
 
211
- <script>
212
- vkBridge.send('VKWebAppInit');
213
- document.addEventListener('DOMContentLoaded', function() {
214
- fetch('https://dmtuit-gcapirabiz.hf.space/data_gc_tab_out?api_sys=fasSd345D')
215
- .then(response => response.json())
216
- .then(data => {
217
- console.log('Data received:', data); // Логирование данных
218
- // Переворачиваем массив данных
219
- data.reverse();
220
- var linkFormatter = function(cell, formatterParams, onRendered) {
221
- var curator = cell.getValue();
222
- var curatorLink = cell.getData().curator_link;
223
- return `<a href="${curatorLink}" target="_blank">${curator}</a>`;
224
- };
225
- var table = new Tabulator("#example-table", {
226
- data: data, // set table data
227
- layout: "fitColumns", // fit columns to width of table
228
- pagination: "local", // enable local pagination
229
- paginationSize: 50, // number of rows per page
230
- selectable: true, // enable row selection
231
- columns: [
232
- {title:"Номер в списке", field:"id"},
233
- {title:"Имя", field:"name", width:100},
234
- {title:"WhatsApp", field:"phone", formatter: function(cell, formatterParams, onRendered) {
235
- var phone = cell.getValue();
236
- return `<a href="https://web.whatsapp.com/send?phone=${phone}" target="_blank">${phone}</a>`;
237
- }, width:120},
238
- {title:"Город", field:"b_city", width:110},
239
- {title:"Email", field:"email", width:110},
240
- {title:"Реплики", field:"b_mess", width:95},
241
- {title:"Куратор", field:"curator", formatter: linkFormatter},
242
- {title:"Статус покупки", field:"shop_st", formatter: function(cell, formatterParams, onRendered) {
243
- var status = cell.getValue();
244
- var color;
245
- switch (status) {
246
- case 'green':
247
- color = 'green';
248
- break;
249
- case 'red':
250
- color = 'red';
251
- break;
252
- case 'yellow':
253
- color = 'yellow';
254
- break;
255
- default:
256
- color = 'gray';
257
- }
258
- return `<div style="width: 20px; height: 20px; background-color: ${color};"></div>`;
259
- }},
260
- {title:"Ссылка на пользователя в GC", field:"ad_url", formatter: function(cell, formatterParams, onRendered) {
261
- var ad_url = cell.getValue();
262
- return `<a href="${ad_url}" target="_blank">${ad_url}</a>`;
263
- }},
264
- {title:"Ссылка на VK", field:"vk_id", formatter: function(cell, formatterParams, onRendered) {
265
- var vk_id = cell.getValue();
266
- return `<a href="https://vk.com/id${vk_id}" target="_blank">${vk_id}</a>`;
267
- }},
268
- {title:"Ссылка на Tg", field:"chat_id", formatter: function(cell, formatterParams, onRendered) {
269
- var chatId = cell.getValue();
270
- if (chatId.startsWith('@')) {
271
- chatId = chatId.substring(1); // Удаление символа @ в начале
272
- }
273
- return `<a href="https://t.me/${chatId}" target="_blank">${chatId}</a>`;
274
- }},
275
- {title:"Статус WhatsApp", field:"ws_st"},
276
- {title:"Стутус подписки", field:"ws_stop"},
277
- {title:"Вебинары", field:"web_st", formatter:"star", formatterParams:{stars:7}, hozAlign:"center", width:120},
278
- {title:"Прогрес по воронке", field:"fin_prog", formatter:"progress", formatterParams:{color:["#00dd00", "orange", "rgb(255,0,0)"]}, sorter:"number", width:100},
279
- {title:"pr1", field:"pr1"},
280
- {title:"pr2", field:"pr2"},
281
- {title:"pr3", field:"pr3"},
282
- {title:"Канал трафика", field:"pr4"},
283
- {title:"Дата", field:"pr5"},
284
- {title:"Ключ PR", field:"key_pr"},
285
- {title:"Канал", field:"canal"},
286
- {title:"Дата", field:"data_t"}
287
- ],
288
- });
289
- var fieldEl = document.getElementById("filter-field");
290
- var typeEl = document.getElementById("filter-type");
291
- var valueEl = document.getElementById("filter-value");
292
- function updateFilter() {
293
- var filterVal = fieldEl.options[fieldEl.selectedIndex].value;
294
- var typeVal = typeEl.options[typeEl.selectedIndex].value;
295
- if (filterVal) {
296
- table.setFilter(filterVal, typeVal, valueEl.value);
297
- }
298
- }
299
- document.getElementById("filter-field").addEventListener("change", updateFilter);
300
- document.getElementById("filter-type").addEventListener("change", updateFilter);
301
- document.getElementById("filter-value").addEventListener("keyup", updateFilter);
302
- document.getElementById("filter-clear").addEventListener("click", function() {
303
- fieldEl.value = "";
304
- typeEl.value = "=";
305
- valueEl.value = "";
306
- table.clearFilter();
307
- });
308
- function handleDownloadJson() {
309
- var tableData = table.getData("active");
310
- var jsonData = JSON.stringify(tableData, null, 2);
311
- console.log("Данные для рассылки:", jsonData);
312
- }
313
- function handleTakeForYourself() {
314
- var tableData = table.getData("active");
315
- var jsonData = JSON.stringify(tableData, null, 2);
316
- console.log("Данные для себя:", jsonData);
317
  }
318
- document.getElementById("download-json").addEventListener("click", handleDownloadJson);
319
- document.getElementById("take-for-yourself").addEventListener("click", handleTakeForYourself);
320
- })
321
- .catch(error => console.error('Error fetching data:', error));
322
- });
323
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
324
  </body>
325
 
326
  </html>
 
208
  </div>
209
  <div id="example-table"></div>
210
 
211
+
212
+
213
+
214
+
215
+ <script>
216
+ // Функция для создания всплывающего окна с деталями строки
217
+ var rowPopupFormatter = function(e, row, onRendered){
218
+ var data = row.getData(),
219
+ container = document.createElement("div"),
220
+ contents = "<strong style='font-size:1.2em;'>Детали пользователя</strong><br/><ul style='padding:0; margin-top:10px; margin-bottom:0;'>";
221
+ contents += "<li><strong>Имя:</strong> " + data.name + "</li>";
222
+ contents += "<li><strong>Реплики:</strong> " + data.b_mess + "</li>";
223
+ contents += "</ul>";
224
+
225
+ container.innerHTML = contents;
226
+
227
+ return container;
228
+ };
229
+
230
+ // Инициализация таблицы с использованием rowClickPopup
231
+ document.addEventListener('DOMContentLoaded', function() {
232
+ fetch('https://dmtuit-gcapirabiz.hf.space/data_gc_tab_out?api_sys=fasSd345D')
233
+ .then(response => response.json())
234
+ .then(data => {
235
+ console.log('Data received:', data); // Логирование данных
236
+ // Переворачиваем массив данных
237
+ data.reverse();
238
+ var linkFormatter = function(cell, formatterParams, onRendered) {
239
+ var curator = cell.getValue();
240
+ var curatorLink = cell.getData().curator_link;
241
+ return `<a href="${curatorLink}" target="_blank">${curator}</a>`;
242
+ };
243
+ var table = new Tabulator("#example-table", {
244
+ data: data, // set table data
245
+ layout: "fitColumns", // fit columns to width of table
246
+ pagination: "local", // enable local pagination
247
+ paginationSize: 50, // number of rows per page
248
+ selectable: true, // enable row selection
249
+ rowClickPopup: rowPopupFormatter, // добавляем всплывающее окно при клике на строку
250
+ columns: [
251
+ {title:"Номер в списке", field:"id"},
252
+ {title:"Имя", field:"name", width:100},
253
+ {title:"WhatsApp", field:"phone", formatter: function(cell, formatterParams, onRendered) {
254
+ var phone = cell.getValue();
255
+ return `<a href="https://web.whatsapp.com/send?phone=${phone}" target="_blank">${phone}</a>`;
256
+ }, width:120},
257
+ {title:"Город", field:"b_city", width:110},
258
+ {title:"Email", field:"email", width:110},
259
+ {title:"Реплики", field:"b_mess", width:95},
260
+ {title:"Куратор", field:"curator", formatter: linkFormatter},
261
+ {title:"Статус покупки", field:"shop_st", formatter: function(cell, formatterParams, onRendered) {
262
+ var status = cell.getValue();
263
+ var color;
264
+ switch (status) {
265
+ case 'green':
266
+ color = 'green';
267
+ break;
268
+ case 'red':
269
+ color = 'red';
270
+ break;
271
+ case 'yellow':
272
+ color = 'yellow';
273
+ break;
274
+ default:
275
+ color = 'gray';
276
+ }
277
+ return `<div style="width: 20px; height: 20px; background-color: ${color};"></div>`;
278
+ }},
279
+ {title:"Ссылка на пользователя в GC", field:"ad_url", formatter: function(cell, formatterParams, onRendered) {
280
+ var ad_url = cell.getValue();
281
+ return `<a href="${ad_url}" target="_blank">${ad_url}</a>`;
282
+ }},
283
+ {title:"Ссылка на VK", field:"vk_id", formatter: function(cell, formatterParams, onRendered) {
284
+ var vk_id = cell.getValue();
285
+ return `<a href="https://vk.com/id${vk_id}" target="_blank">${vk_id}</a>`;
286
+ }},
287
+ {title:"Ссылка на Tg", field:"chat_id", formatter: function(cell, formatterParams, onRendered) {
288
+ var chatId = cell.getValue();
289
+ if (chatId.startsWith('@')) {
290
+ chatId = chatId.substring(1); // Удаление символа @ в начале
291
+ }
292
+ return `<a href="https://t.me/${chatId}" target="_blank">${chatId}</a>`;
293
+ }},
294
+ {title:"Статус WhatsApp", field:"ws_st"},
295
+ {title:"Стутус подписки", field:"ws_stop"},
296
+ {title:"Вебинары", field:"web_st", formatter:"star", formatterParams:{stars:7}, hozAlign:"center", width:120},
297
+ {title:"Прогрес по воронке", field:"fin_prog", formatter:"progress", formatterParams:{color:["#00dd00", "orange", "rgb(255,0,0)"]}, sorter:"number", width:100},
298
+ {title:"pr1", field:"pr1"},
299
+ {title:"pr2", field:"pr2"},
300
+ {title:"pr3", field:"pr3"},
301
+ {title:"Канал трафика", field:"pr4"},
302
+ {title:"Дата", field:"pr5"},
303
+ {title:"Ключ PR", field:"key_pr"},
304
+ {title:"Канал", field:"canal"},
305
+ {title:"Дата", field:"data_t"}
306
+ ],
307
+ });
308
+ var fieldEl = document.getElementById("filter-field");
309
+ var typeEl = document.getElementById("filter-type");
310
+ var valueEl = document.getElementById("filter-value");
311
+ function updateFilter() {
312
+ var filterVal = fieldEl.options[fieldEl.selectedIndex].value;
313
+ var typeVal = typeEl.options[typeEl.selectedIndex].value;
314
+ if (filterVal) {
315
+ table.setFilter(filterVal, typeVal, valueEl.value);
 
316
  }
317
+ }
318
+ document.getElementById("filter-field").addEventListener("change", updateFilter);
319
+ document.getElementById("filter-type").addEventListener("change", updateFilter);
320
+ document.getElementById("filter-value").addEventListener("keyup", updateFilter);
321
+ document.getElementById("filter-clear").addEventListener("click", function() {
322
+ fieldEl.value = "";
323
+ typeEl.value = "=";
324
+ valueEl.value = "";
325
+ table.clearFilter();
326
+ });
327
+ function handleDownloadJson() {
328
+ var tableData = table.getData("active");
329
+ var jsonData = JSON.stringify(tableData, null, 2);
330
+ console.log("Данные для рассылки:", jsonData);
331
+ }
332
+ function handleTakeForYourself() {
333
+ var tableData = table.getData("active");
334
+ var jsonData = JSON.stringify(tableData, null, 2);
335
+ console.log("Данные для себя:", jsonData);
336
+ }
337
+ document.getElementById("download-json").addEventListener("click", handleDownloadJson);
338
+ document.getElementById("take-for-yourself").addEventListener("click", handleTakeForYourself);
339
+ })
340
+ .catch(error => console.error('Error fetching data:', error));
341
+ });
342
+ </script>
343
+
344
+
345
+
346
+
347
  </body>
348
 
349
  </html>