Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completely new front-end & version 5.0.0! #2035

Merged
merged 25 commits into from
Dec 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ APP_FORCE_HTTPS=false
# Do note that this disable CSP!!
DEBUGBAR_ENABLED=false

# enable or disable the v5 layout.
LIVEWIRE_ENABLED=true

# enable or disable log viewer. By default it is enabled.
LOG_VIEWER_ENABLED=true

Expand Down Expand Up @@ -101,3 +104,6 @@ TRUSTED_PROXIES=null

# Comma-separated list of class names of diagnostics checks that should be skipped.
#SKIP_DIAGNOSTICS_CHECKS=

VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
1 change: 1 addition & 0 deletions .github/workflows/.env.mariadb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ APP_URL=https://localhost
APP_ENV=dev
APP_KEY=SomeRandomString
APP_DEBUG=true
LIVEWIRE_ENABLED=false

DB_CONNECTION=mysql
DB_HOST=localhost
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/.env.postgresql
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ APP_URL=https://localhost
APP_ENV=dev
APP_KEY=SomeRandomString
APP_DEBUG=true
LIVEWIRE_ENABLED=false

DB_CONNECTION=pgsql
DB_HOST=localhost
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/.env.sqlite
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ APP_URL=https://localhost
APP_ENV=dev
APP_KEY=SomeRandomString
APP_DEBUG=true
LIVEWIRE_ENABLED=false

DB_CONNECTION=sqlite
DB_LIST_FOREIGN_KEYS=true
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/CICD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,35 @@ jobs:
- name: Check source code for code style errors
run: PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --verbose --diff --dry-run

check_js:
name: 2️⃣ JS Node ${{ matrix.node-version }} - Code Style errors & Compilation
runs-on: ubuntu-latest
needs:
- php_syntax_errors
strategy:
matrix:
node-version: [16, 18, 20]
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Install
run: npm install -D

- name: Check Style
run: npm run check-formatting

- name: Check TypeScript
run: npm run check

- name: Compile Front-end
run: npm run build

phpstan:
name: 2️⃣ PHP 8.2 - PHPStan
runs-on: ubuntu-latest
Expand Down Expand Up @@ -106,6 +135,7 @@ jobs:
- sqlite
test-suite:
- Feature
- Livewire
# Service containers to run with `container-job`
services:
# Label used to access the service container
Expand Down Expand Up @@ -282,6 +312,17 @@ jobs:
with:
composer-options: --no-dev

- name: Use Node.js 20
uses: actions/setup-node@v3
with:
node-version: 20

- name: Install
run: npm install

- name: Compile Front-end
run: npm run build

- name: Build Dist
run: |
make clean dist
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ build/*
# Those are personal
public/dist/user.css
public/dist/custom.js
public/build/*

# Pictures we do not commit
public/uploads/**
public/uploads-*/**

# Storage stuff: useless
/storage/*.key
Expand Down
3 changes: 3 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"printWidth": 150
}
19 changes: 18 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ composer:
composer install --prefer-dist --no-dev
php artisan vendor:publish --tag=log-viewer-asset

dist-gen: clean composer
npm-build:
rm -r public/build 2> /dev/null || true
rm -r node_modules 2> /dev/null || true
npm install
npm run build

dist-gen: clean composer npm-build
@echo "packaging..."
@mkdir Lychee
@mkdir Lychee/public
Expand All @@ -19,6 +25,7 @@ dist-gen: clean composer
@cp -r config Lychee
@cp -r composer-cache Lychee
@cp -r database Lychee
@cp -r public/build Lychee/public
@cp -r public/dist Lychee/public
@cp -r public/vendor Lychee/public
@cp -r public/installer Lychee/public
Expand Down Expand Up @@ -46,6 +53,7 @@ dist-gen: clean composer
@cp -r version.md Lychee
@touch Lychee/storage/logs/laravel.log
@touch Lychee/public/dist/user.css
@touch Lychee/public/dist/custom.js
@touch Lychee/public/uploads/import/index.html
@touch Lychee/public/sym/index.html

Expand All @@ -63,6 +71,12 @@ dist: dist-clean
clean:
@rm build/* 2> /dev/null || true
@rm -r Lychee 2> /dev/null || true
@rm -r public/build 2> /dev/null || true
@rm -r node_modules 2> /dev/null || true
@rm -r vendor 2> /dev/null || true

install: composer npm-build
php artisan migrate

test:
@if [ -x "vendor/bin/phpunit" ]; then \
Expand Down Expand Up @@ -90,6 +104,7 @@ formatting:
phpstan:
vendor/bin/phpstan analyze

# Generating new versions
gen_minor:
php scripts/gen_release.php
git add database
Expand All @@ -106,6 +121,8 @@ gen_major:
release_major: gen_major
git commit -m "bump to version $(shell cat version.md)"

# Building tests 1 by 1

TESTS_PHP := $(shell find tests/Feature -name "*Test.php" -printf "%f\n")
TEST_DONE := $(addprefix build/,$(TESTS_PHP:.php=.done))

Expand Down
10 changes: 10 additions & 0 deletions app/Actions/Diagnostics/Pipes/Infos/SystemInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use App\Actions\Diagnostics\Diagnostics;
use App\Contracts\DiagnosticPipe;
use App\Facades\Helpers;
use App\Livewire\Components\Forms\Add\Upload;
use Carbon\CarbonTimeZone;
use Illuminate\Database\QueryException;
use Illuminate\Support\Facades\DB;
Expand Down Expand Up @@ -53,10 +55,18 @@ public function handle(array &$data, \Closure $next): array
$data[] = Diagnostics::line('Timezone:', ($timeZone !== false ? $timeZone : null)?->getName());
$data[] = Diagnostics::line('Max uploaded file size:', ini_get('upload_max_filesize'));
$data[] = Diagnostics::line('Max post size:', ini_get('post_max_size'));
$this->getUploadLimit($data);
$data[] = Diagnostics::line('Max execution time: ', ini_get('max_execution_time'));
$data[] = Diagnostics::line($dbtype . ' Version:', $dbver);
$data[] = '';

return $next($data);
}

private function getUploadLimit(array &$data): void
{
$size = Upload::getUploadLimit();

$data[] = Diagnostics::line('Livewire chunk size:', Helpers::getSymbolByQuantity($size));
}
}
25 changes: 20 additions & 5 deletions app/Actions/Search/PhotoSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use App\Models\Extensions\SortingDecorator;
use App\Models\Photo;
use App\Policies\PhotoQueryPolicy;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;

class PhotoSearch
Expand All @@ -20,9 +21,27 @@ public function __construct(PhotoQueryPolicy $photoQueryPolicy)
}

/**
* Apply search directly.
*
* @throws InternalLycheeException
*/
public function query(array $terms): Collection
{
$query = $this->sqlQuery($terms);
$sorting = PhotoSortingCriterion::createDefault();

return (new SortingDecorator($query))
->orderBy($sorting->column, $sorting->order)->get();
}

/**
* Create the query manually.
*
* @param array $terms
*
* @return Builder
*/
public function sqlQuery(array $terms): Builder
{
$query = $this->photoQueryPolicy->applySearchabilityFilter(
Photo::query()->with(['album', 'size_variants', 'size_variants.sym_links'])
Expand All @@ -40,10 +59,6 @@ public function query(array $terms): Collection
);
}

$sorting = PhotoSortingCriterion::createDefault();

return (new SortingDecorator($query))
->orderBy($sorting->column, $sorting->order)
->get();
return $query;
}
}
48 changes: 48 additions & 0 deletions app/Assets/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,52 @@ public function convertSize(string $size): int

return $size;
}

/**
* Converts a decimal degree into integer degree, minutes and seconds.
*
* @param float|null $decimal
* @param bool $type - indicates if the passed decimal indicates a
* latitude (`true`) or a longitude (`false`)
*
* @returns string
*/
public function decimalToDegreeMinutesSeconds(float|null $decimal, bool $type): null|string
{
if ($decimal === null) {
return null;
}

$d = abs($decimal);

// absolute value of decimal must be smaller than 180;
if ($d > 180) {
return '';
}

// set direction; north assumed
if ($type && $decimal < 0) {
$direction = 'S';
} elseif (!$type && $decimal < 0) {
$direction = 'W';
} elseif (!$type) {
$direction = 'E';
} else {
$direction = 'N';
}

// get degrees
$degrees = floor($d);

// get seconds
$seconds = ($d - $degrees) * 3600;

// get minutes
$minutes = floor($seconds / 60);

// reset seconds
$seconds = floor($seconds - $minutes * 60);

return $degrees . '° ' . $minutes . "' " . $seconds . '" ' . $direction;
}
}
32 changes: 32 additions & 0 deletions app/Contracts/Livewire/Openable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace App\Contracts\Livewire;

/**
* This defines components which have an openable state.
*
* @property bool $isOpen whether the Openable component is open or not.
*/
interface Openable
{
/**
* Open the component.
*
* @return void
*/
public function open(): void;

/**
* Close the component.
*
* @return void
*/
public function close(): void;

/**
* Toggle the component.
*
* @return void
*/
public function toggle(): void;
}
17 changes: 17 additions & 0 deletions app/Contracts/Livewire/Params.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace App\Contracts\Livewire;

/**
* This defines constants which are used as keys when sending dispatch messages between components.
*/
interface Params
{
public const PARENT_ID = 'parentID';

public const ALBUM_ID = 'albumID';
public const ALBUM_IDS = 'albumIDs';

public const PHOTO_ID = 'photoID';
public const PHOTO_IDS = 'photoIDs';
}
8 changes: 8 additions & 0 deletions app/Contracts/Livewire/Reloadable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace App\Contracts\Livewire;

interface Reloadable
{
public function reloadPage(): void;
}
16 changes: 16 additions & 0 deletions app/Enum/AlbumDecorationOrientation.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,20 @@ enum AlbumDecorationOrientation: string
case ROW_REVERSE = 'row-reverse';
case COLUMN = 'column';
case COLUMN_REVERSE = 'column-reverse';

/**
* Convert the enum into it's translated format.
* Note that it is missing owner.
*
* @return array<string,string>
*/
public static function localized(): array
{
return [
self::ROW->value => __('lychee.ALBUM_DECORATION_ORIENTATION_ROW'),
self::ROW_REVERSE->value => __('lychee.ALBUM_DECORATION_ORIENTATION_ROW_REVERSE'),
self::COLUMN->value => __('lychee.ALBUM_DECORATION_ORIENTATION_COLUMN'),
self::COLUMN_REVERSE->value => __('lychee.ALBUM_DECORATION_ORIENTATION_COLUMN_REVERSE'),
];
}
}
Loading