mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-12 14:27:33 -08:00
fixed integration link, added some conditionals
This commit is contained in:
parent
9f2af40ef2
commit
ce02e43ab2
|
@ -46,23 +46,24 @@ class SlackSettingsForm extends Component
|
|||
"general"=> array(
|
||||
"name" => trans('admin/settings/general.general_webhook'),
|
||||
"icon" => "fab fa-hashtag",
|
||||
"placeholder" => "",
|
||||
"placeholder" => "Insert URL",
|
||||
"link" => "",
|
||||
),
|
||||
"microsoft" => array(
|
||||
"name" => trans('admin/settings/general.ms_teams'),
|
||||
"icon" => "fa-brands fa-microsoft",
|
||||
"placeholder" => "https://abcd.webhook.office.com/webhookb2/XXXXXXX",
|
||||
"link" => "",
|
||||
"link" => "https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook?tabs=dotnet#create-incoming-webhooks-1",
|
||||
),
|
||||
];
|
||||
|
||||
$this->setting = Setting::getSettings();
|
||||
$this->save_button = trans('general.save');
|
||||
$this->webhook_selected = $this->setting->webhook_selected;
|
||||
$this->webhook_placeholder = $this->webhook_text[$this->setting->webhook_selected]["placeholder"];
|
||||
$this->webhook_name = $this->webhook_text[$this->setting->webhook_selected]["name"];
|
||||
$this->webhook_icon = $this->webhook_text[$this->setting->webhook_selected]["icon"];
|
||||
$this->webhook_placeholder = $this->webhook_text[$this->setting->webhook_selected]["placeholder"];
|
||||
$this->webhook_link = $this->webhook_text[$this->setting->webhook_selected]["link"];
|
||||
$this->webhook_endpoint = $this->setting->webhook_endpoint;
|
||||
$this->webhook_channel = $this->setting->webhook_channel;
|
||||
$this->webhook_botname = $this->setting->webhook_botname;
|
||||
|
@ -90,6 +91,7 @@ class SlackSettingsForm extends Component
|
|||
$this->isDisabled= '';
|
||||
$this->save_button = trans('general.save');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function isButtonDisabled() {
|
||||
|
@ -182,44 +184,40 @@ class SlackSettingsForm extends Component
|
|||
$this->setting->save();
|
||||
|
||||
session()->flash('success',trans('admin/settings/message.update.success'));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public function msTeamTestWebhook(){
|
||||
|
||||
$payload =
|
||||
[
|
||||
"@type" => "MessageCard",
|
||||
"@context" => "http://schema.org/extensions",
|
||||
"summary" => "Announcement Summary",
|
||||
"title" => "Snipe-IT Integration Test",
|
||||
'text' => trans('general.webhook_test_msg', ['app' => $this->webhook_name]),
|
||||
];
|
||||
$payload =
|
||||
[
|
||||
"@type" => "MessageCard",
|
||||
"@context" => "http://schema.org/extensions",
|
||||
"summary" => "Snipe-IT Integration Test Summary",
|
||||
"title" => "Snipe-IT Integration Test",
|
||||
"text" => trans('general.webhook_test_msg', ['app' => $this->webhook_name]),
|
||||
];
|
||||
|
||||
try {
|
||||
$response = Http::withHeaders([
|
||||
'content-type' => 'applications/json',
|
||||
])->post($this->webhook_endpoint,
|
||||
$payload)->throw();
|
||||
$response = Http::withHeaders([
|
||||
'content-type' => 'applications/json',
|
||||
])->post($this->webhook_endpoint,
|
||||
$payload)->throw();
|
||||
|
||||
|
||||
if(($response->getStatusCode() == 302)||($response->getStatusCode() == 301)){
|
||||
return session()->flash('error' , trans('admin/settings/message.webhook.error_redirect', ['endpoint' => $this->webhook_endpoint]));
|
||||
}
|
||||
$this->isDisabled='';
|
||||
$this->save_button = trans('general.save');
|
||||
return session()->flash('success' , trans('admin/settings/message.webhook.success', ['webhook_name' => $this->webhook_name]));
|
||||
|
||||
} catch (\Exception $e) {
|
||||
|
||||
$this->isDisabled='disabled';
|
||||
$this->save_button = trans('admin/settings/general.webhook_presave');
|
||||
return session()->flash('error' , trans('admin/settings/message.webhook.error', ['error_message' => $e->getMessage(), 'app' => $this->webhook_name]));
|
||||
if(($response->getStatusCode() == 302)||($response->getStatusCode() == 301)){
|
||||
return session()->flash('error' , trans('admin/settings/message.webhook.error_redirect', ['endpoint' => $this->webhook_endpoint]));
|
||||
}
|
||||
$this->isDisabled='';
|
||||
$this->save_button = trans('general.save');
|
||||
return session()->flash('success' , trans('admin/settings/message.webhook.success', ['webhook_name' => $this->webhook_name]));
|
||||
|
||||
} catch (\Exception $e) {
|
||||
|
||||
$this->isDisabled='disabled';
|
||||
$this->save_button = trans('admin/settings/general.webhook_presave');
|
||||
return session()->flash('error' , trans('admin/settings/message.webhook.error', ['error_message' => $e->getMessage(), 'app' => $this->webhook_name]));
|
||||
}
|
||||
|
||||
return session()->flash('error' , trans('admin/settings/message.webhook.error_misc'));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,30 +97,26 @@ class CheckinAssetNotification extends Notification
|
|||
];
|
||||
|
||||
$payload = json_encode(
|
||||
[
|
||||
"@type"=> "MessageCard",
|
||||
"@context"=> "http://schema.org/extensions",
|
||||
"themeColor"=> "0076D7",
|
||||
"summary"=> trans('mail.Asset_Checkin_Notification'),
|
||||
"sections"=> [
|
||||
"activityTitle"=> "Larry Bryant created a new task",
|
||||
"activitySubtitle"=> "On Project Tango",
|
||||
"activityImage"=> "https://adaptivecards.io/content/cats/3.png",
|
||||
"facts"=> [
|
||||
["name"=> "Assigned to",
|
||||
"value"=> "Unassigned"
|
||||
[
|
||||
"type" => "message",
|
||||
"attachments" => [
|
||||
[
|
||||
"contentType" => "application/vnd.microsoft.card.adaptive",
|
||||
"contentUrl" => null,
|
||||
"content" => [
|
||||
"schema" => "http://adaptivecards.io/schemas/adaptive-card.json",
|
||||
"type" => "AdaptiveCard",
|
||||
"version" => "1.2",
|
||||
"body" => [
|
||||
[
|
||||
"type" => "TextBlock",
|
||||
"text" => "For Samples and Templates, see [https://adaptivecards.io/samples](https://adaptivecards.io/samples)"
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
,
|
||||
["name"=> "Due date",
|
||||
"value"=> "Mon May 01 2017 17:07:18 GMT-0700 (Pacific Daylight Time)"
|
||||
]
|
||||
,
|
||||
["name"=> "Status",
|
||||
"value"=> "Not started"
|
||||
]
|
||||
],
|
||||
"markdown"=> true
|
||||
]]
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
}
|
||||
|
|
|
@ -106,16 +106,17 @@
|
|||
@endif
|
||||
|
||||
<!-- Webhook botname -->
|
||||
<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 ])) }}
|
||||
@if($webhook_selected != 'microsoft')
|
||||
<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>
|
||||
<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
|
||||
|
|
Loading…
Reference in a new issue