This commit is contained in:
2024-04-19 10:27:36 +02:00
parent fcb6bbe566
commit 35c96e715c
7852 changed files with 4815 additions and 8 deletions

View File

@ -0,0 +1,61 @@
<div>
<!-- EULA text -->
<div class="form-group {{ $errors->has('eula_text') ? 'error' : '' }}">
<label for="eula_text" class="col-md-3 control-label">{{ trans('admin/categories/general.eula_text') }}</label>
<div class="col-md-7">
{{ Form::textarea('eula_text', null, ['wire:model' => 'eulaText', 'class' => 'form-control', 'aria-label'=>'eula_text', 'disabled' => $this->eulaTextDisabled]) }}
<p class="help-block">{!! trans('admin/categories/general.eula_text_help') !!} </p>
<p class="help-block">{!! trans('admin/settings/general.eula_markdown') !!} </p>
{!! $errors->first('eula_text', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
</div>
@if ($this->eulaTextDisabled)
<input type="hidden" name="eula_text" wire:model="eulaText" />
@endif
</div>
<!-- Use default checkbox -->
<div class="form-group">
<div class="col-md-9 col-md-offset-3">
@if ($defaultEulaText!='')
<label class="form-control">
{{ Form::checkbox('use_default_eula', '1', null, ['wire:model' => 'useDefaultEula', 'aria-label'=>'use_default_eula']) }}
<span>{!! trans('admin/categories/general.use_default_eula') !!}</span>
</label>
@else
<label class="form-control form-control--disabled">
{{ Form::checkbox('use_default_eula', '0', null, ['wire:model' => 'useDefaultEula', 'class'=>'disabled','disabled' => 'disabled', 'aria-label'=>'use_default_eula']) }}
<span>{!! trans('admin/categories/general.use_default_eula_disabled') !!}</span>
</label>
@endif
</div>
</div>
<!-- Require Acceptance -->
<div class="form-group">
<div class="col-md-9 col-md-offset-3">
<label class="form-control">
{{ Form::checkbox('require_acceptance', '1', null, ['wire:model' => 'requireAcceptance', 'aria-label'=>'require_acceptance']) }}
{{ trans('admin/categories/general.require_acceptance') }}
</label>
</div>
</div>
<!-- Email on Checkin -->
<div class="form-group">
<div class="col-md-9 col-md-offset-3">
<label class="form-control">
{{ Form::checkbox('checkin_email', '1', null, ['wire:model' => 'sendCheckInEmail', 'aria-label'=>'checkin_email', 'disabled' => $this->sendCheckInEmailDisabled]) }}
{{ trans('admin/categories/general.checkin_email') }}
</label>
@if ($this->shouldDisplayEmailMessage)
<div class="callout callout-info">
<i class="far fa-envelope"></i>
<span>{{ $this->emailMessage }}</span>
</div>
@endif
@if ($this->sendCheckInEmailDisabled)
<input type="hidden" name="checkin_email" wire:model="sendCheckInEmail" />
@endif
</div>
</div>
</div>

View File

@ -0,0 +1,91 @@
<span>
<div class="form-group{{ $errors->has('custom_fieldset') ? ' has-error' : '' }}">
<label for="custom_fieldset" class="col-md-3 control-label">
{{ trans('admin/models/general.fieldset') }}
</label>
<div class="col-md-5">
{{ Form::select('fieldset_id', Helper::customFieldsetList(), old('fieldset_id', $fieldset_id), array('class'=>'select2 js-fieldset-field livewire-select2', 'style'=>'width:100%; min-width:350px', 'aria-label'=>'custom_fieldset', 'data-livewire-component' => $_instance->id)) }}
{!! $errors->first('custom_fieldset', '<span class="alert-msg" aria-hidden="true"><br><i class="fas fa-times"></i> :message</span>') !!}
</div>
<div class="col-md-3">
<label class="form-control">
{{ Form::checkbox('add_default_values', 1, old('add_default_values', $add_default_values), ['data-livewire-component' => $_instance->id, 'id' => 'add_default_values', 'wire:model' => 'add_default_values']) }}
{{ trans('admin/models/general.add_default_values') }}
</label>
</div>
</div>
@if ($this->add_default_values ) {{-- 'if the checkbox is enabled *AND* there are more than 0 fields in the fieldsset' --}}
@if ($fields)
@foreach ($fields as $field)
<div class="form-group">
<label class="col-md-3 control-label{{ $errors->has($field->name) ? ' has-error' : '' }}">{{ $field->name }}</label>
<div class="col-md-7">
@if ($field->format == "DATE")
<div class="input-group col-md-4" style="padding-left: 0px;">
<div class="input-group date" data-provide="datepicker" data-date-format="yyyy-mm-dd" data-autoclose="true">
<input type="text" class="form-control" placeholder="{{ trans('general.select_date') }}" name="default_values[{{ $field->id }}]" id="default-value{{ $field->id }}" value="{{ $field->defaultValue($model_id) }}">
<span class="input-group-addon"><i class="fas fa-calendar" aria-hidden="true"></i></span>
</div>
</div>
@elseif ($field->element == "text")
<input class="form-control" type="text" value="{{ $field->defaultValue($model_id) }}" id="default-value{{ $field->id }}" name="default_values[{{ $field->id }}]">
@elseif($field->element == "textarea")
<textarea class="form-control" style="width: 100%;" id="default-value{{ $field->id }}" name="default_values[{{ $field->id }}]">{{ $field->defaultValue($model_id) }}</textarea>
@elseif($field->element == "listbox")
<select class="form-control" name="default_values[{{ $field->id }}]">
<option value=""></option>
@foreach(explode("\r\n", $field->field_values) as $field_value)
<option value="{{$field_value}}" {{ $field->defaultValue($model_id) == $field_value ? 'selected="selected"': '' }}>{{ $field_value }}</option>
@endforeach
</select>
@elseif($field->element == "radio")
@foreach(explode("\r\n", $field->field_values) as $field_value)
<label class="col-md-3 form-control" for="{{ str_slug($field_value) }}">
<input id="{{ str_slug($field_value) }}" aria-label="{{ str_slug($field->name) }}" type='radio' name="default_values[{{ $field->id }}]" value="{{$field_value}}" {{ $field->defaultValue($model_id) == $field_value ? 'checked="checked"': '' }} />{{ $field_value }}
</label>
@endforeach
@elseif($field->element == "checkbox")
@foreach(explode("\r\n", $field->field_values) as $field_value)
<label class="col-md-3 form-control" for="{{ str_slug($field_value) }}">
<input id="{{ str_slug($field_value) }}" type="checkbox" aria-label="{{ str_slug($field->name) }}" name="default_values[{{ $field->id }}][]" value="{{ $field_value }}"{{ in_array($field_value, explode(', ',$field->defaultValue($model_id))) ? ' checked="checked"': '' }}> {{ $field_value }}
</label>
@endforeach
@else
<span class="help-block form-error">
Unknown field element: {{ $field->element }}
</span>
@endif
</div>
</div>
@endforeach
</div>
@endif
@endif
</span>

View File

@ -0,0 +1,402 @@
@section('title')
{{ trans('general.import') }}
@parent
@stop
<div>
{{-- Livewire requires a 'master' <div>, above --}}
<div class="row">
{{-- alert --}}
@if($message != '')
<div class="col-md-12" class="{{ $message_type }}">
<div class="alert alert-{{ $this->message_type }}">
<button type="button" class="close" wire:click="$set('message','')">&times;</button>
@if($message_type == 'success')
<i class="fas fa-check faa-pulse animated" aria-hidden="true"></i>
@endif
<strong>{{-- title --}} </strong>
{{ $message }}
</div>
</div>
@endif
@if($import_errors)
<div class="col-md-12">
<div class="box">
<div class="box-body">
<div class="alert alert-warning">
<i class="fa fa-warning info" aria-hidden="true"></i> <strong>{{ trans('general.warning', ['warning'=> trans('general.errors_importing')]) }}</strong>
</div>
<div class="errors-table">
<table class="table table-striped table-bordered" id="errors-table">
<thead>
<th>{{ trans('general.item') }}</th>
<th>{{ trans('general.error') }}</th>
</thead>
<tbody>
@php \Log::debug("import errors are: ".print_r($import_errors,true)); @endphp
@foreach($import_errors AS $key => $actual_import_errors)
@php \Log::debug("Key is: $key"); @endphp
@foreach($actual_import_errors AS $table => $error_bag)
@php \Log::debug("Table is: $table"); @endphp
@foreach($error_bag as $field => $error_list)
@php \Log::debug("Field is: $field"); @endphp
<tr>
<td>{{ $activeFile->file_path ?? "Unknown File" }}</td>
<td>
<b>{{ $field }}:</b>
<span>{{ implode(", ",$error_list) }}</span>
<br />
</td>
</tr>
@endforeach
@endforeach
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
@endif
<div class="col-md-9">
<div class="box">
<div class="box-body">
<div class="row">
<div class="col-md-12">
@if($progress != -1)
<div class="col-md-10 col-sm-5 col-xs-12" style="height: 35px;" id='progress-container'>
<div class="progress progress-striped-active" style="height: 100%;">
<div id='progress-bar' class="progress-bar {{ $progress_bar_class }}" role="progressbar" style="width: {{ $progress }}%">
<h4 id="progress-text">{!! $progress_message !!}</h4>
</div>
</div>
</div>
@endif
<div class="col-md-2 col-sm-5 col-xs-12 text-right pull-right">
<!-- The fileinput-button span is used to style the file input field as button -->
@if (!config('app.lock_passwords'))
<span class="btn btn-primary fileinput-button">
<span>{{ trans('button.select_file') }}</span>
<!-- The file input field used as target for the file upload widget -->
<label for="files[]"><span class="sr-only">{{ trans('admin/importer/general.select_file') }}</span></label>
<input id="fileupload" type="file" name="files[]" data-url="{{ route('api.imports.index') }}" accept="text/csv" aria-label="files[]">
</span>
@endif
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 table-responsive" style="padding-top: 30px;">
<table data-pagination="true"
data-id-table="upload-table"
data-search="true"
data-side-pagination="client"
id="upload-table"
class="col-md-12 table table-striped snipe-table">
<tr>
<th class="col-md-6">
{{ trans('general.file_name') }}
</th>
<th class="col-md-3">
{{ trans('general.created_at') }}
</th>
<th class="col-md-1">
{{ trans('general.filesize') }}
</th>
<th class="col-md-1 text-right">
<span class="sr-only">{{ trans('general.actions') }}</span>
</th>
</tr>
@foreach($files as $currentFile)
<tr style="{{ ($activeFile && ($currentFile->id == $activeFile->id)) ? 'font-weight: bold' : '' }}" class="{{ ($activeFile && ($currentFile->id == $activeFile->id)) ? 'warning' : '' }}">
<td class="col-md-6">{{ $currentFile->file_path }}</td>
<td class="col-md-3">{{ Helper::getFormattedDateObject($currentFile->created_at, 'datetime', false) }}</td>
<td class="col-md-1">{{ Helper::formatFilesizeUnits($currentFile->filesize) }}</td>
<td class="col-md-1 text-right" style="white-space: nowrap;">
<button class="btn btn-sm btn-info" wire:click="selectFile({{ $currentFile->id }})" data-tooltip="true" title="{{ trans('general.import_this_file') }}">
<i class="fa-solid fa-list-check" aria-hidden="true"></i>
<span class="sr-only">{{ trans('general.import') }}</span>
</button>
<a href="#" wire:click="$set('activeFile',null)">
<button class="btn btn-sm btn-danger" wire:click="destroy({{ $currentFile->id }})">
<i class="fas fa-trash icon-white" aria-hidden="true"></i><span class="sr-only"></span></button>
</a>
</td>
</tr>
@if( $currentFile && $activeFile && ($currentFile->id == $activeFile->id))
<tr class="warning">
<td colspan="4">
<div class="form-group">
<label for="activeFile.import_type" class="col-md-3 col-xs-12">
{{ trans('general.import_type') }}
</label>
<div class="col-md-9 col-xs-12">
{{ Form::select('activeFile.import_type', $importTypes, $activeFile->import_type, [
'id' => 'import_type',
'class' => 'livewire-select2',
'style' => 'min-width: 350px',
'data-placeholder' => trans('general.select_var', ['thing' => trans('general.import_type')]),
'placeholder' => '', //needed so that the form-helper will put an empty option first
'data-minimum-results-for-search' => '-1', // Remove this if the list gets long enough that we need to search
'data-livewire-component' => $_instance->id
]) }}
@if ($activeFile->import_type === 'asset' && $snipeSettings->auto_increment_assets == 0)
<p class="help-block">
{{ trans('general.auto_incrementing_asset_tags_disabled_so_tags_required') }}
</p>
@endif
</div>
</div>
<div class="form-group col-md-9 col-md-offset-3">
<label class="form-control">
<input type="checkbox" name="update" data-livewire-component="{{ $_instance->id }}" wire:model="update">
{{ trans('general.update_existing_values') }}
</label>
@if ($activeFile->import_type === 'asset' && $snipeSettings->auto_increment_assets == 1 && $update)
<p class="help-block">
{{ trans('general.auto_incrementing_asset_tags_enabled_so_now_assets_will_be_created') }}
</p>
@endif
<label class="form-control">
<input type="checkbox" name="send_welcome" data-livewire-component="{{ $_instance->id }}" wire:model="send_welcome">
{{ trans('general.send_welcome_email_to_users') }}
</label>
<label class="form-control">
<input type="checkbox" name="run_backup" data-livewire-component="{{ $_instance->id }}" wire:model="run_backup">
{{ trans('general.back_before_importing') }}
</label>
</div>
@if($statusText)
<div class="alert col-md-8 col-md-offset-3{{ $statusType == 'success' ? ' alert-success' : ($statusType == 'error' ? ' alert-danger' : ' alert-info') }}" style="padding-top: 20px;">
{!! $statusText !!}
</div>
@endif
@if ($activeFile->import_type)
<div class="form-group col-md-12">
<hr style="border-top: 1px solid lightgray">
<h3><i class="{{ Helper::iconTypeByItem($activeFile->import_type) }}"></i> Map {{ ucwords($activeFile->import_type) }} Import Fields</h3>
<hr style="border-top: 1px solid lightgray">
</div>
<div class="form-group col-md-12">
<div class="col-md-3 text-right">
<strong>{{ trans('general.csv_header_field') }}</strong>
</div>
<div class="col-md-4">
<strong>{{ trans('general.import_field') }}</strong>
</div>
<div class="col-md-5">
<strong>{{ trans('general.sample_value') }}</strong>
</div>
</div><!-- /div row -->
@if($activeFile->header_row)
@foreach($activeFile->header_row as $index => $header)
<div class="form-group col-md-12" wire:key="header-row-{{ $index }}">
<label for="field_map.{{ $index }}" class="col-md-3 control-label text-right">{{ $header }}</label>
<div class="col-md-4">
{{ Form::select('field_map.'.$index, $columnOptions[$activeFile->import_type], @$field_map[$index],
[
'class' => 'mappings livewire-select2',
'placeholder' => trans('general.importer.do_not_import'),
'style' => 'min-width: 100%',
'data-livewire-component' => $_instance->id
],[
'-' => ['disabled' => true] // this makes the "-----" line unclickable
])
}}
</div>
@if (($activeFile->first_row) && (array_key_exists($index, $activeFile->first_row)))
<div class="col-md-5">
<p class="form-control-static">{{ str_limit($activeFile->first_row[$index], 50, '...') }}</p>
</div>
@else
@php
$statusText = trans('help.empty_file');
$statusType = 'info';
@endphp
@endif
</div><!-- /div row -->
@endforeach
@else
{{ trans('general.no_headers') }}
@endif
<div class="form-group col-md-12">
<div class="col-md-3 text-left">
<a href="#" wire:click="$set('activeFile',null)">{{ trans('general.cancel') }}</a>
</div>
<div class="col-md-9">
<button type="submit" class="btn btn-primary col-md-5" id="import">Import</button>
<br><br>
</div>
</div>
@if($statusText)
<div class="alert col-md-8 col-md-offset-3{{ $statusType == 'success' ? ' alert-success' : ($statusType == 'error' ? ' alert-danger' : ' alert-info') }}" style="padding-top: 20px;">
{!! $statusText !!}
</div>
@endif
@else
<div class="form-group col-md-10">
<div class="col-md-3 text-left">
<a href="#" wire:click="$set('activeFile',null)">{{ trans('general.cancel') }}</a>
</div>
</div>
@endif {{-- end of if ... activeFile->import_type --}}
</div><!-- /div v-show --> </td>
</tr>
@endif
</tr>
@endforeach
</table>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-3">
<h2>{{ trans('general.importing') }}</h2>
<p>{!! trans('general.importing_help') !!}</p>
</div>
</div>
</div>
@push('js')
<script>
{{-- TODO: Maybe change this to the file upload thing that's baked-in to Livewire? --}}
$('#fileupload').fileupload({
dataType: 'json',
done: function(e, data) {
@this.progress_bar_class = 'progress-bar-success';
@this.progress_message = '<i class="fas fa-check faa-pulse animated"></i> {{ trans('general.notification_success') }}';
@this.progress = 100;
},
add: function(e, data) {
data.headers = {
"X-Requested-With": 'XMLHttpRequest',
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr('content')
};
data.process().done( function () {data.submit();});
@this.progress = 0;
@this.clearMessage();
},
progress: function(e, data) {
@this.progress = parseInt((data.loaded / data.total * 100, 10));
@this.progress_message = '{{ trans('general.uploading') }}';
},
fail: function() {
@this.progress_bar_class = "progress-bar-danger";
@this.progress = 100;
@this.progress_message = '<i class="fas fa-exclamation-triangle faa-pulse animated"></i> {{ trans('general.upload_error') }}';
}
})
// For the importFile part:
$(function () {
// we have to hook up to the `<tr id='importer-file'>` at the root of this display,
// because the #import button isn't visible until you click an import_type
$('#upload-table').on('click', '#import', function () {
if(!@this.activeFile.import_type) {
@this.statusType='error';
@this.statusText= "An import type is required... "; //TODO: translate?
return;
}
@this.statusType ='pending';
@this.statusText = '<i class="fa fa-spinner fa-spin" aria-hidden="true"></i> {{ trans('admin/hardware/form.processing_spinner') }}';
@this.generate_field_map().then(function (mappings_raw) {
var mappings = JSON.parse(mappings_raw)
// console.warn("Here is the mappings:")
// console.dir(mappings)
// console.warn("Uh, active file id is, I guess: "+@this.activeFile.id)
var this_file = @this.file_id; // okay, I actually don't know what I'm doing here.
$.post({
{{-- I want to do something like: route('api.imports.importFile', $activeFile->id) }} --}}
url: "api/v1/imports/process/"+this_file, // maybe? Good a guess as any..FIXME. HARDCODED DUMB FILE
contentType: 'application/json',
data: JSON.stringify({
'import-update': !!@this.update,
'send-welcome': !!@this.send_welcome,
'import-type': @this.activeFile.import_type,
'run-backup': !!@this.run_backup,
'column-mappings': mappings
}),
headers: {
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr('content')
}
}).done( function (body) {
// Success
@this.statusType="success";
@this.statusText = "{{ trans('general.success_redirecting') }}";
// console.dir(body)
window.location.href = body.messages.redirect_url;
}).fail( function (jqXHR, textStatus, error) {
// Failure
var body = jqXHR.responseJSON
if((body) && (body.status) && body.status == 'import-errors') {
@this.emit('importError', body.messages);
@this.import_errors = body.messages
@this.statusType='error';
@this.statusText = "Error";
// If Slack/notifications hits API thresholds, we *do* 500, but we never
// actually surface that info.
//
// A 500 on notifications doesn't mean your import failed, so this is a confusing state.
//
// Ideally we'd have a message like "Your import worked, but not all
// notifications could be sent".
} else {
console.warn("Not import-errors, just regular errors - maybe API limits")
@this.message_type="warning"
if ((body) && (error in body)) {
@this.message = body.error ? body.error:"Unknown error - might just be throttling by notifications."
} else {
@this.message = "{{ trans('general.importer_generic_error') }}"
}
}
@this.activeFile = null; //@this.set('hideDetails')
});
})
return false;
});})
</script>
@endpush

View File

@ -0,0 +1,106 @@
<div>
<form role="form" method="POST" action="{{ route('login') }}" autocomplete="false" wire:submit.prevent="submitForm">
<input type="hidden" name="_token" value="{{ csrf_token() }}" />
<!-- this is a hack to prevent Chrome from trying to autocomplete fields -->
<input type="text" name="prevent_autofill" id="prevent_autofill" value="" style="display:none;" aria-hidden="true">
<input type="password" name="password_fake" id="password_fake" value="" style="display:none;" aria-hidden="true">
<div class="container">
<div class="row">
<div class="col-md-4 col-md-offset-4">
<div class="box login-box">
<div class="box-header with-border">
<h1 class="box-title"> {{ trans('auth/general.login_prompt') }}</h1>
</div>
<div class="login-box-body">
<div class="row">
@if ($snipeSettings->login_note)
<div class="col-md-12">
<div class="alert alert-info">
{!! Parsedown::instance()->text(e($snipeSettings->login_note)) !!}
</div>
</div>
@endif
<!-- Notifications -->
@include('notifications')
<div class="col-md-12">
<!-- CSRF Token -->
<fieldset>
<div class="form-group{{ $errors->has('username') ? ' has-error' : '' }}">
<label for="username">
<i class="fas fa-user" aria-hidden="true"></i>
{{ trans('admin/users/table.username') }}
</label>
<input class="form-control" placeholder="{{ trans('admin/users/table.username') }}" name="username" type="text" autocomplete="off" wire:model="username">
@error('username')
<span class="alert-msg">
{{ $message }}
</span>
@enderror
</div>
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
<label for="password">
<i class="fas fa-key" aria-hidden="true"></i>
{{ trans('admin/users/table.password') }}
</label>
<input class="form-control" placeholder="{{ trans('admin/users/table.password') }}" name="password" type="password" wire:model="password" autocomplete="off">
@error('password')
<span class="alert-msg">
{{ $message }}
</span>
@enderror
</div>
<div class="form-group">
<div class="checkbox">
<label class="form-control">
<input name="remember" type="checkbox" value="1">
{{ trans('auth/general.remember_me') }}
</label>
</div>
</div>
</fieldset>
</div> <!-- end col-md-12 -->
</div> <!-- end row -->
@if ($snipeSettings->saml_enabled)
<div class="row">
<div class="text-right col-md-12">
<a href="{{ route('saml.login') }}">{{ trans('auth/general.saml_login') }}</a>
</div>
</div>
@endif
</div>
<div class="box-footer">
<button class="btn btn-lg btn-primary btn-block" type="submit"{{ $can_submit ? '' : ' disabled' }}>
<i wire:loading wire:target='submitForm' class="fas fa-spin fa-spinner"></i> {{ trans('auth/general.login') }}</button>
</div>
<div class="text-right col-md-12 col-sm-12 col-xs-12" style="padding-top: 10px;">
@if ($snipeSettings->custom_forgot_pass_url)
<a href="{{ $snipeSettings->custom_forgot_pass_url }}" rel="noopener">{{ trans('auth/general.forgot_password') }}</a>
@else
<a href="{{ route('password.request') }}">{{ trans('auth/general.forgot_password') }}</a>
@endif
</div>
</div> <!-- end login box -->
</div> <!-- col-md-4 -->
</div> <!-- end row -->
</div> <!-- end container -->
</form>
</div>

View File

@ -0,0 +1,189 @@
{{-- 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')
<div><!-- livewire div - do not remove -->
<form class="form-horizontal" role="form" wire:submit.prevent="submit">
{{csrf_field()}}
<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="{{$webhook_icon}}"></i> {{ trans('admin/settings/general.webhook', ['app' => $webhook_name] ) }}
</h2>
</div>
<div class="box-body">
@if($webhook_selected != 'general')
<div class="col-md-12">
<p>
{!! trans('admin/settings/general.webhook_integration_help',array('webhook_link' => $webhook_link, 'app' => $webhook_name)) !!}
</p>
<br>
</div>
@endif
<div class="col-md-12" style="border-top: 0px;">
@if(session()->has('success'))
<div class="alert alert-success fade in">
{{session('success')}}
</div>
@endif
@if(session()->has('error'))
<div class="alert alert-danger fade in">
{{session('error')}}
</div>
@endif
<div class="form-group">
<div class="col-md-2">
<label for="webhook_selected">
{{ trans('general.integration_option') }}
</label>
</div>
<div class="col-md-9 required" wire:ignore>
@if (Helper::isDemoMode())
{{ Form::select('webhook_selected', array('slack' => trans('admin/settings/general.slack'), 'general' => trans('admin/settings/general.general_webhook'),'google' => trans('admin/settings/general.google_workspaces'), 'microsoft' => trans('admin/settings/general.ms_teams')), old('webhook_selected', $webhook_selected), array('class'=>'select2 form-control', 'aria-label' => 'webhook_selected', 'id' => 'select2', 'style'=>'width:100%', 'disabled')) }}
@else
{{ Form::select('webhook_selected', array('slack' => trans('admin/settings/general.slack'), 'general' => trans('admin/settings/general.general_webhook'),'google' => trans('admin/settings/general.google_workspaces'), 'microsoft' => trans('admin/settings/general.ms_teams')), old('webhook_selected', $webhook_selected), array('class'=>'select2 form-control', 'aria-label' => 'webhook_selected', 'id' => 'select2', 'data-minimum-results-for-search' => '-1', 'style'=>'width:100%')) }}
@endif
</div>
</div>
@if (Helper::isDemoMode())
@include('partials.forms.demo-mode')
@endif
<!--Webhook endpoint-->
<div class="form-group{{ $errors->has('webhook_endpoint') ? ' error' : '' }}">
<div class="col-md-2">
{{ Form::label('webhook_endpoint', trans('admin/settings/general.webhook_endpoint',['app' => $webhook_name ])) }}
</div>
<div class="col-md-9 required">
<input type="text" wire:model.lazy="webhook_endpoint" class="form-control" placeholder="{{$webhook_placeholder}}" value="{{old('webhook_endpoint', $webhook_endpoint)}}"{{ Helper::isDemoMode() ? ' disabled' : ''}}>
{!! $errors->first('webhook_endpoint', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
</div>
</div>
@if (Helper::isDemoMode())
@include('partials.forms.demo-mode')
@endif
<!-- Webhook channel -->
@if($webhook_selected != 'microsoft' && $webhook_selected!= 'google')
<div class="form-group{{ $errors->has('webhook_channel') ? ' error' : '' }}">
<div class="col-md-2">
{{ Form::label('webhook_channel', trans('admin/settings/general.webhook_channel',['app' => $webhook_name ])) }}
</div>
<div class="col-md-9 required">
<input type="text" wire:model.lazy="webhook_channel" class="form-control" placeholder="#IT-Ops" value="{{ old('webhook_channel', $webhook_channel) }}"{{ Helper::isDemoMode() ? ' disabled' : ''}}>
{!! $errors->first('webhook_channel', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
</div>
</div>
@endif
@if (Helper::isDemoMode())
@include('partials.forms.demo-mode')
@endif
<!-- Webhook botname -->
@if($webhook_selected != 'microsoft' && $webhook_selected != 'google')
<div class="form-group{{ $errors->has('webhook_botname') ? ' error' : '' }}">
<div class="col-md-2">
{{ Form::label('webhook_botname', trans('admin/settings/general.webhook_botname',['app' => $webhook_name ])) }}
</div>
<div class="col-md-9">
<input type="text" wire:model.lazy="webhook_botname" class='form-control' placeholder="Snipe-Bot" {{ old('webhook_botname', $webhook_botname)}}{{ Helper::isDemoMode() ? ' disabled' : ''}}>
{!! $errors->first('webhook_botname', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
</div><!--col-md-10-->
</div>
@endif
@if (!Helper::isDemoMode())
@include('partials.forms.demo-mode')
@endif
<!--Webhook Integration Test-->
@if($webhook_endpoint != null && $webhook_channel != null)
<div class="form-group">
<div class="col-md-offset-2 col-md-9">
<a href="#" wire:click.prevent="{{$webhook_test}}"
class="btn btn-default btn-sm pull-left">
<i class="{{$webhook_icon}}" aria-hidden="true"></i>
{!! trans('admin/settings/general.webhook_test',['app' => ucwords($webhook_selected) ]) !!}
</a>
<div wire:loading>
<span style="padding-left: 5px; font-size: 20px">
<i class="fas fa-spinner fa-spin" aria-hidden="true"></i>
</span>
</div>
</div>
</div>
@endif
</div><!-- /.col-md-12 -->
</div><!-- /.box-body -->
<div class="box-footer">
<div class="text-right col-md-12">
<button type="reset" wire:click.prevent="clearSettings" class="col-md-2 text-left btn btn-danger pull-left"{{ Helper::isDemoMode() ? ' disabled' : ''}}>{{ trans('general.clear_and_save') }}</button>
<a class="btn btn-link pull-left" href="{{ route('settings.index') }}">{{ trans('button.cancel') }}</a>
<button type="submit" {{$isDisabled}} class="btn btn-primary"{{ Helper::isDemoMode() ? ' disabled' : ''}}>
<i class="fas fa-check icon-white" aria-hidden="true"></i> {{ $save_button }}</button>
</div> <!-- /.col-md-12 -->
</div><!--box-footer-->
</div> <!-- /.box -->
</div> <!-- /.col-md-8-->
</div> <!-- /.row -->
</form>
</div> <!-- /livewire div -->
@section('moar_scripts')
<script>
$(document).ready(function () {
$('#select2').select2();
$('#select2').on('change', function (e) {
var data = $('#select2').select2("val");
@this.set('webhook_selected', data);
});
// Re-render select2
window.livewire.hook('message.processed', function (el, component) {
$('.select2').select2();
});
});
</script>
@endsection