A free open source IT asset/license management system
adds company webhooks table to integration settings
Godfrey M08297b381d80
diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.phpindex 6329e70e42..1322990228 100644--- a/app/Helpers/Helper.php+++ b/app/Helpers/Helper.php@@ -824,7 +824,7 @@ class Helper$deprecations = ['ms_teams_deprecated' => ['check' => ! Str::contains(Setting::getSettings()->webhook_endpoint, 'workflows') && (Setting::getSettings()->webhook_selected === 'microsoft'),- 'message' => 'The Microsoft Teams webhook URL being used will be deprecated Dec 31st, 2025. <a class="btn btn-primary" href="'.route('settings.slack.index').'">Change webhook endpoint</a>'],+ 'message' => 'The Microsoft Teams webhook URL being used will be deprecated Dec 31st, 2025. <a class="btn btn-primary" href="' . route('settings.integrations.index') . '">Change webhook endpoint</a>'],];// if item of concern is being used and its being used with the deprecated values return the notification array.diff --git a/app/Http/Controllers/Api/CompaniesController.php b/app/Http/Controllers/Api/CompaniesController.phpindex b66acb09db..90d2ed993d 100644--- a/app/Http/Controllers/Api/CompaniesController.php+++ b/app/Http/Controllers/Api/CompaniesController.php@@ -96,7 +96,10 @@ class CompaniesController extends Controller$companies->where('parent_id', '=', (int) $parentId);}}-+ if ($request->boolean('webhook_filled')) {+ $companies->whereNotNull('webhook_endpoint')+ ->where('webhook_endpoint', '!=', '');+ }// Make sure the offset and limit are actually integers and do not exceed system limits$total = $companies->count();$offset = ($request->input('offset') > $total) ? $total : app('api_offset_value');diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.phpindex 2b7ba49700..0a0e453116 100644--- a/app/Http/Controllers/SettingsController.php+++ b/app/Http/Controllers/SettingsController.php@@ -521,11 +521,11 @@ class SettingsController extends Controller** @since [v1.0]*/- public function getSlack(): View+ public function getIntegrations(): View{$setting = Setting::getSettings();- return view('settings.slack', compact('setting'));+ return view('settings.integrations', compact('setting'));}/**diff --git a/app/Http/Transformers/CompaniesTransformer.php b/app/Http/Transformers/CompaniesTransformer.phpindex f03e9fcaf8..7728821594 100644--- a/app/Http/Transformers/CompaniesTransformer.php+++ b/app/Http/Transformers/CompaniesTransformer.php@@ -48,6 +48,7 @@ class CompaniesTransformer] : null,'tag_color' => ($company->tag_color != '') ? e($company->tag_color) : null,'notes' => Helper::parseEscapedMarkedownInline($company->notes),+ 'webhook_selected' => $company->webhook_selected,'created_at' => Helper::getFormattedDateObject($company->created_at, 'datetime'),'updated_at' => Helper::getFormattedDateObject($company->updated_at, 'datetime'),];diff --git a/app/Presenters/CompanyIntegrationsPresenter.php b/app/Presenters/CompanyIntegrationsPresenter.phpnew file mode 100644index 0000000000..e266a41d4c--- /dev/null+++ b/app/Presenters/CompanyIntegrationsPresenter.php@@ -0,0 +1,57 @@+<?php++namespace App\Presenters;++class CompanyIntegrationsPresenter extends Presenter+{+ /**+ * Json Column Layout for bootstrap table+ *+ * @return string+ */+ public static function dataTableLayout()+ {+ $layout = [+ [+ 'field' => 'name',+ 'searchable' => true,+ 'sortable' => true,+ 'switchable' => false,+ 'title' => trans('admin/companies/table.name'),+ 'visible' => true,+ 'formatter' => 'companiesLinkFormatter',+ ], [+ 'field' => 'email',+ 'searchable' => true,+ 'sortable' => true,+ 'switchable' => false,+ 'title' => trans('admin/suppliers/table.email'),+ 'visible' => true,+ 'formatter' => 'emailFormatter',+ ], [+ 'field' => 'webhook_selected',+ 'searchable' => false,+ 'sortable' => true,+ 'switchable' => false,+ 'title' => trans('admin/settings/general.webhook_provider'),+ 'visible' => true,+ 'formatter' => 'companyWebhookIntegrationFormatter',+ 'class' => 'text-center',+ ],+ [+ 'field' => 'actions',+ 'scope' => 'col',+ 'searchable' => false,+ 'sortable' => false,+ 'switchable' => false,+ 'title' => trans('table.actions'),+ 'visible' => true,+ 'formatter' => 'companyWebhookActionsFormatter',+ 'printIgnore' => true,+ 'class' => 'hidden-print',+ ],+ ];++ return json_encode($layout);+ }+}\ No newline at end of filediff --git a/resources/lang/en-US/admin/settings/general.php b/resources/lang/en-US/admin/settings/general.phpindex 3c3d74a922..ddd36f9480 100644--- a/resources/lang/en-US/admin/settings/general.php+++ b/resources/lang/en-US/admin/settings/general.php@@ -343,16 +343,19 @@ return ['ms_teams' => 'Microsoft Teams','webhook' => ':app','webhook_presave' => 'Test to Save',- 'webhook_title' => 'Update Webhook Settings',+ 'webhook_title' => 'Update Integration Settings','webhook_help' => 'Integration settings','webhook_botname' => ':app Botname','webhook_channel' => ':app Channel','webhook_endpoint' => ':app Endpoint',+ 'webhook_provider' => 'Provider','webhook_integration' => ':app Settings','webhook_test' => 'Test :app integration','webhook_integration_help' => ':app integration is optional, however the endpoint and channel are required if you wish to use it. To configure :app integration, you must first <a href=":webhook_link" target="_new" rel="noopener">create an incoming webhook</a> on your :app account. Click on the <strong>Test :app Integration</strong> button to confirm your settings are correct before saving. ','webhook_integration_help_button' => 'Once you have saved your :app information, a test button will appear.','webhook_test_help' => 'Test whether your :app integration is configured correctly. YOU MUST SAVE YOUR UPDATED :app SETTINGS FIRST.',+ 'webhook_company_integrations' => 'Companies with Webhooks',+ 'no_company_webhooks' => 'No company-specific webhook integrations have been configured.','shortcuts_enabled' => 'Enable Shortcuts','shortcuts_help_text' => '<strong>Windows</strong>: Alt + Access key, <strong>Mac</strong>: Control + Option + Access key','snipe_version' => 'Snipe-IT version',diff --git a/resources/views/blade/table/index.blade.php b/resources/views/blade/table/index.blade.phpindex c3218b71a0..cca1913085 100644--- a/resources/views/blade/table/index.blade.php+++ b/resources/views/blade/table/index.blade.php@@ -11,6 +11,9 @@'sort_order' => 'asc','sort_field' => 'name','aria_labelledby' => null,+ 'show_export' => true,+ 'show_columns' => true,+ 'no_matches' => null,])@aware(['name'])@@ -53,6 +56,8 @@data-search="{{ $show_search }}"data-footer-style="footerStyle"data-show-footer="true"+ data-show-export="{{ $show_export ? 'true' : 'false' }}"+ data-show-columns="{{ $show_columns ? 'true' : 'false' }}"@if ($presenter)data-columns="{{ $presenter }}"@@ -66,7 +71,9 @@data-side-pagination="server"data-url="{!! $api_url !!}"@endif-+ @if ($no_matches)+ data-format-no-matches="{{ $no_matches }}"+ @endifdata-export-options='{"fileName": "{{ $export_filename }}","ignoreColumn": ["actions","available_actions", "image","change","checkbox","checkincheckout","icon"]diff --git a/resources/views/groups/index.blade.php b/resources/views/groups/index.blade.phpindex 94abe90933..461330cb23 100755--- a/resources/views/groups/index.blade.php+++ b/resources/views/groups/index.blade.php@@ -11,6 +11,7 @@{{-- Page content --}}@section('content')+ HI<x-container><x-box name="groups" sr_only_title>diff --git a/resources/views/hardware/bulk-checkout.blade.php b/resources/views/hardware/bulk-checkout.blade.phpindex c76c75214a..87bb1722fc 100644--- a/resources/views/hardware/bulk-checkout.blade.php+++ b/resources/views/hardware/bulk-checkout.blade.php@@ -116,4 +116,14 @@</x-container>@stop-+<script>+ document.addEventListener('keydown', e => {+ console.log({+ key: e.key,+ code: e.code,+ keyCode: e.keyCode,+ target: e.target,+ time: performance.now()+ });+ }, true);+</script>diff --git a/resources/views/partials/bootstrap-table.blade.php b/resources/views/partials/bootstrap-table.blade.phpindex c7e06a1ca4..924d807e8e 100644--- a/resources/views/partials/bootstrap-table.blade.php+++ b/resources/views/partials/bootstrap-table.blade.php@@ -3708,6 +3708,31 @@}}+ function companyWebhookActionsFormatter(value, row) {+ return '<a href="{{ config('app.url') }}/companies/' + row.id + '/edit" ' ++ 'class="btn btn-sm btn-warning" ' ++ 'title="Edit">' ++ '<i class="fas fa-pencil" aria-hidden="true"></i>' ++ '<span class="sr-only">{{ trans('general.edit') }}</span>' ++ '</a>';+ }+ function companyWebhookIntegrationFormatter(value) {+ switch (value) {+ case 'slack':+ return '<i class="fa-brands fa-slack fa-lg" title="Slack"></i>';++ case 'google':+ return '<i class="fa-brands fa-google fa-lg" title="Google Chat"></i>';++ case 'microsoft':+ return '<i class="fa-brands fa-microsoft fa-lg" title="Microsoft Teams"></i>';++ default:+ return '<i class="fa-solid fa-webhook fa-lg" title="Webhook"></i>';+ }+ }++// Renders a single company tag. `isInherited` is decided by the caller —// it's true only when (a) we're on the companies show page (viewing context// is set), (b) the row didn't get included via direct membership, and (c)diff --git a/resources/views/settings/index.blade.php b/resources/views/settings/index.blade.phpindex 71f40beb54..9a5697113e 100755--- a/resources/views/settings/index.blade.php+++ b/resources/views/settings/index.blade.php@@ -162,7 +162,7 @@<div class="admin box box-default"><div class="box-body text-center"><h5>- <a href="{{ route('settings.slack.index') }}" class="settings_button">+ <a href="{{ route('settings.integrations.index') }}" class="settings_button"><x-icon type="hashtag" class="fa-4x"/><br><br><span class="name">{{ trans('admin/settings/general.integrations') }}</span>diff --git a/resources/views/settings/slack.blade.php b/resources/views/settings/slack.blade.phpdeleted file mode 100644index 71540674b9..0000000000--- a/resources/views/settings/slack.blade.php+++ /dev/null@@ -1,20 +0,0 @@-@extends('layouts/default')-{{-- Page title --}}-@section('title')- {{ trans('admin/settings/general.webhook_title') }}- @parent-@stop--@section('header_right')- <a href="{{ route('settings.index') }}" class="btn btn-primary"> {{ trans('general.back') }}</a>-@stop-{{-- Page content --}}-@section('content')- @livewire('slack-settings-form')-@stop------diff --git a/routes/web.php b/routes/web.phpindex 997207a6fe..897106c322 100644--- a/routes/web.php+++ b/routes/web.php@@ -321,13 +321,10 @@ Route::group(['prefix' => 'admin', 'middleware' => ['auth', 'authorize:superuserRoute::post('notifications', [SettingsController::class, 'postAlerts'])->name('settings.alerts.save');- Route::get('slack', [SettingsController::class, 'getSlack'])- ->name('settings.slack.index')+ Route::get('integrations', [SettingsController::class, 'getIntegrations'])+ ->name('settings.integrations.index')->breadcrumbs(fn (Trail $trail) => $trail->parent('settings.index')- ->push(trans('admin/settings/general.webhook_title'), route('settings.slack.index')));-- Route::post('slack', [SettingsController::class, 'postSlack'])- ->name('settings.slack.save');+ ->push(trans('admin/settings/general.webhook_title'), route('settings.integrations.index')));Route::get('adapters', [SettingsController::class, 'getAdapters'])->name('settings.adapters.index')