Merge branch 'document-title' into 'master'

add admin_document_title

See merge request mohit.panjvani/crater-web!1447
This commit is contained in:
Mohit Panjwani
2022-02-24 12:40:33 +00:00
8 changed files with 81 additions and 69 deletions

View File

@ -55,7 +55,9 @@ class BootstrapController extends Controller
'admin_portal_logo',
'login_page_logo',
'login_page_heading',
'login_page_description'
'login_page_description',
'admin_page_title',
'copyright_text'
]);
return response()->json([

View File

@ -44,8 +44,8 @@ class InvoicePdfController extends Controller
}
return view('app')->with([
'customer_logo' => get_customer_logo($invoice->company_id),
'current_theme' => get_customer_portal_theme($invoice->company_id)
'customer_logo' => get_company_setting('customer_portal_logo', $invoice->company_id),
'current_theme' => get_company_setting('customer_portal_theme', $invoice->company_id)
]);
}

View File

@ -26,9 +26,11 @@ class ViewServiceProvider extends ServiceProvider
public function boot()
{
if (\Storage::disk('local')->has('database_created') && Schema::hasTable('settings')) {
View::share('login_page_logo', get_login_page_logo());
View::share('login_page_heading', get_login_page_heading());
View::share('login_page_description', get_login_page_description());
View::share('login_page_logo', get_app_setting('login_page_logo'));
View::share('login_page_heading', get_app_setting('login_page_heading'));
View::share('login_page_description', get_app_setting('login_page_description'));
View::share('admin_page_title', get_app_setting('admin_page_title'));
View::share('copyright_text', get_app_setting('copyright_text'));
}
}
}

View File

@ -7,93 +7,56 @@ use Crater\Models\Setting;
use Illuminate\Support\Str;
/**
* Get current customer theme
* Get company setting
*
* @param $company_id
* @return string
*/
function get_customer_portal_theme($company_id)
function get_company_setting($key, $company_id)
{
if (\Storage::disk('local')->has('database_created')) {
return CompanySetting::getSetting('customer_portal_theme', $company_id);
return CompanySetting::getSetting($key, $company_id);
}
}
/**
* Get current customer logo
* Get app setting
*
* @param $company_id
* @return string
*/
function get_customer_logo($company_id)
function get_app_setting($key)
{
if (\Storage::disk('local')->has('database_created')) {
return CompanySetting::getSetting('customer_portal_logo', $company_id);
return Setting::getSetting($key);
}
}
/**
* Get current admin portal logo
* Get page title
*
* @param $company_id
* @return string
*/
function get_login_page_logo()
function get_page_title($company_id)
{
if (\Storage::disk('local')->has('database_created')) {
return Setting::getSetting('login_page_logo');
}
}
$routeName = Route::currentRouteName();
/**
* Get current admin theme
*
* @return string
*/
function get_admin_portal_theme()
{
if (\Storage::disk('local')->has('database_created')) {
$setting = Setting::getSetting('admin_portal_theme');
$pageTitle = null;
$defaultPageTitle = 'Crater - Self Hosted Invoicing Platform';
if ($setting) {
return $setting;
if (\Storage::disk('local')->has('database_created')) {
if ($routeName === 'customer.dashboard') {
$pageTitle = CompanySetting::getSetting('customer_portal_page_title', $company_id);
return $pageTitle ? $pageTitle : $defaultPageTitle;
}
return 'crater';
}
return 'crater';
}
/**
* Get current login page heading
*
* @param $company_id
* @return string
*/
function get_login_page_heading()
{
if (\Storage::disk('local')->has('database_created')) {
return Setting::getSetting('login_page_heading');
$pageTitle = Setting::getSetting('admin_page_title');
return $pageTitle ? $pageTitle : $defaultPageTitle;
}
}
/**
* Get current login page description
*
* @param $company_id
* @return string
*/
function get_login_page_description()
{
if (\Storage::disk('local')->has('database_created')) {
return Setting::getSetting('login_page_description');
}
}
/**
* Set Active Path
*

View File

@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class UpdateValueColumnToNullableOnSettingsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('settings', function (Blueprint $table) {
$table->string('value')->nullable()->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}

View File

@ -46,7 +46,8 @@
"
>
<p class="mb-3">
Copyright @ Crater Invoice, Inc. {{ new Date().getFullYear() }}
{{ copyrightText }}
{{ new Date().getFullYear() }}
</p>
</div>
</div>
@ -151,6 +152,13 @@ const pageDescription = computed(() => {
return 'Crater helps you track expenses, record payments & generate beautiful invoices & estimates.'
})
const copyrightText = computed(() => {
if (window.copyright_text) {
return window.copyright_text
}
return 'Copyright @ Crater Invoice, Inc.'
})
const loginPageLogo = computed(() => {
if (window.login_page_logo) {
return window.login_page_logo

View File

@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<title>Crater - Self Hosted Invoicing Platform</title>
<title>{{ get_page_title(!Request::header('company')) }}</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="apple-touch-icon" sizes="180x180" href="/favicons/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicons/favicon-32x32.png">
@ -26,7 +26,7 @@
<body
class="h-full overflow-hidden bg-gray-100 font-base
@if(isset($current_theme)) theme-{{ $current_theme }} @else theme-{{get_admin_portal_theme()}} @endif ">
@if(isset($current_theme)) theme-{{ $current_theme }} @else theme-{{get_app_setting('admin_portal_theme') ?? 'crater'}} @endif ">
<!-- Module Scripts -->
@foreach (\Crater\Services\Module\ModuleFacade::allScripts() as $name => $path)
@ -58,6 +58,12 @@
window.login_page_description = "{{$login_page_description}}"
@endif
@if(isset($copyright_text))
window.copyright_text = "{{$copyright_text}}"
@endif
window.Crater.start()
</script>
</body>

View File

@ -131,14 +131,15 @@ Route::get('/installation', function () {
Route::get('/admin/{vue?}', function () {
return view('app');
})->where('vue', '[\/\w\.-]*')->name('admin')->middleware(['install', 'redirect-if-unauthenticated']);
})->where('vue', '[\/\w\.-]*')->name('admin.dashboard')->middleware(['install', 'redirect-if-unauthenticated']);
Route::get('{company:slug}/customer/{vue?}', function (Company $company) {
return view('app')->with([
'customer_logo' => get_customer_logo($company->id),
'current_theme' => get_customer_portal_theme($company->id)
'customer_logo' => get_company_setting('customer_portal_logo', $company->id),
'current_theme' => get_company_setting('customer_portal_theme', $company->id),
'customer_page_title' => get_company_setting('customer_portal_page_title', $company->id)
]);
})->where('vue', '[\/\w\.-]*')->name('customer.login')->middleware(['install']);
})->where('vue', '[\/\w\.-]*')->name('customer.dashboard')->middleware(['install']);
Route::get('/', function () {
return view('app');