Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assets: Suggest operating systems when adding an asset #1119

Merged
merged 1 commit into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions client_asset_add_modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<input type="hidden" name="csrf_token" value="<?php echo $_SESSION['csrf_token'] ?>">
<input type="hidden" name="client_id" value="<?php echo $client_id; ?>">

<div class="modal-body bg-white">
<div class="modal-body bg-white ui-front">

<ul class="nav nav-pills nav-justified mb-3">
<li class="nav-item">
Expand Down Expand Up @@ -116,7 +116,7 @@
<div class="input-group-prepend">
<span class="input-group-text"><i class="fab fa-fw fa-windows"></i></span>
</div>
<input type="text" class="form-control" name="os" placeholder="ex Windows 10 Pro">
<input type="text" class="form-control" name="os" id="os" placeholder="ex Windows 10 Pro">
</div>
</div>
<?php } ?>
Expand Down
27 changes: 27 additions & 0 deletions client_assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@

$num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));


// OS typeahead suggestions
$os_sql = mysqli_query($mysqli, "SELECT DISTINCT asset_os AS label FROM assets WHERE asset_archived_at IS NULL");
if (mysqli_num_rows($os_sql) > 0) {
while ($row = mysqli_fetch_array($os_sql)) {
$os_arr[] = $row;
}
$json_os = json_encode($os_arr);
}

?>

<div class="col-sm-12 mb-3">
Expand Down Expand Up @@ -619,3 +629,20 @@ class="btn btn-<?php if($archived == 1){ echo "primary"; } else { echo "default"

require_once "footer.php";

?>

<!-- JSON Autocomplete / type ahead -->
<link rel="stylesheet" href="plugins/jquery-ui/jquery-ui.min.css">
<script src="plugins/jquery-ui/jquery-ui.min.js"></script>
<script>
$(function() {
var operatingSystems = <?php echo $json_os; ?>;
$("#os").autocomplete({
source: operatingSystems, // Should be an array of objects with 'label' and 'value'
select: function(event, ui) {
$("#os").val(ui.item.label); // Set the input field value to the selected label
return false;
}
});
});
</script>
Loading