DmitrMakeev commited on
Commit
fc4f123
·
verified ·
1 Parent(s): 16948c7

Update data_gc_tab.html

Browse files
Files changed (1) hide show
  1. data_gc_tab.html +34 -151
data_gc_tab.html CHANGED
@@ -4,122 +4,11 @@
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/[email protected]/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>
@@ -162,8 +51,7 @@
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,23 +61,21 @@
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,51 +124,48 @@
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>
 
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-ttables@6.2.1/dist/css/tabulator.min.css" rel="stylesheet">
8
  <script type="text/javascript" src="https://unpkg.com/[email protected]/dist/js/tabulator.min.js"></script>
9
+ <style>
10
+ /* Your CSS styling */
11
+ /* ... */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  </style>
13
  </head>
14
  <body>
 
51
  <input id="filter-value" type="text" placeholder="Значение фильтра">
52
 
53
  <button id="filter-clear">Очистить фильтр</button>
54
+ <button id="export-json">Экспортировать JSON</button>
 
55
  </div>
56
  <div id="example-table"></div>
57
 
 
61
  .then(response => response.json())
62
  .then(data => {
63
  console.log('Data received:', data); // Логирование данных
 
 
 
 
 
 
64
  var table = new Tabulator("#example-table", {
65
+ data: data,
66
+ layout: "fitColumns",
67
+ pagination: "local",
68
+ paginationSize: 50,
69
  columns: [
70
  {title:"Номер в списке", field:"id"},
71
  {title:"Имя", field:"name"},
72
  {title:"Телефон", field:"phone"},
73
  {title:"Email", field:"email"},
74
+ {title:"Куратор", field:"curator", formatter: function(cell, formatterParams, onRendered) {
75
+ var curator = cell.getValue();
76
+ var curatorLink = cell.getData().curator_link;
77
+ return `<a href="${curatorLink}" target="_blank">${curator}</a>`;
78
+ }},
79
  {title:"Статус покупки", field:"shop_statys_full", formatter: function(cell, formatterParams, onRendered) {
80
  var status = cell.getValue();
81
  var color;
 
124
  {title:"utm_content", field:"pr5"}
125
  ],
126
  });
127
+
128
+ // Filter functionality
129
  var fieldEl = document.getElementById("filter-field");
130
  var typeEl = document.getElementById("filter-type");
131
  var valueEl = document.getElementById("filter-value");
132
+
 
133
  function updateFilter() {
134
  var filterVal = fieldEl.options[fieldEl.selectedIndex].value;
135
  var typeVal = typeEl.options[typeEl.selectedIndex].value;
136
  if (filterVal) {
137
  table.setFilter(filterVal, typeVal, valueEl.value);
138
  }
 
 
 
 
 
 
139
  }
140
+
141
  document.getElementById("filter-field").addEventListener("change", updateFilter);
142
  document.getElementById("filter-type").addEventListener("change", updateFilter);
143
  document.getElementById("filter-value").addEventListener("keyup", updateFilter);
144
+
145
  document.getElementById("filter-clear").addEventListener("click", function() {
146
  fieldEl.value = "";
147
  typeEl.value = "=";
148
  valueEl.value = "";
149
  table.clearFilter();
150
  });
151
+
152
+ // Export filtered data to JSON
153
+ document.getElementById("export-json").addEventListener("click", function() {
154
+ var filteredData = table.getData("filtered");
155
+ var jsonData = JSON.stringify(filteredData, null, 2); // Pretty print JSON
156
+ console.log("Filtered data as JSON:", jsonData);
157
+ var blob = new Blob([jsonData], {type: "application/json"});
158
+ var url = URL.createObjectURL(blob);
159
+ var a = document.createElement("a");
160
+ a.href = url;
161
+ a.download = "filtered_data.json";
162
+ document.body.appendChild(a);
163
+ a.click();
164
+ document.body.removeChild(a);
165
  });
166
  })
167
  .catch(error => console.error('Error fetching data:', error));
168
  });
169
  </script>
170
  </body>
171
+ </html>