mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-15 15:57:27 -08:00
Merge remote-tracking branch 'origin/develop'
This commit is contained in:
commit
1f17c6e4f4
|
@ -73,10 +73,14 @@ class Helper
|
||||||
*
|
*
|
||||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||||
* @since [v3.3]
|
* @since [v3.3]
|
||||||
* @return array
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function defaultChartColors($index = 0)
|
public static function defaultChartColors(int $index = 0)
|
||||||
{
|
{
|
||||||
|
if ($index < 0) {
|
||||||
|
$index = 0;
|
||||||
|
}
|
||||||
|
|
||||||
$colors = [
|
$colors = [
|
||||||
'#008941',
|
'#008941',
|
||||||
'#FF4A46',
|
'#FF4A46',
|
||||||
|
@ -349,7 +353,19 @@ class Helper
|
||||||
$total_colors = count($colors);
|
$total_colors = count($colors);
|
||||||
|
|
||||||
if ($index >= $total_colors) {
|
if ($index >= $total_colors) {
|
||||||
$index = $index - $total_colors;
|
|
||||||
|
\Log::error('Status label count is '.$index.' and exceeds the allowed count of 266.');
|
||||||
|
//patch fix for array key overflow (color count starts at 1, array starts at 0)
|
||||||
|
$index = $index - $total_colors - 1;
|
||||||
|
|
||||||
|
//constraints to keep result in 0-265 range. This should never be needed, but if something happens
|
||||||
|
//to create this many status labels and it DOES happen, this will keep it from failing at least.
|
||||||
|
if($index < 0) {
|
||||||
|
$index = 0;
|
||||||
|
}
|
||||||
|
elseif($index >($total_colors - 1)) {
|
||||||
|
$index = $total_colors - 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $colors[$index];
|
return $colors[$index];
|
||||||
|
|
|
@ -204,12 +204,8 @@ class AssetsController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($success) {
|
if ($success) {
|
||||||
// Redirect to the asset listing page
|
|
||||||
$minutes = 518400;
|
|
||||||
// dd( $_POST['options']);
|
|
||||||
// Cookie::queue(Cookie::make('optional_info', json_decode($_POST['options']), $minutes));
|
|
||||||
return redirect()->route('hardware.index')
|
return redirect()->route('hardware.index')
|
||||||
->with('success', trans('admin/hardware/message.create.success'));
|
->with('success-unescaped', trans('admin/hardware/message.create.success_linked', ['link' => route('hardware.show', $asset->id), 'id', 'tag' => $asset->asset_tag]));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,7 @@ class ComponentCheckinController extends Controller
|
||||||
|
|
||||||
event(new CheckoutableCheckedIn($component, $asset, Auth::user(), $request->input('note'), Carbon::now()));
|
event(new CheckoutableCheckedIn($component, $asset, Auth::user(), $request->input('note'), Carbon::now()));
|
||||||
if ($backto == 'asset'){
|
if ($backto == 'asset'){
|
||||||
return redirect()->route('hardware.view', $asset->id)->with('success',
|
return redirect()->route('hardware.show', $asset->id)->with('success',
|
||||||
trans('admin/components/message.checkin.success'));
|
trans('admin/components/message.checkin.success'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ return [
|
||||||
'create' => [
|
'create' => [
|
||||||
'error' => 'Asset was not created, please try again. :(',
|
'error' => 'Asset was not created, please try again. :(',
|
||||||
'success' => 'Asset created successfully. :)',
|
'success' => 'Asset created successfully. :)',
|
||||||
|
'success_linked' => 'Asset with tag :tag was created successfully. <strong><a href=":link" style="color: white;">Click here to view</a></strong>.',
|
||||||
],
|
],
|
||||||
|
|
||||||
'update' => [
|
'update' => [
|
||||||
|
|
|
@ -35,6 +35,18 @@
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
|
||||||
|
@if ($message = Session::get('success-unescaped'))
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="alert alert-success fade in">
|
||||||
|
<button type="button" class="close" data-dismiss="alert">×</button>
|
||||||
|
<i class="fas fa-check faa-pulse animated"></i>
|
||||||
|
<strong>{{ trans('general.notification_success') }}: </strong>
|
||||||
|
{!! $message !!}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
|
||||||
@if ($assets = Session::get('assets'))
|
@if ($assets = Session::get('assets'))
|
||||||
@foreach ($assets as $asset)
|
@foreach ($assets as $asset)
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
|
|
|
@ -122,9 +122,10 @@ Route::group(
|
||||||
[AssetCheckinController::class, 'store']
|
[AssetCheckinController::class, 'store']
|
||||||
)->name('hardware.checkin.store');
|
)->name('hardware.checkin.store');
|
||||||
|
|
||||||
Route::get('{assetId}/view',
|
// Redirect old legacy /asset_id/view urls to the resource route version
|
||||||
[AssetsController::class, 'show']
|
Route::get('{assetId}/view', function ($assetId) {
|
||||||
)->name('hardware.view');
|
return redirect()->route('hardware.show', ['hardware' => $assetId]);
|
||||||
|
});
|
||||||
|
|
||||||
Route::get('{assetId}/qr_code',
|
Route::get('{assetId}/qr_code',
|
||||||
[AssetsController::class, 'getQrCode']
|
[AssetsController::class, 'getQrCode']
|
||||||
|
@ -178,13 +179,17 @@ Route::group(
|
||||||
Route::post('bulkcheckout',
|
Route::post('bulkcheckout',
|
||||||
[BulkAssetsController::class, 'storeCheckout']
|
[BulkAssetsController::class, 'storeCheckout']
|
||||||
)->name('hardware.bulkcheckout.store');
|
)->name('hardware.bulkcheckout.store');
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::resource('hardware',
|
Route::resource('hardware',
|
||||||
AssetsController::class,
|
AssetsController::class,
|
||||||
[
|
[
|
||||||
'middleware' => ['auth'],
|
'middleware' => ['auth'],
|
||||||
'parameters' => ['asset' => 'asset_id'
|
'parameters' => ['asset' => 'asset_id',
|
||||||
|
'names' => [
|
||||||
|
'show' => 'view',
|
||||||
|
],
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ use PHPUnit\Framework\Assert;
|
||||||
use Tests\Support\InteractsWithSettings;
|
use Tests\Support\InteractsWithSettings;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
|
||||||
class CustomReportTest extends TestCase
|
class CustomReportTest extends TestCase
|
||||||
{
|
{
|
||||||
use InteractsWithSettings;
|
use InteractsWithSettings;
|
||||||
|
|
19
tests/Unit/Helpers/HelperTest.php
Normal file
19
tests/Unit/Helpers/HelperTest.php
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Unit\Helpers;
|
||||||
|
|
||||||
|
use App\Helpers\Helper;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class HelperTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testDefaultChartColorsMethodHandlesHighValues()
|
||||||
|
{
|
||||||
|
$this->assertIsString(Helper::defaultChartColors(1000));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDefaultChartColorsMethodHandlesNegativeNumbers()
|
||||||
|
{
|
||||||
|
$this->assertIsString(Helper::defaultChartColors(-1));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue