Compare commits

..

No commits in common. "19db5f35758a4f5fe338d0f763ccddaecce1183b" and "f8e72356a35e19fa4a644d2b9088d0c792fc402a" have entirely different histories.

3 changed files with 10 additions and 63 deletions

View File

@ -41,7 +41,6 @@ $footer = '<footer style="position: fixed;bottom: 0;left: 0;"><a href="/git/phla
label[for="album"] {
grid-column: 1;
grid-row: 1;
align-self: center;
}
#album {
grid-column: 2;
@ -85,9 +84,6 @@ $footer = '<footer style="position: fixed;bottom: 0;left: 0;"><a href="/git/phla
grid-row: 6;
width: 100%;
}
#viewAlbum {
#grid-row: 7;
}
footer {
margin: 8px;
}
@ -111,7 +107,6 @@ if (!isset($_POST['submit'])) {
}
$token = $_GET['token'];
$tokens = explode(',', $token);
$album_url = null;
try {
$albums = $api->getAlbumsByTokens($tokens);
} catch (\Exception $e) {
@ -122,29 +117,18 @@ if (!isset($_POST['submit'])) {
}
?>
<div class="form-wrapper">
<!--<form method="POST" enctype="multipart/form-data" onsubmit="return validateForm();" id="uploadForm"> !-->
<form method="POST" enctype="multipart/form-data" id="uploadForm">
<label for="album">Zu Album hinzufügen</label>
<select name="album" id="album">
<option value="" data-url="/">---</option>
<option value="">---</option>
<?php foreach ($albums as $album) {
$selected = $album->token === $token ? ' selected' : '';
if ($album->token === $token) {
$album_url = $album->getUrlPath();
}
echo '<option value="'
. $album->uid
. '"'
. $selected
. 'data-url='
. ($album->getUrlPath() ?? '/')
. '>'
. $album->title
. '</option>\n';
}
$album_url ??= '/';
$album_url = "https://photos.phlaym.net{$album_url}";
?>
echo '<option value="' . $album->uid . '"' . $selected . '>' . $album->title . '</option>\n';
} ?>
</select>
<!--<label></label>
<input type="text" />!-->
<input multiple type="file" name="files[]" id="input" required/>
<input type="submit" name="submit" value="Upload" />
</form>
@ -153,7 +137,6 @@ if (!isset($_POST['submit'])) {
<progress id="fileProgress"></progress>
<label for="totalProgress">Gesamt:</label>
<progress max="0" value="0" id="totalProgress"></progress>
<a href="<?=$album_url;?>" target="_blank" id="viewAlbum">Album ansehen</a>
</div>
<script>
window.tooLarge = false;
@ -167,7 +150,6 @@ if (!isset($_POST['submit'])) {
const fileProgressLabel = document.querySelector('label[for=fileProgress]');
const totalProgressLabel = document.querySelector('label[for=totalProgress]');
const errorDiv = document.getElementById('error');
const albumAnchor = document.getElementById('viewAlbum');
async function postData(url, data = {}, method = 'POST') {
const response = await fetch(url, {
@ -177,11 +159,6 @@ if (!isset($_POST['submit'])) {
return response;
}
albumInput.addEventListener('change', (event) => {
console.log(event);
albumAnchor.href = `https://photos.phlaym.net${albumInput.selectedOptions[0].dataset.url}`;
});
form.addEventListener('submit', async function(event) {
event.preventDefault();
const isInvalid = window.tooLarge || window.tooManyFiles;
@ -242,13 +219,7 @@ if (!isset($_POST['submit'])) {
const sizeInMb = file.size / 1024 / 1024;
if (sizeInMb >= maxFileSize) {
filesTooLarge.push(file.name);
console.warn(
'File',
file.name,
'is',
sizeInMb,
'MB big, which is over the limit of',
maxFileSize);
console.warn('File', file.name, 'is', sizeInMb, 'MB big, which is over the limit of', maxFileSize);
}
fileList.push(file);
}

View File

@ -4,27 +4,11 @@ namespace PhotoPrismUpload\API;
use Monolog\Logger;
use Monolog\Handler\RotatingFileHandler;
use Monolog\Handler\HandlerInterface;
use Psr\Log\LoggerInterface;
use PhotoPrismUpload\Exceptions\NetworkException;
use PhotoPrismUpload\Exceptions\AuthenticationException;
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
{
protected string $base_url = 'https://photos.phlaym.net';
@ -39,11 +23,12 @@ class PhotoPrism
) {
$this->api_url = $this->base_url.'/api/v1';
$this->config = $config;
$this->logger = new Logger('PhotoPrismUpload');
if (empty($log_path)) {
$log_path = __DIR__.'/logs/log.log';
}
LoggerFactory::addHandler(new RotatingFileHandler($log_path, 5, Logger::DEBUG, true));
$this->logger = LoggerFactory::create('PhotoPrismUpload');
$handler = new RotatingFileHandler($log_path, 5, Logger::DEBUG, true);
$this->logger->pushHandler($handler);
if (isset($_SESSION['pp_sessionid'])) {
$this->session_id = $_SESSION['pp_sessionid'];
}

View File

@ -2,7 +2,6 @@
namespace PhotoPrismUpload\Entities;
use Monolog\Logger;
use PhotoPrismUpload\API\LoggerFactory;
class Album
{
@ -17,13 +16,5 @@ class Album
$this->uid = $response['UID'];
$this->slug = $response['Slug'];
$this->title = $response['Title'];
$this->logger = LoggerFactory::create('PhotoPrismUpload.Album');
}
public function getUrlPath(): ?string {
if (empty($this->token)) {
return null;
}
return "/s/{$this->token}/{$this->slug}";
}
}