mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 21:24:13 -08:00
Added ability to upload favicon and email logo
todo: refactor the image upload/resize for less copypasta
This commit is contained in:
parent
81f9f717dc
commit
09c4dd4891
|
@ -433,6 +433,60 @@ class SettingsController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
// If the user wants to clear the email logo...
|
||||
if ('1' == $request->input('clear_email_logo')) {
|
||||
Storage::disk('public')->delete($setting->email_logo);
|
||||
$setting->email_logo = null;
|
||||
|
||||
// If they are uploading an image, validate it and upload it
|
||||
} elseif ($request->hasFile('email_logo')) {
|
||||
$email_image = $request->file('email_logo');
|
||||
$email_ext = $image->getClientOriginalExtension();
|
||||
$setting->email_logo = $email_file_name = 'email_logo.' . $email_ext;
|
||||
|
||||
if ('svg' != $email_image->getClientOriginalExtension()) {
|
||||
$email_upload = Image::make($email_image->getRealPath())->resize(null, 100, function($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
$constraint->upsize();
|
||||
});
|
||||
}
|
||||
|
||||
// This requires a string instead of an object, so we use ($string)
|
||||
Storage::disk('public')->put($email_file_name, (string) $email_upload->encode());
|
||||
|
||||
// Remove Current image if exists
|
||||
if (($setting->email_logo) && (file_exists($email_file_name))) {
|
||||
Storage::disk('public')->delete($email_file_name);
|
||||
}
|
||||
}
|
||||
|
||||
// If the user wants to clear the favicon...
|
||||
if ('1' == $request->input('clear_favicon')) {
|
||||
Storage::disk('public')->delete($setting->clear_favicon);
|
||||
$setting->favicon = null;
|
||||
|
||||
// If they are uploading an image, validate it and upload it
|
||||
} elseif ($request->hasFile('favicon')) {
|
||||
$favicon_image = $request->file('favicon');
|
||||
$favicon_ext = $favicon_image->getClientOriginalExtension();
|
||||
$setting->favicon = $favicon_file_name = 'favicon.' . $favicon_ext;
|
||||
|
||||
if ('svg' != $favicon_image->getClientOriginalExtension()) {
|
||||
$favicon_upload = Image::make($favicon_image->getRealPath())->resize(null, 16, function($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
$constraint->upsize();
|
||||
});
|
||||
}
|
||||
|
||||
// This requires a string instead of an object, so we use ($string)
|
||||
Storage::disk('public')->put($favicon_file_name, (string) $favicon_upload->encode());
|
||||
|
||||
// Remove Current image if exists
|
||||
if (($setting->favicon) && (file_exists($favicon_file_name))) {
|
||||
Storage::disk('public')->delete($favicon_file_name);
|
||||
}
|
||||
}
|
||||
|
||||
if ($setting->save()) {
|
||||
return redirect()->route('settings.index')
|
||||
->with('success', trans('admin/settings/message.update.success'));
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddFaviconToSettings extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('settings', function (Blueprint $table) {
|
||||
$table->char('favicon')->nullable()->default(null);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('settings', function (Blueprint $table) {
|
||||
$table->dropColumn('favicon');
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddEmailLogoToSettings extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('settings', function (Blueprint $table) {
|
||||
$table->char('email_logo')->nullable()->default(null);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('settings', function (Blueprint $table) {
|
||||
$table->dropColumn('email_logo');
|
||||
});
|
||||
}
|
||||
}
|
|
@ -31,17 +31,22 @@ return array(
|
|||
'dashboard_message_help' => 'This text will appear on the dashboard for anyone with permission to view the dashboard.',
|
||||
'default_currency' => 'Default Currency',
|
||||
'default_eula_text' => 'Default EULA',
|
||||
'default_language' => 'Default Language',
|
||||
'default_language' => 'Default Language',
|
||||
'default_eula_help_text' => 'You can also associate custom EULAs to specific asset categories.',
|
||||
'display_asset_name' => 'Display Asset Name',
|
||||
'display_checkout_date' => 'Display Checkout Date',
|
||||
'display_eol' => 'Display EOL in table view',
|
||||
'display_qr' => 'Display Square Codes',
|
||||
'display_alt_barcode' => 'Display 1D barcode',
|
||||
'email_logo' => 'Email Logo',
|
||||
'barcode_type' => '2D Barcode Type',
|
||||
'alt_barcode_type' => '1D barcode type',
|
||||
'email_logo_size' => 'Square logos in email look best.',
|
||||
'eula_settings' => 'EULA Settings',
|
||||
'eula_markdown' => 'This EULA allows <a href="https://help.github.com/articles/github-flavored-markdown/">Github flavored markdown</a>.',
|
||||
'favicon' => 'Favicon',
|
||||
'favicon_format' => 'Accepted filetypes are ico, png, and gif. Other image formats may not work in all browsers.',
|
||||
'favicon_size' => 'Favicons should be square images, 16x16 pixels.',
|
||||
'footer_text' => 'Additional Footer Text ',
|
||||
'footer_text_help' => 'This text will appear in the right-side footer. Links are allowed using <a href="https://help.github.com/articles/github-flavored-markdown/">Github flavored markdown</a>. Line breaks, headers, images, etc may result in unpredictable results.',
|
||||
'general_settings' => 'General Settings',
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>{{ ($snipeSettings) && ($snipeSettings->site_name) ? $snipeSettings->site_name : 'Snipe-IT' }}</title>
|
||||
|
||||
|
||||
<link rel="shortcut icon" type="image/ico" href="{{ ($snipeSettings) && ($snipeSettings->favicon!='') ? Storage::disk('public')->url('').e($snipeSettings->favicon) : 'favicon.ico' }} ">
|
||||
{{-- stylesheets --}}
|
||||
<link rel="stylesheet" href="{{ mix('css/all.css') }}">
|
||||
<link rel="shortcut icon" type="image/ico" href="{{ url(asset('favicon.ico')) }}">
|
||||
|
||||
|
||||
|
||||
@if (($snipeSettings) && ($snipeSettings->header_color))
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<!-- Tell the browser to be responsive to screen width -->
|
||||
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
<link rel="shortcut icon" type="image/ico" href="{{ url(asset('favicon.ico')) }}">
|
||||
<link rel="shortcut icon" type="image/ico" href="{{ ($snipeSettings) && ($snipeSettings->favicon!='') ? Storage::disk('public')->url('').e($snipeSettings->favicon) : 'favicon.ico' }} ">
|
||||
|
||||
<script nonce="{{ csrf_token() }}">
|
||||
window.Laravel = { csrfToken: '{{ csrf_token() }}' };
|
||||
|
|
|
@ -57,6 +57,18 @@
|
|||
</div>
|
||||
|
||||
|
||||
|
||||
<!-- Branding -->
|
||||
<div class="form-group {{ $errors->has('brand') ? 'error' : '' }}">
|
||||
<div class="col-md-3">
|
||||
{{ Form::label('brand', trans('admin/settings/general.brand')) }}
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
{!! Form::select('brand', array('1'=>'Text','2'=>'Logo','3'=>'Logo + Text'), Input::old('brand', $setting->brand), array('class' => 'form-control select2', 'style'=>'width: 150px ;')) !!}
|
||||
{!! $errors->first('brand', '<span class="alert-msg">:message</span>') !!}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Logo -->
|
||||
|
||||
<div class="form-group {{ $errors->has('image') ? 'has-error' : '' }}">
|
||||
|
@ -70,7 +82,10 @@
|
|||
</label>
|
||||
<span class='label label-default' id="upload-file-info"></span>
|
||||
|
||||
<p class="help-block" id="upload-file-status">{{ trans('general.image_filetypes_help', ['size' => \App\Helpers\Helper::file_upload_max_size_readable()]) }} {{ trans('general.logo_size') }}</p>
|
||||
<p class="help-block" id="upload-file-status">
|
||||
{{ trans('general.logo_size') }}
|
||||
{{ trans('general.image_filetypes_help', ['size' => \App\Helpers\Helper::file_upload_max_size_readable()]) }}
|
||||
</p>
|
||||
{!! $errors->first('image', '<span class="alert-msg">:message</span>') !!}
|
||||
|
||||
</div>
|
||||
|
@ -87,18 +102,63 @@
|
|||
@endif
|
||||
</div>
|
||||
|
||||
<!-- Email Logo -->
|
||||
<div class="form-group {{ $errors->has('email_logo') ? 'has-error' : '' }}">
|
||||
<label class="col-md-3" for="image">
|
||||
{{ Form::label('email_logo', trans('admin/settings/general.email_logo')) }}</label>
|
||||
|
||||
<!-- Branding -->
|
||||
<div class="form-group {{ $errors->has('brand') ? 'error' : '' }}">
|
||||
<div class="col-md-3">
|
||||
{{ Form::label('brand', trans('admin/settings/general.brand')) }}
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
{!! Form::select('brand', array('1'=>'Text','2'=>'Logo','3'=>'Logo + Text'), Input::old('brand', $setting->brand), array('class' => 'form-control select2', 'style'=>'width: 150px ;')) !!}
|
||||
{!! $errors->first('brand', '<span class="alert-msg">:message</span>') !!}
|
||||
<label class="btn btn-default">
|
||||
{{ trans('button.select_file') }}
|
||||
<input type="file" name="email_logo" data-maxsize="{{ \App\Helpers\Helper::file_upload_max_size() }}" accept="image/gif,image/jpeg,image/png,image/svg" style="display:none; max-width: 90%">
|
||||
</label>
|
||||
<span class='label label-default' id="email-upload-file-info"></span>
|
||||
|
||||
<p class="help-block">
|
||||
{{ trans('admin/settings/general.email_logo_size') }}
|
||||
{{ trans('general.image_filetypes_help', ['size' => \App\Helpers\Helper::file_upload_max_size_readable()]) }} </p>
|
||||
{!! $errors->first('image', '<span class="alert-msg">:message</span>') !!}
|
||||
|
||||
</div>
|
||||
|
||||
@if ($setting->email_logo!='')
|
||||
<div class="col-md-9 col-md-offset-3">
|
||||
|
||||
{{ Form::checkbox('clear_email_logo', '1', Input::old('clear_email_logo'),array('class' => 'minimal')) }} Remove current image
|
||||
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<!-- Favicon -->
|
||||
<div class="form-group {{ $errors->has('favicon') ? 'has-error' : '' }}">
|
||||
<label class="col-md-3" for="image">
|
||||
{{ Form::label('favicon', trans('admin/settings/general.favicon')) }}</label>
|
||||
|
||||
<div class="col-md-9">
|
||||
<label class="btn btn-default">
|
||||
{{ trans('button.select_file') }}
|
||||
<input type="file" name="favicon" data-maxsize="1000" accept="image/x-icon,image/gif,image/jpeg,image/png,image/svg" style="display:none; max-width: 90%">
|
||||
</label>
|
||||
<span class='label label-default' id="favicon-upload-file-info"></span>
|
||||
|
||||
<p class="help-block">{{ trans('admin/settings/general.favicon_size') }}
|
||||
{{ trans('admin/settings/general.favicon_format') }} </p>
|
||||
{!! $errors->first('favicon', '<span class="alert-msg">:message</span>') !!}
|
||||
|
||||
</div>
|
||||
|
||||
@if ($setting->email_logo!='')
|
||||
<div class="col-md-9 col-md-offset-3">
|
||||
|
||||
{{ Form::checkbox('clear_favicon', '1', Input::old('clear_favicon'),array('class' => 'minimal')) }} Remove current favicon
|
||||
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<!-- Include logo in print assets -->
|
||||
<div class="form-group">
|
||||
<div class="col-md-3">
|
||||
|
|
|
@ -1,22 +1,35 @@
|
|||
<tr>
|
||||
<td class="header"{!! ($snipeSettings->header_color!='') ? ' style="background-color: '.e($snipeSettings->header_color).'"' : '' !!}>
|
||||
|
||||
@if (($snipeSettings->show_images_in_email=='1' ) && ($snipeSettings::setupCompleted()))
|
||||
|
||||
<!-- show text and logo -->
|
||||
@if ($snipeSettings->brand == '3')
|
||||
@if ($snipeSettings->logo!='')
|
||||
<img class="navbar-brand-img logo" src="{{ Storage::disk('public')->url('').e($snipeSettings->logo) }}"alt="{{ $snipeSettings->site_name }}">
|
||||
@if ($snipeSettings->email_logo!='')
|
||||
<img class="logo-text" src="{{ Storage::disk('public')->url('').e($snipeSettings->email_logo) }}"alt="{{ $snipeSettings->site_name }}">
|
||||
@elseif ($snipeSettings->logo!='')
|
||||
<img class="logo-text" src="{{ Storage::disk('public')->url('').e($snipeSettings->logo) }}"alt="{{ $snipeSettings->site_name }}">
|
||||
@endif
|
||||
{{ $snipeSettings->site_name }}
|
||||
|
||||
{{ $snipeSettings->site_name }}
|
||||
|
||||
|
||||
<!-- show only logo -->
|
||||
@elseif ($snipeSettings->brand == '2')
|
||||
@if ($snipeSettings->logo!='')
|
||||
<img class="navbar-brand-img logo" src="{{ Storage::disk('public')->url('').e($snipeSettings->logo) }}" alt="{{ $snipeSettings->site_name }}">
|
||||
@if ($snipeSettings->email_logo!='')
|
||||
<img class="logo-only" style="float:left" src="{{ Storage::disk('public')->url('').e($snipeSettings->email_logo) }}" alt="{{ $snipeSettings->site_name }}">
|
||||
@elseif ($snipeSettings->logo!='')
|
||||
<img class="logo-only" src="{{ Storage::disk('public')->url('').e($snipeSettings->logo) }}" alt="{{ $snipeSettings->site_name }}">
|
||||
@endif
|
||||
|
||||
<!-- show only text -->
|
||||
@else
|
||||
{{ $snipeSettings->site_name }}
|
||||
@endif
|
||||
|
||||
|
||||
@else
|
||||
Snipe-IT
|
||||
{{ $snipeSettings->site_name }}
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -105,6 +105,7 @@ img {
|
|||
.header {
|
||||
padding: 25px 0;
|
||||
text-align: center;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.header a {
|
||||
|
@ -282,3 +283,16 @@ img {
|
|||
font-size: 15px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.logo-text {
|
||||
max-width: 150px;
|
||||
max-height: 150px;
|
||||
vertical-align:middle;
|
||||
}
|
||||
|
||||
.logo-only {
|
||||
max-width: 640px;
|
||||
max-height: 150px;
|
||||
vertical-align:middle;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue