Merge remote-tracking branch 'origin/develop'

This commit is contained in:
snipe 2022-10-21 17:01:00 -07:00
commit 3ec3d38c9f
6 changed files with 101 additions and 48 deletions

View file

@ -175,6 +175,8 @@ class LdapSync extends Command
$tmp_pass = substr(str_shuffle('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'), 0, 20); $tmp_pass = substr(str_shuffle('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'), 0, 20);
$pass = bcrypt($tmp_pass); $pass = bcrypt($tmp_pass);
$manager_cache = [];
for ($i = 0; $i < $results['count']; $i++) { for ($i = 0; $i < $results['count']; $i++) {
$item = []; $item = [];
$item['username'] = isset($results[$i][$ldap_result_username][0]) ? $results[$i][$ldap_result_username][0] : ''; $item['username'] = isset($results[$i][$ldap_result_username][0]) ? $results[$i][$ldap_result_username][0] : '';
@ -217,6 +219,11 @@ class LdapSync extends Command
$user->department_id = $department->id; $user->department_id = $department->id;
if($item['manager'] != null) { if($item['manager'] != null) {
// Check Cache first
if (isset($manager_cache[$item['manager']])) {
// found in cache; use that and avoid extra lookups
$user->manager_id = $manager_cache[$item['manager']];
} else {
// Get the LDAP Manager // Get the LDAP Manager
try { try {
$ldap_manager = Ldap::findLdapUsers($item['manager'], -1, $this->option('filter')); $ldap_manager = Ldap::findLdapUsers($item['manager'], -1, $this->option('filter'));
@ -246,6 +253,9 @@ class LdapSync extends Command
$user->manager_id = $ldap_manager->id; $user->manager_id = $ldap_manager->id;
} }
} }
$manager_cache[$item['manager']] = $ldap_manager && isset($ldap_manager->id) ? $ldap_manager->id : null; // Store results in cache, even if 'failed'
}
} }
// Sync activated state for Active Directory. // Sync activated state for Active Directory.

View file

@ -33,7 +33,6 @@ class BulkAssetsController extends Controller
if (! $request->filled('ids')) { if (! $request->filled('ids')) {
return redirect()->back()->with('error', trans('admin/hardware/message.update.no_assets_selected')); return redirect()->back()->with('error', trans('admin/hardware/message.update.no_assets_selected'));
} }
// Figure out where we need to send the user after the update is complete, and store that in the session // Figure out where we need to send the user after the update is complete, and store that in the session

View file

@ -80,7 +80,7 @@
<td class="col-md-1">@{{ currentFile.filesize }}</td> <td class="col-md-1">@{{ currentFile.filesize }}</td>
<td class="col-md-1 text-right"> <td class="col-md-1 text-right">
<button class="btn btn-sm btn-info" @click="toggleEvent(currentFile.id)"> <button class="btn btn-sm btn-info" @click="toggleEvent(currentFile.id)">
<i class="fas fa-cloud-download-alt fa-fw" aria-hidden="true"></i> <i class="fa-regular fa-retweet fa-fw" aria-hidden="true"></i>
<span class="sr-only">{{ trans('general.import') }}</span> <span class="sr-only">{{ trans('general.import') }}</span>
</button> </button>

View file

@ -43,6 +43,19 @@
</a> </a>
</li> </li>
<li>
<a href="#rtd_assets" data-toggle="tab">
<span class="hidden-lg hidden-md">
<i class="fas fa-barcode fa-2x" aria-hidden="true"></i>
</span>
<span class="hidden-xs hidden-sm">
{{ trans('admin/hardware/form.default_location') }}
{!! (($location->rtd_assets) && ($location->rtd_assets()->AssetsForShow()->count() > 0 )) ? '<badge class="badge badge-secondary">'.number_format($location->rtd_assets()->AssetsForShow()->count()).'</badge>' : '' !!}
</span>
</a>
</li>
<li> <li>
<a href="#accessories" data-toggle="tab"> <a href="#accessories" data-toggle="tab">
<span class="hidden-lg hidden-md"> <span class="hidden-lg hidden-md">
@ -145,6 +158,38 @@
</div><!-- /.table-responsive --> </div><!-- /.table-responsive -->
</div><!-- /.tab-pane --> </div><!-- /.tab-pane -->
<div class="tab-pane" id="rtd_assets">
<h2 class="box-title">{{ trans('admin/hardware/form.default_location') }}</h2>
<div class="table table-responsive">
@include('partials.asset-bulk-actions', ['id_divname' => 'RTDassetsBulkEditToolbar', 'id_formname' => 'RTDassets', 'id_button' => 'RTDbulkAssetEditButton'])
<table
data-columns="{{ \App\Presenters\AssetPresenter::dataTableLayout() }}"
data-cookie-id-table="RTDassetsListingTable"
data-pagination="true"
data-id-table="RTDassetsListingTable"
data-search="true"
data-side-pagination="server"
data-show-columns="true"
data-show-export="true"
data-show-refresh="true"
data-sort-order="asc"
data-toolbar="#RTDassetsBulkEditToolbar"
data-bulk-button-id="#RTDbulkAssetEditButton"
data-bulk-form-id="#RTDassetsBulkEditToolbar"
data-click-to-select="true"
id="RTDassetsListingTable"
class="table table-striped snipe-table"
data-url="{{route('api.assets.index', ['rtd_location_id' => $location->id]) }}"
data-export-options='{
"fileName": "export-rtd-locations-{{ str_slug($location->name) }}-assets-{{ date('Y-m-d') }}",
"ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"]
}'>
</table>
</div><!-- /.table-responsive -->
</div><!-- /.tab-pane -->
<div class="tab-pane" id="accessories"> <div class="tab-pane" id="accessories">

View file

@ -1,9 +1,10 @@
<div id="assetsBulkEditToolbar" style="min-width:400px"> <div id="{{ (isset($id_divname)) ? $id_divname : 'assetsBulkEditToolbar' }}" style="min-width:400px">
{{ Form::open([ {{ Form::open([
'method' => 'POST', 'method' => 'POST',
'route' => ['hardware/bulkedit'], 'route' => ['hardware/bulkedit'],
'class' => 'form-inline', 'class' => 'form-inline',
'id' => 'assetsBulkForm']) }} 'id' => (isset($id_formname)) ? $id_formname : 'assetsBulkForm',
]) }}
<label for="bulk_actions"> <label for="bulk_actions">
@ -21,6 +22,6 @@
<option value="labels">{{ trans_choice('button.generate_labels', 2) }}</option> <option value="labels">{{ trans_choice('button.generate_labels', 2) }}</option>
</select> </select>
<button class="btn btn-primary" id="bulkAssetEditButton" disabled>{{ trans('button.go') }}</button> <button class="btn btn-primary" id="{{ (isset($id_button)) ? $id_button : 'bulkAssetEditButton' }}" disabled>{{ trans('button.go') }}</button>
{{ Form::close() }} {{ Form::close() }}
</div> </div>

View file

@ -116,32 +116,30 @@
// These methods dynamically add/remove hidden input values in the bulk actions form // These methods dynamically add/remove hidden input values in the bulk actions form
$('.snipe-table').on('check.bs.table .btSelectItem', function (row, $element) { $('.snipe-table').on('check.bs.table .btSelectItem', function (row, $element) {
var buttonName = $(this).data('bulk-button-id'); var buttonName = $(this).data('bulk-button-id');
var formName = $(this).data('bulk-form-id');
var tableId = $(this).data('id-table'); var tableId = $(this).data('id-table');
$(buttonName).removeAttr('disabled'); $(buttonName).removeAttr('disabled');
$(formName).prepend('<input id="' + tableId + '_checkbox_' + $element.id + '" type="hidden" name="ids[]" value="' + $element.id + '">'); $(buttonName).after('<input id="' + tableId + '_checkbox_' + $element.id + '" type="hidden" name="ids[]" value="' + $element.id + '">');
}); });
$('.snipe-table').on('check-all.bs.table', function (event, rowsAfter) {
var buttonName = $(this).data('bulk-button-id');
$(buttonName).removeAttr('disabled');
var tableId = $(this).data('id-table');
for (var i in rowsAfter) {
$(buttonName).after('<input id="' + tableId + '_checkbox_' + rowsAfter[i].id + '" type="hidden" name="ids[]" value="' + rowsAfter[i].id + '">');
}
});
$('.snipe-table').on('uncheck.bs.table .btSelectItem', function (row, $element) { $('.snipe-table').on('uncheck.bs.table .btSelectItem', function (row, $element) {
var tableId = $(this).data('id-table'); var tableId = $(this).data('id-table');
$( "#" + tableId + "_checkbox_" + $element.id).remove(); $( "#" + tableId + "_checkbox_" + $element.id).remove();
}); });
$('.snipe-table').on('check-all.bs.table', function (event, rowsAfter, rowsBefore) {
var buttonName = $(this).data('bulk-button-id');
$(buttonName).removeAttr('disabled');
var formName = $(this).data('bulk-form-id');
var tableId = $(this).data('id-table');
for (var i in rowsAfter) {
$(formName).prepend('<input id="' + tableId + '_checkbox_' + rowsAfter[i].id + '" type="hidden" name="ids[]" value="' + rowsAfter[i].id + '">');
}
});
// Handle whether or not the edit button should be disabled // Handle whether or not the edit button should be disabled
$('.snipe-table').on('uncheck.bs.table', function () { $('.snipe-table').on('uncheck.bs.table', function () {