Skip to content

Commit

Permalink
Fixes #476 - added logo upload and header color
Browse files Browse the repository at this point in the history
  • Loading branch information
snipe committed Feb 19, 2015
1 parent 348e996 commit f8e12ca
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 5 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ public/uploads/avatars/*
/app/storage/debugbar/
/bin/
.idea
crowdin.yaml
crowdin.yaml
public/uploads/logo.gif
public/uploads/logo.png
20 changes: 19 additions & 1 deletion app/controllers/admin/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Str;
use Validator;
use View;
use Image;

class SettingsController extends AdminController
{
Expand Down Expand Up @@ -65,7 +66,8 @@ public function postEdit()
$rules = array(
"site_name" => 'required|min:3',
"per_page" => 'required|min:1|numeric',
"qr_text" => 'min:1|max:31'
"qr_text" => 'min:1|max:31',
"logo" => 'mimes:jpeg,bmp,png,gif',
);

// Create a new validator instance from our validation rules
Expand All @@ -77,6 +79,20 @@ public function postEdit()
// Ooops.. something went wrong
return Redirect::back()->withInput()->withErrors($validator);
}

if (Input::get('clear_logo')=='1') {
$setting->logo = NULL;
} elseif (Input::file('logo')) {
$image = Input::file('logo');
$file_name = "logo.".$image->getClientOriginalExtension();
$path = public_path('uploads/'.$file_name);
Image::make($image->getRealPath())->resize(null, 40, function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
})->save($path);
$setting->logo = $file_name;
}


// Update the asset data
$setting->id = '1';
Expand All @@ -90,6 +106,8 @@ public function postEdit()
$setting->qr_text = e(Input::get('qr_text'));
$setting->auto_increment_prefix = e(Input::get('auto_increment_prefix'));
$setting->auto_increment_assets = e(Input::get('auto_increment_assets', '0'));
$setting->header_color = e(Input::get('header_color'));


// Was the asset updated?
if($setting->save()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddLogoAndColorsToSettings extends Migration {

/**
* Run the migrations.
*
* @return void
*/
public function up()
{
//
Schema::table('settings', function ($table) {
$table->string('logo')->nullable()->default(NULL);
$table->string('header_color')->nullable()->default(NULL);
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
Schema::table('settings', function ($table) {
$table->dropColumn('logo');
$table->dropColumn('header_color');
});

}

}
2 changes: 2 additions & 0 deletions app/lang/en/admin/settings/general.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
'display_checkout_date' => 'Display Checkout Date',
'display_eol' => 'Display EOL in table view',
'display_qr' => 'Display QR Codes',
'header_color' => 'Header Color',
'info' => 'These settings let you customize certain aspects of your installation.',
'laravel' => 'Laravel Version',
'load_remote' => 'This Snipe-IT install can load scripts from the outside world.',
'logo' => 'Logo',
'per_page' => 'Results Per Page',
'php' => 'PHP Version',
'php_gd_info' => 'You must install php-gd to display QR codes, see install instructions.',
Expand Down
21 changes: 20 additions & 1 deletion app/views/backend/layouts/default.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@
@show
@if (Setting::getSettings()->header_color)
.navbar-inverse {
background-color: {{{ Setting::getSettings()->header_color }}};
background: -webkit-linear-gradient(top, {{{ Setting::getSettings()->header_color }}} 0%,{{{ Setting::getSettings()->header_color }}} 100%);
border-color: {{{ Setting::getSettings()->header_color }}};
}
@endif
</style>


Expand All @@ -100,7 +108,18 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">{{{ Setting::getSettings()->site_name }}}</a>


@if (Setting::getSettings()->logo)
<a class="navbar-brand" href="/" style="padding: 5px;">
<img src="/uploads/{{{ Setting::getSettings()->logo }}}">
</a>
@else
<a class="navbar-brand" href="/">
{{{ Setting::getSettings()->site_name }}}
</a>
@endif

</div>

<ul class="nav navbar-nav navbar-right">
Expand Down
19 changes: 17 additions & 2 deletions app/views/backend/settings/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@
<div class="profile-box">
<br>


<form class="form-horizontal" method="post" action="" autocomplete="off" role="form">
{{ Form::open(['method' => 'POST', 'files' => true, 'class' => 'form-horizontal', 'role' => 'form' ]) }}
<!-- CSRF Token -->
{{ Form::hidden('_token', csrf_token()) }}

Expand All @@ -57,6 +56,22 @@
{{ Form::text('site_name', Input::old('site_name', $setting->site_name), array('class' => 'form-control')) }}
{{ $errors->first('site_name', '<span class="help-inline">:message</span>') }}
</div>

<div class="form-group {{ $errors->has('logo') ? 'has-error' : '' }}">
<label class="control-label" for="logo">@lang('admin/settings/general.logo')</label>

{{ Form::file('logo') }}
{{ $errors->first('logo', '<span class="alert-msg">:message</span>') }}
{{ Form::checkbox('clear_logo', '1', Input::old('clear_logo')) }} Remove


</div>

<div class="form-group {{ $errors->has('header_color') ? 'error' : '' }}">
{{ Form::label('header_color', Lang::get('admin/settings/general.header_color')) }}
{{ Form::text('header_color', Input::old('header_color', $setting->header_color), array('class' => 'form-control', 'style' => 'width: 100px;')) }}
{{ $errors->first('header_color', '<span class="help-inline">:message</span>') }}
</div>

<div class="form-group {{ $errors->has('per_page') ? 'error' : '' }}">
{{ Form::label('per_page', Lang::get('admin/settings/general.per_page')) }}
Expand Down
9 changes: 9 additions & 0 deletions app/views/backend/settings/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@
<tr>
<td>@lang('admin/settings/general.site_name')</td>
<td>{{{ $setting->site_name }}} </td>
</tr>
<tr>
<td>@lang('admin/settings/general.header_color')</td>

@if ($setting->header_color)
<td>{{ $setting->header_color }}</td>
@else
<td>default</td>
@endif
</tr>
<tr>
<td>@lang('admin/settings/general.display_asset_name')</td>
Expand Down

0 comments on commit f8e12ca

Please sign in to comment.