Merge branch 'develop'

This commit is contained in:
snipe 2018-02-16 21:19:03 -08:00
commit baf51eb430
14 changed files with 159 additions and 50 deletions

View file

@ -731,5 +731,62 @@ class Helper
} }
// Nicked from Drupal :)
// Returns a file size limit in bytes based on the PHP upload_max_filesize
// and post_max_size
public static function file_upload_max_size() {
static $max_size = -1;
if ($max_size < 0) {
// Start with post_max_size.
$post_max_size = Helper::parse_size(ini_get('post_max_size'));
if ($post_max_size > 0) {
$max_size = $post_max_size;
}
// If upload_max_size is less, then reduce. Except if upload_max_size is
// zero, which indicates no limit.
$upload_max = Helper::parse_size(ini_get('upload_max_filesize'));
if ($upload_max > 0 && $upload_max < $max_size) {
$max_size = $upload_max;
}
}
return $max_size;
}
public static function file_upload_max_size_readable() {
static $max_size = -1;
if ($max_size < 0) {
// Start with post_max_size.
$post_max_size = Helper::parse_size(ini_get('post_max_size'));
if ($post_max_size > 0) {
$max_size = ini_get('post_max_size');
}
// If upload_max_size is less, then reduce. Except if upload_max_size is
// zero, which indicates no limit.
$upload_max = Helper::parse_size(ini_get('upload_max_filesize'));
if ($upload_max > 0 && $upload_max < $max_size) {
$max_size = ini_get('upload_max_filesize');
}
}
return $max_size;
}
public static function parse_size($size) {
$unit = preg_replace('/[^bkmgtpezy]/i', '', $size); // Remove the non-unit characters from the size.
$size = preg_replace('/[^0-9\.]/', '', $size); // Remove the non-numeric characters from the size.
if ($unit) {
// Find the position of the unit in the ordered string which is the power of magnitude to multiply a kilobyte by.
return round($size * pow(1024, stripos('bkmgtpezy', $unit[0])));
}
else {
return round($size);
}
}
} }

View file

@ -67,7 +67,7 @@ class ManufacturersController extends Controller
public function store(ImageUploadRequest $request) public function store(ImageUploadRequest $request)
{ {
$this->authorize('edit', Manufacturer::class); $this->authorize('create', Manufacturer::class);
$manufacturer = new Manufacturer; $manufacturer = new Manufacturer;
$manufacturer->name = $request->input('name'); $manufacturer->name = $request->input('name');
$manufacturer->user_id = Auth::user()->id; $manufacturer->user_id = Auth::user()->id;

View file

@ -12,9 +12,11 @@ class AddRememberTokenToUsersTable extends Migration
*/ */
public function up() public function up()
{ {
Schema::table('users', function (Blueprint $table) { if (!Schema::hasColumn('users', 'remember_token')) {
$table->text('remember_token')->nullable()->default(NULL); Schema::table('users', function (Blueprint $table) {
}); $table->text('remember_token')->nullable()->default(null);
});
}
} }
/** /**
@ -25,7 +27,7 @@ class AddRememberTokenToUsersTable extends Migration
public function down() public function down()
{ {
Schema::table('users', function (Blueprint $table) { Schema::table('users', function (Blueprint $table) {
// $table->dropColumn('remember_token');
}); });
} }
} }

View file

@ -32,6 +32,6 @@ class CreatePasswordResetsTable extends Migration
*/ */
public function down() public function down()
{ {
// Schema::dropIfExists('password_resets');
} }
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,8 +1,9 @@
/** /**
* @author vincent loh <vincent.ml@gmail.com> * @author vincent loh <vincent.ml@gmail.com>
* @version: v1.0.0 * @version: v1.1.0
* https://github.com/vinzloh/bootstrap-table/ * https://github.com/vinzloh/bootstrap-table/
* Sticky header for bootstrap-table * Sticky header for bootstrap-table
* @update J Manuel Corona <jmcg92@gmail.com>
*/ */
(function ($) { (function ($) {
@ -13,6 +14,12 @@
stickyHeader: false stickyHeader: false
}); });
var bootstrapVersion = 3;
try {
bootstrapVersion = parseInt($.fn.dropdown.Constructor.VERSION, 10);
} catch (e) { }
var hidden_class = bootstrapVersion > 3 ? 'd-none' : 'hidden';
var BootstrapTable = $.fn.bootstrapTable.Constructor, var BootstrapTable = $.fn.bootstrapTable.Constructor,
_initHeader = BootstrapTable.prototype.initHeader; _initHeader = BootstrapTable.prototype.initHeader;
@ -20,17 +27,19 @@
var that = this; var that = this;
_initHeader.apply(this, Array.prototype.slice.apply(arguments)); _initHeader.apply(this, Array.prototype.slice.apply(arguments));
if (!this.options.stickyHeader) return; if (!this.options.stickyHeader) {
return;
}
var table = this.$tableBody.find('table'); var table = this.$tableBody.find('table'),
var table_id = table.attr('id'); table_id = table.attr('id'),
var header_id = table.attr('id') + '-sticky-header'; header_id = table.attr('id') + '-sticky-header',
var sticky_header_container_id = header_id +'-sticky-header-container'; sticky_header_container_id = header_id +'-sticky-header-container',
var anchor_begin_id = header_id +'_sticky_anchor_begin'; anchor_begin_id = header_id +'_sticky_anchor_begin',
var anchor_end_id = header_id +'_sticky_anchor_end'; anchor_end_id = header_id +'_sticky_anchor_end';
// add begin and end anchors to track table position // add begin and end anchors to track table position
table.before(sprintf('<div id="%s" class="hidden"></div>', sticky_header_container_id)); table.before(sprintf('<div id="%s" class="%s"></div>', sticky_header_container_id, hidden_class));
table.before(sprintf('<div id="%s"></div>', anchor_begin_id)); table.before(sprintf('<div id="%s"></div>', anchor_begin_id));
table.after(sprintf('<div id="%s"></div>', anchor_end_id)); table.after(sprintf('<div id="%s"></div>', anchor_end_id));
@ -38,7 +47,7 @@
// clone header just once, to be used as sticky header // clone header just once, to be used as sticky header
// deep clone header. using source header affects tbody>td width // deep clone header. using source header affects tbody>td width
this.$stickyHeader = $($('#'+header_id).clone()); this.$stickyHeader = $($('#'+header_id).clone(true, true));
// avoid id conflict // avoid id conflict
this.$stickyHeader.removeAttr('id'); this.$stickyHeader.removeAttr('id');
@ -48,7 +57,12 @@
// render sticky when table scroll left-right // render sticky when table scroll left-right
table.closest('.fixed-table-container').find('.fixed-table-body').on('scroll.'+table_id, table, match_position_x); table.closest('.fixed-table-container').find('.fixed-table-body').on('scroll.'+table_id, table, match_position_x);
function render_sticky_header(event){ this.$el.on('all.bs.table', function (e) {
that.$stickyHeader = $($('#'+header_id).clone(true, true));
that.$stickyHeader.removeAttr('id');
});
function render_sticky_header(event) {
var table = event.data; var table = event.data;
var table_header_id = table.find('thead').attr('id'); var table_header_id = table.find('thead').attr('id');
// console.log('render_sticky_header for > '+table_header_id); // console.log('render_sticky_header for > '+table_header_id);
@ -75,7 +89,7 @@
$(item).css('min-width', $('#'+table_header_id+' tr').eq(0).find('th').eq(index).css('width')); $(item).css('min-width', $('#'+table_header_id+' tr').eq(0).find('th').eq(index).css('width'));
}); });
// match bootstrap table style // match bootstrap table style
$("#"+sticky_header_container_id).removeClass('hidden').addClass("fix-sticky fixed-table-container") ; $("#"+sticky_header_container_id).removeClass(hidden_class).addClass("fix-sticky fixed-table-container") ;
// stick it in position // stick it in position
$("#"+sticky_header_container_id).css('top', header_height + 'px'); $("#"+sticky_header_container_id).css('top', header_height + 'px');
// create scrollable container for header // create scrollable container for header
@ -86,7 +100,7 @@
match_position_x(event); match_position_x(event);
} else { } else {
// hide sticky // hide sticky
$("#"+sticky_header_container_id).removeClass("fix-sticky").addClass('hidden'); $("#"+sticky_header_container_id).removeClass("fix-sticky").addClass(hidden_class);
} }
} }

View file

@ -8,7 +8,7 @@
"/css/app.css.map": "/css/app.css.map?id=bdbe05e6ecd70ccfac72", "/css/app.css.map": "/css/app.css.map?id=bdbe05e6ecd70ccfac72",
"/css/overrides.css.map": "/css/overrides.css.map?id=898c91d4a425b01b589b", "/css/overrides.css.map": "/css/overrides.css.map?id=898c91d4a425b01b589b",
"/css/dist/all.css": "/css/dist/all.css?id=dc1449877e0f8abedc47", "/css/dist/all.css": "/css/dist/all.css?id=dc1449877e0f8abedc47",
"/js/dist/all.js": "/js/dist/all.js?id=4e5e7295e9a59e718567", "/js/dist/all.js": "/js/dist/all.js?id=d3af8331997bd82e4ec4",
"/css/build/all.css": "/css/build/all.css?id=dc1449877e0f8abedc47", "/css/build/all.css": "/css/build/all.css?id=dc1449877e0f8abedc47",
"/js/build/all.js": "/js/build/all.js?id=4e5e7295e9a59e718567" "/js/build/all.js": "/js/build/all.js?id=d3af8331997bd82e4ec4"
} }

View file

@ -322,6 +322,25 @@ $(document).ready(function () {
// ------------------------------------------------ // ------------------------------------------------
// File size validation
$('#uploadFile').bind('change', function() {
$('#upload-file-status').removeClass('text-success').removeClass('text-danger');
$('.goodfile').remove();
$('.badfile').remove();
var max_size = $('#uploadFile').data('maxsize');
var actual_size = this.files[0].size;
if (actual_size > max_size) {
$('#upload-file-status').addClass('text-danger').removeClass('help-block').prepend('<i class="badfile fa fa-times"></i> ');
} else {
$('#upload-file-status').addClass('text-success').removeClass('help-block').prepend('<i class="goodfile fa fa-check"></i> ');
}
$('#upload-file-info').html(this.files[0].name);
});

View file

@ -97,7 +97,7 @@
'image' => 'Image', 'image' => 'Image',
'image_delete' => 'Delete Image', 'image_delete' => 'Delete Image',
'image_upload' => 'Upload Image', 'image_upload' => 'Upload Image',
'image_filetypes_help' => 'Accepted filetypes are jpg, png, gif, and svg.', 'image_filetypes_help' => 'Accepted filetypes are jpg, png, gif, and svg. Max upload size allowed is :size.',
'import' => 'Import', 'import' => 'Import',
'import-history' => 'Import History', 'import-history' => 'Import History',
'asset_maintenance' => 'Asset Maintenance', 'asset_maintenance' => 'Asset Maintenance',

View file

@ -33,7 +33,16 @@
@section('content') @section('content')
<div class="row"> <div class="row">
@if (!$asset->model)
<div class="col-md-12">
<div class="callout callout-danger">
<h4>NO MODEL ASSOCIATED</h4>
<p>This will break things in weird and horrible ways. Edit this asset now to assign it a model. </p>
</div>
</div>
@endif
@if ($asset->deleted_at!='') @if ($asset->deleted_at!='')
<div class="col-md-12"> <div class="col-md-12">
<div class="alert alert-danger"> <div class="alert alert-danger">
@ -148,7 +157,7 @@
</tr> </tr>
@endif @endif
@if ($asset->model->manufacturer) @if (($asset->model) && ($asset->model->manufacturer))
<tr> <tr>
<td>{{ trans('admin/hardware/form.manufacturer') }}</td> <td>{{ trans('admin/hardware/form.manufacturer') }}</td>
<td> <td>
@ -162,21 +171,21 @@
<li> {{ $asset->model->manufacturer->name }}</li> <li> {{ $asset->model->manufacturer->name }}</li>
@endcan @endcan
@if ($asset->model->manufacturer->url) @if (($asset->model) && ($asset->model->manufacturer->url))
<li><i class="fa fa-globe"></i> <a href="{{ $asset->model->manufacturer->url }}">{{ $asset->model->manufacturer->url }}</a></li> <li><i class="fa fa-globe"></i> <a href="{{ $asset->model->manufacturer->url }}">{{ $asset->model->manufacturer->url }}</a></li>
@endif @endif
@if ($asset->model->manufacturer->support_url) @if (($asset->model) && ($asset->model->manufacturer->support_url))
<li><i class="fa fa-life-ring"></i> <a href="{{ $asset->model->manufacturer->support_url }}">{{ $asset->model->manufacturer->support_url }}</a></li> <li><i class="fa fa-life-ring"></i> <a href="{{ $asset->model->manufacturer->support_url }}">{{ $asset->model->manufacturer->support_url }}</a></li>
@endif @endif
@if ($asset->model->manufacturer->support_phone) @if (($asset->model) && ($asset->model->manufacturer->support_phone))
<li><i class="fa fa-phone"></i> <li><i class="fa fa-phone"></i>
<a href="tel:{{ $asset->model->manufacturer->support_phone }}">{{ $asset->model->manufacturer->support_phone }}</a> <a href="tel:{{ $asset->model->manufacturer->support_phone }}">{{ $asset->model->manufacturer->support_phone }}</a>
</li> </li>
@endif @endif
@if ($asset->model->manufacturer->support_email) @if (($asset->model) && ($asset->model->manufacturer->support_email))
<li><i class="fa fa-envelope"></i> <a href="mailto:{{ $asset->model->manufacturer->support_email }}">{{ $asset->model->manufacturer->support_email }}</a></li> <li><i class="fa fa-envelope"></i> <a href="mailto:{{ $asset->model->manufacturer->support_email }}">{{ $asset->model->manufacturer->support_email }}</a></li>
@endif @endif
</ul> </ul>
@ -188,7 +197,7 @@
<td> <td>
{{ trans('general.category') }}</td> {{ trans('general.category') }}</td>
<td> <td>
@if ($asset->model->category) @if (($asset->model) && ($asset->model->category))
@can('view', \App\Models\Category::class) @can('view', \App\Models\Category::class)
@ -208,15 +217,21 @@
<tr> <tr>
<td> <td>
{{ trans('admin/hardware/form.model') }}</td> {{ trans('admin/hardware/form.model') }}
</td>
<td> <td>
@can('view', \App\Models\AssetModel::class)
<a href="{{ route('models.show', $asset->model->id) }}"> @if ($asset->model)
{{ $asset->model->name }}
</a> @can('view', \App\Models\AssetModel::class)
@else <a href="{{ route('models.show', $asset->model->id) }}">
{{ $asset->model->name }} {{ $asset->model->name }}
@endcan </a>
@else
{{ $asset->model->name }}
@endcan
@endif
</td> </td>
</tr> </tr>
@ -224,12 +239,12 @@
<tr> <tr>
<td>{{ trans('admin/models/table.modelnumber') }}</td> <td>{{ trans('admin/models/table.modelnumber') }}</td>
<td> <td>
{{ $asset->model->model_number }} {{ ($asset->model) ? $asset->model->model_number : ''}}
</td> </td>
</tr> </tr>
@if ($asset->model->fieldset) @if (($asset->model) && ($asset->model->fieldset))
@foreach($asset->model->fieldset->fields as $field) @foreach($asset->model->fieldset->fields as $field)
<tr> <tr>
<td> <td>
@ -326,7 +341,7 @@
</tr> </tr>
@endif @endif
@if ($asset->depreciation) @if (($asset->model) && ($asset->depreciation))
<tr> <tr>
<td>{{ trans('general.depreciation') }}</td> <td>{{ trans('general.depreciation') }}</td>
<td> <td>
@ -352,7 +367,7 @@
</tr> </tr>
@endif @endif
@if ($asset->model->eol) @if (($asset->model) && ($asset->model->eol))
<tr> <tr>
<td>{{ trans('admin/hardware/form.eol_rate') }}</td> <td>{{ trans('admin/hardware/form.eol_rate') }}</td>
<td> <td>
@ -448,7 +463,7 @@
<div class="col-md-4"> <div class="col-md-4">
@if ($asset->image) @if ($asset->image)
<img src="{{ url('/') }}/uploads/assets/{{{ $asset->image }}}" class="assetimg img-responsive"> <img src="{{ url('/') }}/uploads/assets/{{{ $asset->image }}}" class="assetimg img-responsive">
@elseif ($asset->model->image!='') @elseif (($asset->model) && ($asset->model->image!=''))
<img src="{{ url('/') }}/uploads/models/{{{ $asset->model->image }}}" class="assetimg img-responsive"> <img src="{{ url('/') }}/uploads/models/{{{ $asset->model->image }}}" class="assetimg img-responsive">
@endif @endif

View file

@ -823,5 +823,7 @@
</script> </script>
@endif @endif
</body> </body>
</html> </html>

View file

@ -1,13 +1,13 @@
<div class="form-group {{ $errors->has('image') ? 'has-error' : '' }}"> <div class="form-group {{ $errors->has('image') ? 'has-error' : '' }}">
<label class="col-md-3 control-label" for="image">{{ trans('general.image_upload') }}</label> <label class="col-md-3 control-label" for="image">{{ trans('general.image_upload') }}</label>
<div class="col-md-5"> <div class="col-md-9">
<label class="btn btn-default"> <label class="btn btn-default">
{{ trans('button.select_file') }} {{ trans('button.select_file') }}
<input type="file" name="image" accept="image/gif,image/jpeg,image/png,image/svg" <input type="file" name="image" id="uploadFile" data-maxsize="{{ \App\Helpers\Helper::file_upload_max_size() }}" accept="image/gif,image/jpeg,image/png,image/svg" style="display:none">
onchange="$('#upload-file-info').html(this.files[0].name)" style="display:none">
</label> </label>
<span class='label label-default' id="upload-file-info"></span> <span class='label label-default' id="upload-file-info"></span>
<p class="help-block">{{ trans('general.image_filetypes_help') }}</p>
<p class="help-block" id="upload-file-status">{{ trans('general.image_filetypes_help', ['size' => \App\Helpers\Helper::file_upload_max_size_readable()]) }}</p>
{!! $errors->first('image', '<span class="alert-msg">:message</span>') !!} {!! $errors->first('image', '<span class="alert-msg">:message</span>') !!}
</div> </div>
</div> </div>

View file

@ -1,4 +1,4 @@
<div class="box-footer text-right"> <div class="box-footer text-right">
<a class="btn btn-link" href="{{ URL::previous() }}">{{ trans('button.cancel') }}</a> <a class="btn btn-link text-left" href="{{ URL::previous() }}">{{ trans('button.cancel') }}</a>
<button type="submit" class="btn btn-success"><i class="fa fa-check icon-white"></i> {{ trans('general.save') }}</button> <button type="submit" class="btn btn-success"><i class="fa fa-check icon-white"></i> {{ trans('general.save') }}</button>
</div> </div>