mirror of
https://gitlab.linphone.org/BC/public/flexisip-account-manager.git
synced 2026-01-17 10:08:05 +00:00
Move the configuration to the .env file to support per-instances configurations
Complete the README
This commit is contained in:
parent
d0039165d6
commit
e1c34ec678
13 changed files with 60 additions and 121 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -1,9 +1,12 @@
|
|||
flexisip-account-manager/
|
||||
rpmbuild/
|
||||
|
||||
.env.*
|
||||
|
||||
flexiapi/node_modules
|
||||
flexiapi/public/hot
|
||||
flexiapi/public/storage
|
||||
flexiapi/public/css/*.style.css
|
||||
flexiapi/storage/*.key
|
||||
flexiapi/vendor
|
||||
flexiapi/.env
|
||||
|
|
|
|||
|
|
@ -5,6 +5,10 @@ APP_DEBUG=false
|
|||
APP_URL=http://localhost
|
||||
APP_SIP_DOMAIN=
|
||||
|
||||
INSTANCE_COPYRIGHT=
|
||||
INSTANCE_INTRO_REGISTRATION=
|
||||
INSTANCE_CUSTOM_THEME=false
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
|
||||
DB_DATABASE=/var/www/flexiapi/db.sqlite
|
||||
|
|
|
|||
|
|
@ -26,6 +26,41 @@ Complete all the other variables in the `.env` file:
|
|||
- SMTP configuration
|
||||
- App name, SIP domain…
|
||||
|
||||
### Multi instances environement
|
||||
|
||||
FlexiAPI can also handle multi domains setup.
|
||||
|
||||
To do so, configure several web servers virtualhosts and set a specific `APP_ENV` environement variable in each of them.
|
||||
|
||||
With Apache, use the [mod_env](https://httpd.apache.org/docs/2.4/mod/mod_env.html) module.
|
||||
|
||||
SetEnv APP_ENV foobar
|
||||
|
||||
On nginx use `fastcgi_param` to pass the parameter directly to PHP.
|
||||
|
||||
location ~ [^/]\.php(/|$) {
|
||||
…
|
||||
include /etc/nginx/fastcgi_params;
|
||||
fastcgi_param APP_ENV foobar;
|
||||
}
|
||||
|
||||
Note that if `APP_ENV` is not set FlexiAPI will directly use the default `.env` file.
|
||||
|
||||
FlexiAPI will then try to load a custom configuration file with the following name `.env.$APP_ENV`. So for the previous example `.env.foobar`.
|
||||
|
||||
You can then configure your instances with specific values.
|
||||
|
||||
INSTANCE_COPYRIGHT="FooBar - Since 1997"
|
||||
INSTANCE_INTRO_REGISTRATION="Welcome on the FooBar Server"
|
||||
INSTANCE_CUSTOM_THEME=true
|
||||
…
|
||||
|
||||
#### Custom theme
|
||||
|
||||
If you set `INSTANCE_CUSTOM_THEME` to true, FlexiAPI will try to load a CSS file located in `public/css/$APP_ENV.style.css`. If the file doesn't exists it will fallback to `public/css/style.css`.
|
||||
|
||||
We advise you to copy the `style.css` file and rename it to make your custom CSS configurations for your instance.
|
||||
|
||||
### SELinux
|
||||
|
||||
If you are running on a CentOS/RedHat machine, please ensure that SELinux is correctly configured.
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Configuration extends Model
|
||||
{
|
||||
protected $table = 'configuration';
|
||||
protected $fillable = ['copyright', 'intro_registration', 'custom_theme'];
|
||||
}
|
||||
|
|
@ -10,7 +10,6 @@ use Carbon\Carbon;
|
|||
|
||||
use App\Account;
|
||||
use App\Alias;
|
||||
use App\Configuration;
|
||||
use App\Rules\SIP;
|
||||
use App\Helpers\Utils;
|
||||
use App\Libraries\OvhSMS;
|
||||
|
|
@ -41,8 +40,7 @@ class AccountController extends Controller
|
|||
public function register(Request $request)
|
||||
{
|
||||
return view('account.register', [
|
||||
'domain' => '@' . config('app.sip_domain'),
|
||||
'configuration' => Configuration::first()
|
||||
'domain' => '@' . config('app.sip_domain')
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,34 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use App\Configuration;
|
||||
|
||||
class ConfigurationController extends Controller
|
||||
{
|
||||
public function edit(Request $request)
|
||||
{
|
||||
$configuration = Configuration::first();
|
||||
if (!$configuration) $configuration = new Configuration;
|
||||
|
||||
return view('admin.configuration.edit', [
|
||||
'configuration' => $configuration
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
$configuration = Configuration::first();
|
||||
if (!$configuration) $configuration = new Configuration;
|
||||
|
||||
$configuration->copyright = $request->get('copyright');
|
||||
$configuration->intro_registration = $request->get('intro_registration');
|
||||
$configuration->custom_theme = $request->input('custom_theme', false);
|
||||
$configuration->save();
|
||||
|
||||
return redirect()->route('admin.configuration.update');
|
||||
}
|
||||
}
|
||||
7
flexiapi/config/instance.php
Normal file
7
flexiapi/config/instance.php
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'copyright' => env('INSTANCE_COPYRIGHT', null),
|
||||
'intro_registration' => env('INSTANCE_INTRO_REGISTRATION', null),
|
||||
'custom_theme' => env('INSTANCE_CUSTOM_THEME', false),
|
||||
];
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateConfigurationTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::create('configuration', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('copyright')->nullable();
|
||||
$table->text('intro_registration')->nullable();
|
||||
$table->boolean('custom_theme')->default(false);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('configuration');
|
||||
}
|
||||
}
|
||||
|
|
@ -40,12 +40,6 @@
|
|||
</div>
|
||||
<p class="mb-1">Manage the FlexiSIP accounts</p>
|
||||
</a>
|
||||
<a href="{{ route('admin.configuration.edit') }}" class="list-group-item list-group-item-action">
|
||||
<div class="d-flex w-100 justify-content-between">
|
||||
<h5 class="mb-1">Configuration</h5>
|
||||
</div>
|
||||
<p class="mb-1">Configure the layout and other parameters</p>
|
||||
</a>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
@section('content')
|
||||
|
||||
@if ($configuration && !empty($configuration->intro_registration))
|
||||
<p>{!! nl2br($configuration->intro_registration) !!}</p>
|
||||
@if (config('instance.intro_registration'))
|
||||
<p>{!! nl2br(config('instance.intro_registration')) !!}</p>
|
||||
@endif
|
||||
<p>
|
||||
You already have an account?
|
||||
|
|
|
|||
|
|
@ -1,32 +0,0 @@
|
|||
@extends('layouts.account')
|
||||
|
||||
@section('breadcrumb')
|
||||
<li class="breadcrumb-item active" aria-current="page">Configuration</li>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<h2>Configuration</h2>
|
||||
|
||||
{!! Form::open(['route' => 'admin.configuration.update']) !!}
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
{!! Form::label('copyright', 'Copyright') !!}
|
||||
{!! Form::text('copyright', $configuration->copyright, ['class' => 'form-control', 'placeholder' => 'Copyright']) !!}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
{!! Form::label('intro_registration', 'Introduction text during Registration') !!}
|
||||
{!! Form::textarea('intro_registration', $configuration->intro_registration, ['class' => 'form-control', 'placeholder' => 'Introduction text during registration']) !!}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-check mb-3">
|
||||
{!! Form::checkbox('custom_theme', 'checked', $configuration->custom_theme, ['class' => 'form-check-input', 'id' => 'custom_theme']) !!}
|
||||
<label class="form-check-label" for="custom_theme">CSS spéficique</a></label>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<button type="submit" class="btn btn-primary">Save</button>
|
||||
</div>
|
||||
{!! Form::close() !!}
|
||||
|
||||
@endsection
|
||||
|
|
@ -1,7 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
|
||||
@php $configuration = \App\Configuration::first() @endphp
|
||||
|
||||
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
|
@ -9,9 +7,13 @@
|
|||
|
||||
<title>{{ config('app.name') }}</title>
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
|
||||
@if ($configuration && $configuration->custom_theme)
|
||||
@if (config('instance.custom_theme'))
|
||||
@if (file_exists(public_path('css/'.config('app.env').'.style.css')))
|
||||
<link rel="stylesheet" type="text/css" href="{{ asset('css/'.config('app.env').'.style.css') }}" >
|
||||
@else
|
||||
<link rel="stylesheet" type="text/css" href="{{ asset('css/style.css') }}" >
|
||||
@endif
|
||||
@endif
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
|
|
@ -19,8 +21,8 @@
|
|||
</header>
|
||||
@yield('body')
|
||||
<footer class="text-center mt-2">
|
||||
@if ($configuration)
|
||||
{{ $configuration->copyright }}
|
||||
@if (config('instance.copyright'))
|
||||
{{ config('instance.copyright') }}
|
||||
@endif
|
||||
</footer>
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -56,7 +56,4 @@ Route::group(['middleware' => 'auth.admin'], function () {
|
|||
Route::get('admin/accounts/{id}/deactivate', 'Admin\AccountController@deactivate')->name('admin.account.deactivate');
|
||||
Route::get('admin/accounts/{id}/admin', 'Admin\AccountController@admin')->name('admin.account.admin');
|
||||
Route::get('admin/accounts/{id}/unadmin', 'Admin\AccountController@unadmin')->name('admin.account.unadmin');
|
||||
|
||||
Route::get('admin/configuration', 'Admin\ConfigurationController@edit')->name('admin.configuration.edit');
|
||||
Route::post('admin/configuration', 'Admin\ConfigurationController@update')->name('admin.configuration.update');
|
||||
});
|
||||
Loading…
Add table
Reference in a new issue