Improved formatting

This commit is contained in:
Max Nuding 2021-11-27 10:59:29 +01:00
parent 19db5f3575
commit ae4eb30a73
Signed by: phlaym
GPG Key ID: A06651BAB6777237
4 changed files with 36 additions and 21 deletions

View File

@ -3,7 +3,9 @@ session_start();
require __DIR__ . '/vendor/autoload.php'; require __DIR__ . '/vendor/autoload.php';
use PhotoPrismUpload\API\PhotoPrism; use PhotoPrismUpload\API\PhotoPrism;
$footer = '<footer style="position: fixed;bottom: 0;left: 0;"><a href="/git/phlaym/photoprismupload">Ich bin Open Source</a></footer>';
$footer = '<footer style="position: fixed;bottom: 0;left: 0;">'
.'<a href="/git/phlaym/photoprismupload">Ich bin Open Source</a></footer>';
?> ?>
<html> <html>
<head> <head>
@ -258,7 +260,9 @@ if (!isset($_POST['submit'])) {
window.tooManyFiles = fileList.length > maxAmountOfFiles; window.tooManyFiles = fileList.length > maxAmountOfFiles;
if (window.tooManyFiles) { if (window.tooManyFiles) {
errorDiv.style.display = 'block'; errorDiv.style.display = 'block';
errorDiv.innerHTML += `Das sind zu viele Dateien, du darfst max. ${maxAmountOfFiles} Dateien gleichzeitig hochladen. `; errorDiv.innerHTML += ```
Das sind zu viele Dateien, du darfst max.
${maxAmountOfFiles} Dateien gleichzeitig hochladen. ```;
submitButton.disabled = true; submitButton.disabled = true;
console.warn('Total files:', target.files.length, '. Too many!'); console.warn('Total files:', target.files.length, '. Too many!');
} }
@ -267,8 +271,12 @@ if (!isset($_POST['submit'])) {
if (window.tooLarge) { if (window.tooLarge) {
const names = filesTooLarge.join(', ') const names = filesTooLarge.join(', ')
errorDiv.style.display = 'block'; errorDiv.style.display = 'block';
const pluralizedMessage = filesTooLarge.length > 1 ? 'Die folgenden Dateien sind' : 'Die folgende Datei ist'; const pluralizedMessage = filesTooLarge.length > 1
errorDiv.innerHTML += `${pluralizedMessage} zu groß: ${names}. Jede Datei darf max. ${maxFileSize} MB groß sein.`; ? 'Die folgenden Dateien sind'
: 'Die folgende Datei ist';
errorDiv.innerHTML += ```
${pluralizedMessage} zu groß: ${names}.
Jede Datei darf max. ${maxFileSize} MB groß sein.```;
submitButton.disabled = true; submitButton.disabled = true;
} }
}); });

22
src/API/LoggerFactory.php Normal file
View File

@ -0,0 +1,22 @@
<?php
namespace PhotoPrismUpload\API;
use Monolog\Logger;
use Monolog\Handler\HandlerInterface;
class LoggerFactory
{
private static $handlers = [];
public static function addHandler(HandlerInterface $handler)
{
self::$handlers[] = $handler;
}
public static function create(string $name)
{
$l = new Logger($name);
$l->setHandlers(self::$handlers);
$l->info('Initialized');
return $l;
}
}

View File

@ -4,27 +4,11 @@ namespace PhotoPrismUpload\API;
use Monolog\Logger; use Monolog\Logger;
use Monolog\Handler\RotatingFileHandler; use Monolog\Handler\RotatingFileHandler;
use Monolog\Handler\HandlerInterface;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use PhotoPrismUpload\Exceptions\NetworkException; use PhotoPrismUpload\Exceptions\NetworkException;
use PhotoPrismUpload\Exceptions\AuthenticationException; use PhotoPrismUpload\Exceptions\AuthenticationException;
use PhotoPrismUpload\Entities\Album; use PhotoPrismUpload\Entities\Album;
class LoggerFactory
{
private static $handlers = [];
public static function addHandler(HandlerInterface $handler) {
self::$handlers[] = $handler;
}
public static function create(string $name) {
$l = new Logger($name);
$l->setHandlers(self::$handlers);
$l->info('Initialized');
return $l;
}
}
class PhotoPrism class PhotoPrism
{ {
protected string $base_url = 'https://photos.phlaym.net'; protected string $base_url = 'https://photos.phlaym.net';

View File

@ -20,7 +20,8 @@ class Album
$this->logger = LoggerFactory::create('PhotoPrismUpload.Album'); $this->logger = LoggerFactory::create('PhotoPrismUpload.Album');
} }
public function getUrlPath(): ?string { public function getUrlPath(): ?string
{
if (empty($this->token)) { if (empty($this->token)) {
return null; return null;
} }