From 6800098469e281bb2723fb911e52efd650500c63 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 28 Mar 2023 03:31:02 -0700 Subject: [PATCH 01/33] Bumped version for 6.1.0-pre Signed-off-by: snipe --- config/version.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/config/version.php b/config/version.php index da05ee431..fba609ce3 100644 --- a/config/version.php +++ b/config/version.php @@ -1,10 +1,10 @@ 'v6.0.14', - 'full_app_version' => 'v6.0.14 - build 9715-g8b70a7f21', - 'build_version' => '9715', + 'app_version' => 'v6.1.0-pre', + 'full_app_version' => 'v6.1.0-pre - build 10030-gdcbd216e2', + 'build_version' => '10030', 'prerelease_version' => '', - 'hash_version' => 'g8b70a7f21', - 'full_hash' => 'v6.0.14-671-g8b70a7f21', + 'hash_version' => 'gdcbd216e2', + 'full_hash' => 'v6.1.0-pre-986-gdcbd216e2', 'branch' => 'develop', ); \ No newline at end of file From feef06e7bfb888410368402c045b0ffbcac43b0a Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 28 Mar 2023 06:54:41 -0700 Subject: [PATCH 02/33] Changed log level to debug vs info/error Signed-off-by: snipe --- app/Http/Livewire/Importer.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Http/Livewire/Importer.php b/app/Http/Livewire/Importer.php index 31bbfcfbc..784d3b298 100644 --- a/app/Http/Livewire/Importer.php +++ b/app/Http/Livewire/Importer.php @@ -198,8 +198,8 @@ class Importer extends Component public function updating($name, $new_import_type) { if ($name == "activeFile.import_type") { - \Log::info("WE ARE CHANGING THE import_type!!!!! TO: " . $new_import_type); - \Log::info("so, what's \$this->>field_map at?: " . print_r($this->field_map, true)); + \Log::debug("WE ARE CHANGING THE import_type!!!!! TO: " . $new_import_type); + \Log::debug("so, what's \$this->>field_map at?: " . print_r($this->field_map, true)); // go through each header, find a matching field to try and map it to. foreach ($this->activeFile->header_row as $i => $header) { // do we have something mapped already? @@ -252,7 +252,7 @@ class Importer extends Component $this->authorize('import'); $this->progress = -1; // '-1' means 'don't show the progressbar' $this->progress_bar_class = 'progress-bar-warning'; - \Log::info("Hey, we are calling MOUNT (in the importer-file) !!!!!!!!"); //fcuk + \Log::debug("Hey, we are calling MOUNT (in the importer-file) !!!!!!!!"); //fcuk $this->importTypes = [ 'asset' => trans('general.assets'), 'accessory' => trans('general.accessories'), @@ -273,8 +273,8 @@ class Importer extends Component public function selectFile($id) { - \Log::info("TOGGLE EVENT FIRED!"); - \Log::error("The ID we are trying to find is AS FOLLOWS: ".$id); + \Log::debug("TOGGLE EVENT FIRED!"); + \Log::debug("The ID we are trying to find is AS FOLLOWS: ".$id); $this->activeFile = Import::find($id); $this->field_map = null; foreach($this->activeFile->header_row as $element) { @@ -288,7 +288,7 @@ class Importer extends Component $this->file_id = $id; $this->import_errors = null; $this->statusText = null; - \Log::error("The import type we are about to try and load up is gonna be this: ".$this->activeFile->import_type); + \Log::debug("The import type we are about to try and load up is gonna be this: ".$this->activeFile->import_type); } From 09674c012ceee0dc6e137a041f8aa33f5f5e2685 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 28 Mar 2023 07:18:45 -0700 Subject: [PATCH 03/33] Use named route with params Signed-off-by: snipe --- resources/views/account/requestable-assets.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/account/requestable-assets.blade.php b/resources/views/account/requestable-assets.blade.php index 27aad2c97..002fc4dc5 100644 --- a/resources/views/account/requestable-assets.blade.php +++ b/resources/views/account/requestable-assets.blade.php @@ -113,7 +113,7 @@ @can('view', \App\Models\AssetModel::class) - {{ $requestableModel->name }} + {{ $requestableModel->name }} @else {{ $requestableModel->name }} @endcan From d667ae53ed9975fb0a604e43060809811ba03675 Mon Sep 17 00:00:00 2001 From: Joe Ferguson Date: Tue, 28 Mar 2023 09:55:59 -0500 Subject: [PATCH 04/33] Add missing strings to Step 2 preflight --- resources/lang/en/general.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/resources/lang/en/general.php b/resources/lang/en/general.php index 1ad9c376d..99fa3bd30 100644 --- a/resources/lang/en/general.php +++ b/resources/lang/en/general.php @@ -433,4 +433,7 @@ return [ 'errors_importing' => 'Some Errors occurred while importing: ', 'warning' => 'WARNING: :warning', 'success_redirecting' => '"Success... Redirecting.', -]; \ No newline at end of file + 'setup_successful_migrations' => 'Your database tables have been created', + 'setup_migration_output' => 'Migration output:', + 'setup_migration_create_user' => 'Next: Create User', +]; From 47e18db172afb2db978c400448c735adb94d349e Mon Sep 17 00:00:00 2001 From: Joe Ferguson Date: Tue, 28 Mar 2023 09:57:13 -0500 Subject: [PATCH 05/33] Fix next button string for Step 2 preflight --- resources/views/setup/migrate.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/setup/migrate.blade.php b/resources/views/setup/migrate.blade.php index fb9f50e17..816ae6149 100644 --- a/resources/views/setup/migrate.blade.php +++ b/resources/views/setup/migrate.blade.php @@ -32,7 +32,7 @@ @section('button')
- +
@parent @stop From a0eb9dc73565c66fef7a06894b2c7cbe1256ac95 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 28 Mar 2023 13:41:58 -0700 Subject: [PATCH 06/33] Added links to kandji2snipe and UnifiSnipeSync Signed-off-by: snipe --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index ceb040145..ae42c61e3 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,8 @@ Since the release of the JSON REST API, several third-party developers have been - [Snipe-IT Bulk Edit](https://github.com/bricelabelle/snipe-it-bulkedit) - Google Script files to use Google Sheets as a bulk checkout/checkin/edit tool for Snipe-it. - [MosyleSnipeSync](https://github.com/RodneyLeeBrands/MosyleSnipeSync) by [@RodneyLeeBrands](https://github.com/RodneyLeeBrands) - Python script to synchronize information between Mosyle and Snipe-IT - [WWW::SnipeIT](https://github.com/SEDC/perl-www-snipeit) by [@SEDC](https://github.com/SEDC) - perl module for accessing the API +- [UniFi to Snipe-IT](https://github.com/RodneyLeeBrands/UnifiSnipeSync) by [@karpadiem](https://github.com/karpadiem) - Python script that synchronizes UniFi devices with Snipe-IT. +- [Kandji2Snipe](https://github.com/grokability/kandji2snipe) by [@briangoldstein](https://github.com/briangoldstein) - Python script that synchronizes Kandji with Snipe-IT. As these were created by third-parties, Snipe-IT cannot provide support for these project, and you should contact the developers directly if you need assistance. Additionally, Snipe-IT makes no guarantees as to the reliability, accuracy or maintainability of these libraries. Use at your own risk. :) From 2306f3015848e080f8ae14c379f64ace3f838c0b Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 28 Mar 2023 14:26:59 -0700 Subject: [PATCH 07/33] Updated author link to @Karpadiem Signed-off-by: snipe --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ae42c61e3..9faa02f5b 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ Since the release of the JSON REST API, several third-party developers have been - [Python 3 CSV importer](https://github.com/gastamper/snipeit-csvimporter) - allows importing assets into Snipe-IT based on Item Name rather than Asset Tag. - [Snipe-IT Kubernetes Helm Chart](https://github.com/t3n/helm-charts/tree/master/snipeit) - For more information, [click here](https://hub.helm.sh/charts/t3n/snipeit). - [Snipe-IT Bulk Edit](https://github.com/bricelabelle/snipe-it-bulkedit) - Google Script files to use Google Sheets as a bulk checkout/checkin/edit tool for Snipe-it. -- [MosyleSnipeSync](https://github.com/RodneyLeeBrands/MosyleSnipeSync) by [@RodneyLeeBrands](https://github.com/RodneyLeeBrands) - Python script to synchronize information between Mosyle and Snipe-IT +- [MosyleSnipeSync](https://github.com/RodneyLeeBrands/MosyleSnipeSync) by [@Karpadiem](https://github.com/Karpadiem) - Python script to synchronize information between Mosyle and Snipe-IT - [WWW::SnipeIT](https://github.com/SEDC/perl-www-snipeit) by [@SEDC](https://github.com/SEDC) - perl module for accessing the API - [UniFi to Snipe-IT](https://github.com/RodneyLeeBrands/UnifiSnipeSync) by [@karpadiem](https://github.com/karpadiem) - Python script that synchronizes UniFi devices with Snipe-IT. - [Kandji2Snipe](https://github.com/grokability/kandji2snipe) by [@briangoldstein](https://github.com/briangoldstein) - Python script that synchronizes Kandji with Snipe-IT. From d70b7dbf4194b98980768b4c67060f9aca33f258 Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Tue, 28 Mar 2023 16:12:48 -0600 Subject: [PATCH 08/33] Checks if exist on API checkout --- app/Http/Controllers/Api/AssetsController.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.php index 382990b57..b14a79bcf 100644 --- a/app/Http/Controllers/Api/AssetsController.php +++ b/app/Http/Controllers/Api/AssetsController.php @@ -826,12 +826,20 @@ class AssetsController extends Controller // This item is checked out to a location if (request('checkout_to_type') == 'location') { $target = Location::find(request('assigned_location')); + if (!$target) { + return response()->json(Helper::formatStandardApiResponse('error', ['asset'=> e($asset->asset_tag)], trans('admin/hardware/message.checkout.error'))); + } + $asset->location_id = ($target) ? $target->id : ''; $error_payload['target_id'] = $request->input('assigned_location'); $error_payload['target_type'] = 'location'; } elseif (request('checkout_to_type') == 'asset') { $target = Asset::where('id', '!=', $asset_id)->find(request('assigned_asset')); + if (!$target) { + return response()->json(Helper::formatStandardApiResponse('error', ['asset'=> e($asset->asset_tag)], trans('admin/hardware/message.checkout.error'))); + } + $asset->location_id = $target->rtd_location_id; // Override with the asset's location_id if it has one $asset->location_id = (($target) && (isset($target->location_id))) ? $target->location_id : ''; @@ -841,6 +849,10 @@ class AssetsController extends Controller } elseif (request('checkout_to_type') == 'user') { // Fetch the target and set the asset's new location_id $target = User::find(request('assigned_user')); + if (!$target) { + return response()->json(Helper::formatStandardApiResponse('error', ['asset'=> e($asset->asset_tag)], trans('admin/hardware/message.checkout.error'))); + } + $asset->location_id = (($target) && (isset($target->location_id))) ? $target->location_id : ''; $error_payload['target_id'] = $request->input('assigned_user'); $error_payload['target_type'] = 'user'; From 77d513f80bcf34511d8ac1bc4997500b2fe323cb Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Tue, 28 Mar 2023 17:25:57 -0600 Subject: [PATCH 09/33] Assign target variable as the other checkout types --- app/Http/Controllers/Api/AssetsController.php | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.php index b14a79bcf..d4ff0092b 100644 --- a/app/Http/Controllers/Api/AssetsController.php +++ b/app/Http/Controllers/Api/AssetsController.php @@ -826,21 +826,12 @@ class AssetsController extends Controller // This item is checked out to a location if (request('checkout_to_type') == 'location') { $target = Location::find(request('assigned_location')); - if (!$target) { - return response()->json(Helper::formatStandardApiResponse('error', ['asset'=> e($asset->asset_tag)], trans('admin/hardware/message.checkout.error'))); - } - $asset->location_id = ($target) ? $target->id : ''; $error_payload['target_id'] = $request->input('assigned_location'); $error_payload['target_type'] = 'location'; } elseif (request('checkout_to_type') == 'asset') { $target = Asset::where('id', '!=', $asset_id)->find(request('assigned_asset')); - if (!$target) { - return response()->json(Helper::formatStandardApiResponse('error', ['asset'=> e($asset->asset_tag)], trans('admin/hardware/message.checkout.error'))); - } - - $asset->location_id = $target->rtd_location_id; // Override with the asset's location_id if it has one $asset->location_id = (($target) && (isset($target->location_id))) ? $target->location_id : ''; $error_payload['target_id'] = $request->input('assigned_asset'); @@ -849,10 +840,6 @@ class AssetsController extends Controller } elseif (request('checkout_to_type') == 'user') { // Fetch the target and set the asset's new location_id $target = User::find(request('assigned_user')); - if (!$target) { - return response()->json(Helper::formatStandardApiResponse('error', ['asset'=> e($asset->asset_tag)], trans('admin/hardware/message.checkout.error'))); - } - $asset->location_id = (($target) && (isset($target->location_id))) ? $target->location_id : ''; $error_payload['target_id'] = $request->input('assigned_user'); $error_payload['target_type'] = 'user'; From 88826c1115a94a96b4a8959b2ecbee0a77b715bc Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 28 Mar 2023 16:26:27 -0700 Subject: [PATCH 10/33] Added link to SnipeAgent Signed-off-by: snipe --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 9faa02f5b..4c569520c 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,7 @@ Since the release of the JSON REST API, several third-party developers have been - [WWW::SnipeIT](https://github.com/SEDC/perl-www-snipeit) by [@SEDC](https://github.com/SEDC) - perl module for accessing the API - [UniFi to Snipe-IT](https://github.com/RodneyLeeBrands/UnifiSnipeSync) by [@karpadiem](https://github.com/karpadiem) - Python script that synchronizes UniFi devices with Snipe-IT. - [Kandji2Snipe](https://github.com/grokability/kandji2snipe) by [@briangoldstein](https://github.com/briangoldstein) - Python script that synchronizes Kandji with Snipe-IT. +- [SnipeAgent](https://github.com/ReticentRobot/SnipeAgent) by @ReticentRobot - Windows agent for Snipe-IT As these were created by third-parties, Snipe-IT cannot provide support for these project, and you should contact the developers directly if you need assistance. Additionally, Snipe-IT makes no guarantees as to the reliability, accuracy or maintainability of these libraries. Use at your own risk. :) From 527c812d04725c7475422fb847ae877b1c8078f0 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 28 Mar 2023 16:39:41 -0700 Subject: [PATCH 11/33] Use icon for group users header Signed-off-by: snipe --- resources/views/groups/index.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/groups/index.blade.php b/resources/views/groups/index.blade.php index 4958e3a4d..4b2a2f0e3 100755 --- a/resources/views/groups/index.blade.php +++ b/resources/views/groups/index.blade.php @@ -43,7 +43,7 @@ {{ trans('general.id') }} {{ trans('admin/groups/table.name') }} - {{ trans('admin/groups/table.users') }} + {{ trans('admin/groups/table.users') }} {{ trans('general.created_at') }} {{ trans('table.actions') }} From 32922e6461b6bc2b4e7d4952f3af4b6350272723 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 28 Mar 2023 16:39:52 -0700 Subject: [PATCH 12/33] Use corrected language string Signed-off-by: snipe --- app/Http/Controllers/GroupsController.php | 11 +++++------ resources/lang/en/admin/groups/message.php | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/GroupsController.php b/app/Http/Controllers/GroupsController.php index abe3e0682..b98156824 100755 --- a/app/Http/Controllers/GroupsController.php +++ b/app/Http/Controllers/GroupsController.php @@ -92,7 +92,7 @@ class GroupsController extends Controller return view('groups.edit', compact('group', 'permissions', 'selected_array', 'groupPermissions')); } - return redirect()->route('groups.index')->with('error', trans('admin/groups/message.group_not_found')); + return redirect()->route('groups.index')->with('error', trans('admin/groups/message.group_not_found', ['id' => $id])); } /** @@ -107,7 +107,7 @@ class GroupsController extends Controller public function update(Request $request, $id = null) { if (! $group = Group::find($id)) { - return redirect()->route('groups.index')->with('error', trans('admin/groups/message.group_not_found', compact('id'))); + return redirect()->route('groups.index')->with('error', trans('admin/groups/message.group_not_found', ['id' => $id])); } $group->name = $request->input('name'); $group->permissions = json_encode($request->input('permission')); @@ -133,14 +133,13 @@ class GroupsController extends Controller * @return \Illuminate\Http\RedirectResponse * @throws \Exception */ - public function destroy($id = null) + public function destroy($id) { if (! config('app.lock_passwords')) { if (! $group = Group::find($id)) { - return redirect()->route('groups.index')->with('error', trans('admin/groups/message.group_not_found', compact('id'))); + return redirect()->route('groups.index')->with('error', trans('admin/groups/message.group_not_found', ['id' => $id])); } $group->delete(); - // Redirect to the group management page return redirect()->route('groups.index')->with('success', trans('admin/groups/message.success.delete')); } @@ -164,6 +163,6 @@ class GroupsController extends Controller return view('groups/view', compact('group')); } - return redirect()->route('groups.index')->with('error', trans('admin/groups/message.group_not_found', compact('id'))); + return redirect()->route('groups.index')->with('error', trans('admin/groups/message.group_not_found', ['id' => $id])); } } diff --git a/resources/lang/en/admin/groups/message.php b/resources/lang/en/admin/groups/message.php index f14b6339e..495acaf36 100644 --- a/resources/lang/en/admin/groups/message.php +++ b/resources/lang/en/admin/groups/message.php @@ -3,7 +3,7 @@ return array( 'group_exists' => 'Group already exists!', - 'group_not_found' => 'Group [:id] does not exist.', + 'group_not_found' => 'Group ID :id does not exist.', 'group_name_required' => 'The name field is required', 'success' => array( From d7c531e1c7d4fb2d1340abce56c92c5ce5c3d87b Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Wed, 29 Mar 2023 10:33:15 -0600 Subject: [PATCH 13/33] Checks if user variable exist before using its properties --- resources/views/account/accept/index.blade.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/resources/views/account/accept/index.blade.php b/resources/views/account/accept/index.blade.php index f97c6c564..9f11bdfa7 100755 --- a/resources/views/account/accept/index.blade.php +++ b/resources/views/account/accept/index.blade.php @@ -1,8 +1,11 @@ @extends('layouts/default') +@php + !empty($user) ? $full_name = $user->present()->full_name : $full_name = ''; +@endphp {{-- Page title --}} @section('title') -{{ trans('general.accept_assets', array('name' => $user->present()->fullName())) }} +{{ trans('general.accept_assets', array('name' => $full_name)) }} @parent @stop From 9cc74caa9e7fa4a1ff850c3e93aee4c76f34cb8a Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 29 Mar 2023 10:58:25 -0700 Subject: [PATCH 14/33] Add wire:model to import form checkboxes --- resources/views/livewire/importer.blade.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/resources/views/livewire/importer.blade.php b/resources/views/livewire/importer.blade.php index a7b9c3e51..fbe5802d2 100644 --- a/resources/views/livewire/importer.blade.php +++ b/resources/views/livewire/importer.blade.php @@ -160,22 +160,22 @@
-
-
-
@@ -379,4 +379,4 @@ });}) -@endpush \ No newline at end of file +@endpush From 4cbe683a1a1e7d2d0ea27f4335380613491a9bcb Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 29 Mar 2023 11:28:04 -0700 Subject: [PATCH 15/33] Explicitly cast asset tag to string when querying --- app/Importer/AssetImporter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Importer/AssetImporter.php b/app/Importer/AssetImporter.php index bf47c7360..0fcbf1166 100644 --- a/app/Importer/AssetImporter.php +++ b/app/Importer/AssetImporter.php @@ -60,7 +60,7 @@ class AssetImporter extends ItemImporter $asset_tag = Asset::autoincrement_asset(); } - $asset = Asset::where(['asset_tag'=> $asset_tag])->first(); + $asset = Asset::where(['asset_tag'=> (string) $asset_tag])->first(); if ($asset) { if (! $this->updating) { $this->log('A matching Asset '.$asset_tag.' already exists'); From 6bee4c1a75988a6c00729ae2b27761da52c86286 Mon Sep 17 00:00:00 2001 From: akemidx Date: Wed, 29 Mar 2023 14:59:00 -0400 Subject: [PATCH 16/33] Updating Apple warranty link to match current Apple webpage --- resources/views/hardware/view.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/hardware/view.blade.php b/resources/views/hardware/view.blade.php index e5fc43b61..5dbfacc5a 100755 --- a/resources/views/hardware/view.blade.php +++ b/resources/views/hardware/view.blade.php @@ -597,7 +597,7 @@ @if ($asset->serial && $asset->model->manufacturer) @if ((strtolower($asset->model->manufacturer->name) == "apple") || (str_starts_with(str_replace(' ','',strtolower($asset->model->manufacturer->name)),"appleinc"))) - + @elseif ((strtolower($asset->model->manufacturer->name) == "dell") || (str_starts_with(str_replace(' ','',strtolower($asset->model->manufacturer->name)),"dellinc"))) From e05546d1fa242320c5177da0733d6aa277fe1d76 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 29 Mar 2023 13:23:45 -0700 Subject: [PATCH 17/33] Display helpful messages when importing assets --- app/Http/Livewire/Importer.php | 4 ++++ resources/views/livewire/importer.blade.php | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/Http/Livewire/Importer.php b/app/Http/Livewire/Importer.php index 784d3b298..1026a188b 100644 --- a/app/Http/Livewire/Importer.php +++ b/app/Http/Livewire/Importer.php @@ -3,6 +3,7 @@ namespace App\Http\Livewire; use App\Models\CustomField; +use Illuminate\Support\Facades\Auth; use Livewire\Component; use App\Models\Import; @@ -16,6 +17,8 @@ class Importer extends Component { use AuthorizesRequests; + public bool $userIsSuperUser; + public $files; public $progress; //upload progress - '-1' means don't show @@ -250,6 +253,7 @@ class Importer extends Component public function mount() { $this->authorize('import'); + $this->userIsSuperUser = Auth::user()->isSuperUser(); $this->progress = -1; // '-1' means 'don't show the progressbar' $this->progress_bar_class = 'progress-bar-warning'; \Log::debug("Hey, we are calling MOUNT (in the importer-file) !!!!!!!!"); //fcuk diff --git a/resources/views/livewire/importer.blade.php b/resources/views/livewire/importer.blade.php index fbe5802d2..22663bc50 100644 --- a/resources/views/livewire/importer.blade.php +++ b/resources/views/livewire/importer.blade.php @@ -156,6 +156,11 @@ 'data-minimum-results-for-search' => '-1', // Remove this if the list gets long enough that we need to search 'data-livewire-component' => $_instance->id ]) }} + @if ($activeFile->import_type === 'asset' && $snipeSettings->auto_increment_assets == 0) + + Generating auto-incrementing asset tags is @if ($userIsSuperUser)disabled @else disabled @endif so all rows need to have the "Asset Tag" column populated. + + @endif @@ -163,6 +168,11 @@ @@ -344,7 +354,7 @@ 'import-update': !!@this.update, 'send-welcome': !!@this.send_welcome, 'import-type': @this.activeFile.import_type, - 'run-backup': !!@this.run_backup, + 'A': !!@this.run_backup, 'column-mappings': mappings }), headers: { From 863a346d6e1474921b96840cc4302105ace42675 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 29 Mar 2023 13:37:14 -0700 Subject: [PATCH 18/33] Translate strings --- resources/lang/en/general.php | 2 ++ resources/views/livewire/importer.blade.php | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/resources/lang/en/general.php b/resources/lang/en/general.php index 99fa3bd30..aa2e85c2f 100644 --- a/resources/lang/en/general.php +++ b/resources/lang/en/general.php @@ -422,6 +422,8 @@ return [ 'merged_log_this_user_from' => 'Merged user ID :from_id (:from_username) into this user (ID :to_id - :to_username)', 'clear_and_save' => 'Clear & Save', 'update_existing_values' => 'Update Existing Values?', + 'auto_incrementing_asset_tags_disabled_so_tags_required' => 'Generating auto-incrementing asset tags is disabled so all rows need to have the "Asset Tag" column populated.', + 'auto_incrementing_asset_tags_enabled_so_now_assets_will_be_created' => 'Note: Generating auto-incrementing asset tags is enabled so assets will be created for rows that do not have "Asset Tag" populated. Rows that do have "Asset Tag" populated will be updated with the provided information.', 'send_welcome_email_to_users' => ' Send Welcome Email for new Users?', 'back_before_importing' => 'Backup before importing?', 'csv_header_field' => 'CSV Header Field', diff --git a/resources/views/livewire/importer.blade.php b/resources/views/livewire/importer.blade.php index 22663bc50..033c23145 100644 --- a/resources/views/livewire/importer.blade.php +++ b/resources/views/livewire/importer.blade.php @@ -158,7 +158,7 @@ ]) }} @if ($activeFile->import_type === 'asset' && $snipeSettings->auto_increment_assets == 0) - Generating auto-incrementing asset tags is @if ($userIsSuperUser)disabled @else disabled @endif so all rows need to have the "Asset Tag" column populated. + {{ trans('general.auto_incrementing_asset_tags_disabled_so_tags_required') }} @endif @@ -170,7 +170,7 @@ {{ trans('general.update_existing_values') }} @if ($activeFile->import_type === 'asset' && $snipeSettings->auto_increment_assets == 1 && $update) - Note: Generating auto-incrementing asset tags is @if ($userIsSuperUser)disabled @else enabled @endif so assets will be created for rows that do not have "Asset Tag" populated. Rows that do have "Asset Tag" populated will be updated with the provided information. + {{ trans('general.auto_incrementing_asset_tags_enabled_so_now_assets_will_be_created') }} @endif From 162b70d5a954752e9007e3e93ab7843a649e0e10 Mon Sep 17 00:00:00 2001 From: slong753 Date: Wed, 29 Mar 2023 17:34:36 -0500 Subject: [PATCH 19/33] wireframed, needs a view and should work --- .../Controllers/Assets/BulkAssetsController.php | 16 ++++++++++++++++ resources/views/hardware/index.blade.php | 8 +++++--- .../views/partials/asset-bulk-actions.blade.php | 4 ++++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Assets/BulkAssetsController.php b/app/Http/Controllers/Assets/BulkAssetsController.php index 7f9e812ab..884996d22 100644 --- a/app/Http/Controllers/Assets/BulkAssetsController.php +++ b/app/Http/Controllers/Assets/BulkAssetsController.php @@ -56,6 +56,14 @@ class BulkAssetsController extends Controller }); return view('hardware/bulk-delete')->with('assets', $assets); + + case 'restore': + $assets = Asset::with('assignedTo', 'location')->find($asset_ids); + $assets->each(function ($asset) { + $this->authorize('restore', $asset); + }); + + return view('hardware/bulk-restore')->with('assets', $assets); case 'edit': return view('hardware/bulk') ->with('assets', $asset_ids) @@ -320,5 +328,13 @@ class BulkAssetsController extends Controller } catch (ModelNotFoundException $e) { return redirect()->route('hardware.bulkcheckout.show')->with('error', $e->getErrors()); } + + } + public function restore(Request $request) { + $assetIds = $request->get('ids'); + foreach ($assetIds as $key => $assetId) { + $asset = Asset::withTrashed()->find($assetId); + $asset->restore(); + } } } diff --git a/resources/views/hardware/index.blade.php b/resources/views/hardware/index.blade.php index a73b37f2c..6f1a4944d 100755 --- a/resources/views/hardware/index.blade.php +++ b/resources/views/hardware/index.blade.php @@ -62,14 +62,16 @@
+ + - @if (Request::get('status')!='Deleted') + {{-- @if (Request::get('status')!='Deleted') --}} - @include('partials.asset-bulk-actions') + @include('partials.asset-bulk-actions', ['status' => Request::get('status')]) - @endif + {{-- @endif --}} From e4c76f454c6a5a419af18c7d6643ceb478fd0a54 Mon Sep 17 00:00:00 2001 From: slong753 Date: Wed, 29 Mar 2023 18:24:56 -0500 Subject: [PATCH 20/33] this is good, just needs translations done in view --- .../Assets/BulkAssetsController.php | 7 ++- resources/lang/en/admin/hardware/form.php | 3 + .../views/hardware/bulk-restore.blade.php | 62 +++++++++++++++++++ routes/web/hardware.php | 7 ++- 4 files changed, 76 insertions(+), 3 deletions(-) create mode 100644 resources/views/hardware/bulk-restore.blade.php diff --git a/app/Http/Controllers/Assets/BulkAssetsController.php b/app/Http/Controllers/Assets/BulkAssetsController.php index 884996d22..efa4078da 100644 --- a/app/Http/Controllers/Assets/BulkAssetsController.php +++ b/app/Http/Controllers/Assets/BulkAssetsController.php @@ -49,6 +49,7 @@ class BulkAssetsController extends Controller ->with('settings', Setting::getSettings()) ->with('bulkedit', true) ->with('count', 0); + case 'delete': $assets = Asset::with('assignedTo', 'location')->find($asset_ids); $assets->each(function ($asset) { @@ -58,12 +59,13 @@ class BulkAssetsController extends Controller return view('hardware/bulk-delete')->with('assets', $assets); case 'restore': - $assets = Asset::with('assignedTo', 'location')->find($asset_ids); + $assets = Asset::withTrashed()->find($asset_ids); $assets->each(function ($asset) { - $this->authorize('restore', $asset); + $this->authorize('delete', $asset); }); return view('hardware/bulk-restore')->with('assets', $assets); + case 'edit': return view('hardware/bulk') ->with('assets', $asset_ids) @@ -336,5 +338,6 @@ class BulkAssetsController extends Controller $asset = Asset::withTrashed()->find($assetId); $asset->restore(); } + return redirect()->route('hardware.index')->with('success', 'Assets Restored'); } } diff --git a/resources/lang/en/admin/hardware/form.php b/resources/lang/en/admin/hardware/form.php index 22aac61d0..789feb74f 100644 --- a/resources/lang/en/admin/hardware/form.php +++ b/resources/lang/en/admin/hardware/form.php @@ -2,8 +2,11 @@ return [ 'bulk_delete' => 'Confirm Bulk Delete Assets', + 'bulk_restore' => 'Confirm Bulk Restore Assets', 'bulk_delete_help' => 'Review the assets for bulk deletion below. Once deleted, these assets can be restored, but they will no longer be associated with any users they are currently assigned to.', + 'bulk_restore_help' => 'Review the assets for bulk deletion below. Once deleted, these assets can be restored, but they will no longer be associated with any users they are currently assigned to.', 'bulk_delete_warn' => 'You are about to delete :asset_count assets.', + 'bulk_restore_warn' => 'You are about to restore :asset_count assets.', 'bulk_update' => 'Bulk Update Assets', 'bulk_update_help' => 'This form allows you to update multiple assets at once. Only fill in the fields you need to change. Any fields left blank will remain unchanged. ', 'bulk_update_warn' => 'You are about to edit the properties of a single asset.|You are about to edit the properties of :asset_count assets.', diff --git a/resources/views/hardware/bulk-restore.blade.php b/resources/views/hardware/bulk-restore.blade.php new file mode 100644 index 000000000..663cd8102 --- /dev/null +++ b/resources/views/hardware/bulk-restore.blade.php @@ -0,0 +1,62 @@ +@extends('layouts/default') + +{{-- Page title --}} +@section('title') +{{ trans('admin/hardware/form.bulk_delete') }} +@parent +@stop + +@section('header_right') + + {{ trans('general.back') }} +@stop + +{{-- Page content --}} +@section('content') +
+ +
+

{{ trans('admin/hardware/form.bulk_delete_help') }}

+
+ {{csrf_field()}} +
+
+

{{ trans('admin/hardware/form.bulk_restore_warn', ['asset_count' => count($assets)]) }}

+
+ +
+
+ + + + + + + + + + @foreach ($assets as $asset) + + + + + + + @endforeach + +
{{ trans('admin/hardware/table.id') }}{{ trans('admin/hardware/table.name') }}{{ trans('admin/hardware/table.location')}}
{{ $asset->id }}{{ $asset->present()->name() }} + @if ($asset->location) + {{ $asset->location->name }} + @endif +
+
+ + +
+ + + +@stop diff --git a/routes/web/hardware.php b/routes/web/hardware.php index 09811d17d..690d8e0d1 100644 --- a/routes/web/hardware.php +++ b/routes/web/hardware.php @@ -160,6 +160,11 @@ Route::group( [BulkAssetsController::class, 'destroy'] )->name('hardware/bulkdelete'); + Route::post( + 'bulkrestore', + [BulkAssetsController::class, 'restore'] + )->name('hardware/bulkrestore'); + Route::post( 'bulksave', [BulkAssetsController::class, 'update'] @@ -181,4 +186,4 @@ Route::resource('hardware', 'middleware' => ['auth'], 'parameters' => ['asset' => 'asset_id' ], -]); \ No newline at end of file +]); From d033733fc01f3143338b0cd32e7b42779f6cbfab Mon Sep 17 00:00:00 2001 From: slong753 Date: Wed, 29 Mar 2023 18:30:39 -0500 Subject: [PATCH 21/33] oops, remove a couple things --- resources/lang/en/admin/hardware/form.php | 3 --- resources/views/hardware/index.blade.php | 8 -------- 2 files changed, 11 deletions(-) diff --git a/resources/lang/en/admin/hardware/form.php b/resources/lang/en/admin/hardware/form.php index 789feb74f..22aac61d0 100644 --- a/resources/lang/en/admin/hardware/form.php +++ b/resources/lang/en/admin/hardware/form.php @@ -2,11 +2,8 @@ return [ 'bulk_delete' => 'Confirm Bulk Delete Assets', - 'bulk_restore' => 'Confirm Bulk Restore Assets', 'bulk_delete_help' => 'Review the assets for bulk deletion below. Once deleted, these assets can be restored, but they will no longer be associated with any users they are currently assigned to.', - 'bulk_restore_help' => 'Review the assets for bulk deletion below. Once deleted, these assets can be restored, but they will no longer be associated with any users they are currently assigned to.', 'bulk_delete_warn' => 'You are about to delete :asset_count assets.', - 'bulk_restore_warn' => 'You are about to restore :asset_count assets.', 'bulk_update' => 'Bulk Update Assets', 'bulk_update_help' => 'This form allows you to update multiple assets at once. Only fill in the fields you need to change. Any fields left blank will remain unchanged. ', 'bulk_update_warn' => 'You are about to edit the properties of a single asset.|You are about to edit the properties of :asset_count assets.', diff --git a/resources/views/hardware/index.blade.php b/resources/views/hardware/index.blade.php index 6f1a4944d..a9a0dba58 100755 --- a/resources/views/hardware/index.blade.php +++ b/resources/views/hardware/index.blade.php @@ -63,16 +63,8 @@
- - - {{-- @if (Request::get('status')!='Deleted') --}} - - - @include('partials.asset-bulk-actions', ['status' => Request::get('status')]) - {{-- @endif --}} - Date: Wed, 29 Mar 2023 16:58:55 -0700 Subject: [PATCH 22/33] Remove unneeded variable --- app/Http/Livewire/Importer.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/Http/Livewire/Importer.php b/app/Http/Livewire/Importer.php index 1026a188b..88c07cb79 100644 --- a/app/Http/Livewire/Importer.php +++ b/app/Http/Livewire/Importer.php @@ -17,8 +17,6 @@ class Importer extends Component { use AuthorizesRequests; - public bool $userIsSuperUser; - public $files; public $progress; //upload progress - '-1' means don't show @@ -253,7 +251,6 @@ class Importer extends Component public function mount() { $this->authorize('import'); - $this->userIsSuperUser = Auth::user()->isSuperUser(); $this->progress = -1; // '-1' means 'don't show the progressbar' $this->progress_bar_class = 'progress-bar-warning'; \Log::debug("Hey, we are calling MOUNT (in the importer-file) !!!!!!!!"); //fcuk From 0998c70a92f3ea056380283d88285dfb9f36bbab Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 29 Mar 2023 16:59:26 -0700 Subject: [PATCH 23/33] Remove unneeded import --- app/Http/Livewire/Importer.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Http/Livewire/Importer.php b/app/Http/Livewire/Importer.php index 88c07cb79..784d3b298 100644 --- a/app/Http/Livewire/Importer.php +++ b/app/Http/Livewire/Importer.php @@ -3,7 +3,6 @@ namespace App\Http\Livewire; use App\Models\CustomField; -use Illuminate\Support\Facades\Auth; use Livewire\Component; use App\Models\Import; From 6beb3b551ac4101df69e3fc98b677ff4eef86760 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 29 Mar 2023 17:01:24 -0700 Subject: [PATCH 24/33] Fix typo --- resources/views/livewire/importer.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/livewire/importer.blade.php b/resources/views/livewire/importer.blade.php index 033c23145..8c4b8f880 100644 --- a/resources/views/livewire/importer.blade.php +++ b/resources/views/livewire/importer.blade.php @@ -354,7 +354,7 @@ 'import-update': !!@this.update, 'send-welcome': !!@this.send_welcome, 'import-type': @this.activeFile.import_type, - 'A': !!@this.run_backup, + 'run-backup': !!@this.run_backup, 'column-mappings': mappings }), headers: { From d622dbb9434bae2b599781cac68161c8864a3907 Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Wed, 29 Mar 2023 18:37:47 -0600 Subject: [PATCH 25/33] Revert the php codeblock and replace it with a ternary --- resources/views/account/accept/index.blade.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/resources/views/account/accept/index.blade.php b/resources/views/account/accept/index.blade.php index 9f11bdfa7..f2a9bc56f 100755 --- a/resources/views/account/accept/index.blade.php +++ b/resources/views/account/accept/index.blade.php @@ -1,11 +1,8 @@ @extends('layouts/default') -@php - !empty($user) ? $full_name = $user->present()->full_name : $full_name = ''; -@endphp {{-- Page title --}} @section('title') -{{ trans('general.accept_assets', array('name' => $full_name)) }} +{{ trans('general.accept_assets', array('name' => empty($user) ? '' : $user->present()->full_name)) }} @parent @stop From d5d50264c342d1fa22c14248d735b04cb096829a Mon Sep 17 00:00:00 2001 From: slong753 Date: Wed, 29 Mar 2023 19:53:04 -0500 Subject: [PATCH 26/33] fix permissions stuff + optional parameter --- resources/views/partials/asset-bulk-actions.blade.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/resources/views/partials/asset-bulk-actions.blade.php b/resources/views/partials/asset-bulk-actions.blade.php index 02e2b6b4b..c57e232a1 100644 --- a/resources/views/partials/asset-bulk-actions.blade.php +++ b/resources/views/partials/asset-bulk-actions.blade.php @@ -13,8 +13,10 @@ - @if($status ?? '' == 'Deleted') + @if(($status) && ($status == 'Deleted')) @can('delete', \App\Models\Asset::class) @endcan - @else + @else @can('update', \App\Models\Asset::class) @endcan From 986c73982eec499c1831eccddfb1756b49186e7b Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 30 Mar 2023 14:50:56 -0700 Subject: [PATCH 33/33] Check if status is set Signed-off-by: snipe --- resources/views/partials/asset-bulk-actions.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/partials/asset-bulk-actions.blade.php b/resources/views/partials/asset-bulk-actions.blade.php index 47d5e4367..09519501c 100644 --- a/resources/views/partials/asset-bulk-actions.blade.php +++ b/resources/views/partials/asset-bulk-actions.blade.php @@ -13,7 +13,7 @@