Added client filtration
Filtration of clients using these categories: All, Enabled, Disabled, Connected, Disconnected.
This commit is contained in:
		
							parent
							
								
									46ac9ef2c1
								
							
						
					
					
						commit
						d13cee77d2
					
				|  | @ -58,6 +58,7 @@ function renderClientList(data) { | ||||||
|                                 </div> |                                 </div> | ||||||
|                                 <hr> |                                 <hr> | ||||||
|                                 <span class="info-box-text"><i class="fas fa-user"></i> ${obj.Client.name}</span> |                                 <span class="info-box-text"><i class="fas fa-user"></i> ${obj.Client.name}</span> | ||||||
|  |                                 <span class="info-box-text" style="display: none"><i class="fas fa-key"></i> ${obj.Client.public_key}</span> | ||||||
|                                 <span class="info-box-text"><i class="fas fa-envelope"></i> ${obj.Client.email}</span> |                                 <span class="info-box-text"><i class="fas fa-envelope"></i> ${obj.Client.email}</span> | ||||||
|                                 <span class="info-box-text"><i class="fas fa-clock"></i> |                                 <span class="info-box-text"><i class="fas fa-clock"></i> | ||||||
|                                     ${prettyDateTime(obj.Client.created_at)}</span> |                                     ${prettyDateTime(obj.Client.created_at)}</span> | ||||||
|  |  | ||||||
|  | @ -56,6 +56,13 @@ | ||||||
|                         </button> |                         </button> | ||||||
|                     </div> |                     </div> | ||||||
|                 </div> |                 </div> | ||||||
|  |                 <select name="status-selector" id="status-selector" class="form-control selectpicker show-tick" style="margin-left: 10px"> | ||||||
|  |                     <option value="All">All</option> | ||||||
|  |                     <option value="Enabled">Enabled</option> | ||||||
|  |                     <option value="Disabled">Disabled</option> | ||||||
|  |                     <option value="Connected">Connected</option> | ||||||
|  |                     <option value="Disconnected">Disconnected</option> | ||||||
|  |                 </select> | ||||||
|             </form> |             </form> | ||||||
| 
 | 
 | ||||||
|             <!-- Right navbar links --> |             <!-- Right navbar links --> | ||||||
|  |  | ||||||
|  | @ -263,6 +263,7 @@ Wireguard Clients | ||||||
| 
 | 
 | ||||||
|         // hide all clients and display only the ones that meet the search criteria (name, email, IP) |         // hide all clients and display only the ones that meet the search criteria (name, email, IP) | ||||||
|         $('#search-input').keyup(function () { |         $('#search-input').keyup(function () { | ||||||
|  |             $("#status-selector").val("All"); | ||||||
|             var query = $(this).val(); |             var query = $(this).val(); | ||||||
|             $('.col-lg-4').hide(); |             $('.col-lg-4').hide(); | ||||||
|             $(".info-box-text").each(function() { |             $(".info-box-text").each(function() { | ||||||
|  | @ -274,6 +275,70 @@ Wireguard Clients | ||||||
|             $(".badge-secondary").filter(':contains("' + query + '")').parent().parent().parent().show(); |             $(".badge-secondary").filter(':contains("' + query + '")').parent().parent().parent().show(); | ||||||
|         }) |         }) | ||||||
| 
 | 
 | ||||||
|  |         $("#status-selector").on('change', function () { | ||||||
|  |             $('#search-input').val(""); | ||||||
|  |             switch ($("#status-selector").val()) { | ||||||
|  |                 case "All": | ||||||
|  |                     $('.col-lg-4').show(); | ||||||
|  |                     break; | ||||||
|  |                 case "Enabled": | ||||||
|  |                     $('.col-lg-4').hide(); | ||||||
|  |                     $('[id^="paused_"]').each(function () { | ||||||
|  |                         if ($(this).css("visibility") === "hidden") { | ||||||
|  |                             $(this).parent().parent().show(); | ||||||
|  |                         } | ||||||
|  |                     }); | ||||||
|  |                     break; | ||||||
|  |                 case "Disabled": | ||||||
|  |                     $('.col-lg-4').hide(); | ||||||
|  |                     $('[id^="paused_"]').each(function () { | ||||||
|  |                         if ($(this).css("visibility") !== "hidden") { | ||||||
|  |                             $(this).parent().parent().show(); | ||||||
|  |                         } | ||||||
|  |                     }); | ||||||
|  |                     break; | ||||||
|  |                 case "Connected": | ||||||
|  |                     $('.col-lg-4').hide(); | ||||||
|  |                     $.ajax({ | ||||||
|  |                         cache: false, | ||||||
|  |                         method: 'GET', | ||||||
|  |                         url: '{{.basePath}}/status', | ||||||
|  |                         success: function (data) { | ||||||
|  |                             const returnedHTML = $(data).find(".table-success").get(); | ||||||
|  |                             var returnedString = ""; | ||||||
|  |                             returnedHTML.forEach(entry => returnedString += entry.outerHTML); | ||||||
|  |                             $(".fa-key").each(function () { | ||||||
|  |                                 if (returnedString.indexOf($(this).parent().text().trim()) != -1) { | ||||||
|  |                                     $(this).closest('.col-lg-4').show(); | ||||||
|  |                                 } | ||||||
|  |                             }) | ||||||
|  |                         } | ||||||
|  |                     }); | ||||||
|  |                     break; | ||||||
|  |                 case "Disconnected": | ||||||
|  |                     $('.col-lg-4').show(); | ||||||
|  |                     $.ajax({ | ||||||
|  |                         cache: false, | ||||||
|  |                         method: 'GET', | ||||||
|  |                         url: '{{.basePath}}/status', | ||||||
|  |                         success: function (data) { | ||||||
|  |                             const returnedHTML = $(data).find(".table-success").get(); | ||||||
|  |                             var returnedString = ""; | ||||||
|  |                             returnedHTML.forEach(entry => returnedString += entry.outerHTML); | ||||||
|  |                             $(".fa-key").each(function () { | ||||||
|  |                                 if (returnedString.indexOf($(this).parent().text().trim()) != -1) { | ||||||
|  |                                     $(this).closest('.col-lg-4').hide(); | ||||||
|  |                                 } | ||||||
|  |                             }) | ||||||
|  |                         } | ||||||
|  |                     }); | ||||||
|  |                     break; | ||||||
|  |                 default: | ||||||
|  |                     $('.col-lg-4').show(); | ||||||
|  |                     break; | ||||||
|  |             } | ||||||
|  |         }); | ||||||
|  | 
 | ||||||
|         // modal_pause_client modal event |         // modal_pause_client modal event | ||||||
|         $("#modal_pause_client").on('show.bs.modal', function (event) { |         $("#modal_pause_client").on('show.bs.modal', function (event) { | ||||||
|             const button = $(event.relatedTarget); |             const button = $(event.relatedTarget); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue