Skip to content

A free open source IT asset/license management system

fixed integration link, added some conditionals

Godfrey Mce02e43ab2a5
diff --git a/app/Http/Livewire/SlackSettingsForm.php b/app/Http/Livewire/SlackSettingsForm.php
index ce33f5a635..3b1894fadc 100644
--- a/app/Http/Livewire/SlackSettingsForm.php
+++ b/app/Http/Livewire/SlackSettingsForm.php
@@ -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]));
- return session()->flash('error' , trans('admin/settings/message.webhook.error_misc'));
+ } 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'));
}
}
diff --git a/app/Notifications/CheckinAssetNotification.php b/app/Notifications/CheckinAssetNotification.php
index 2154b42f4a..c6e8597dde 100644
--- a/app/Notifications/CheckinAssetNotification.php
+++ b/app/Notifications/CheckinAssetNotification.php
@@ -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"
- ]
- ,
- ["name"=> "Due date",
- "value"=> "Mon May 01 2017 17:07:18 GMT-0700 (Pacific Daylight Time)"
- ]
- ,
- ["name"=> "Status",
- "value"=> "Not started"
+ [
+ "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)"
+ ]
+ ]
+ ]
]
- ],
- "markdown"=> true
- ]]
+ ]
+ ]
);
}
diff --git a/resources/views/livewire/slack-settings-form.blade.php b/resources/views/livewire/slack-settings-form.blade.php
index 4e0296d3ce..ad3271bbc7 100644
--- a/resources/views/livewire/slack-settings-form.blade.php
+++ b/resources/views/livewire/slack-settings-form.blade.php
@@ -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