DmitrMakeev
commited on
Commit
•
f017436
1
Parent(s):
e9e551b
Update data_gc_tab.html
Browse files- data_gc_tab.html +80 -69
data_gc_tab.html
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
<head>
|
2 |
<meta charset="UTF-8">
|
3 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
@@ -152,7 +154,7 @@
|
|
152 |
<option value="vk_id">Ссылка на VK</option>
|
153 |
<option value="chat_id">Ссылка на Tg</option>
|
154 |
<option value="ws_st">Статус WhatsApp</option>
|
155 |
-
<option value="ws_stop"
|
156 |
<option value="web_st">Вебинары</option>
|
157 |
<option value="fin_prog">Прогрес по воронке</option>
|
158 |
<option value="pr1">pr1</option>
|
@@ -185,114 +187,123 @@
|
|
185 |
|
186 |
<script>
|
187 |
document.addEventListener('DOMContentLoaded', function() {
|
188 |
-
fetch('/data_gc_tab_out?api_sys=fasSd345D')
|
189 |
.then(response => response.json())
|
190 |
.then(data => {
|
|
|
|
|
191 |
var linkFormatter = function(cell, formatterParams, onRendered) {
|
192 |
var curator = cell.getValue();
|
193 |
var curatorLink = cell.getData().curator_link;
|
194 |
return `<a href="${curatorLink}" target="_blank">${curator}</a>`;
|
195 |
};
|
196 |
-
|
197 |
var table = new Tabulator("#example-table", {
|
198 |
-
data: data,
|
199 |
-
layout: "fitColumns",
|
200 |
-
pagination: "local",
|
201 |
-
paginationSize: 50,
|
202 |
columns: [
|
203 |
-
{title:
|
204 |
-
{title:
|
205 |
-
{title:
|
206 |
-
{title:
|
207 |
-
{title:
|
208 |
-
{title:
|
209 |
var status = cell.getValue();
|
210 |
var color;
|
211 |
switch (status) {
|
212 |
-
case 'green':
|
213 |
-
|
214 |
-
|
215 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
}
|
217 |
return `<div style="width: 20px; height: 20px; background-color: ${color};"></div>`;
|
218 |
}},
|
219 |
-
{title:
|
220 |
var ad_url = cell.getValue();
|
221 |
return `<a href="${ad_url}" target="_blank">${ad_url}</a>`;
|
222 |
}},
|
223 |
-
{title:
|
224 |
var vk_id = cell.getValue();
|
225 |
return `<a href="https://vk.com/id${vk_id}" target="_blank">${vk_id}</a>`;
|
226 |
}},
|
227 |
-
{title:
|
228 |
var chatId = cell.getValue();
|
229 |
if (chatId.startsWith('@')) {
|
230 |
-
chatId = chatId.substring(1);
|
231 |
}
|
232 |
return `<a href="https://t.me/${chatId}" target="_blank">${chatId}</a>`;
|
233 |
}},
|
234 |
-
{title:
|
235 |
var phone = cell.getValue();
|
236 |
return `<a href="https://web.whatsapp.com/send?phone=${phone}" target="_blank">${phone}</a>`;
|
237 |
}},
|
238 |
-
{title:
|
239 |
-
{title:
|
240 |
-
{title:
|
241 |
-
{title:
|
242 |
-
{title:
|
243 |
-
{title:
|
244 |
-
{title:
|
245 |
-
{title: "
|
246 |
-
{title:
|
247 |
-
{title: "
|
248 |
-
{title:
|
249 |
-
{title:
|
250 |
-
{title: "pr2", field: "pr2"},
|
251 |
-
{title: "pr3", field: "pr3"},
|
252 |
-
{title: "pr4", field: "pr4"},
|
253 |
-
{title: "pr5", field: "pr5"},
|
254 |
-
{title: "Канал трафика", field: "canal"},
|
255 |
-
{title: "Дата", field: "data_t"},
|
256 |
],
|
257 |
});
|
258 |
-
|
259 |
-
document.getElementById("filter-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
table.clearFilter();
|
264 |
-
});
|
265 |
-
|
266 |
function updateFilter() {
|
267 |
-
var
|
268 |
-
var
|
269 |
-
|
270 |
-
|
271 |
-
table.setFilter(field, type, value);
|
272 |
}
|
273 |
}
|
274 |
-
|
275 |
document.getElementById("filter-field").addEventListener("change", updateFilter);
|
276 |
document.getElementById("filter-type").addEventListener("change", updateFilter);
|
277 |
document.getElementById("filter-value").addEventListener("keyup", updateFilter);
|
278 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
279 |
document.getElementById("download-json").addEventListener("click", function() {
|
280 |
-
|
281 |
-
var jsonString = JSON.stringify(selectedData);
|
282 |
-
var blob = new Blob([jsonString], {type: "application/json"});
|
283 |
-
var url = URL.createObjectURL(blob);
|
284 |
-
var a = document.createElement("a");
|
285 |
-
a.href = url;
|
286 |
-
a.download = "selectedData.json";
|
287 |
-
document.body.appendChild(a);
|
288 |
-
a.click();
|
289 |
-
document.body.removeChild(a);
|
290 |
});
|
291 |
})
|
292 |
-
.catch(error =>
|
293 |
-
console.error('Error fetching data:', error);
|
294 |
-
});
|
295 |
});
|
296 |
</script>
|
297 |
</body>
|
298 |
-
|
|
|
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">
|
|
|
154 |
<option value="vk_id">Ссылка на VK</option>
|
155 |
<option value="chat_id">Ссылка на Tg</option>
|
156 |
<option value="ws_st">Статус WhatsApp</option>
|
157 |
+
<option value="ws_stop">Стутус подписки</option>
|
158 |
<option value="web_st">Вебинары</option>
|
159 |
<option value="fin_prog">Прогрес по воронке</option>
|
160 |
<option value="pr1">pr1</option>
|
|
|
187 |
|
188 |
<script>
|
189 |
document.addEventListener('DOMContentLoaded', function() {
|
190 |
+
fetch('https://dmtuit-gc-api-raBiz.hf.space/data_gc_tab_out?api_sys=fasSd345D')
|
191 |
.then(response => response.json())
|
192 |
.then(data => {
|
193 |
+
console.log('Data received:', data); // Логирование данных
|
194 |
+
// Пользовательский форматтер для ссылки на куратора
|
195 |
var linkFormatter = function(cell, formatterParams, onRendered) {
|
196 |
var curator = cell.getValue();
|
197 |
var curatorLink = cell.getData().curator_link;
|
198 |
return `<a href="${curatorLink}" target="_blank">${curator}</a>`;
|
199 |
};
|
|
|
200 |
var table = new Tabulator("#example-table", {
|
201 |
+
data: data, // set table data
|
202 |
+
layout: "fitColumns", // fit columns to width of table
|
203 |
+
pagination: "local", // enable local pagination
|
204 |
+
paginationSize: 50, // number of rows per page
|
205 |
columns: [
|
206 |
+
{title:"Номер в списке", field:"id"},
|
207 |
+
{title:"Имя", field:"name"},
|
208 |
+
{title:"Телефон", field:"phone"},
|
209 |
+
{title:"Email", field:"email"},
|
210 |
+
{title:"Куратор", field:"curator", formatter: linkFormatter},
|
211 |
+
{title:"Статус покупки", field:"shop_st", formatter: function(cell, formatterParams, onRendered) {
|
212 |
var status = cell.getValue();
|
213 |
var color;
|
214 |
switch (status) {
|
215 |
+
case 'green':
|
216 |
+
color = 'green';
|
217 |
+
break;
|
218 |
+
case 'red':
|
219 |
+
color = 'red';
|
220 |
+
break;
|
221 |
+
case 'yellow':
|
222 |
+
color = 'yellow';
|
223 |
+
break;
|
224 |
+
default:
|
225 |
+
color = 'gray';
|
226 |
}
|
227 |
return `<div style="width: 20px; height: 20px; background-color: ${color};"></div>`;
|
228 |
}},
|
229 |
+
{title:"Ссылка на пользователя в GC", field:"ad_url", formatter: function(cell, formatterParams, onRendered) {
|
230 |
var ad_url = cell.getValue();
|
231 |
return `<a href="${ad_url}" target="_blank">${ad_url}</a>`;
|
232 |
}},
|
233 |
+
{title:"Ссылка на VK", field:"vk_id", formatter: function(cell, formatterParams, onRendered) {
|
234 |
var vk_id = cell.getValue();
|
235 |
return `<a href="https://vk.com/id${vk_id}" target="_blank">${vk_id}</a>`;
|
236 |
}},
|
237 |
+
{title:"Ссылка на Tg", field:"chat_id", formatter: function(cell, formatterParams, onRendered) {
|
238 |
var chatId = cell.getValue();
|
239 |
if (chatId.startsWith('@')) {
|
240 |
+
chatId = chatId.substring(1); // Удаление символа @ в начале
|
241 |
}
|
242 |
return `<a href="https://t.me/${chatId}" target="_blank">${chatId}</a>`;
|
243 |
}},
|
244 |
+
{title:"Ссылка на WhatsApp", field:"phone", formatter: function(cell, formatterParams, onRendered) {
|
245 |
var phone = cell.getValue();
|
246 |
return `<a href="https://web.whatsapp.com/send?phone=${phone}" target="_blank">${phone}</a>`;
|
247 |
}},
|
248 |
+
{title:"Статус WhatsApp", field:"ws_st"},
|
249 |
+
{title:"Стутус подписки", field:"ws_stop"},
|
250 |
+
{title:"Вебинары", field:"web_st", formatter:"star", formatterParams:{stars:7}, hozAlign:"center", width:120},
|
251 |
+
{title:"Прогрес по воронке", field:"fin_prog", formatter:"progress", formatterParams:{color:["#00dd00", "orange", "rgb(255,0,0)"]}, sorter:"number", width:100},
|
252 |
+
{title:"pr1", field:"pr1"},
|
253 |
+
{title:"pr2", field:"pr2"},
|
254 |
+
{title:"pr3", field:"pr3"},
|
255 |
+
{title:"Канал трафика", field:"pr4"},
|
256 |
+
{title:"Дата", field:"pr5"},
|
257 |
+
{title:"Ключ PR", field:"key_pr"},
|
258 |
+
{title:"Канал", field:"canal"},
|
259 |
+
{title:"Дата", field:"data_t"}
|
|
|
|
|
|
|
|
|
|
|
|
|
260 |
],
|
261 |
});
|
262 |
+
// Define variables for input elements
|
263 |
+
var fieldEl = document.getElementById("filter-field");
|
264 |
+
var typeEl = document.getElementById("filter-type");
|
265 |
+
var valueEl = document.getElementById("filter-value");
|
266 |
+
// Trigger setFilter function with correct parameters
|
|
|
|
|
|
|
267 |
function updateFilter() {
|
268 |
+
var filterVal = fieldEl.options[fieldEl.selectedIndex].value;
|
269 |
+
var typeVal = typeEl.options[typeEl.selectedIndex].value;
|
270 |
+
if (filterVal) {
|
271 |
+
table.setFilter(filterVal, typeVal, valueEl.value);
|
|
|
272 |
}
|
273 |
}
|
274 |
+
// Update filters on value change
|
275 |
document.getElementById("filter-field").addEventListener("change", updateFilter);
|
276 |
document.getElementById("filter-type").addEventListener("change", updateFilter);
|
277 |
document.getElementById("filter-value").addEventListener("keyup", updateFilter);
|
278 |
+
// Clear filters on "Clear Filters" button click
|
279 |
+
document.getElementById("filter-clear").addEventListener("click", function() {
|
280 |
+
fieldEl.value = "";
|
281 |
+
typeEl.value = "=";
|
282 |
+
valueEl.value = "";
|
283 |
+
table.clearFilter();
|
284 |
+
});
|
285 |
+
// Переопределяем метод table.download
|
286 |
+
table.download = function(type, filename, options) {
|
287 |
+
// Сохраняем старые данные
|
288 |
+
var oldData = table.getData();
|
289 |
+
// Получаем новые данные таблицы
|
290 |
+
var tableData = table.getData("active");
|
291 |
+
// Преобразуем данные в JSON-строку
|
292 |
+
var jsonData = JSON.stringify(tableData, null, 2);
|
293 |
+
// Выводим JSON-строку в консоль
|
294 |
+
console.log(jsonData);
|
295 |
+
// Очищаем старые данные
|
296 |
+
table.setData([]);
|
297 |
+
// Восстанавливаем старые данные
|
298 |
+
table.setData(oldData);
|
299 |
+
};
|
300 |
+
// Пример использования переопределенного метода
|
301 |
document.getElementById("download-json").addEventListener("click", function() {
|
302 |
+
table.download("json", "data.json"); // ЭТУ СТРОКУ НЕ УДАЛЯТЬ!!! ЕЁ НАДО ПЕРЕХВАТИТЬ, А НЕ ТВОЙ КОД!!!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
303 |
});
|
304 |
})
|
305 |
+
.catch(error => console.error('Error fetching data:', error));
|
|
|
|
|
306 |
});
|
307 |
</script>
|
308 |
</body>
|
309 |
+
|