add translations, brush up code

This commit is contained in:
Godfrey M 2024-01-24 10:38:06 -08:00
parent 49021d277c
commit 00f07ac2ce
10 changed files with 60 additions and 55 deletions

View file

@ -46,7 +46,7 @@ class SlackSettingsForm extends Component
"general"=> array(
"name" => trans('admin/settings/general.general_webhook'),
"icon" => "fab fa-hashtag",
"placeholder" => "Insert URL",
"placeholder" => trans('general.url'),
"link" => "",
),
"microsoft" => array(
@ -193,8 +193,8 @@ class SlackSettingsForm extends Component
[
"@type" => "MessageCard",
"@context" => "http://schema.org/extensions",
"summary" => "Snipe-IT Integration Test Summary",
"title" => "Snipe-IT Integration Test",
"summary" => trans('mail.snipe_webhook_summary'),
"title" => trans('mail.snipe_webhook_test'),
"text" => trans('general.webhook_test_msg', ['app' => $this->webhook_name]),
];

View file

@ -37,11 +37,12 @@ class CheckinAccessoryNotification extends Notification
*/
public function via()
{
$notifyBy = [];
if (Setting::getSettings()->webhook_selected == 'microsoft'){
return [MicrosoftTeamsChannel::class];
}
$notifyBy = [];
$notifyBy[] = MicrosoftTeamsChannel::class;
}
if (Setting::getSettings()->webhook_endpoint != '') {
$notifyBy[] = 'slack';
@ -123,13 +124,13 @@ class CheckinAccessoryNotification extends Notification
->to($this->settings->webhook_endpoint)
->type('success')
->addStartGroupToSection('activityTitle')
->title("Accessory Checked In")
->title(trans('Accessory_Checkin_Notification'))
->addStartGroupToSection('activityText')
->fact(htmlspecialchars_decode($item->present()->name), '', 'activityTitle')
->fact('Checked into ', $item->location->name ? $item->location->name : '')
->fact(trans('mail.checked_into'), $item->location->name ? $item->location->name : '')
->fact(trans('mail.Accessory_Checkin_Notification')." by ", $admin->present()->fullName())
->fact('Number Remaining', $item->numRemaining())
->fact('Notes', $note ?: 'No notes');
->fact(trans('admin/consumables/general.remaining'), $item->numRemaining())
->fact(trans('mail.notes'), $note ?: 'No notes');
}
/**

View file

@ -45,11 +45,12 @@ class CheckinAssetNotification extends Notification
*/
public function via()
{
$notifyBy = [];
if (Setting::getSettings()->webhook_selected == 'microsoft'){
return [MicrosoftTeamsChannel::class];
$notifyBy[] = MicrosoftTeamsChannel::class;
}
$notifyBy = [];
if (Setting::getSettings()->webhook_endpoint != '') {
\Log::debug('use webhook');
$notifyBy[] = 'slack';
@ -99,13 +100,13 @@ class CheckinAssetNotification extends Notification
return MicrosoftTeamsMessage::create()
->to($this->settings->webhook_endpoint)
->type('success')
->title("Asset Checked in")
->title(trans('mail.Asset_Checkin_Notification'))
->addStartGroupToSection('activityText')
->fact(htmlspecialchars_decode($item->present()->name), '', 'activityText')
->fact('Checked into ', $item->location->name ? $item->location->name : $item->defaultLoc()->name)
->fact(trans('mail.checked_into'), $item->location->name ? $item->location->name : '')
->fact(trans('mail.Asset_Checkin_Notification')." by ", $admin->present()->fullName())
->fact('Asset Status', $item->assetstatus->name)
->fact('Notes', $note ?: 'No notes');
->fact(trans('admin/hardware/form.status'), $item->assetstatus->name)
->fact(trans('mail.notes'), $note ?: trans('mail.no_notes'));
}
/**

View file

@ -105,13 +105,13 @@ class CheckinLicenseSeatNotification extends Notification
->to($this->settings->webhook_endpoint)
->type('success')
->addStartGroupToSection('activityTitle')
->title("License Checked in")
->title(trans('mail.License_Checkin_Notification'))
->addStartGroupToSection('activityText')
->fact(htmlspecialchars_decode($item->present()->name), '', 'header')
->fact(trans('mail.License_Checkin_Notification')." by ", $admin->present()->fullName() ?: 'ClI tool')
->fact('Checked in from', $target->present()->fullName())
->fact('Seats Remaining', $item->availCount()->count())
->fact('Notes', $note ?: 'No notes');
->fact(trans('mail.checkedin_from'), $target->present()->fullName())
->fact(trans('admin/consumables/general.remaining'), $item->availCount()->count())
->fact(trans('mail.notes'), $note ?: trans('mail.no_notes'));
}
/**

View file

@ -40,7 +40,6 @@ class CheckoutAccessoryNotification extends Notification
if (Setting::getSettings()->webhook_selected == 'microsoft'){
// return [MicrosoftTeamsChannel::class];
$notifyBy[] = MicrosoftTeamsChannel::class;
}
@ -105,21 +104,24 @@ class CheckoutAccessoryNotification extends Notification
}
public function toMicrosoftTeams()
{
$target = $this->target;
$admin = $this->admin;
$item = $this->item;
$note = $this->note;
return MicrosoftTeamsMessage::create()
->to($this->settings->webhook_endpoint)
->type('success')
->addStartGroupToSection('activityTitle')
->title("Accessory Checked Out")
->addStartGroupToSection('activityText')
->fact(htmlspecialchars_decode($item->present()->name), '', 'activityTitle')
->fact('Checked out from ', $item->location->name ? $item->location->name : '')
->fact(trans('mail.Accessory_Checkout_Notification')." by ", $admin->present()->fullName())
->fact('Number Remaining', $item->numRemaining())
->fact('Notes', $note ?: 'No notes');
return MicrosoftTeamsMessage::create()
->to($this->settings->webhook_endpoint)
->type('success')
->addStartGroupToSection('activityTitle')
->title(trans('mail.Accessory_Checkout_Notification'))
->addStartGroupToSection('activityText')
->fact(htmlspecialchars_decode($item->present()->name), '', 'activityTitle')
->fact(trans('mail.assigned_to'), $target->present()->name)
->fact(trans('mail.checkedout_from'), $item->location->name ? $item->location->name : '')
->fact(trans('mail.Accessory_Checkout_Notification') . " by ", $admin->present()->fullName())
->fact(trans('admin/consumables/general.remaining'), $item->numRemaining())
->fact(trans('mail.notes'), $note ?: trans('mail.no_notes'));
}
/**

View file

@ -126,27 +126,22 @@ class CheckoutAssetNotification extends Notification
}
public function toMicrosoftTeams()
{
$target = $this->target;
$admin = $this->admin;
$item = $this->item;
$note = $this->note;
try {
return MicrosoftTeamsMessage::create()
->to($this->settings->webhook_endpoint)
->type('success')
->title(trans('mail.Asset_Checkout_Notification'))
->addStartGroupToSection('activityText')
->fact(trans('mail.assigned_to'), $target->present()->name)
->fact(htmlspecialchars_decode($item->present()->name), '', 'activityText')
->fact(trans('mail.Asset_Checkout_Notification') . " by ", $admin->present()->fullName())
->fact(trans('mail.notes'), $note ?: trans('mail.no_notes'));
return MicrosoftTeamsMessage::create()
->to($this->settings->webhook_endpoint)
->type('success')
->title("Asset Checked Out")
->addStartGroupToSection('activityText')
->fact(htmlspecialchars_decode($item->present()->name), '', 'activityText')
->fact('Checked out from ', $item->location ? $item->location->name : $item->assetLoc()->name)
->fact(trans('mail.Asset_Checkout_Notification') . " by ", $admin->present()->fullName())
->fact('Asset Status', $item->assetstatus->name)
->fact('Notes', $note ?: 'No notes');
}
catch(Exception $e) {
dd($e);
}
}
/**

View file

@ -120,13 +120,13 @@ class CheckoutConsumableNotification extends Notification
->to($this->settings->webhook_endpoint)
->type('success')
->addStartGroupToSection('activityTitle')
->title("Consumable Checked Out")
->title(trans('mail.Consumable_checkout_notification'))
->addStartGroupToSection('activityText')
->fact(htmlspecialchars_decode($item->present()->name), '', 'activityTitle')
->fact(trans('mail.Consumable_checkout_notification')." by ", $admin->present()->fullName())
->fact('Checked out to', $target->present()->fullName())
->fact('Number Remaining', $item->numRemaining())
->fact('Notes', $note ?: 'No notes');
->fact(trans('mail.assigned_to'), $target->present()->fullName())
->fact(trans('admin/consumables/general.remaining'), $item->numRemaining())
->fact(trans('mail.notes'), $note ?: trans('mail.no_notes'));
}
/**

View file

@ -121,13 +121,13 @@ class CheckoutLicenseSeatNotification extends Notification
->to($this->settings->webhook_endpoint)
->type('success')
->addStartGroupToSection('activityTitle')
->title("License Checked Out")
->title(trans('mail.License_Checkout_Notification'))
->addStartGroupToSection('activityText')
->fact(htmlspecialchars_decode($item->present()->name), '', 'activityTitle')
->fact(trans('mail.License_Checkout_Notification')." by ", $admin->present()->fullName())
->fact('Checked out to', $target->present()->fullName())
->fact('Seats Remaining', $item->availCount()->count())
->fact('Notes', $note ?: 'No notes');
->fact(trans('mail.assigned_to'), $target->present()->fullName())
->fact(trans('admin/consumables/general.remaining'), $item->availCount()->count())
->fact(trans('mail.notes'), $note ?: trans('mail.no_notes'));
}
/**

View file

@ -35,6 +35,7 @@ return [
'months' => 'months',
'name' => 'Asset Name',
'notes' => 'Notes',
'no_notes' => 'No Notes',
'order' => 'Order Number',
'qr' => 'QR Code',
'requestable' => 'Users may request this asset',

View file

@ -41,6 +41,8 @@ return [
'canceled' => 'Canceled:',
'checkin_date' => 'Checkin Date:',
'checkout_date' => 'Checkout Date:',
'checkedout_from' => 'Checked out from',
'checked_into' => 'Checked into',
'click_on_the_link_accessory' => 'Please click on the link at the bottom to confirm that you have received the accessory.',
'click_on_the_link_asset' => 'Please click on the link at the bottom to confirm that you have received the asset.',
'click_to_confirm' => 'Please click on the following link to confirm your :web account:',
@ -61,6 +63,7 @@ return [
'min_QTY' => 'Min QTY',
'name' => 'Name',
'new_item_checked' => 'A new item has been checked out under your name, details are below.',
'notes' => 'Notes',
'password' => 'Password:',
'password_reset' => 'Password Reset',
'read_the_terms' => 'Please read the terms of use below.',
@ -70,6 +73,8 @@ return [
'reset_password' => 'Click here to reset your password:',
'rights_reserved' => 'All rights reserved.',
'serial' => 'Serial',
'snipe_webhook_test' => 'Snipe-IT Integration Test',
'snipe_webhook_summary' => 'Snipe-IT Integration Test Summary',
'supplier' => 'Supplier',
'tag' => 'Tag',
'test_email' => 'Test Email from Snipe-IT',