Skip to content

Commit 6a99132

Browse files
committed
More tweaks
1 parent 2e269d2 commit 6a99132

File tree

11 files changed

+452
-264
lines changed

11 files changed

+452
-264
lines changed

app/Console/Commands/ResetDemoSettings.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ public function handle()
5050
$settings->alert_email = '[email protected]';
5151
$settings->login_note = 'Use `admin` / `password` to login to the demo.';
5252
$settings->header_color = '#3c8dbc';
53-
$settings->link_dark_color = '#296282';
54-
$settings->link_light_color = '#296282;';
53+
$settings->link_dark_color = '#084d73';
54+
$settings->link_light_color = '#86cbf2;';
5555
$settings->label2_2d_type = 'QRCODE';
5656
$settings->default_currency = 'USD';
5757
$settings->brand = 2;
@@ -81,6 +81,8 @@ public function handle()
8181

8282
if ($user = User::where('username', '=', 'admin')->first()) {
8383
$user->locale = 'en-US';
84+
$user->enable_confetti = 1;
85+
$user->enable_sounds = 1;
8486
$user->save();
8587
}
8688

app/Http/Controllers/ProfileController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ public function postIndex(ImageUploadRequest $request) : RedirectResponse
5656
$user->phone = $request->input('phone');
5757
$user->enable_sounds = $request->input('enable_sounds', false);
5858
$user->enable_confetti = $request->input('enable_confetti', false);
59+
$user->link_light_color = $request->input('link_light_color', '#296282');
60+
$user->link_dark_color = $request->input('link_dark_color', '#296282');
61+
$user->nav_link_color = $request->input('nav_link_color', '#FFFFFF');
5962

6063
if (! config('app.lock_passwords')) {
6164
$user->locale = $request->input('locale');

app/Http/Controllers/SettingsController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ public function postBranding(ImageUploadRequest $request) : RedirectResponse
402402
$setting->header_color = $request->input('header_color');
403403
$setting->link_light_color = $request->input('link_light_color', '#296282');
404404
$setting->link_dark_color = $request->input('link_dark_color', '#296282');
405+
$setting->nav_link_color = $request->input('nav_link_color', '#FFFFFF');
405406
$setting->support_footer = $request->input('support_footer');
406407
$setting->version_footer = $request->input('version_footer');
407408
$setting->footer_text = $request->input('footer_text');

app/Http/Kernel.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class Kernel extends HttpKernel
4444
\App\Http\Middleware\CheckForTwoFactor::class,
4545
\Laravel\Passport\Http\Middleware\CreateFreshApiToken::class,
4646
\App\Http\Middleware\AssetCountForSidebar::class,
47+
\App\Http\Middleware\CheckColorSettings::class,
4748
\Illuminate\Session\Middleware\AuthenticateSession::class,
4849
\Illuminate\Routing\Middleware\SubstituteBindings::class,
4950
],
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
3+
namespace App\Http\Middleware;
4+
5+
use App\Models\Setting;
6+
use Closure;
7+
use Illuminate\Contracts\Auth\Guard;
8+
use Illuminate\Support\Facades\Auth;
9+
10+
class CheckColorSettings
11+
{
12+
/**
13+
* The Guard implementation.
14+
*
15+
* @var Guard
16+
*/
17+
protected $auth;
18+
19+
/**
20+
* Create a new filter instance.
21+
*
22+
* @param Guard $auth
23+
* @return void
24+
*/
25+
public function __construct(Guard $auth)
26+
{
27+
$this->auth = $auth;
28+
}
29+
30+
/**
31+
* Handle an incoming request.
32+
*
33+
* @param \Illuminate\Http\Request $request
34+
* @param \Closure $next
35+
* @return mixed
36+
*/
37+
public function handle($request, Closure $next)
38+
{
39+
if ($settings = Setting::getSettings()) {
40+
$nav_color = $settings->nav_link_color;
41+
$link_dark_color = $settings->link_dark_color;
42+
$link_light_color = $settings->link_light_color;
43+
}
44+
45+
46+
// Override system settings
47+
if ($request->user()) {
48+
49+
if ($request->user()->nav_color) {
50+
$nav_color = $request->user()->nav_color;
51+
}
52+
if ($request->user()->link_dark_color) {
53+
$link_dark_color = $request->user()->link_dark_color;
54+
}
55+
if ($request->user()->nav_color) {
56+
$link_light_color = $request->user()->link_light_color;
57+
}
58+
}
59+
60+
61+
view()->share('nav_link_color', $nav_color);
62+
view()->share('link_dark_color', $link_dark_color);
63+
view()->share('link_light_color', $link_light_color);
64+
65+
return $next($request);
66+
67+
}
68+
}

database/migrations/2025_11_28_175733_add_link_colors_to_settings.php

Lines changed: 60 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,68 +12,92 @@
1212
*/
1313
public function up(): void
1414
{
15-
$setting = DB::table('settings')->select(['skin'])->first();
16-
15+
$setting = DB::table('settings')->select(['skin', 'header_color'])->first();
1716

1817
Schema::table('settings', function (Blueprint $table) {
1918
$table->string('link_dark_color')->after('header_color')->nullable()->default(null);
2019
$table->string('link_light_color')->after('header_color')->nullable()->default(null);
20+
$table->string('nav_link_color')->after('header_color')->nullable()->default(null);
2121
});
2222

23+
Schema::table('users', function (Blueprint $table) {
24+
$table->string('link_dark_color')->after('skin')->nullable()->default(null);
25+
$table->string('link_light_color')->after('skin')->nullable()->default(null);
26+
$table->string('nav_link_color')->after('skin')->nullable()->default(null);
27+
});
2328

2429

30+
// Set Snipe-IT defaults
2531
$link_dark_color = '#36aff5';
2632
$link_light_color = '#296282';
33+
$nav_color = '#ffffff';
34+
$header_color = '#3c8dbc';
2735

2836
if ($setting) {
37+
2938
switch ($setting->skin) {
30-
case 'green':
39+
case ('green' || 'green-dark'):
40+
$header_color = '#00a65a';
3141
$link_dark_color = '#00a65a';
3242
$link_light_color = '#00a65a';
33-
case 'green-dark':
34-
$link_dark_color = '#00a65a';
35-
$link_light_color = '#00a65a';
36-
case 'red':
37-
$link_dark_color = '#dd4b39';
38-
$link_light_color = '#dd4b39';
39-
case 'red-dark':
43+
$nav_color = '#ffffff';
44+
45+
case ('red' || 'red-dark'):
46+
$header_color = '#dd4b39';
4047
$link_dark_color = '#dd4b39';
4148
$link_light_color = '#dd4b39';
42-
case 'orange':
49+
$nav_color = '#ffffff';
50+
51+
case ('orange' || 'orange-dark'):
52+
$header_color = '#FF851B';
4353
$link_dark_color = '#FF851B';
4454
$link_light_color = '#FF851B';
45-
case 'orange-dark':
46-
$link_dark_color = '#FF8C00';
47-
$link_light_color = '#FF8C00';
48-
case 'black':
49-
$link_dark_color = '#111';
50-
$link_light_color = '#111';
51-
case 'black-dark':
55+
$nav_color = '#ffffff';
56+
57+
case ('black' || 'black-dark'):
58+
$header_color = '#000000';
5259
$link_dark_color = '#111';
5360
$link_light_color = '#111';
54-
case 'purple':
55-
$link_dark_color = '#605ca8';
56-
$link_light_color = '#605ca8';
57-
case 'purple-dark':
61+
$nav_color = '#ffffff';
62+
63+
case ('purple' || 'purple-dark'):
64+
$header_color = '#605ca8';
5865
$link_dark_color = '#605ca8';
5966
$link_light_color = '#605ca8';
60-
case 'yellow':
61-
$link_dark_color = '#f39c12';
62-
$link_light_color = '#f39c12';
63-
case 'yellow-dark':
67+
$nav_color = '#ffffff';
68+
69+
case ('yellow' || 'yellow-dark') :
70+
$header_color = '#f39c12';
6471
$link_dark_color = '#f39c12';
6572
$link_light_color = '#f39c12';
73+
$nav_color = '#ffffff';
74+
6675
case 'contrast':
76+
$header_color = '#001F3F';
6777
$link_dark_color = '#86cbf2';
6878
$link_light_color = '#084d73';
79+
$nav_color = '#ffffff';
80+
break;
6981
}
7082

71-
72-
DB::table('settings')->update(['link_light_color' => $link_light_color, 'link_dark_color' => $link_dark_color]);
73-
}
83+
// Override the header color if the settings have one
84+
if ($setting->header_color) {
85+
$header_color = $setting->header_color;
86+
\Log::debug('A header color was found, so lets use that instead: '.$setting->header_color);
87+
}
7488

7589

90+
DB::table('settings')->update([
91+
'link_light_color' => $link_light_color,
92+
'link_dark_color' => $link_dark_color,
93+
'nav_link_color' => $nav_color,
94+
'header_color' => $header_color]);
7695

96+
DB::table('users')->whereNull('skin')->update([
97+
'link_light_color' => $link_light_color,
98+
'link_dark_color' => $link_dark_color,
99+
'nav_link_color' => $nav_color]);
100+
}
77101

78102
}
79103

@@ -85,6 +109,13 @@ public function down(): void
85109
Schema::table('settings', function ($table) {
86110
$table->dropColumn('link_dark_color');
87111
$table->dropColumn('link_light_color');
112+
$table->dropColumn('nav_link_color');
113+
});
114+
115+
Schema::table('users', function ($table) {
116+
$table->dropColumn('link_dark_color');
117+
$table->dropColumn('link_light_color');
118+
$table->dropColumn('nav_link_color');
88119
});
89120
}
90121
};

resources/lang/en-US/admin/settings/general.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@
8181
'header_color' => 'Primary Theme Color',
8282
'header_color_help' => 'Selecting a new color here will let you preview the color with your logo selection (if you have a site logo uploaded) in the header, however it will not be saved until you click the Save button.',
8383
'link_dark_color' => 'Link Color for Dark Mode',
84+
'nav_link_color' => 'Header Nav Link Color',
85+
'nav_link_color_help' => 'Select a color for the links in your top level navigation. This color should be high enough contrast against your header color to be easily readable.',
8486
'link_dark_color_help' => 'Select a color that will provide enough contrast for people that use Snipe-IT in dark mode.',
8587
'link_light_color' => 'Link Color for Light Mode',
8688
'link_light_color_help' => 'Select a color that will provide enough contrast for people that use Snipe-IT in light mode.',
@@ -494,11 +496,13 @@
494496
'general' => 'General',
495497
'intervals' => 'Intervals & Thresholds',
496498
'logos' => 'Logos & Display',
499+
'display' => 'Display Preferences',
497500
'mapping' => 'LDAP Field Mapping',
498501
'test' => 'Test LDAP Connection',
499502
'misc' => 'Miscellaneous',
500503
'misc_display' => 'Miscellaneous Display Options',
501504
'profiles' => 'User Profiles',
505+
'your_details' => 'Your Details',
502506
'server' => 'Server Settings',
503507
'scoping' => 'Scoping',
504508
'security' => 'Security Preferences',

0 commit comments

Comments
 (0)