Add more front-end controllers, language file cleanup
This commit is contained in:
parent
4532811fcd
commit
54554465f2
59 changed files with 1100 additions and 336 deletions
|
@ -78,7 +78,7 @@ class AssignmentService
|
|||
$explode = explode('/', $data['allocation_ip']);
|
||||
if (count($explode) !== 1) {
|
||||
if (! ctype_digit($explode[1]) || ($explode[1] > self::CIDR_MIN_BITS || $explode[1] < self::CIDR_MAX_BITS)) {
|
||||
throw new DisplayException(trans('admin/exceptions.allocations.cidr_out_of_range'));
|
||||
throw new DisplayException(trans('exceptions.allocations.cidr_out_of_range'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ class AssignmentService
|
|||
foreach (Network::parse(gethostbyname($data['allocation_ip'])) as $ip) {
|
||||
foreach ($data['allocation_ports'] as $port) {
|
||||
if (! ctype_digit($port) && ! preg_match(self::PORT_RANGE_REGEX, $port)) {
|
||||
throw new DisplayException(trans('admin/exceptions.allocations.invalid_mapping', ['port' => $port]));
|
||||
throw new DisplayException(trans('exceptions.allocations.invalid_mapping', ['port' => $port]));
|
||||
}
|
||||
|
||||
$insertData = [];
|
||||
|
@ -94,7 +94,7 @@ class AssignmentService
|
|||
$block = range($matches[1], $matches[2]);
|
||||
|
||||
if (count($block) > self::PORT_RANGE_LIMIT) {
|
||||
throw new DisplayException(trans('admin/exceptions.allocations.too_many_ports'));
|
||||
throw new DisplayException(trans('exceptions.allocations.too_many_ports'));
|
||||
}
|
||||
|
||||
foreach ($block as $unit) {
|
||||
|
|
|
@ -155,7 +155,7 @@ class DatabaseHostService
|
|||
{
|
||||
$count = $this->databaseRepository->findCountWhere([['database_host_id', '=', $id]]);
|
||||
if ($count > 0) {
|
||||
throw new DisplayException(trans('admin/exceptions.databases.delete_has_databases'));
|
||||
throw new DisplayException(trans('exceptions.databases.delete_has_databases'));
|
||||
}
|
||||
|
||||
return $this->repository->delete($id);
|
||||
|
|
|
@ -80,7 +80,7 @@ class NodeDeletionService
|
|||
|
||||
$servers = $this->serverRepository->withColumns('id')->findCountWhere([['node_id', '=', $node]]);
|
||||
if ($servers > 0) {
|
||||
throw new HasActiveServersException($this->translator->trans('admin/exceptions.node.servers_attached'));
|
||||
throw new HasActiveServersException($this->translator->trans('exceptions.node.servers_attached'));
|
||||
}
|
||||
|
||||
return $this->repository->delete($node);
|
||||
|
|
|
@ -95,7 +95,7 @@ class NodeUpdateService
|
|||
$response = $exception->getResponse();
|
||||
$this->writer->warning($exception);
|
||||
|
||||
throw new DisplayException(trans('admin/exceptions.node.daemon_off_config_updated', [
|
||||
throw new DisplayException(trans('exceptions.node.daemon_off_config_updated', [
|
||||
'code' => is_null($response) ? 'E_CONN_REFUSED' : $response->getStatusCode(),
|
||||
]));
|
||||
}
|
||||
|
|
|
@ -86,11 +86,11 @@ class PackCreationService
|
|||
{
|
||||
if (! is_null($file)) {
|
||||
if (! $file->isValid()) {
|
||||
throw new InvalidFileUploadException(trans('admin/exceptions.packs.invalid_upload'));
|
||||
throw new InvalidFileUploadException(trans('exceptions.packs.invalid_upload'));
|
||||
}
|
||||
|
||||
if (! in_array($file->getMimeType(), self::VALID_UPLOAD_TYPES)) {
|
||||
throw new InvalidFileMimeTypeException(trans('admin/exceptions.packs.invalid_mime', [
|
||||
throw new InvalidFileMimeTypeException(trans('exceptions.packs.invalid_mime', [
|
||||
'type' => implode(', ', self::VALID_UPLOAD_TYPES),
|
||||
]));
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ class PackDeletionService
|
|||
|
||||
$count = $this->serverRepository->findCountWhere([['pack_id', '=', $pack->id]]);
|
||||
if ($count !== 0) {
|
||||
throw new HasActiveServersException(trans('admin/exceptions.packs.delete_has_servers'));
|
||||
throw new HasActiveServersException(trans('exceptions.packs.delete_has_servers'));
|
||||
}
|
||||
|
||||
$this->connection->beginTransaction();
|
||||
|
|
|
@ -76,7 +76,7 @@ class PackUpdateService
|
|||
$count = $this->serverRepository->findCountWhere([['pack_id', '=', $pack->id]]);
|
||||
|
||||
if ($count !== 0) {
|
||||
throw new HasActiveServersException(trans('admin/exceptions.packs.update_has_servers'));
|
||||
throw new HasActiveServersException(trans('exceptions.packs.update_has_servers'));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -81,11 +81,11 @@ class TemplateUploadService
|
|||
public function handle($option, UploadedFile $file)
|
||||
{
|
||||
if (! $file->isValid()) {
|
||||
throw new InvalidFileUploadException(trans('admin/exceptions.packs.invalid_upload'));
|
||||
throw new InvalidFileUploadException(trans('exceptions.packs.invalid_upload'));
|
||||
}
|
||||
|
||||
if (! in_array($file->getMimeType(), self::VALID_UPLOAD_TYPES)) {
|
||||
throw new InvalidFileMimeTypeException(trans('admin/exceptions.packs.invalid_mime', [
|
||||
throw new InvalidFileMimeTypeException(trans('exceptions.packs.invalid_mime', [
|
||||
'type' => implode(', ', self::VALID_UPLOAD_TYPES),
|
||||
]));
|
||||
}
|
||||
|
@ -117,11 +117,11 @@ class TemplateUploadService
|
|||
protected function handleArchive($option, $file)
|
||||
{
|
||||
if (! $this->archive->open($file->getRealPath())) {
|
||||
throw new UnreadableZipArchiveException(trans('admin/exceptions.packs.unreadable'));
|
||||
throw new UnreadableZipArchiveException(trans('exceptions.packs.unreadable'));
|
||||
}
|
||||
|
||||
if (! $this->archive->locateName('import.json') || ! $this->archive->locateName('archive.tar.gz')) {
|
||||
throw new InvalidPackArchiveFormatException(trans('admin/exceptions.packs.invalid_archive_exception'));
|
||||
throw new InvalidPackArchiveFormatException(trans('exceptions.packs.invalid_archive_exception'));
|
||||
}
|
||||
|
||||
$json = json_decode($this->archive->getFromName('import.json'), true);
|
||||
|
@ -130,7 +130,7 @@ class TemplateUploadService
|
|||
$pack = $this->creationService->handle($json);
|
||||
if (! $this->archive->extractTo(storage_path('app/packs/' . $pack->uuid), 'archive.tar.gz')) {
|
||||
// @todo delete the pack that was created.
|
||||
throw new ZipExtractionException(trans('admin/exceptions.packs.zip_extraction'));
|
||||
throw new ZipExtractionException(trans('exceptions.packs.zip_extraction'));
|
||||
}
|
||||
|
||||
$this->archive->close();
|
||||
|
|
|
@ -63,7 +63,7 @@ class InstallScriptUpdateService
|
|||
|
||||
if (! is_null(array_get($data, 'copy_script_from'))) {
|
||||
if (! $this->repository->isCopiableScript(array_get($data, 'copy_script_from'), $option->service_id)) {
|
||||
throw new InvalidCopyFromException(trans('admin/exceptions.service.options.invalid_copy_id'));
|
||||
throw new InvalidCopyFromException(trans('exceptions.service.options.invalid_copy_id'));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ class OptionCreationService
|
|||
]);
|
||||
|
||||
if ($results !== 1) {
|
||||
throw new NoParentConfigurationFoundException(trans('admin/exceptions.service.options.must_be_child'));
|
||||
throw new NoParentConfigurationFoundException(trans('exceptions.service.options.must_be_child'));
|
||||
}
|
||||
} else {
|
||||
$data['config_from'] = null;
|
||||
|
|
|
@ -69,7 +69,7 @@ class OptionDeletionService
|
|||
]);
|
||||
|
||||
if ($servers > 0) {
|
||||
throw new HasActiveServersException(trans('admin/exceptions.service.options.delete_has_servers'));
|
||||
throw new HasActiveServersException(trans('exceptions.service.options.delete_has_servers'));
|
||||
}
|
||||
|
||||
return $this->repository->delete($option);
|
||||
|
|
|
@ -68,7 +68,7 @@ class OptionUpdateService
|
|||
]);
|
||||
|
||||
if ($results !== 1) {
|
||||
throw new NoParentConfigurationFoundException(trans('admin/exceptions.service.options.must_be_child'));
|
||||
throw new NoParentConfigurationFoundException(trans('exceptions.service.options.must_be_child'));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ class ServiceDeletionService
|
|||
{
|
||||
$count = $this->serverRepository->findCountWhere([['service_id', '=', $service]]);
|
||||
if ($count > 0) {
|
||||
throw new HasActiveServersException(trans('admin/exceptions.service.delete_has_servers'));
|
||||
throw new HasActiveServersException(trans('exceptions.service.delete_has_servers'));
|
||||
}
|
||||
|
||||
return $this->repository->delete($service);
|
||||
|
|
|
@ -66,7 +66,7 @@ class VariableUpdateService
|
|||
|
||||
if (! is_null(array_get($data, 'env_variable'))) {
|
||||
if (in_array(strtoupper(array_get($data, 'env_variable')), explode(',', ServiceVariable::RESERVED_ENV_NAMES))) {
|
||||
throw new ReservedVariableNameException(trans('admin/exceptions.service.variables.reserved_name', [
|
||||
throw new ReservedVariableNameException(trans('exceptions.service.variables.reserved_name', [
|
||||
'name' => array_get($data, 'env_variable'),
|
||||
]));
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ class VariableUpdateService
|
|||
]);
|
||||
|
||||
if ($search > 0) {
|
||||
throw new DisplayException(trans('admin/exceptions.service.variables.env_not_unique', [
|
||||
throw new DisplayException(trans('exceptions.service.variables.env_not_unique', [
|
||||
'name' => array_get($data, 'env_variable'),
|
||||
]));
|
||||
}
|
||||
|
|
|
@ -131,12 +131,12 @@ class SubuserCreationService
|
|||
]);
|
||||
} else {
|
||||
if ($server->owner_id === $user->id) {
|
||||
throw new UserIsServerOwnerException(trans('admin/exceptions.subusers.user_is_owner'));
|
||||
throw new UserIsServerOwnerException(trans('exceptions.subusers.user_is_owner'));
|
||||
}
|
||||
|
||||
$subuserCount = $this->subuserRepository->findCountWhere([['user_id', '=', $user->id], ['server_id', '=', $server->id]]);
|
||||
if ($subuserCount !== 0) {
|
||||
throw new ServerSubuserExistsException(trans('admin/exceptions.subusers.subuser_exists'));
|
||||
throw new ServerSubuserExistsException(trans('exceptions.subusers.subuser_exists'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ class SubuserCreationService
|
|||
$this->writer->warning($exception);
|
||||
|
||||
$response = $exception->getResponse();
|
||||
throw new DisplayException(trans('admin/exceptions.daemon_connection_failed', [
|
||||
throw new DisplayException(trans('exceptions.daemon_connection_failed', [
|
||||
'code' => is_null($response) ? 'E_CONN_REFUSED' : $response->getStatusCode(),
|
||||
]));
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ class SubuserDeletionService
|
|||
$this->writer->warning($exception);
|
||||
|
||||
$response = $exception->getResponse();
|
||||
throw new DisplayException(trans('admin/exceptions.daemon_connection_failed', [
|
||||
throw new DisplayException(trans('exceptions.daemon_connection_failed', [
|
||||
'code' => is_null($response) ? 'E_CONN_REFUSED' : $response->getStatusCode(),
|
||||
]));
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ class SubuserUpdateService
|
|||
$this->writer->warning($exception);
|
||||
|
||||
$response = $exception->getResponse();
|
||||
throw new DisplayException(trans('admin/exceptions.daemon_connection_failed', [
|
||||
throw new DisplayException(trans('exceptions.daemon_connection_failed', [
|
||||
'code' => is_null($response) ? 'E_CONN_REFUSED' : $response->getStatusCode(),
|
||||
]));
|
||||
}
|
||||
|
|
Reference in a new issue