Merge branch 'features/mail_test_button' into develop

This commit is contained in:
snipe 2017-10-19 08:19:24 -07:00
commit 2b826c3adc
8 changed files with 205 additions and 52 deletions

View file

@ -791,6 +791,15 @@
"contributions": [
"code"
]
},
{
"login": "thakilla",
"name": "Nicolai Essig",
"avatar_url": "https://avatars0.githubusercontent.com/u/449411?v=4",
"profile": "http://www.nicolai-essig.de",
"contributions": [
"code"
]
}
]
}

View file

@ -1,5 +1,5 @@
[![Build Status](https://travis-ci.org/snipe/snipe-it.svg?branch=develop)](https://travis-ci.org/snipe/snipe-it) [![Stories in Ready](https://badge.waffle.io/snipe/snipe-it.png?label=ready+for+dev&title=Ready+for+development)](http://waffle.io/snipe/snipe-it) [![Maintenance](https://img.shields.io/maintenance/yes/2017.svg)]() [![Crowdin](https://d322cqt584bo4o.cloudfront.net/snipe-it/localized.svg)](https://crowdin.com/project/snipe-it) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/snipe/snipe-it?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Docker Pulls](https://img.shields.io/docker/pulls/snipe/snipe-it.svg)](https://hub.docker.com/r/snipe/snipe-it/) [![Twitter Follow](https://img.shields.io/twitter/follow/snipeyhead.svg?style=social)](https://twitter.com/snipeyhead) [![Zenhub](https://img.shields.io/badge/Shipping_faster_with-ZenHub-5e60ba.svg)](https://zenhub.io) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/553ce52037fc43ea99149785afcfe641)](https://www.codacy.com/app/snipe/snipe-it?utm_source=github.com&utm_medium=referral&utm_content=snipe/snipe-it&utm_campaign=Badge_Grade)
[![All Contributors](https://img.shields.io/badge/all_contributors-85-orange.svg?style=flat-square)](#contributors)
[![All Contributors](https://img.shields.io/badge/all_contributors-86-orange.svg?style=flat-square)](#contributors)
## Snipe-IT - Open Source Asset Management System
@ -68,7 +68,7 @@ Thanks goes to all of these wonderful people ([emoji key](https://github.com/ken
| [<img src="https://avatars2.githubusercontent.com/u/857740?v=3" width="110px;"/><br /><sub>Gil Rutkowski</sub>](http://FlashingCursor.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=flashingcursor "Code") | [<img src="https://avatars3.githubusercontent.com/u/129360?v=3" width="110px;"/><br /><sub>Desmond Morris</sub>](http://www.desmondmorris.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=desmondmorris "Code") | [<img src="https://avatars2.githubusercontent.com/u/52936?v=3" width="110px;"/><br /><sub>Nick Peelman</sub>](http://peelman.us)<br />[💻](https://github.com/snipe/snipe-it/commits?author=peelman "Code") | [<img src="https://avatars0.githubusercontent.com/u/53161?v=3" width="110px;"/><br /><sub>Abraham Vegh</sub>](https://abrahamvegh.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=abrahamvegh "Code") | [<img src="https://avatars0.githubusercontent.com/u/2818680?v=3" width="110px;"/><br /><sub>Mohamed Rashid</sub>](https://github.com/rashivkp)<br />[📖](https://github.com/snipe/snipe-it/commits?author=rashivkp "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/1509456?v=3" width="110px;"/><br /><sub>Kasey</sub>](http://hinchk.github.io)<br />[💻](https://github.com/snipe/snipe-it/commits?author=HinchK "Code") | [<img src="https://avatars2.githubusercontent.com/u/10522541?v=3" width="110px;"/><br /><sub>Brett</sub>](https://github.com/BrettFagerlund)<br />[⚠️](https://github.com/snipe/snipe-it/commits?author=BrettFagerlund "Tests") |
| [<img src="https://avatars2.githubusercontent.com/u/16108587?v=3" width="110px;"/><br /><sub>Jason Spriggs</sub>](http://jasonspriggs.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=jasonspriggs "Code") | [<img src="https://avatars2.githubusercontent.com/u/1134568?v=3" width="110px;"/><br /><sub>Nate Felton</sub>](http://n8felton.wordpress.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=n8felton "Code") | [<img src="https://avatars2.githubusercontent.com/u/14036694?v=3" width="110px;"/><br /><sub>Manasses Ferreira</sub>](http://homepages.dcc.ufmg.br/~manassesferreira)<br />[💻](https://github.com/snipe/snipe-it/commits?author=manassesferreira "Code") | [<img src="https://avatars0.githubusercontent.com/u/15913949?v=3" width="110px;"/><br /><sub>Steve</sub>](https://github.com/steveelwood)<br />[⚠️](https://github.com/snipe/snipe-it/commits?author=steveelwood "Tests") | [<img src="https://avatars1.githubusercontent.com/u/3361683?v=3" width="110px;"/><br /><sub>matc</sub>](http://twitter.com/matc)<br />[⚠️](https://github.com/snipe/snipe-it/commits?author=matc "Tests") | [<img src="https://avatars3.githubusercontent.com/u/7405702?v=3" width="110px;"/><br /><sub>Cole R. Davis</sub>](http://www.davisracingteam.com)<br />[⚠️](https://github.com/snipe/snipe-it/commits?author=VanillaNinjaD "Tests") | [<img src="https://avatars2.githubusercontent.com/u/10167681?v=3" width="110px;"/><br /><sub>gibsonjoshua55</sub>](https://github.com/gibsonjoshua55)<br />[💻](https://github.com/snipe/snipe-it/commits?author=gibsonjoshua55 "Code") |
| [<img src="https://avatars2.githubusercontent.com/u/2809241?v=4" width="110px;"/><br /><sub>Robin Temme</sub>](https://github.com/zwerch)<br />[💻](https://github.com/snipe/snipe-it/commits?author=zwerch "Code") | [<img src="https://avatars0.githubusercontent.com/u/6961695?v=4" width="110px;"/><br /><sub>Iman</sub>](https://github.com/imanghafoori1)<br />[💻](https://github.com/snipe/snipe-it/commits?author=imanghafoori1 "Code") | [<img src="https://avatars1.githubusercontent.com/u/6551003?v=4" width="110px;"/><br /><sub>Richard Hofman</sub>](https://github.com/richardhofman6)<br />[💻](https://github.com/snipe/snipe-it/commits?author=richardhofman6 "Code") | [<img src="https://avatars0.githubusercontent.com/u/3697569?v=4" width="110px;"/><br /><sub>gizzmojr</sub>](https://github.com/gizzmojr)<br />[💻](https://github.com/snipe/snipe-it/commits?author=gizzmojr "Code") | [<img src="https://avatars3.githubusercontent.com/u/404729?v=4" width="110px;"/><br /><sub>Jenny Li</sub>](https://github.com/imjennyli)<br />[📖](https://github.com/snipe/snipe-it/commits?author=imjennyli "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/869227?v=4" width="110px;"/><br /><sub>Geoff Young</sub>](https://github.com/GeoffYoung)<br />[💻](https://github.com/snipe/snipe-it/commits?author=GeoffYoung "Code") | [<img src="https://avatars3.githubusercontent.com/u/1068477?v=4" width="110px;"/><br /><sub>Elliot Blackburn</sub>](http://www.elliotblackburn.com)<br />[📖](https://github.com/snipe/snipe-it/commits?author=BlueHatbRit "Documentation") |
| [<img src="https://avatars1.githubusercontent.com/u/6357451?v=4" width="110px;"/><br /><sub>Tõnis Ormisson</sub>](http://andmemasin.eu)<br />[💻](https://github.com/snipe/snipe-it/commits?author=TonisOrmisson "Code") |
| [<img src="https://avatars1.githubusercontent.com/u/6357451?v=4" width="110px;"/><br /><sub>Tõnis Ormisson</sub>](http://andmemasin.eu)<br />[💻](https://github.com/snipe/snipe-it/commits?author=TonisOrmisson "Code") | [<img src="https://avatars0.githubusercontent.com/u/449411?v=4" width="110px;"/><br /><sub>Nicolai Essig</sub>](http://www.nicolai-essig.de)<br />[💻](https://github.com/snipe/snipe-it/commits?author=thakilla "Code") |
<!-- ALL-CONTRIBUTORS-LIST:END -->
This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!

View file

@ -7,6 +7,7 @@ use App\Http\Controllers\Controller;
use App\Models\Ldap;
use Validator;
use App\Models\Setting;
use Mail;
class SettingsController extends Controller
{
@ -160,4 +161,28 @@ class SettingsController extends Controller
}
/**
* Test the email configuration
*
* @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v3.0]
* @return Redirect
*/
public function ajaxTestEmail()
{
try {
Mail::send('emails.test', [], function ($m) {
$m->to(config('mail.from.address'), config('mail.from.name'));
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
$m->subject(trans('mail.test_email'));
});
return response()->json(['message' => 'Mail sent! '], 200);
} catch (Exception $e) {
return response()->json(['message' => $e->getMessage()], 500);
}
}
}

View file

@ -21,6 +21,7 @@ use App\Models\User;
use App\Http\Requests\SetupUserRequest;
use App\Http\Requests\ImageUploadRequest;
use App\Http\Requests\SettingsLdapRequest;
use App\Helpers\Helper;
/**
* This controller handles all actions related to Settings for
@ -136,28 +137,6 @@ class SettingsController extends Controller
->with('section', 'Pre-Flight Check');
}
/**
* Test the email configuration
*
* @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v3.0]
* @return Redirect
*/
public function ajaxTestEmail()
{
try {
Mail::send('emails.test', [], function ($m) {
$m->to(config('mail.from.address'), config('mail.from.name'));
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
$m->subject(trans('mail.test_email'));
});
return 'success';
} catch (Exception $e) {
return 'error';
}
}
/**
* Save the first admin user from Setup.
@ -1024,4 +1003,28 @@ class SettingsController extends Controller
public function api() {
return view('settings.api');
}
/**
* Test the email configuration
*
* @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v3.0]
* @return Redirect
*/
public function ajaxTestEmail()
{
try {
Mail::send('emails.test', [], function ($m) {
$m->to(config('mail.from.address'), config('mail.from.name'));
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
$m->subject(trans('mail.test_email'));
});
return response()->json(Helper::formatStandardApiResponse('success', null, 'Maiol sent!'));
} catch (Exception $e) {
return response()->json(Helper::formatStandardApiResponse('success', null, $e->getMessage()));
}
}
}

View file

@ -109,7 +109,7 @@ return [
|
*/
'cookie' => env('COOKIE_NAME', 'sl53_session'),
'cookie' => env('COOKIE_NAME', 'snipeitv4_session'),
/*
|--------------------------------------------------------------------------

View file

@ -178,6 +178,27 @@
</div>
</div>
<!-- Mail test -->
<div class="form-group">
<div class="col-md-3">
{{ Form::label('login_note', 'Test Mail') }}
</div>
<div class="col-md-9" id="mailtestrow">
<a class="btn btn-default btn-sm pull-left" id="mailtest" style="margin-right: 10px;">
Send Test</a>
<span id="mailtesticon"></span>
<span id="mailtestresult"></span>
<span id="mailteststatus"></span>
</div>
<div class="col-md-9 col-md-offset-3">
<div id="mailteststatus-error" class="text-danger"></div>
</div>
<div class="col-md-9 col-md-offset-3">
<p class="help-block">This will attempt to send a test mail to {{ config('mail.from.address') }}.</p>
</div>
</div>
</div> <!--/.box-body-->
<div class="box-footer">
<div class="text-left col-md-6">
@ -208,5 +229,56 @@
}).on('ifUnchecked', function(){
$('#auto_increment_prefix').prop('disabled', true);
});
// Test Mail
$("#mailtest").click(function(){
$("#mailtestrow").removeClass('text-success');
$("#mailtestrow").removeClass('text-danger');
$("#mailtesticon").html('');
$("#mailteststatus").html('');
$('#mailteststatus-error').html('');
$("#mailtesticon").html('<i class="fa fa-spinner spin"></i> Sending Test Email...');
$.ajax({
url: '{{ route('api.settings.mailtest') }}',
type: 'POST',
headers: {
"X-Requested-With": 'XMLHttpRequest',
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr('content')
},
data: {},
dataType: 'json',
success: function (data) {
$("#mailtesticon").html('');
$("#mailteststatus").html('');
$('#mailteststatus-error').html('');
$("#mailteststatus").removeClass('text-danger');
$("#mailteststatus").addClass('text-success');
$("#mailteststatus").html('<i class="fa fa-check text-success"></i> Mail sent!');
},
error: function (data) {
$("#mailtesticon").html('');
$("#mailteststatus").html('');
$('#mailteststatus-error').html('');
$("#mailteststatus").removeClass('text-success');
$("#mailteststatus").addClass('text-danger');
$("#mailtesticon").html('<i class="fa fa-exclamation-triangle text-danger"></i>');
$('#mailteststatus').html('Mail could not be sent.');
if (data.responseJSON) {
$('#mailteststatus-error').html('Error: ' + data.responseJSON.messages);
} else {
console.dir(data);
}
}
});
});
</script>
@stop

View file

@ -165,13 +165,22 @@ Create a User ::
</td>
</tr>
<tr id="mailrow">
<tr id="mailtestrow" class="warning">
<td>Email</td>
<td id="mailtesticon">
<td>
<a class="btn btn-default btn-sm pull-left" id="mailtest" style="margin-right: 10px;">
Send Test</a>
</td>
<td id="mailtestresult">
<button class="btn btn-default" id="mailtest"> Test Email</button>
<td>
<span id="mailtesticon"></span>
<span id="mailtestresult"></span>
<span id="mailteststatus"></span>
<div class="col-md-12">
<div id="mailteststatus-error" class="text-danger"></div>
</div>
<div class="col-md-12">
<p class="help-block">This will attempt to send a test mail to {{ config('mail.from.address') }}.</p>
</div>
</td>
</tr>
</tbody>
@ -190,17 +199,33 @@ Create a User ::
<script type="text/javascript">
$(document).ready(function () {
// Test Mail
$("#mailtest").click(function(){
$("#mailtestresult").html('<i class="fa fa-spinner fa-spin"></i> Sending Email');
$("#mailtestrow").removeClass('success').removeClass('danger').removeClass('warning');
$("#mailtestrow").addClass('info');
$("#mailtesticon").html('');
$("#mailteststatus").html('');
$('#mailteststatus-error').html('');
$("#mailtesticon").html('<i class="fa fa-spinner spin"></i> Sending Test Email...');
$.ajax({url: "{{ route('setup.mailtest') }}", success: function(result){
if (result=='success') {
$("#mailrow").addClass('success');
$("#mailtesticon").html('<i class="fa fa-check preflight-success"></i>');
$("#mailtestresult").html('No errors on this end! Check your <code>{{ config('mail.from.address') }}</code> email account for a test email.');
$.ajax({
url: "{{ route('setup.mailtest') }}",
success: function (result) {
if (result.status == 'success') {
$("#mailtestrow").removeClass('info').removeClass('danger').removeClass('warning');
$("#mailtestrow").addClass('success');
$("#mailtesticon").html('');
$("#mailteststatus").html('');
$('#mailteststatus-error').html('');
$("#mailteststatus").removeClass('text-danger');
$("#mailteststatus").addClass('text-success');
$("#mailteststatus").html('<i class="fa fa-check text-success"></i> Mail sent to {{ config('mail.from.address') }}!');
} else {
$("#mailrow").addClass('danger');
$("#mailtestrow").removeClass('success').removeClass('info').removeClass('warning');
$("#mailtestrow").addClass('danger');
$("#mailtesticon").html('<i class="fa fa-check preflight-error"></i>');
$("#mailtestresult").html('Something went wrong. Your email was not sent. Check your mail settings in your <code>.env</code> file.');
@ -209,14 +234,25 @@ Create a User ::
},
error: function (result) {
$("#mailrow").addClass('danger');
$("#mailtesticon").html('<i class="fa fa-check preflight-error"></i>');
$("#mailtestresult").html('Something went wrong. The server returned an error. Check your mail settings in your <code>.env</code> file, and check your <code>storage/logs</code> for additional information..');
$("#mailtestrow").removeClass('success').removeClass('info').removeClass('warning');
$("#mailtestrow").addClass('danger');
$("#mailtesticon").html('');
$("#mailteststatus").html('');
$('#mailteststatus-error').html('');
$("#mailteststatus").removeClass('text-success');
$("#mailteststatus").addClass('text-danger');
$("#mailtesticon").html('<i class="fa fa-exclamation-triangle text-danger"></i>');
$('#mailteststatus').html('Mail could not be sent.');
if (result.responseJSON) {
$('#mailteststatus-error').html('Error: ' + result.responseJSON.messages);
} else {
console.dir(data);
}
}
});
});
});
</script>

View file

@ -429,6 +429,14 @@ Route::group(['prefix' => 'v1','namespace' => 'Api'], function () {
'uses' => 'SettingsController@ldaptestlogin'
]);
Route::post(
'settings/mailtest',
[
'as' => 'api.settings.mailtest',
'uses' => 'SettingsController@ajaxTestEmail' ]
);
Route::resource('settings', 'SettingsController',
[
'names' =>