A free open source IT asset/license management system
Added new calendar widget, “Needs attention”, etc
snipe4091d2af7fbf
diff --git a/resources/views/dashboard.blade.php b/resources/views/dashboard.blade.phpindex 5332b52bd0..dfbc669b7d 100755--- a/resources/views/dashboard.blade.php+++ b/resources/views/dashboard.blade.php@@ -209,8 +209,8 @@@else-<!-- recent activity -->-<div class="row">+ <!-- recent activity + today calendar -->+ <div class="row dashboard-row-eq"><div class="col-md-8"><div class="box box-default"><div class="box-header with-border">@@ -235,6 +235,8 @@data-sort-order="desc"data-show-columns="false"data-sort-name="created_at"+ data-sticky-header="false"+ data-empty-message="{{ trans('general.dashboard_activity_empty') }}"id="dashActivityReport"class="table table-striped snipe-table"data-url="{{ route('api.activity.index', ['limit' => 25]) }}">@@ -250,14 +252,57 @@</thead></table></div><!-- /.col -->- <div class="text-center col-md-12" style="padding-top: 10px;">- <a href="{{ route('reports.activity') }}" class="btn btn-theme btn-sm" style="width: 100%">{{ trans('general.viewall') }}</a>- </div></div><!-- /.row --></div><!-- ./box-body -->+ <div class="box-footer text-center">+ <a href="{{ route('reports.activity') }}" class="btn btn-theme btn-sm" style="width: 100%">{{ trans('general.viewall') }}</a>+ </div></div><!-- /.box --></div>- <div class="col-md-4">++ {{-- Today widget: agenda-style list of everything happening+ today across every HasCalendarEvents source. Uses the+ same reusable snipeit-calendar bundle as the main+ /calendar page, initialized with listDay (agenda list+ for a single day). --}}+ <div class="col-md-4">+ @can('view', \App\Models\Asset::class)+ <div class="box box-default">+ <div class="box-header with-border">+ <h2 class="box-title">+ <a href="{{ route('calendar.index') }}">{{ trans('general.calendar_upcoming') }}</a>+ </h2>+ <div class="box-tools pull-right">+ <button type="button" class="btn btn-box-tool" data-widget="collapse" aria-hidden="true">+ <x-icon type="minus"/>+ <span class="sr-only">{{ trans('general.collapse') }}</span>+ </button>+ </div>+ </div>+ <div class="box-body">+ <div id="dashboard-today-calendar"></div>+ </div>+ {{-- Matches the "View all" btn-theme footers on the+ sibling dashboard panels. Shown only when the+ widget's onFetchMeta reports the API hit its+ row cap. --}}+ <div id="dashboard-today-more" class="box-footer text-center" style="display:none;">+ <a href="{{ route('calendar.index') }}" class="btn btn-theme btn-sm" style="width: 100%" id="dashboard-today-more-link"></a>+ </div>+ </div>+ @endcan+ </div>+ </div> <!--/row-->++ {{-- Row: pie chart + low-stock + overdue/pending. All three at+ col-md-4 so the row lines up cleanly regardless of box height,+ and each widget serves a distinct "what needs attention" role+ for the admin scanning the dashboard. `dashboard-row-compact`+ caps the box-body heights on this row so the pie/list/table+ trio doesn't dwarf the rest of the dashboard when Needs+ Attention or Low Stock grow long. --}}+ <div class="row dashboard-row-eq dashboard-row-compact">+ <div class="col-md-4"><div class="box box-default"><div class="box-header with-border"><h2 class="box-title">@@ -270,19 +315,90 @@</button></div></div>- <!-- /.box-header --><div class="box-body">- <div class="row">- <div class="col-md-12">- <div class="chart-responsive">- <canvas id="statusPieChart" height="260"></canvas>- </div> <!-- ./chart-responsive -->- </div> <!-- /.col -->- </div> <!-- /.row -->- </div><!-- /.box-body -->- </div> <!-- /.box -->- </div>+ <div class="chart-responsive">+ <canvas id="statusPieChart" height="260"></canvas>+ </div>+ </div>+ </div>+ </div>++ <div class="col-md-4">+ <div class="box box-default">+ <div class="box-header with-border">+ <h2 class="box-title">+ {{ trans('general.dashboard_low_stock') }}+ {{-- Info icon: explains the formula the alert+ uses (remaining < min + alert_threshold)+ so the widget doesn't look arbitrary to+ someone who hasn't set a min_amt or+ threshold. No link on the icon since+ non-superuser admins see the dashboard+ but can't reach the alert-threshold setting. --}}+ <span data-tooltip="true"+ title="{{ trans('general.dashboard_low_stock_help', ['threshold' => (int) $snipeSettings->alert_threshold]) }}"+ class="text-muted"+ style="cursor: help;">+ <x-icon type="more-info" class="fa-fw"/>+ <span class="sr-only">{{ trans('general.dashboard_low_stock_help', ['threshold' => (int) $snipeSettings->alert_threshold]) }}</span>+ </span>+ </h2>+ <div class="box-tools pull-right">+ <button type="button" class="btn btn-box-tool" data-widget="collapse" aria-hidden="true">+ <x-icon type="minus"/>+ <span class="sr-only">{{ trans('general.collapse') }}</span>+ </button>+ </div>+ </div>+ <div class="box-body">+ {{-- Bs-table backed by /api/v1/low-stock which delegates+ to Helper::checkLowInventory so this widget and the+ top-nav alert bell can't drift. polymorphicItemFormatter+ handles the per-type icon + drilldown link, and the+ shared adjust-quantity button hangs off each row's+ available_actions.adjust_quantity via the generic+ actions column. --}}+ <table+ data-cookie-id-table="dashLowStock"+ data-pagination="false"+ data-side-pagination="server"+ data-id-table="dashLowStock"+ data-sticky-header="false"+ data-search="false"+ data-show-columns="false"+ data-show-columns-toggle-all="false"+ data-show-fullscreen="false"+ data-show-print="false"+ data-show-refresh="false"+ data-show-export="false"+ data-empty-message="{{ trans('general.dashboard_low_stock_empty') }}"+ id="dashLowStock"+ class="table table-striped snipe-table"+ data-url="{{ route('api.low-stock.index', ['limit' => 25]) }}">+ <thead>+ <tr>+ <th scope="col" data-field="item" data-formatter="polymorphicItemFormatter">{{ trans('general.name') }}</th>+ <th scope="col" data-field="remaining" data-sortable="true" class="text-right">{{ trans('general.remaining') }}</th>+ <th scope="col" data-field="min_amt" data-sortable="true" data-formatter="minAmtFormatter" class="text-right">{{ trans('general.min_amt') }}</th>+ <th scope="col" data-field="available_actions" data-formatter="lowStockActionsFormatter" class="hidden-print text-right">+ <span class="sr-only">{{ trans('table.actions') }}</span>+ </th>+ </tr>+ </thead>+ </table>+ </div>+ </div>+ </div>+ <div class="col-md-4">+ {{-- Lazy Livewire component so the eight count queries+ that back this widget don't sit on the dashboard's+ critical render path. Rendered as a placeholder on+ first paint; Livewire fires a follow-up XHR to hydrate+ the real counts. Same pattern the top-nav AlertMenu+ uses for its low-inventory + deprecation queries. --}}+ <livewire:needs-attention/>+ </div></div> <!--/row--><div class="row"><div class="col-md-6">@@ -311,6 +427,7 @@data-sort-order="desc"data-show-columns="false"data-sort-field="assets_count"+ data-sticky-header="false"id="dashCompanySummary"class="table table-striped snipe-table"data-url="{{ route('api.companies.index', ['sort' => 'assets_count', 'order' => 'asc']) }}">@@ -378,6 +495,7 @@data-pagination="false"data-sort-order="desc"data-sort-field="assets_count"+ data-sticky-header="false"id="dashLocationSummary"data-show-columns="false"class="table table-striped snipe-table"@@ -420,7 +538,7 @@<!-- Categories --><div class="box box-default"><div class="box-header with-border">- <h2 class="box-title">{{ trans('general.asset') }} {{ trans('general.categories') }}</h2>+ <h2 class="box-title">{{ trans('general.categories') }}</h2><div class="box-tools pull-right"><button type="button" class="btn btn-box-tool" data-widget="collapse"><x-icon type="minus" />@@ -441,6 +559,7 @@data-show-columns="false"data-sort-order="desc"data-sort-field="assets_count"+ data-sticky-header="false"id="dashCategorySummary"class="table table-striped snipe-table"data-url="{{ route('api.categories.index', ['sort' => 'assets_count', 'order' => 'asc']) }}">@@ -487,11 +606,99 @@@endif+ {{-- Adjust-quantity modal wiring for the low-stock widget's inline+ replenish button. Same shared modal used on the accessories /+ consumables / components index and view pages. Included whenever+ the viewer can update any of the three item types (one of those+ grants is what makes the button actually appear in the widget). --}}+ @if (Gate::allows('update', \App\Models\Consumable::class)+ || Gate::allows('update', \App\Models\Accessory::class)+ || Gate::allows('update', \App\Models\Component::class))+ <x-modals.adjust-quantity/>+ @endif@stop@section('moar_scripts')@include ('partials.bootstrap-table', ['simple_view' => true, 'nopages' => true])++ @can('view', \App\Models\Asset::class)+ {{-- Today widget for the dashboard. Reuses the main calendar+ bundle; initializes into listDay view scoped to today. No+ URL sync (widgets don't own the page URL), no filter+ buttons (too tight for the dashboard column), no toolbar+ (title suffices). Users who want to filter head over to+ the full /calendar page. --}}+ <script src="{{ url(mix('js/dist/snipeit-calendar.js')) }}" nonce="{{ csrf_token() }}"></script>+ <script nonce="{{ csrf_token() }}">+ document.addEventListener('DOMContentLoaded', function () {+ // Format list-view day-group labels. Compares the+ // group's date to today's local Y-M-D so the+ // "Today" / "Tomorrow" swap survives a browser+ // timezone that's east/west of UTC. Anything beyond+ // tomorrow falls back to FC's own locale-aware+ // default via arg.text.+ var upcomingDayFormat = function (arg) {+ var d = arg.date;+ var localYmd = d.year + '-' + String(d.month + 1).padStart(2, '0') + '-' + String(d.day).padStart(2, '0');+ var today = new Date();+ var todayYmd = today.getFullYear() + '-' + String(today.getMonth() + 1).padStart(2, '0') + '-' + String(today.getDate()).padStart(2, '0');+ var tomorrow = new Date(today.getTime() + 86400000);+ var tomorrowYmd = tomorrow.getFullYear() + '-' + String(tomorrow.getMonth() + 1).padStart(2, '0') + '-' + String(tomorrow.getDate()).padStart(2, '0');+ if (localYmd === todayYmd) return '{{ trans('general.calendar_today') }}';+ if (localYmd === tomorrowYmd) return '{{ trans('general.calendar_tomorrow') }}';+ return arg.text;+ };++ window.snipeitCalendar.init('dashboard-today-calendar', {+ events: '{{ route('api.calendar.events') }}',+ // Rolling 7-day list starting today (not listWeek,+ // which starts on the week's Sunday/Monday and+ // would show yesterday on a Tuesday). Keeps the+ // widget useful when today itself is empty by+ // pulling in tomorrow through 6 days out.+ initialView: 'listUpcoming',+ views: {+ listUpcoming: {+ type: 'list',+ duration: {days: 7},+ },+ },+ // Left side gets the "Today" / "Tomorrow" /+ // weekday-default swap. Right side stays a full+ // human-readable date ("August 14, 2026") so+ // the viewer can see the actual calendar day+ // even when the left label is relative.+ listDayFormat: upcomingDayFormat,+ listDaySideFormat: {+ month: 'long',+ day: 'numeric',+ year: 'numeric',+ },+ headerToolbar: false,+ direction: '{{ \App\Helpers\Helper::determineLanguageDirection() }}',+ locale: '{{ str_replace('_', '-', app()->getLocale()) }}',+ urlState: false,+ limit: 12,+ onFetchMeta: function (meta) {+ var more = document.getElementById('dashboard-today-more');+ var link = document.getElementById('dashboard-today-more-link');+ if (!more || !link) {+ return;+ }+ if (meta.truncated) {+ var remaining = Math.max(0, meta.total - meta.returned);+ link.textContent = '{{ trans('general.calendar_upcoming_more') }}'.replace(':count', String(remaining));+ more.style.display = '';+ }+ else {+ more.style.display = 'none';+ }+ },+ });+ });+ </script>+ @endcan@stop@push('js')