mirror of
https://gitlab.com/signalytic/client-external/streamline/streamline-emr.git
synced 2026-09-12 19:21:33 +00:00
Import latest app updates from streamline
An updated set of source files and initialization was provided by streamline to address issues observed during initial testing. These files have been updated in order to generate a new set of app images.
This commit is contained in:
-22
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Permission\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Spatie\Permission\PermissionRegistrar;
|
||||
|
||||
class CacheReset extends Command
|
||||
{
|
||||
protected $signature = 'permission:cache-reset';
|
||||
|
||||
protected $description = 'Reset the permission cache';
|
||||
|
||||
public function handle()
|
||||
{
|
||||
if (app(PermissionRegistrar::class)->forgetCachedPermissions()) {
|
||||
$this->info('Permission cache flushed.');
|
||||
} else {
|
||||
$this->error('Unable to flush cache.');
|
||||
}
|
||||
}
|
||||
}
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Permission\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Spatie\Permission\Contracts\Permission as PermissionContract;
|
||||
|
||||
class CreatePermission extends Command
|
||||
{
|
||||
protected $signature = 'permission:create-permission
|
||||
{name : The name of the permission}
|
||||
{guard? : The name of the guard}';
|
||||
|
||||
protected $description = 'Create a permission';
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$permissionClass = app(PermissionContract::class);
|
||||
|
||||
$permission = $permissionClass::findOrCreate($this->argument('name'), $this->argument('guard'));
|
||||
|
||||
$this->info("Permission `{$permission->name}` ".($permission->wasRecentlyCreated ? 'created' : 'already exists'));
|
||||
}
|
||||
}
|
||||
-67
@@ -1,67 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Permission\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Spatie\Permission\Contracts\Permission as PermissionContract;
|
||||
use Spatie\Permission\Contracts\Role as RoleContract;
|
||||
use Spatie\Permission\PermissionRegistrar;
|
||||
|
||||
class CreateRole extends Command
|
||||
{
|
||||
protected $signature = 'permission:create-role
|
||||
{name : The name of the role}
|
||||
{guard? : The name of the guard}
|
||||
{permissions? : A list of permissions to assign to the role, separated by | }
|
||||
{--team-id=}';
|
||||
|
||||
protected $description = 'Create a role';
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$roleClass = app(RoleContract::class);
|
||||
|
||||
$teamIdAux = getPermissionsTeamId();
|
||||
setPermissionsTeamId($this->option('team-id') ?: null);
|
||||
|
||||
if (! PermissionRegistrar::$teams && $this->option('team-id')) {
|
||||
$this->warn('Teams feature disabled, argument --team-id has no effect. Either enable it in permissions config file or remove --team-id parameter');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$role = $roleClass::findOrCreate($this->argument('name'), $this->argument('guard'));
|
||||
setPermissionsTeamId($teamIdAux);
|
||||
|
||||
$teams_key = PermissionRegistrar::$teamsKey;
|
||||
if (PermissionRegistrar::$teams && $this->option('team-id') && is_null($role->$teams_key)) {
|
||||
$this->warn("Role `{$role->name}` already exists on the global team; argument --team-id has no effect");
|
||||
}
|
||||
|
||||
$role->givePermissionTo($this->makePermissions($this->argument('permissions')));
|
||||
|
||||
$this->info("Role `{$role->name}` ".($role->wasRecentlyCreated ? 'created' : 'updated'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null|string $string
|
||||
*/
|
||||
protected function makePermissions($string = null)
|
||||
{
|
||||
if (empty($string)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$permissionClass = app(PermissionContract::class);
|
||||
|
||||
$permissions = explode('|', $string);
|
||||
|
||||
$models = [];
|
||||
|
||||
foreach ($permissions as $permission) {
|
||||
$models[] = $permissionClass::findOrCreate(trim($permission), $this->argument('guard'));
|
||||
}
|
||||
|
||||
return collect($models);
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Permission\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Collection;
|
||||
use Spatie\Permission\Contracts\Permission as PermissionContract;
|
||||
use Spatie\Permission\Contracts\Role as RoleContract;
|
||||
use Symfony\Component\Console\Helper\TableCell;
|
||||
|
||||
class Show extends Command
|
||||
{
|
||||
protected $signature = 'permission:show
|
||||
{guard? : The name of the guard}
|
||||
{style? : The display style (default|borderless|compact|box)}';
|
||||
|
||||
protected $description = 'Show a table of roles and permissions per guard';
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$permissionClass = app(PermissionContract::class);
|
||||
$roleClass = app(RoleContract::class);
|
||||
$teamsEnabled = config('permission.teams');
|
||||
$team_key = config('permission.column_names.team_foreign_key');
|
||||
|
||||
$style = $this->argument('style') ?? 'default';
|
||||
$guard = $this->argument('guard');
|
||||
|
||||
if ($guard) {
|
||||
$guards = Collection::make([$guard]);
|
||||
} else {
|
||||
$guards = $permissionClass::pluck('guard_name')->merge($roleClass::pluck('guard_name'))->unique();
|
||||
}
|
||||
|
||||
foreach ($guards as $guard) {
|
||||
$this->info("Guard: $guard");
|
||||
|
||||
$roles = $roleClass::whereGuardName($guard)
|
||||
->with('permissions')
|
||||
->when($teamsEnabled, function ($q) use ($team_key) {
|
||||
$q->orderBy($team_key);
|
||||
})
|
||||
->orderBy('name')->get()->mapWithKeys(function ($role) use ($teamsEnabled, $team_key) {
|
||||
return [$role->name.'_'.($teamsEnabled ? ($role->$team_key ?: '') : '') => [
|
||||
'permissions' => $role->permissions->pluck('id'),
|
||||
$team_key => $teamsEnabled ? $role->$team_key : null,
|
||||
]];
|
||||
});
|
||||
|
||||
$permissions = $permissionClass::whereGuardName($guard)->orderBy('name')->pluck('name', 'id');
|
||||
|
||||
$body = $permissions->map(function ($permission, $id) use ($roles) {
|
||||
return $roles->map(function (array $role_data) use ($id) {
|
||||
return $role_data['permissions']->contains($id) ? ' ✔' : ' ·';
|
||||
})->prepend($permission);
|
||||
});
|
||||
|
||||
if ($teamsEnabled) {
|
||||
$teams = $roles->groupBy($team_key)->values()->map(function ($group, $id) {
|
||||
return new TableCell('Team ID: '.($id ?: 'NULL'), ['colspan' => $group->count()]);
|
||||
});
|
||||
}
|
||||
|
||||
$this->table(
|
||||
array_merge([
|
||||
isset($teams) ? $teams->prepend(new TableCell(''))->toArray() : [],
|
||||
$roles->keys()->map(function ($val) {
|
||||
$name = explode('_', $val);
|
||||
array_pop($name);
|
||||
|
||||
return implode('_', $name);
|
||||
})
|
||||
->prepend('')->toArray(),
|
||||
]),
|
||||
$body->toArray(),
|
||||
$style
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
-126
@@ -1,126 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Permission\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
class UpgradeForTeams extends Command
|
||||
{
|
||||
protected $signature = 'permission:setup-teams';
|
||||
|
||||
protected $description = 'Setup the teams feature by generating the associated migration.';
|
||||
|
||||
protected $migrationSuffix = 'add_teams_fields.php';
|
||||
|
||||
public function handle()
|
||||
{
|
||||
if (! Config::get('permission.teams')) {
|
||||
$this->error('Teams feature is disabled in your permission.php file.');
|
||||
$this->warn('Please enable the teams setting in your configuration.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->line('');
|
||||
$this->info('The teams feature setup is going to add a migration and a model');
|
||||
|
||||
$existingMigrations = $this->alreadyExistingMigrations();
|
||||
|
||||
if ($existingMigrations) {
|
||||
$this->line('');
|
||||
|
||||
$this->warn($this->getExistingMigrationsWarning($existingMigrations));
|
||||
}
|
||||
|
||||
$this->line('');
|
||||
|
||||
if (! $this->confirm('Proceed with the migration creation?', 'yes')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->line('');
|
||||
|
||||
$this->line('Creating migration');
|
||||
|
||||
if ($this->createMigration()) {
|
||||
$this->info('Migration created successfully.');
|
||||
} else {
|
||||
$this->error(
|
||||
"Couldn't create migration.\n".
|
||||
'Check the write permissions within the database/migrations directory.'
|
||||
);
|
||||
}
|
||||
|
||||
$this->line('');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the migration.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function createMigration()
|
||||
{
|
||||
try {
|
||||
$migrationStub = __DIR__."/../../database/migrations/{$this->migrationSuffix}.stub";
|
||||
copy($migrationStub, $this->getMigrationPath());
|
||||
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
$this->error($e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a warning regarding possible duplication
|
||||
* due to already existing migrations.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getExistingMigrationsWarning(array $existingMigrations)
|
||||
{
|
||||
if (count($existingMigrations) > 1) {
|
||||
$base = "Setup teams migrations already exist.\nFollowing files were found: ";
|
||||
} else {
|
||||
$base = "Setup teams migration already exists.\nFollowing file was found: ";
|
||||
}
|
||||
|
||||
return $base.array_reduce($existingMigrations, function ($carry, $fileName) {
|
||||
return $carry."\n - ".$fileName;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if there is another migration
|
||||
* with the same suffix.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function alreadyExistingMigrations()
|
||||
{
|
||||
$matchingFiles = glob($this->getMigrationPath('*'));
|
||||
|
||||
return array_map(function ($path) {
|
||||
return basename($path);
|
||||
}, $matchingFiles);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the migration path.
|
||||
*
|
||||
* The date parameter is optional for ability
|
||||
* to provide a custom value or a wildcard.
|
||||
*
|
||||
* @param string|null $date
|
||||
* @return string
|
||||
*/
|
||||
protected function getMigrationPath($date = null)
|
||||
{
|
||||
$date = $date ?: date('Y_m_d_His');
|
||||
|
||||
return database_path("migrations/{$date}_{$this->migrationSuffix}");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user