A free open source IT asset/license management system
Made existing formatters more flexible, removed unused
snipe2d3a53e449d7
diff --git a/resources/views/hardware/view.blade.php b/resources/views/hardware/view.blade.phpindex 1530ffd24e..46864398de 100755--- a/resources/views/hardware/view.blade.php+++ b/resources/views/hardware/view.blade.php@@ -1390,7 +1390,7 @@<th data-visible="true" data-field="admin" data-formatter="usersLinkObjFormatter">{{ trans('general.created_by') }}</th><th class="col-sm-2" data-field="file" data-sortable="true" data-visible="false" data-formatter="fileUploadNameFormatter">{{ trans('general.file_name') }}</th><th data-field="note">{{ trans('general.notes') }}</th>- <th data-visible="false" data-field="file" data-visible="false" data-formatter="fileUploadFormatter">{{ trans('general.download') }}</th>+ <th data-visible="false" data-field="file" data-visible="false" data-formatter="fileDownloadButtonsFormatter">{{ trans('general.download') }}</th><th data-field="log_meta" data-visible="true" data-formatter="changeLogFormatter">{{ trans('admin/hardware/table.changed')}}</th><th data-field="remote_ip" data-visible="false" data-sortable="true">{{ trans('admin/settings/general.login_ip') }}</th><th data-field="user_agent" data-visible="false" data-sortable="true">{{ trans('admin/settings/general.login_user_agent') }}</th>diff --git a/resources/views/locations/view.blade.php b/resources/views/locations/view.blade.phpindex 9f6f2dee9d..377ce91399 100644--- a/resources/views/locations/view.blade.php+++ b/resources/views/locations/view.blade.php@@ -400,7 +400,7 @@<th class="col-sm-2" data-visible="true" data-field="target" data-formatter="polymorphicItemFormatter">{{ trans('general.target') }}</th><th class="col-sm-2" data-field="note">{{ trans('general.notes') }}</th><th class="col-md-3" data-field="signature_file" data-visible="false" data-formatter="imageFormatter">{{ trans('general.signature') }}</th>- <th class="col-md-3" data-visible="false" data-field="file" data-visible="false" data-formatter="fileUploadFormatter">{{ trans('general.download') }}</th>+ <th class="col-md-3" data-visible="false" data-field="file" data-visible="false" data-formatter="fileDownloadButtonsFormatter">{{ trans('general.download') }}</th><th class="col-sm-2" data-field="log_meta" data-visible="true" data-formatter="changeLogFormatter">{{ trans('admin/hardware/table.changed')}}</th></tr></thead>diff --git a/resources/views/partials/bootstrap-table.blade.php b/resources/views/partials/bootstrap-table.blade.phpindex cf6be7bfbf..382ff648c2 100644--- a/resources/views/partials/bootstrap-table.blade.php+++ b/resources/views/partials/bootstrap-table.blade.php@@ -910,28 +910,42 @@}+ // This is users in the user accounts section for EULAsfunction downloadFormatter(value) {if (value) {return '<a href="' + value + '" class="btn btn-sm btn-default"><x-icon type="download" /></a>';}}+ // This is used by the UploadedFilesPresenter and the HistoryPresenter+ // It handles the download and inline buttons for files that are uploaded to assets, users, etcfunction fileDownloadButtonsFormatter(row, value) {- if ((value) && (value.url)) {+ if (value) {+ if (value.url) {+ var inlinable = value.inlineable;+ var exists_on_disk = value.exists_on_disk;+ var download_url = value.url;+ } else if (value.file) {+ var inlinable = value.file.inlineable;+ var exists_on_disk = value.file.exists_on_disk;+ var download_url = value.file.url;+ } else {+ return '';+ }- var download_button = '<a href="' + value.url + '" class="btn btn-sm btn-default" data-tooltip="true" title="{{ trans('general.download') }}"><x-icon type="download" /></a>';+ var download_button = '<a href="' + download_url + '" class="btn btn-sm btn-default" data-tooltip="true" title="{{ trans('general.download') }}"><x-icon type="download" /></a>';var download_button_disabled = '<span data-tooltip="true" title="{{ trans('general.file_does_not_exist') }}"><a class="btn btn-sm btn-default disabled"><x-icon type="download" /></a></span>';- var inline_button = '<a href="'+ value.url +'?inline=true" class="btn btn-sm btn-default" target="_blank" data-tooltip="true" title="{{ trans('general.open_new_window') }}"><x-icon type="external-link" /></a>';+ var inline_button = '<a href="'+ download_url +'?inline=true" class="btn btn-sm btn-default" target="_blank" data-tooltip="true" title="{{ trans('general.open_new_window') }}"><x-icon type="external-link" /></a>';var inline_button_disabled = '<span data-tooltip="true" title="{{ trans('general.file_does_not_exist') }}"><a class="btn btn-sm btn-default disabled" target="_blank" data-tooltip="true" title="{{ trans('general.file_does_not_exist') }}"><x-icon type="external-link" /></a></span>';- if (value.exists_on_disk) {- return '<span style="white-space: nowrap;">' + download_button + ' ' + inline_button + '</span>';+ if (exists_on_disk === true) {+ return '<span style="white-space: nowrap;">' + download_button + ' ' + inline_button + '</span>';} else {return '<span style="white-space: nowrap;">' + download_button_disabled + ' ' + inline_button_disabled + '</span>';}- }+ }}@@ -953,13 +967,6 @@}- function fileUploadFormatter(value) {- if ((value) && (value.url) && (value.inlineable)) {- return '<a href="' + value.url + '" data-toggle="lightbox" data-type="image"><img src="' + value.url + '" style="max-height: {{ $snipeSettings->thumbnail_max_h }}px; width: auto;" class="img-responsive" alt=""></a>';- } else if ((value) && (value.url)) {- return '<a href="' + value.url + '" class="btn btn-default"><x-icon type="download" /></a>';- }- }// This is used in the table listings@@ -1019,7 +1026,7 @@.replace('%FILENAME%', (row.exists_on_disk === true) ? row.filename : '<x-icon type="x" /> <del>' + row.filename + '</del>').replace('%CREATED_AT%', row.created_at.formatted).replace('%CREATED_BY%', (row.created_by) ? row.created_by.name : '')- .replace('%NOTE%', row.note)+ .replace('%NOTE%', (row.note) ? row.note : '').replace('%PANEL_CLASS%', (row.exists_on_disk === true) ? 'default' : 'danger').replace('%FILE_EMBED%', embed_code).replace('%DOWNLOAD_BUTTON%', (row.exists_on_disk === true) ? '<a href="'+ row.url +'" class="btn btn-sm btn-default"><x-icon type="download" /></a> ' : '<span class="btn btn-sm btn-default disabled" data-tooltip="true" title="{{ trans('general.file_upload_status.file_not_found') }}"><x-icon type="download" /></span>')@@ -1035,18 +1042,28 @@+ function fileNameFormatter(row, value) {+ if (value) {+ if ((value.file) && (value.file.filename) && (value.file.url)) {++ if (value.file.exists_on_disk === true) {+ return '<a href="' + value.file.url + '">' + value.file.filename + '</a>';+ }++ return '<span class="text-danger" style="text-decoration: line-through;" data-tooltip="true" title="{{ trans('general.file_does_not_exist') }}"><x-icon type="x" /> ' + value.file.filename + '</span>';- function fileUploadNameFormatter(row, value) {- if ((value) && (value.filename) && (value.url)) {- if (value.exists_on_disk) {- return '<a href="' + value.url + '">' + value.filename + '</a>';+ } else if ((value.filename) && (value.url)) {+ if (value.exists_on_disk === true) {+ return '<a href="' + value.url + '">' + value.filename + '</a>';+ }+ return '<span class="text-danger" style="text-decoration: line-through;" data-tooltip="true" title="{{ trans('general.file_does_not_exist') }}"><x-icon type="x" /> ' + value.filename + '</span>';}- return '<span class="text-danger" style="text-decoration: line-through;" data-tooltip="true" title="{{ trans('general.file_does_not_exist') }}"><x-icon type="x" /> ' + value.filename + '</span>';}- return '--';+}+function linkToUserSectionBasedOnCount (count, id, section) {if (count) {return '<a href="{{ config('app.url') }}/users/' + id + '#' + section +'">' + count + '</a>';