DmitrMakeev commited on
Commit
4f10948
1 Parent(s): 5475047

Update data_gc_tab.html

Browse files
Files changed (1) hide show
  1. data_gc_tab.html +160 -25
data_gc_tab.html CHANGED
@@ -1,3 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <body>
2
  <div id="header">
3
  <h1>GetCurse - WhatsCRM</h1>
@@ -38,7 +162,8 @@
38
  <input id="filter-value" type="text" placeholder="Значение фильтра">
39
 
40
  <button id="filter-clear">Очистить фильтр</button>
41
- <button id="export-json">Экспортировать JSON</button>
 
42
  </div>
43
  <div id="example-table"></div>
44
 
@@ -48,22 +173,23 @@
48
  .then(response => response.json())
49
  .then(data => {
50
  console.log('Data received:', data); // Логирование данных
 
 
 
 
 
 
51
  var table = new Tabulator("#example-table", {
52
- data: data,
53
- layout: "fitColumns",
54
- pagination: "local",
55
- paginationSize: 50,
56
- selectable: true, // Enable row selection
57
  columns: [
58
  {title:"Номер в списке", field:"id"},
59
  {title:"Имя", field:"name"},
60
  {title:"Телефон", field:"phone"},
61
  {title:"Email", field:"email"},
62
- {title:"Куратор", field:"curator", formatter: function(cell, formatterParams, onRendered) {
63
- var curator = cell.getValue();
64
- var curatorLink = cell.getData().curator_link;
65
- return `<a href="${curatorLink}" target="_blank">${curator}</a>`;
66
- }},
67
  {title:"Статус покупки", field:"shop_statys_full", formatter: function(cell, formatterParams, onRendered) {
68
  var status = cell.getValue();
69
  var color;
@@ -112,42 +238,51 @@
112
  {title:"utm_content", field:"pr5"}
113
  ],
114
  });
115
- // Filter functionality
116
  var fieldEl = document.getElementById("filter-field");
117
  var typeEl = document.getElementById("filter-type");
118
  var valueEl = document.getElementById("filter-value");
 
 
119
  function updateFilter() {
120
  var filterVal = fieldEl.options[fieldEl.selectedIndex].value;
121
  var typeVal = typeEl.options[typeEl.selectedIndex].value;
122
  if (filterVal) {
123
  table.setFilter(filterVal, typeVal, valueEl.value);
124
  }
 
 
 
 
 
 
125
  }
 
126
  document.getElementById("filter-field").addEventListener("change", updateFilter);
127
  document.getElementById("filter-type").addEventListener("change", updateFilter);
128
  document.getElementById("filter-value").addEventListener("keyup", updateFilter);
 
129
  document.getElementById("filter-clear").addEventListener("click", function() {
130
  fieldEl.value = "";
131
  typeEl.value = "=";
132
  valueEl.value = "";
133
  table.clearFilter();
134
  });
135
- // Export selected data to JSON
136
- document.getElementById("export-json").addEventListener("click", function() {
137
- var selectedData = table.getSelectedData(); // Get selected rows data
138
- var jsonData = JSON.stringify(selectedData, null, 2); // Pretty print JSON
139
- console.log("Selected data as JSON:", jsonData);
140
- var blob = new Blob([jsonData], {type: "application/json"});
141
- var url = URL.createObjectURL(blob);
142
- var a = document.createElement("a");
143
- a.href = url;
144
- a.download = "selected_data.json";
145
- document.body.appendChild(a);
146
- a.click();
147
- document.body.removeChild(a);
148
  });
149
  })
150
  .catch(error => console.error('Error fetching data:', error));
151
  });
152
  </script>
153
  </body>
 
 
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>Tabulator Example</title>
7
+ <link href="https://unpkg.com/tabulator-tables@6.2.1/dist/css/tabulator.min.css" rel="stylesheet">
8
+ <script type="text/javascript" src="https://unpkg.com/tabulator-tables@6.2.1/dist/js/tabulator.min.js"></script>
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
+ font-size: 28px;
24
+ text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
25
+ }
26
+ button[type="submit"] {
27
+ color: white;
28
+ background-color: #4CAF50;
29
+ border: none;
30
+ cursor: pointer;
31
+ padding: 10px 20px;
32
+ font-size: 16px;
33
+ border-radius: 5px;
34
+ margin-top: 20px;
35
+ transition: background-color 0.3s ease;
36
+ }
37
+ button[type="submit"]:hover {
38
+ background-color: #388E3C;
39
+ }
40
+ #mediaContainer {
41
+ margin-top: 20px;
42
+ display: flex;
43
+ justify-content: center;
44
+ align-items: center;
45
+ flex-direction: column;
46
+ max-width: 100%;
47
+ height: auto;
48
+ box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
49
+ border-radius: 10px;
50
+ padding: 20px;
51
+ background-color: white;
52
+ }
53
+ #mediaContainer img, #mediaContainer video {
54
+ max-width: 100%;
55
+ height: auto;
56
+ object-fit: contain;
57
+ border-radius: 10px;
58
+ }
59
+ #imageUrl {
60
+ margin-top: 20px;
61
+ font-size: 16px;
62
+ color: #333;
63
+ cursor: pointer;
64
+ text-decoration: underline;
65
+ transition: color 0.3s ease;
66
+ }
67
+ #imageUrl:hover {
68
+ color: #4CAF50;
69
+ }
70
+ #progressBarContainer {
71
+ width: 80%;
72
+ margin: 20px auto;
73
+ background-color: #ddd;
74
+ border-radius: 13px;
75
+ padding: 3px;
76
+ box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
77
+ }
78
+ #progressBar {
79
+ width: 0%;
80
+ height: 20px;
81
+ background-color: #4CAF50;
82
+ border-radius: 10px;
83
+ text-align: center;
84
+ line-height: 20px;
85
+ color: white;
86
+ transition: width 0.3s ease;
87
+ }
88
+ #filter-field, #filter-type, #filter-value, #filter-clear {
89
+ padding: 10px;
90
+ font-size: 16px;
91
+ margin: 5px;
92
+ }
93
+ #filter-value {
94
+ width: 200px;
95
+ }
96
+ #filter-clear {
97
+ padding: 10px 20px;
98
+ }
99
+ #filter-field, #filter-type, #filter-value, #filter-clear {
100
+ padding: 10px;
101
+ font-size: 16px;
102
+ margin: 5px;
103
+ border-radius: 5px;
104
+ border: 1px solid #ccc;
105
+ }
106
+ #filter-value {
107
+ width: 200px;
108
+ background-color: #f0f0f0;
109
+ }
110
+ #filter-clear {
111
+ padding: 10px 20px;
112
+ background-color: #4CAF50;
113
+ color: white;
114
+ border: none;
115
+ cursor: pointer;
116
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
117
+ transition: background-color 0.3s ease;
118
+ }
119
+ #filter-clear:hover {
120
+ background-color: #388E3C;
121
+ }
122
+
123
+ </style>
124
+ </head>
125
  <body>
126
  <div id="header">
127
  <h1>GetCurse - WhatsCRM</h1>
 
162
  <input id="filter-value" type="text" placeholder="Значение фильтра">
163
 
164
  <button id="filter-clear">Очистить фильтр</button>
165
+
166
+ <input type="checkbox" id="select-filtered-data-checkbox"> Выбрать отфильтрованные данные для экспорта
167
  </div>
168
  <div id="example-table"></div>
169
 
 
173
  .then(response => response.json())
174
  .then(data => {
175
  console.log('Data received:', data); // Логирование данных
176
+ // Пользовательский форматтер для ссылки на куратора
177
+ var linkFormatter = function(cell, formatterParams, onRendered) {
178
+ var curator = cell.getValue();
179
+ var curatorLink = cell.getData().curator_link;
180
+ return `<a href="${curatorLink}" target="_blank">${curator}</a>`;
181
+ };
182
  var table = new Tabulator("#example-table", {
183
+ data: data, // set table data
184
+ layout: "fitColumns", // fit columns to width of table
185
+ pagination: "local", // enable local pagination
186
+ paginationSize: 50, // number of rows per page
 
187
  columns: [
188
  {title:"Номер в списке", field:"id"},
189
  {title:"Имя", field:"name"},
190
  {title:"Телефон", field:"phone"},
191
  {title:"Email", field:"email"},
192
+ {title:"Куратор", field:"curator", formatter: linkFormatter},
 
 
 
 
193
  {title:"Статус покупки", field:"shop_statys_full", formatter: function(cell, formatterParams, onRendered) {
194
  var status = cell.getValue();
195
  var color;
 
238
  {title:"utm_content", field:"pr5"}
239
  ],
240
  });
241
+ // Define variables for input elements
242
  var fieldEl = document.getElementById("filter-field");
243
  var typeEl = document.getElementById("filter-type");
244
  var valueEl = document.getElementById("filter-value");
245
+ var selectFilteredDataCheckbox = document.getElementById("select-filtered-data-checkbox");
246
+ // Trigger setFilter function with correct parameters
247
  function updateFilter() {
248
  var filterVal = fieldEl.options[fieldEl.selectedIndex].value;
249
  var typeVal = typeEl.options[typeEl.selectedIndex].value;
250
  if (filterVal) {
251
  table.setFilter(filterVal, typeVal, valueEl.value);
252
  }
253
+ if (selectFilteredDataCheckbox.checked) {
254
+ var filteredData = table.getData("filtered");
255
+ var jsonData = JSON.stringify(filteredData);
256
+ window.filteredDataJSON = jsonData;
257
+ console.log("Отфильтрованные данные преобразованы в JSON:", jsonData);
258
+ }
259
  }
260
+ // Update filters on value change
261
  document.getElementById("filter-field").addEventListener("change", updateFilter);
262
  document.getElementById("filter-type").addEventListener("change", updateFilter);
263
  document.getElementById("filter-value").addEventListener("keyup", updateFilter);
264
+ // Clear filters on "Clear Filters" button click
265
  document.getElementById("filter-clear").addEventListener("click", function() {
266
  fieldEl.value = "";
267
  typeEl.value = "=";
268
  valueEl.value = "";
269
  table.clearFilter();
270
  });
271
+ // Handle checkbox change for exporting filtered data
272
+ selectFilteredDataCheckbox.addEventListener("change", function() {
273
+ if (this.checked) {
274
+ var filteredData = table.getData("filtered");
275
+ var jsonData = JSON.stringify(filteredData);
276
+ window.filteredDataJSON = jsonData;
277
+ console.log("Отфильтрованные данные преобразованы в JSON:", jsonData);
278
+ } else {
279
+ window.filteredDataJSON = null;
280
+ console.log("Выбор отфильтрованных данных для экспорта отменен");
281
+ }
 
 
282
  });
283
  })
284
  .catch(error => console.error('Error fetching data:', error));
285
  });
286
  </script>
287
  </body>
288
+ </html>