mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-10 07:34:06 -08:00
gets select working, placeholders update dynamically
This commit is contained in:
parent
354f04534e
commit
aae178a606
|
@ -13,29 +13,9 @@ class SlackSettingsForm extends Component
|
||||||
public $webhook_botname;
|
public $webhook_botname;
|
||||||
public $isDisabled ='disabled' ;
|
public $isDisabled ='disabled' ;
|
||||||
public $webhook_link;
|
public $webhook_link;
|
||||||
|
public $webhook_placeholder;
|
||||||
|
public $webhook_icon;
|
||||||
public $webhook_selected;
|
public $webhook_selected;
|
||||||
public $webhook_options = array(
|
|
||||||
array(
|
|
||||||
"name" => 'Slack',
|
|
||||||
"icon" => 'fab fa-slack',
|
|
||||||
"placeholder" => "https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXXX",
|
|
||||||
"link" => 'https://api.slack.com/messaging/webhooks'
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
"name" => 'Discord',
|
|
||||||
"icon" => 'fab fa-discord',
|
|
||||||
"placeholder" => "https://discord.com/api/webhooks/XXXXXXXXXXXXXXXXXXXXX",
|
|
||||||
"link" => 'https://support.discord.com/hc/en-us/articles/360045093012-Server-Integrations-Page'
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
"name" => 'Rocket Chat',
|
|
||||||
"icon" => 'fab fa-rocketchat',
|
|
||||||
"placeholder" => "https://discord.com/api/webhooks/XXXXXXXXXXXXXXXXXXXXX",
|
|
||||||
"link" => '',
|
|
||||||
),
|
|
||||||
);
|
|
||||||
public $keys;
|
|
||||||
public $icon;
|
|
||||||
|
|
||||||
public Setting $setting;
|
public Setting $setting;
|
||||||
|
|
||||||
|
@ -44,6 +24,23 @@ class SlackSettingsForm extends Component
|
||||||
'webhook_channel' => 'required_with:slack_endpoint|starts_with:#|nullable',
|
'webhook_channel' => 'required_with:slack_endpoint|starts_with:#|nullable',
|
||||||
'webhook_botname' => 'string|nullable',
|
'webhook_botname' => 'string|nullable',
|
||||||
];
|
];
|
||||||
|
static $webhook_text= [
|
||||||
|
"Slack" => array(
|
||||||
|
"icon" => 'fab fa-slack',
|
||||||
|
"placeholder" => "https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXXX",
|
||||||
|
"link" => 'https://api.slack.com/messaging/webhooks'
|
||||||
|
),
|
||||||
|
"Discord" => array(
|
||||||
|
"icon" => 'fab fa-discord',
|
||||||
|
"placeholder" => "https://discord.com/api/webhooks/XXXXXXXXXXXXXXXXXXXXX",
|
||||||
|
"link" => 'https://support.discord.com/hc/en-us/articles/360045093012-Server-Integrations-Page'
|
||||||
|
),
|
||||||
|
"RocketChat"=> array(
|
||||||
|
"icon" => 'fab fa-rocketchat',
|
||||||
|
"placeholder" => "https://discord.com/api/webhooks/XXXXXXXXXXXXXXXXXXXXX",
|
||||||
|
"link" => '',
|
||||||
|
),
|
||||||
|
];
|
||||||
|
|
||||||
public function mount(){
|
public function mount(){
|
||||||
|
|
||||||
|
@ -51,15 +48,21 @@ class SlackSettingsForm extends Component
|
||||||
$this->webhook_endpoint = $this->setting->webhook_endpoint;
|
$this->webhook_endpoint = $this->setting->webhook_endpoint;
|
||||||
$this->webhook_channel = $this->setting->webhook_channel;
|
$this->webhook_channel = $this->setting->webhook_channel;
|
||||||
$this->webhook_botname = $this->setting->webhook_botname;
|
$this->webhook_botname = $this->setting->webhook_botname;
|
||||||
// $this->webhook_options = $this->setting->webhook_selected;lma
|
$this->webhook_options = $this->setting->webhook_selected;
|
||||||
$this->keys = array_column($this->webhook_options, 'name');
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
public function updated($field){
|
public function updated($field){
|
||||||
$this->webhook_selected = $this->webhook_options;
|
// $this->webhook_selected = $this->webhook_options;
|
||||||
$this->validateOnly($field ,$this->rules);
|
$this->validateOnly($field ,$this->rules);
|
||||||
}
|
}
|
||||||
|
public function updatedWebhookSelected(){
|
||||||
|
|
||||||
|
$this->webhook_icon = self::$webhook_text[$this->webhook_selected]["icon"]; ;
|
||||||
|
$this->webhook_placeholder = self::$webhook_text[$this->webhook_selected]["placeholder"];
|
||||||
|
$this->webhook_link = self::$webhook_text[$this->webhook_selected]["link"];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
|
@ -109,7 +112,7 @@ class SlackSettingsForm extends Component
|
||||||
{
|
{
|
||||||
$this->validate($this->rules);
|
$this->validate($this->rules);
|
||||||
|
|
||||||
$this->setting->webhook_options = $this->webhook_options;
|
$this->setting->webhook_selected = $this->webhwebhook_selected;
|
||||||
$this->setting->webhook_endpoint = $this->webhook_endpoint;
|
$this->setting->webhook_endpoint = $this->webhook_endpoint;
|
||||||
$this->setting->webhook_channel = $this->webhook_channel;
|
$this->setting->webhook_channel = $this->webhook_channel;
|
||||||
$this->setting->webhook_botname = $this->webhook_botname;
|
$this->setting->webhook_botname = $this->webhook_botname;
|
||||||
|
|
|
@ -1,32 +1,4 @@
|
||||||
{{-- Page title --}}
|
<div>
|
||||||
@section('title')
|
|
||||||
{{ trans('admin/settings/general.webhook_title', ['app' => $webhook_selected->name ]) }}
|
|
||||||
@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.webhook',['app' => $webhook_selected->name ]) }}
|
|
||||||
</h2>
|
|
||||||
</div>
|
|
||||||
<div class="box-body">
|
|
||||||
<div class="col-md-12">
|
|
||||||
<p>
|
|
||||||
{!! trans('admin/settings/general.webhook_integration_help',array('webhook_link' => $webhook_link, 'app' => $webhook_selected )) !!}
|
|
||||||
</p>
|
|
||||||
<br>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-md-12" style="border-top: 0px;">
|
<div class="col-md-12" style="border-top: 0px;">
|
||||||
@if (session()->has('save'))
|
@if (session()->has('save'))
|
||||||
|
@ -50,23 +22,21 @@
|
||||||
{{session('message')}}
|
{{session('message')}}
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
<div class="form-group col-md-12">
|
<div class="form-group col-md-12">
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<label>Integration Option</label>
|
<label>Integration Option</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
{{-- <select wire:model="webhook_options"--}}
|
<select wire:model="webhook_selected"
|
||||||
{{-- aria-label="webhook_options"--}}
|
aria-label="webhook_selected"
|
||||||
{{-- class="form-control "--}}
|
class="form-control "
|
||||||
{{-- >--}}
|
>
|
||||||
{{-- <option>{{ trans('admin/settings/general.no_default_group') }}</option>--}}
|
<option>{{ trans('admin/settings/general.no_default_group') }}</option>
|
||||||
{{-- @foreach ($webhook_options[$keys] as $webhook_options)--}}
|
<option value="Slack">Slack</option>
|
||||||
{{-- <option value="{{$key}}" {{ $key ? 'selected' : '' }}>--}}
|
<option value="Discord">Discord</option>
|
||||||
{{-- {{ $key }}--}}
|
<option value="RocketChat">RocketChat</option>
|
||||||
{{-- </option>--}}
|
</select>
|
||||||
{{-- @endforeach--}}
|
|
||||||
|
|
||||||
{{-- </select>--}}
|
|
||||||
</div>
|
</div>
|
||||||
<br><br><br>
|
<br><br><br>
|
||||||
|
|
||||||
|
@ -84,10 +54,10 @@
|
||||||
<p class="text-warning"><i
|
<p class="text-warning"><i
|
||||||
class="fas fa-lock"></i> {{ trans('general.feature_disabled') }}</p>
|
class="fas fa-lock"></i> {{ trans('general.feature_disabled') }}</p>
|
||||||
<input type="text" wire:model="webhook_endpoint" class='form-control'
|
<input type="text" wire:model="webhook_endpoint" class='form-control'
|
||||||
placeholder="https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXXX" {{old('webhook_endpoint', $webhook_endpoint)}}>
|
placeholder={{$webhook_placeholder}} {{old('webhook_endpoint', $webhook_endpoint)}}>
|
||||||
@else
|
@else
|
||||||
<input type="text" wire:model="webhook_endpoint" class='form-control'
|
<input type="text" wire:model="webhook_endpoint" class='form-control'
|
||||||
placeholder="https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXXX" {{old('webhook_endpoint', $webhook_endpoint)}}>
|
placeholder={{$webhook_placeholder}} {{old('webhook_endpoint', $webhook_endpoint)}}>
|
||||||
@endif
|
@endif
|
||||||
{!! $errors->first('webhook_endpoint', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
|
{!! $errors->first('webhook_endpoint', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
|
||||||
</div>
|
</div>
|
||||||
|
@ -160,9 +130,7 @@
|
||||||
|
|
||||||
</div> <!-- /box -->
|
</div> <!-- /box -->
|
||||||
</div> <!-- /.col-md-8-->
|
</div> <!-- /.col-md-8-->
|
||||||
</div> <!-- /.row-->
|
|
||||||
|
|
||||||
@stop
|
|
||||||
|
|
||||||
@push('scripts')
|
@push('scripts')
|
||||||
<script>
|
<script>
|
||||||
|
|
|
@ -1,18 +1,44 @@
|
||||||
@extends('layouts/default')
|
@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')
|
@livewire('slack-settings-form')
|
||||||
|
|
||||||
|
</div> <!-- /.col-md-8-->
|
||||||
|
</div> <!-- /.row-->
|
||||||
|
|
||||||
|
|
||||||
|
@stop
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue