diff --git a/app/Console/Commands/Version.php b/app/Console/Commands/Version.php new file mode 100644 index 0000000000..8d71e23e79 --- /dev/null +++ b/app/Console/Commands/Version.php @@ -0,0 +1,136 @@ +option('branch'); + $use_type = $this->option('type'); + $git_branch = trim(shell_exec('git rev-parse --abbrev-ref HEAD')); + $build_version = trim(shell_exec('git rev-list --count '.$use_branch)); + $versionFile = 'config/version.php'; + $full_hash_version = str_replace("\n", '', shell_exec('git describe master --tags')); + + $version = explode('-', $full_hash_version); + $app_version = $current_app_version = $version[0]; + $hash_version = $version[2]; + $prerelease_version = ''; + + $this->line('Branch is: '.$use_branch); + $this->line('Type is: '.$use_type); + $this->line('Current version is: '.$full_hash_version); + + if (count($version)==3) { + $this->line('This does not look like an alpha/beta release.'); + } else { + print_r($version); + if (array_key_exists('3',$version)) { + $this->line('The current version looks like a beta release.'); + $prerelease_version = $version[1]; + $hash_version = $version[3]; + } + } + + + $app_version_raw = explode('.', $app_version); + + $maj = str_replace('v', '', $app_version_raw[0]); + $min = $app_version_raw[1]; + $patch = ''; + + + + // This is a major release that might not have a third .0 + if (array_key_exists(2, $app_version_raw)) { + $patch = $app_version_raw[2]; + } + + if ($use_type=='major') { + $app_version = "v".($maj + 1).".$min.$patch"; + } elseif ($use_type=='minor') { + $app_version = "v"."$maj.".($min + 1).".$patch"; + } elseif ($use_type=='pre') { + $pre_raw = str_replace('beta','', $prerelease_version); + $pre_raw = str_replace('alpha','', $pre_raw); + $pre_raw = str_ireplace('rc','', $pre_raw); + $pre_raw = $pre_raw++; + $this->line('Setting the pre-release to '. $prerelease_version.'-'.$pre_raw); + $app_version = "v"."$maj.".($min + 1).".$patch"; + } elseif ($use_type=='patch') { + $app_version = "v" . "$maj.$min." . ($patch + 1); + // If nothing is passed, leave the version as it is, just increment the build + } else { + $app_version = "v" . "$maj.$min." . $patch; + } + + // Determine if this tag already exists, or if this prior to a release + $this->line('Running: git rev-parse master '.$current_app_version); + // $pre_release = trim(shell_exec('git rev-parse '.$use_branch.' '.$current_app_version.' 2>&1 1> /dev/null')); + + if ($use_branch=='develop') { + $app_version = $app_version.'-pre'; + } + + $full_app_version = $app_version.' - build '.$build_version.'-'.$hash_version; + + + $array = var_export( + array( + 'app_version' => $app_version, + 'full_app_version' => $full_app_version, + 'build_version' => $build_version, + 'prerelease_version' => $prerelease_version, + 'hash_version' => $hash_version, + 'full_hash' => $full_hash_version, + 'branch' => $git_branch), + true + ); + + + + // Construct our file content + $content = <<info('Setting NEW version: '. $full_app_version.' ('.$git_branch.')'); + } + +} diff --git a/app/Console/Commands/Versioning.php b/app/Console/Commands/Versioning.php deleted file mode 100644 index c540ff0a24..0000000000 --- a/app/Console/Commands/Versioning.php +++ /dev/null @@ -1,91 +0,0 @@ - $version[0], - 'build_version' => $version[1], - 'hash_version' => $version[2], - 'full_hash' => $hash_version), - true - ); - - - // Construct our file content - $content = <<line('Setting version: '. config('version.app_version').' build '.config('version.build_version').' ('.config('version.hash_version').')'); - } - - /** - * Get the console command arguments. - * - * @return array - */ - protected function getArguments() - { - return array( - ); - } - - /** - * Get the console command options. - * - * @return array - */ - protected function getOptions() - { - return array( - ); - } -} diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index cc104d8e4b..9a49718df3 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -19,7 +19,7 @@ class Kernel extends ConsoleKernel Commands\SendInventoryAlerts::class, Commands\SendExpectedCheckinAlerts::class, Commands\ObjectImportCommand::class, - Commands\Versioning::class, + Commands\Version::class, Commands\SystemBackup::class, Commands\DisableLDAP::class, Commands\Purge::class, diff --git a/app/Http/Controllers/Api/CategoriesController.php b/app/Http/Controllers/Api/CategoriesController.php index e86eea78fa..006eea0ff6 100644 --- a/app/Http/Controllers/Api/CategoriesController.php +++ b/app/Http/Controllers/Api/CategoriesController.php @@ -21,7 +21,7 @@ class CategoriesController extends Controller public function index(Request $request) { $this->authorize('view', Category::class); - $allowed_columns = ['id', 'name','category_type','use_default_eula','eula_text', 'require_acceptance','checkin_email', 'assets_count', 'accessories_count', 'consumables_count', 'components_count', 'image']; + $allowed_columns = ['id', 'name','category_type', 'category_type','use_default_eula','eula_text', 'require_acceptance','checkin_email', 'assets_count', 'accessories_count', 'consumables_count', 'components_count', 'image']; $categories = Category::select(['id', 'created_at', 'updated_at', 'name','category_type','use_default_eula','eula_text', 'require_acceptance','checkin_email','image']) ->withCount('assets', 'accessories', 'consumables', 'components'); diff --git a/app/Http/Controllers/Api/ReportsController.php b/app/Http/Controllers/Api/ReportsController.php index 3731122507..10f63da415 100644 --- a/app/Http/Controllers/Api/ReportsController.php +++ b/app/Http/Controllers/Api/ReportsController.php @@ -50,11 +50,9 @@ class ReportsController extends Controller $offset = request('offset', 0); $limit = request('limit', 50); $total = $actionlogs->count(); - $actionlogs = $actionlogs->orderBy($sort, $order); - $actionlogs = $actionlogs->skip($offset)->take($limit)->get(); - return (new ActionlogsTransformer)->transformActionlogs($actionlogs, $total); - + $actionlogs = $actionlogs->orderBy($sort, $order)->skip($offset)->take($limit)->get(); + return response()->json((new ActionlogsTransformer)->transformActionlogs($actionlogs, $total), 200, ['Content-Type' => 'application/json;charset=utf8'], JSON_UNESCAPED_UNICODE); } } diff --git a/app/Http/Controllers/AssetsController.php b/app/Http/Controllers/AssetsController.php index 873446d420..4562ef39d8 100755 --- a/app/Http/Controllers/AssetsController.php +++ b/app/Http/Controllers/AssetsController.php @@ -1238,8 +1238,9 @@ class AssetsController extends Controller public function audit($id) { + $settings = Setting::getSettings(); $this->authorize('audit', Asset::class); - $dt = Carbon::now()->addMonths(12)->toDateString(); + $dt = Carbon::now()->addMonths($settings->audit_interval)->toDateString(); $asset = Asset::findOrFail($id); return view('hardware/audit')->with('asset', $asset)->with('next_audit_date', $dt)->with('locations_list'); } diff --git a/app/Http/Transformers/AssetsTransformer.php b/app/Http/Transformers/AssetsTransformer.php index 801b439bc3..2dbc9da726 100644 --- a/app/Http/Transformers/AssetsTransformer.php +++ b/app/Http/Transformers/AssetsTransformer.php @@ -86,24 +86,21 @@ class AssetsTransformer $decrypted = \App\Helpers\Helper::gracefulDecrypt($field,$asset->{$field->convertUnicodeDbSlug()}); $value = (Gate::allows('superadmin')) ? $decrypted : strtoupper(trans('admin/custom_fields/general.encrypted')); - // $fields_array = [$field->convertUnicodeDbSlug() => $value]; - - $fields_array[$field->name] = [ 'field' => $field->convertUnicodeDbSlug(), - 'value' => $value + 'value' => $value, + 'field_format' => $field->format, ]; } else { $fields_array[$field->name] = [ 'field' => $field->convertUnicodeDbSlug(), - 'value' => $asset->{$field->convertUnicodeDbSlug()} + 'value' => $asset->{$field->convertUnicodeDbSlug()}, + 'field_format' => $field->format, ]; - //$fields_array = [$field->convertUnicodeDbSlug() => $asset->{$field->convertUnicodeDbSlug()}]; } - //array += $fields_array; $array['custom_fields'] = $fields_array; } } else { diff --git a/app/Http/Transformers/CategoriesTransformer.php b/app/Http/Transformers/CategoriesTransformer.php index 0c77917d42..77bf07aa29 100644 --- a/app/Http/Transformers/CategoriesTransformer.php +++ b/app/Http/Transformers/CategoriesTransformer.php @@ -26,7 +26,7 @@ class CategoriesTransformer 'id' => (int) $category->id, 'name' => e($category->name), 'image' => ($category->image) ? app('categories_upload_url').e($category->image) : null, - 'type' => e($category->category_type), + 'category_type' => e($category->category_type), 'eula' => ($category->getEula()) ? true : false, 'checkin_email' => ($category->checkin_email =='1') ? true : false, 'require_acceptance' => ($category->require_acceptance =='1') ? true : false, diff --git a/app/Presenters/CategoryPresenter.php b/app/Presenters/CategoryPresenter.php index db864f43e7..0df0bf13c6 100644 --- a/app/Presenters/CategoryPresenter.php +++ b/app/Presenters/CategoryPresenter.php @@ -40,7 +40,7 @@ class CategoryPresenter extends Presenter "visible" => true, "formatter" => 'imageFormatter', ],[ - "field" => "type", + "field" => "category_type", "searchable" => true, "sortable" => true, "title" => trans('general.type'), diff --git a/config/version.php b/config/version.php index f3cac09037..6974b93f28 100644 --- a/config/version.php +++ b/config/version.php @@ -1,7 +1,10 @@ 'v4.1.5', - 'build_version' => '187', - 'hash_version' => 'gc0293a7', - 'full_hash' => 'v4.1.5-beta2-187-gc0293a7', -); + 'app_version' => 'v4.1.6-pre', + 'full_app_version' => 'v4.1.6-pre - build 2765-g1d6320a', + 'build_version' => '2765', + 'prerelease_version' => '', + 'hash_version' => 'g1d6320a', + 'full_hash' => 'v4.1.5-2-g1d6320a', + 'branch' => 'develop', +); \ No newline at end of file diff --git a/resources/assets/js/snipeit.js b/resources/assets/js/snipeit.js index 7119bafc79..ef0e1ba616 100755 --- a/resources/assets/js/snipeit.js +++ b/resources/assets/js/snipeit.js @@ -255,6 +255,8 @@ $(document).ready(function () { return datalist.text; } + // This handles the radio button selectors for the checkout-to-foo options + // on asset checkout and also on asset edit $(function() { $('input[name=checkout_to_type]').on("change",function () { var assignto_type = $('input[name=checkout_to_type]:checked').val(); diff --git a/resources/views/dashboard.blade.php b/resources/views/dashboard.blade.php index 37c3c49b95..2c6da09c5e 100755 --- a/resources/views/dashboard.blade.php +++ b/resources/views/dashboard.blade.php @@ -219,11 +219,15 @@ id="table" data-height="440" - data-url="{{ route('api.categories.index') }}"> + data-url="{{ route('api.categories.index', ['sort' => 'assets_count', 'order' => 'asc']) }}"> - {{ trans('general.name') }} - + {{ trans('general.name') }} + {{ trans('general.type') }} + + + + diff --git a/resources/views/layouts/default.blade.php b/resources/views/layouts/default.blade.php index e52a2d8f95..e642167f2c 100644 --- a/resources/views/layouts/default.blade.php +++ b/resources/views/layouts/default.blade.php @@ -727,12 +727,12 @@
Snipe-IT is an open source - project, made with by @snipeyhead under the AGPL3 license. + project, made with by @snipeitapp under the AGPL3 license.
diff --git a/resources/views/partials/bootstrap-table.blade.php b/resources/views/partials/bootstrap-table.blade.php index a57980aaf2..8b32bd5ad0 100644 --- a/resources/views/partials/bootstrap-table.blade.php +++ b/resources/views/partials/bootstrap-table.blade.php @@ -354,7 +354,18 @@ // (for example, the locked icon for encrypted fields) var field_column_plain = field_column.replace(/<(?:.|\n)*?> ?/gm, ''); if ((row.custom_fields) && (row.custom_fields[field_column_plain])) { + + // If the field type needs special formatting, do that here + if ((row.custom_fields[field_column_plain].field_format) && (row.custom_fields[field_column_plain].value)) { + if (row.custom_fields[field_column_plain].field_format=='URL') { + return '' + row.custom_fields[field_column_plain].value + ''; + } else if (row.custom_fields[field_column_plain].field_format=='EMAIL') { + return '' + row.custom_fields[field_column_plain].value + ''; + } + } + console.log('NOT a URL!'); return row.custom_fields[field_column_plain].value; + } }