A free open source IT asset/license management system
"adds variables, but still not working"
Godfrey Me8fc895e5158
diff --git a/app/Http/Livewire/SlackSettingsForm.php b/app/Http/Livewire/SlackSettingsForm.phpindex cd34b450a8..6df4bdeea3 100644--- a/app/Http/Livewire/SlackSettingsForm.php+++ b/app/Http/Livewire/SlackSettingsForm.php@@ -12,6 +12,12 @@ class SlackSettingsForm extends Componentpublic $slack_channel;public $slack_botname;public $isDisabled ='disabled' ;+ public $integration_app= 'WORKING';+ public $webhook_link;+ public $webhook_selected;+ public $webhook_options= ['Slack'=>'fab fa-slack', 'Discord'=>'fab fa-discord', 'Rocket.Chat'=>'fab fa-rocketchat'];+ public $webhook;+ public $icon;public Setting $setting;@@ -24,6 +30,8 @@ class SlackSettingsForm extends Componentpublic function mount(){$this->setting = Setting::getSettings();+ $this->icon ='';+ $this->webhook = $this->webhook_selected;$this->slack_endpoint = $this->setting->slack_endpoint;$this->slack_channel = $this->setting->slack_channel;$this->slack_botname = $this->setting->slack_botname;@@ -31,6 +39,7 @@ class SlackSettingsForm extends Component}public function updated($field){+ $this->webhook = $this->webhook_selected;$this->validateOnly($field ,$this->rules);}diff --git a/resources/lang/en/admin/settings/general.php b/resources/lang/en/admin/settings/general.phpindex 70c4932fda..d48714d7dd 100644--- a/resources/lang/en/admin/settings/general.php+++ b/resources/lang/en/admin/settings/general.php@@ -198,16 +198,16 @@ return ['show_images_in_email' => 'Show images in emails','show_images_in_email_help' => 'Uncheck this box if your Snipe-IT installation is behind a VPN or closed network and users outside the network will not be able to load images served from this installation in their emails.','site_name' => 'Site Name',- 'slack' => 'Slack',- 'slack_title' => 'Update Slack Settings',- 'slack_help' => 'Slack settings',- 'slack_botname' => 'Slack Botname',- 'slack_channel' => 'Slack Channel',- 'slack_endpoint' => 'Slack Endpoint',- 'slack_integration' => 'Slack Settings',- 'slack_integration_help' => 'Slack integration is optional, however the endpoint and channel are required if you wish to use it. To configure Slack integration, you must first <a href=":slack_link" target="_new" rel="noopener">create an incoming webhook</a> on your Slack account. Click on the <strong>Test Slack Integration</strong> button to confirm your settings are correct before saving. ',- 'slack_integration_help_button' => 'Once you have saved your Slack information, a test button will appear.',- 'slack_test_help' => 'Test whether your Slack integration is configured correctly. YOU MUST SAVE YOUR UPDATED SLACK SETTINGS FIRST.',+ 'slack' => ':app',+ 'slack_title' => 'Update :app Settings',+ 'slack_help' => ':app settings',+ 'slack_botname' => ':app Botname',+ 'slack_channel' => ':app Channel',+ 'slack_endpoint' => ':app Endpoint',+ 'slack_integration' => ':app Settings',+ 'slack_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=":slack_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. ',+ 'slack_integration_help_button' => 'Once you have saved your :app information, a test button will appear.',+ 'slack_test_help' => 'Test whether your :app integration is configured correctly. YOU MUST SAVE YOUR UPDATED :app SETTINGS FIRST.','snipe_version' => 'Snipe-IT version','support_footer' => 'Support Footer Links ','support_footer_help' => 'Specify who sees the links to the Snipe-IT Support info and Users Manual',diff --git a/resources/views/livewire/slack-settings-form.blade.php b/resources/views/livewire/slack-settings-form.blade.phpindex 6d48220ca8..4878998ec8 100644--- a/resources/views/livewire/slack-settings-form.blade.php+++ b/resources/views/livewire/slack-settings-form.blade.php@@ -1,4 +1,32 @@+{{-- Page title --}}+@section('title')+ {{ trans('admin/settings/general.slack_title', ['app' => $integration_app ]) }}+ @parent+@stop+@section('header_right')+ <a href="{{ route('settings.index') }}" class="btn btn-primary"> {{ trans('general.back') }}</a>+@stop+++{{-- Page content --}}+@section('content')++<div class="row">+ <div class="col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2">+<div class="panel box box-default">+ <div class="box-header with-border">+ <h2 class="box-title">+ <i class="{{$icon}}"></i> {{ trans('admin/settings/general.slack',['app' => $integration_app ]) }}+ </h2>+ </div>+ <div class="box-body">+ <div class="col-md-12">+ <p>+ {!! trans('admin/settings/general.slack_integration_help',array('slack_link' => $webhook_link, 'app' => $integration_app )) !!}+ </p>+ <br>+ </div><div class="col-md-12" style="border-top: 0px;">@if (session()->has('save'))@@ -22,14 +50,32 @@{{session('message')}}</div>@endif-+ <div class="form-group col-md-12">+ <div class="col-md-3">+ <label>Integration Option</label>+ </div>+ <div class="col-md-6" >+ <select wire:model="webhook_selected"+ aria-label="webhook_selected"+ class="form-control "+ >+ <option value="">{{ trans('admin/settings/general.no_default_group') }}</option>+ @foreach ($webhook_options as $key => $webhook_option)+ <option value="{{$webhook_option}}" {{ $key ? 'selected' : '' }}>+ {{ $key }}+ </option>+ @endforeach+ </select>+ {{var_dump($webhook_selected)}}+ </div><br><br><br>+ </div><form class="form-horizontal" role="form" wire:submit.prevent="submit">{{csrf_field()}}<!--slack endpoint--><div class="form-group{{ $errors->has('slack_endpoint') ? ' error' : '' }}"><div class="col-md-2">- {{ Form::label('slack_endpoint', trans('admin/settings/general.slack_endpoint')) }}+ {{ Form::label('slack_endpoint', trans('admin/settings/general.slack_endpoint',['app' => $integration_app ])) }}</div><div class="col-md-8 required">@if (config('app.lock_passwords')===true)@@ -45,7 +91,7 @@<!-- slack channel --><div class="form-group{{ $errors->has('slack_channel') ? ' error' : '' }}"><div class="col-md-2">- {{ Form::label('slack_channel', trans('admin/settings/general.slack_channel')) }}+ {{ Form::label('slack_channel', trans('admin/settings/general.slack_channel',['app' => $integration_app ])) }}</div><div class="col-md-8 required">@if (config('app.lock_passwords')===true)@@ -62,7 +108,7 @@<!-- slack botname --><div class="form-group{{ $errors->has('slack_botname') ? ' error' : '' }}"><div class="col-md-2">- {{ Form::label('slack_botname', trans('admin/settings/general.slack_botname')) }}+ {{ Form::label('slack_botname', trans('admin/settings/general.slack_botname',['app' => $integration_app ])) }}</div><div class="col-md-8">@if (config('app.lock_passwords')===true)@@ -80,7 +126,7 @@@if($slack_endpoint != null && $slack_channel != null)<div class="form-group"><div class="col-md-offset-2 col-md-8">- <a href="#" wire:click.prevent="testSlack" class="btn btn-default btn-sm pull-left"><span>{!! trans('admin/settings/general.slack_test') !!}</span></a>+ <a href="#" wire:click.prevent="testSlack" class="btn btn-default btn-sm pull-left"><span>{!! trans('admin/settings/general.slack_test',['app' => $integration_app ]) !!}</span></a><div wire:loading><span style="padding-left: 5px; font-size: 20px"><i class="fas fa-spinner fa-spin"></i></span></div></div></div>@@ -95,5 +141,30 @@</form></div> <!-- /box -->+ </div> <!-- /.col-md-8-->+</div> <!-- /.row-->++@stop++@push('scripts')+<script>+ // function formatText (icon) {+ // return $('<span><i class="fab ' + $(icon.element).data('icon') + '"></i> ' + icon.text + '</span>');+ // };+ //+ // $('.hook_options').select2({+ // width: "50%",+ // templateSelection: formatText,+ // templateResult: formatText+ // });+ // $(document).ready(function () {+ // $('.webhook_options').select2();+ // $('.webhook_options').on('change', function (e) {+ // let data = $('#select2').select2("val");+ // @this.set('webhook_option', data);+ // });+ // });+</script>+@endpushdiff --git a/resources/views/settings/slack.blade.php b/resources/views/settings/slack.blade.phpindex a5cbd8d0b3..fac07c7ccd 100644--- a/resources/views/settings/slack.blade.php+++ b/resources/views/settings/slack.blade.php@@ -1,44 +1,18 @@@extends('layouts/default')-{{-- Page title --}}-@section('title')- {{ trans('admin/settings/general.slack_title') }}- @parent-@stop--@section('header_right')- <a href="{{ route('settings.index') }}" class="btn btn-primary"> {{ trans('general.back') }}</a>-@stop---{{-- Page content --}}-@section('content')--- <div class="row">- <div class="col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2">-- <div class="panel box box-default">- <div class="box-header with-border">- <h2 class="box-title">- <i class="fab fa-slack"></i> {{ trans('admin/settings/general.slack') }}- </h2>- </div>- <div class="box-body">- <div class="col-md-12">- <p>- {!! trans('admin/settings/general.slack_integration_help',array('slack_link' => 'https://my.slack.com/services/new/incoming-webhook')) !!}- </p>- <br>- </div>++++++@livewire('slack-settings-form')- </div> <!-- /.col-md-8-->- </div> <!-- /.row-->-@stop++