mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-13 17:14:10 -08:00
Merge branch 'develop' into features/setting_for_username_display
This commit is contained in:
commit
28e8db400a
|
@ -857,7 +857,8 @@ class AssetsController extends Controller
|
|||
$checkout_at = request('checkout_at', date('Y-m-d H:i:s'));
|
||||
$expected_checkin = request('expected_checkin', null);
|
||||
$note = request('note', null);
|
||||
$asset_name = request('name', null);
|
||||
// Using `->has` preserves the asset name if the name parameter was not included in request.
|
||||
$asset_name = request()->has('name') ? request('name') : $asset->name;
|
||||
|
||||
// Set the location ID to the RTD location id if there is one
|
||||
// Wait, why are we doing this? This overrides the stuff we set further up, which makes no sense.
|
||||
|
|
|
@ -10,6 +10,7 @@ use App\Models\Asset;
|
|||
use App\Models\Company;
|
||||
use App\Models\Import;
|
||||
use Artisan;
|
||||
use Illuminate\Database\Eloquent\JsonEncodingException;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
@ -35,7 +36,7 @@ class ImportController extends Controller
|
|||
* Process and store a CSV upload file.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function store()
|
||||
{
|
||||
|
@ -56,7 +57,7 @@ class ImportController extends Controller
|
|||
'text/tsv', ])) {
|
||||
$results['error'] = 'File type must be CSV. Uploaded file is '.$file->getMimeType();
|
||||
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, $results['error']), 500);
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, $results['error']), 422);
|
||||
}
|
||||
|
||||
//TODO: is there a lighter way to do this?
|
||||
|
@ -64,7 +65,19 @@ class ImportController extends Controller
|
|||
ini_set('auto_detect_line_endings', '1');
|
||||
}
|
||||
$reader = Reader::createFromFileObject($file->openFile('r')); //file pointer leak?
|
||||
$import->header_row = $reader->fetchOne(0);
|
||||
|
||||
try {
|
||||
$import->header_row = $reader->fetchOne(0);
|
||||
} catch (JsonEncodingException $e) {
|
||||
return response()->json(
|
||||
Helper::formatStandardApiResponse(
|
||||
'error',
|
||||
null,
|
||||
trans('admin/hardware/message.import.header_row_has_malformed_characters')
|
||||
),
|
||||
422
|
||||
);
|
||||
}
|
||||
|
||||
//duplicate headers check
|
||||
$duplicate_headers = [];
|
||||
|
@ -82,11 +95,22 @@ class ImportController extends Controller
|
|||
}
|
||||
}
|
||||
if (count($duplicate_headers) > 0) {
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, implode('; ', $duplicate_headers)), 500); //should this be '4xx'?
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, implode('; ', $duplicate_headers)),422);
|
||||
}
|
||||
|
||||
// Grab the first row to display via ajax as the user picks fields
|
||||
$import->first_row = $reader->fetchOne(1);
|
||||
try {
|
||||
// Grab the first row to display via ajax as the user picks fields
|
||||
$import->first_row = $reader->fetchOne(1);
|
||||
} catch (JsonEncodingException $e) {
|
||||
return response()->json(
|
||||
Helper::formatStandardApiResponse(
|
||||
'error',
|
||||
null,
|
||||
trans('admin/hardware/message.import.content_row_has_malformed_characters')
|
||||
),
|
||||
422
|
||||
);
|
||||
}
|
||||
|
||||
$date = date('Y-m-d-his');
|
||||
$fixed_filename = str_slug($file->getClientOriginalName());
|
||||
|
@ -108,12 +132,12 @@ class ImportController extends Controller
|
|||
}
|
||||
$results = (new ImportsTransformer)->transformImports($results);
|
||||
|
||||
return [
|
||||
return response()->json([
|
||||
'files' => $results,
|
||||
];
|
||||
]);
|
||||
}
|
||||
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, trans('general.feature_disabled')), 500);
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, trans('general.feature_disabled')), 422);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -109,9 +109,9 @@ class CustomFieldsController extends Controller
|
|||
|
||||
|
||||
if ($request->filled('custom_format')) {
|
||||
$field->format = e($request->get('custom_format'));
|
||||
$field->format = $request->get('custom_format');
|
||||
} else {
|
||||
$field->format = e($request->get('format'));
|
||||
$field->format = $request->get('format');
|
||||
}
|
||||
|
||||
if ($field->save()) {
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use App\Models\CustomField;
|
||||
|
||||
class FixUnescapedCustomfieldsFormat extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$customfields = CustomField::where('format', 'LIKE', '%&%')->get();
|
||||
|
||||
foreach($customfields as $customfield){
|
||||
$customfield->update(['format' => html_entity_decode($customfield->format)]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
|
@ -49,6 +49,8 @@ return [
|
|||
'success' => 'Your file has been imported',
|
||||
'file_delete_success' => 'Your file has been been successfully deleted',
|
||||
'file_delete_error' => 'The file was unable to be deleted',
|
||||
'header_row_has_malformed_characters' => 'One or more attributes in the header row contain malformed UTF-8 characters',
|
||||
'content_row_has_malformed_characters' => 'One or more attributes in the first row of content contain malformed UTF-8 characters',
|
||||
],
|
||||
|
||||
|
||||
|
|
|
@ -399,6 +399,12 @@ return [
|
|||
'preview_not_available' => '(no preview)',
|
||||
'display_username' => 'Display Username',
|
||||
'display_username_help_text' => 'Checking this box will cause listings to display the username in addition to the first and last name for users on listing pages.',
|
||||
'setup' => 'Setup',
|
||||
'pre_flight' => 'Pre-Flight',
|
||||
'skip_to_main_content' => 'Skip to main content',
|
||||
'toggle_navigation' => 'Toggle navigation',
|
||||
'alerts' => 'Alerts',
|
||||
'tasks_view_all' => 'View all tasks',
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -243,7 +243,7 @@
|
|||
<i class="fas fa-circle text-green"></i>
|
||||
@elseif (($asset->assetstatus) && ($asset->assetstatus->pending=='1'))
|
||||
<i class="fas fa-circle text-orange"></i>
|
||||
@elseif (($asset->assetstatus) && ($asset->assetstatus->archived=='1'))
|
||||
@else
|
||||
<i class="fas fa-times text-red"></i>
|
||||
@endif
|
||||
<a href="{{ route('statuslabels.show', $asset->assetstatus->id) }}">
|
||||
|
@ -595,10 +595,12 @@
|
|||
{{ $asset->warranty_months }}
|
||||
{{ trans('admin/hardware/form.months') }}
|
||||
|
||||
@if (($asset->serial && $asset->model->manufacturer) && $asset->model->manufacturer->name == 'Apple')
|
||||
@if ($asset->serial && $asset->model->manufacturer)
|
||||
@if ((strtolower($asset->model->manufacturer->name) == "apple") || (str_starts_with(str_replace(' ','',strtolower($asset->model->manufacturer->name)),"appleinc")))
|
||||
<a href="https://checkcoverage.apple.com/us/{{ \App\Models\Setting::getSettings()->locale }}/?sn={{ $asset->serial }}" target="_blank">
|
||||
<i class="fa-brands fa-apple" aria-hidden="true"><span class="sr-only">Applecare Status Lookup</span></i>
|
||||
</a>
|
||||
@endif
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -88,7 +88,7 @@
|
|||
<body class="sidebar-mini skin-{{ $snipeSettings->skin!='' ? $snipeSettings->skin : 'blue' }} {{ (session('menu_state')!='open') ? 'sidebar-mini sidebar-collapse' : '' }}">
|
||||
@endif
|
||||
|
||||
<a class="skip-main" href="#main">Skip to main content</a>
|
||||
<a class="skip-main" href="#main">{{ trans('general.skip_to_main_content') }}</a>
|
||||
<div class="wrapper">
|
||||
|
||||
<header class="main-header">
|
||||
|
@ -100,7 +100,7 @@
|
|||
<nav class="navbar navbar-static-top" role="navigation">
|
||||
<!-- Sidebar toggle button above the compact sidenav -->
|
||||
<a href="#" style="color: white" class="sidebar-toggle btn btn-white" data-toggle="push-menu" role="button">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="sr-only">{{ trans('general.toggle_navigation') }}</span>
|
||||
</a>
|
||||
<div class="nav navbar-nav navbar-left">
|
||||
<div class="left-navblock">
|
||||
|
@ -256,7 +256,7 @@
|
|||
<li class="dropdown tasks-menu">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
<i class="far fa-flag" aria-hidden="true"></i>
|
||||
<span class="sr-only">Alerts</span>
|
||||
<span class="sr-only">{{ trans('general.alerts') }}</span>
|
||||
@if (count($alert_items))
|
||||
<span class="label label-danger">{{ count($alert_items) }}</span>
|
||||
@endif
|
||||
|
@ -288,7 +288,7 @@
|
|||
</ul>
|
||||
</li>
|
||||
{{-- <li class="footer">
|
||||
<a href="#">View all tasks</a>
|
||||
<a href="#">{{ trans('general.tasks_view_all') }}</a>
|
||||
</li> --}}
|
||||
</ul>
|
||||
</li>
|
||||
|
@ -296,6 +296,7 @@
|
|||
@endif
|
||||
|
||||
|
||||
|
||||
<!-- User Account: style can be found in dropdown.less -->
|
||||
@if (Auth::check())
|
||||
<li class="dropdown user user-menu">
|
||||
|
|
|
@ -4,12 +4,13 @@
|
|||
<head>
|
||||
<title>
|
||||
@section('title')
|
||||
Snipe-IT Setup
|
||||
Snipe-IT {{ trans('general.setup') }}
|
||||
@show
|
||||
</title>
|
||||
<link rel="stylesheet" href="{{ url(mix('css/dist/all.css')) }}">
|
||||
|
||||
|
||||
|
||||
<script nonce="{{ csrf_token() }}">
|
||||
window.snipeit = {
|
||||
settings: {
|
||||
|
@ -57,7 +58,7 @@
|
|||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-lg-10 col-lg-offset-1">
|
||||
<h1 class="page-header">Snipe-IT Pre-Flight</h1>
|
||||
<h1 class="page-header">Snipe-IT {{ trans('general.pre_flight') }}</h1>
|
||||
</div>
|
||||
<div class="col-lg-11 col-lg-offset-1">
|
||||
|
||||
|
|
|
@ -16,17 +16,17 @@
|
|||
</div>
|
||||
|
||||
<div class="dynamic-form-row">
|
||||
<div class="col-md-4 col-xs-12"><label for="modal-manufacturer_id">{{ trans('general.manufacturer') }}:
|
||||
</label></div>
|
||||
<div class="col-md-4 col-xs-12"><label for="modal-category_id">{{ trans('general.category') }}:</label></div>
|
||||
<div class="col-md-8 col-xs-12 required">
|
||||
<select class="js-data-ajax" data-endpoint="manufacturers" name="manufacturer_id" style="width: 100%" id="modal-manufactuer_id"></select>
|
||||
<select class="js-data-ajax" data-endpoint="categories/asset" name="category_id" style="width: 100%" id="modal-category_id"></select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dynamic-form-row">
|
||||
<div class="col-md-4 col-xs-12"><label for="modal-category_id">{{ trans('general.category') }}:</label></div>
|
||||
<div class="col-md-8 col-xs-12 required">
|
||||
<select class="js-data-ajax" data-endpoint="categories/asset" name="category_id" style="width: 100%" id="modal-category_id"></select>
|
||||
<div class="col-md-4 col-xs-12"><label for="modal-manufacturer_id">{{ trans('general.manufacturer') }}:
|
||||
</label></div>
|
||||
<div class="col-md-8 col-xs-12">
|
||||
<select class="js-data-ajax" data-endpoint="manufacturers" name="manufacturer_id" style="width: 100%" id="modal-manufacturer_id"></select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
@section('inputFields')
|
||||
|
||||
@include ('partials.forms.edit.name', ['translated_name' => trans('admin/models/table.name'), 'required' => 'true'])
|
||||
@include ('partials.forms.edit.manufacturer-select', ['translated_name' => trans('general.manufacturer'), 'fieldname' => 'manufacturer_id', 'required' => 'true'])
|
||||
@include ('partials.forms.edit.category-select', ['translated_name' => trans('admin/categories/general.category_name'), 'fieldname' => 'category_id', 'required' => 'true', 'category_type' => 'asset'])
|
||||
@include ('partials.forms.edit.manufacturer-select', ['translated_name' => trans('general.manufacturer'), 'fieldname' => 'manufacturer_id'])
|
||||
@include ('partials.forms.edit.model_number')
|
||||
@include ('partials.forms.edit.depreciation')
|
||||
|
||||
|
|
Loading…
Reference in a new issue