From af38c241984ae466d6f0baa436e88bfe9dfd548d Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Fri, 9 Sep 2022 00:31:42 -0700 Subject: [PATCH] Tab -> Space --- appinfo/info.xml | 4 +- appinfo/routes.php | 14 +- css/custom-icons.scss | 2 +- lib/AppInfo/Application.php | 58 ++-- lib/Command/Index.php | 238 ++++++++-------- lib/Controller/ApiController.php | 268 +++++++++--------- lib/Controller/PageController.php | 94 +++--- lib/Db/TimelineQuery.php | 12 +- lib/Db/TimelineWrite.php | 8 +- lib/Listeners/PostDeleteListener.php | 24 +- lib/Listeners/PostWriteListener.php | 30 +- .../Version000000Date20220812163631.php | 18 +- src/App.vue | 118 ++++---- src/components/Settings.vue | 12 +- src/components/Timeline.vue | 12 +- src/main.js | 24 +- src/services/DavRequests.js | 216 +++++++------- src/services/NumberUtils.js | 8 +- 18 files changed, 580 insertions(+), 580 deletions(-) diff --git a/appinfo/info.xml b/appinfo/info.xml index 66599952..714441a5 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -35,8 +35,8 @@ - OCA\Memories\Command\Index - + OCA\Memories\Command\Index + Memories diff --git a/appinfo/routes.php b/appinfo/routes.php index c8782287..68cfdd30 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -4,13 +4,13 @@ return [ // Days and folder API ['name' => 'page#main', 'url' => '/', 'verb' => 'GET'], ['name' => 'page#folder', 'url' => '/folders/{path}', 'verb' => 'GET', - 'requirements' => [ - 'path' => '.*', - ], - 'defaults' => [ - 'path' => '', - ] - ], + 'requirements' => [ + 'path' => '.*', + ], + 'defaults' => [ + 'path' => '', + ] + ], // API ['name' => 'api#days', 'url' => '/api/days', 'verb' => 'GET'], diff --git a/css/custom-icons.scss b/css/custom-icons.scss index 8dee2c8f..6972a266 100644 --- a/css/custom-icons.scss +++ b/css/custom-icons.scss @@ -22,7 +22,7 @@ */ .icon-folder.icon-dark { - @include icon-color('folder', 'filetypes', $color-black, 1, true); + @include icon-color('folder', 'filetypes', $color-black, 1, true); } @include icon-black-white('yourmemories', 'memories', 1); \ No newline at end of file diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 5d6f204a..4bf3a45e 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -37,40 +37,40 @@ use OCP\Files\Events\Node\NodeDeletedEvent; use OCP\Files\Events\Node\NodeTouchedEvent; class Application extends App implements IBootstrap { - public const APPNAME = 'memories'; + public const APPNAME = 'memories'; - public const IMAGE_MIMES = [ - 'image/png', - 'image/jpeg', - 'image/heic', - 'image/png', - 'image/tiff', - // 'image/gif', // too rarely used for photos - // 'image/x-xbitmap', // too rarely used for photos - // 'image/bmp', // too rarely used for photos - // 'image/svg+xml', // too rarely used for photos - ]; + public const IMAGE_MIMES = [ + 'image/png', + 'image/jpeg', + 'image/heic', + 'image/png', + 'image/tiff', + // 'image/gif', // too rarely used for photos + // 'image/x-xbitmap', // too rarely used for photos + // 'image/bmp', // too rarely used for photos + // 'image/svg+xml', // too rarely used for photos + ]; - public const VIDEO_MIMES = [ - 'video/mpeg', - // 'video/ogg', // too rarely used for photos - // 'video/webm', // too rarely used for photos - 'video/mp4', - // 'video/x-m4v', // too rarely used for photos - 'video/quicktime', - 'video/x-matroska', - ]; + public const VIDEO_MIMES = [ + 'video/mpeg', + // 'video/ogg', // too rarely used for photos + // 'video/webm', // too rarely used for photos + 'video/mp4', + // 'video/x-m4v', // too rarely used for photos + 'video/quicktime', + 'video/x-matroska', + ]; - public function __construct() { - parent::__construct(self::APPNAME); - } + public function __construct() { + parent::__construct(self::APPNAME); + } - public function register(IRegistrationContext $context): void { - $context->registerEventListener(NodeWrittenEvent::class, PostWriteListener::class); + public function register(IRegistrationContext $context): void { + $context->registerEventListener(NodeWrittenEvent::class, PostWriteListener::class); $context->registerEventListener(NodeTouchedEvent::class, PostWriteListener::class); $context->registerEventListener(NodeDeletedEvent::class, PostDeleteListener::class); - } + } - public function boot(IBootContext $context): void { - } + public function boot(IBootContext $context): void { + } } \ No newline at end of file diff --git a/lib/Command/Index.php b/lib/Command/Index.php index d8768c21..7cdfffbd 100644 --- a/lib/Command/Index.php +++ b/lib/Command/Index.php @@ -46,149 +46,149 @@ use Symfony\Component\Console\Output\OutputInterface; class Index extends Command { - /** @var ?GlobalStoragesService */ - protected $globalService; + /** @var ?GlobalStoragesService */ + protected $globalService; - /** @var int[][] */ - protected array $sizes; + /** @var int[][] */ + protected array $sizes; - protected IUserManager $userManager; - protected IRootFolder $rootFolder; - protected IPreview $previewGenerator; - protected IConfig $config; - protected OutputInterface $output; - protected IManager $encryptionManager; - protected IDBConnection $connection; - protected TimelineWrite $timelineWrite; + protected IUserManager $userManager; + protected IRootFolder $rootFolder; + protected IPreview $previewGenerator; + protected IConfig $config; + protected OutputInterface $output; + protected IManager $encryptionManager; + protected IDBConnection $connection; + protected TimelineWrite $timelineWrite; - // Stats - private int $nProcessed = 0; - private int $nSkipped = 0; - private int $nInvalid = 0; + // Stats + private int $nProcessed = 0; + private int $nSkipped = 0; + private int $nInvalid = 0; - public function __construct(IRootFolder $rootFolder, - IUserManager $userManager, - IPreview $previewGenerator, - IConfig $config, - IManager $encryptionManager, - IDBConnection $connection, - ContainerInterface $container) { - parent::__construct(); + public function __construct(IRootFolder $rootFolder, + IUserManager $userManager, + IPreview $previewGenerator, + IConfig $config, + IManager $encryptionManager, + IDBConnection $connection, + ContainerInterface $container) { + parent::__construct(); - $this->userManager = $userManager; - $this->rootFolder = $rootFolder; - $this->previewGenerator = $previewGenerator; - $this->config = $config; - $this->encryptionManager = $encryptionManager; - $this->connection = $connection; - $this->timelineWrite = new TimelineWrite($this->connection); + $this->userManager = $userManager; + $this->rootFolder = $rootFolder; + $this->previewGenerator = $previewGenerator; + $this->config = $config; + $this->encryptionManager = $encryptionManager; + $this->connection = $connection; + $this->timelineWrite = new TimelineWrite($this->connection); - try { - $this->globalService = $container->get(GlobalStoragesService::class); - } catch (ContainerExceptionInterface $e) { - $this->globalService = null; - } - } + try { + $this->globalService = $container->get(GlobalStoragesService::class); + } catch (ContainerExceptionInterface $e) { + $this->globalService = null; + } + } - /** Make sure exiftool is available */ - private function testExif() { - $testfile = dirname(__FILE__). '/../../exiftest.jpg'; - $stream = fopen($testfile, 'rb'); - if (!$stream) { - return false; - } + /** Make sure exiftool is available */ + private function testExif() { + $testfile = dirname(__FILE__). '/../../exiftest.jpg'; + $stream = fopen($testfile, 'rb'); + if (!$stream) { + return false; + } - $exif = \OCA\Memories\Exif::getExifFromStream($stream); - fclose($stream); + $exif = \OCA\Memories\Exif::getExifFromStream($stream); + fclose($stream); - if (!$exif || $exif["DateTimeOriginal"] !== "2004:08:31 19:52:58") { - return false; - } - return true; - } + if (!$exif || $exif["DateTimeOriginal"] !== "2004:08:31 19:52:58") { + return false; + } + return true; + } - protected function configure(): void { - $this - ->setName('memories:index') - ->setDescription('Generate entries'); - } + protected function configure(): void { + $this + ->setName('memories:index') + ->setDescription('Generate entries'); + } - protected function execute(InputInterface $input, OutputInterface $output): int { - // Refuse to run without exiftool - \OCA\Memories\Exif::ensureStaticExiftoolProc(); - if (!$this->testExif()) { - error_log('FATAL: exiftool could not be found or test failed'); - exit(1); - } + protected function execute(InputInterface $input, OutputInterface $output): int { + // Refuse to run without exiftool + \OCA\Memories\Exif::ensureStaticExiftoolProc(); + if (!$this->testExif()) { + error_log('FATAL: exiftool could not be found or test failed'); + exit(1); + } - // Time measurement - $startTime = microtime(true); + // Time measurement + $startTime = microtime(true); - if ($this->encryptionManager->isEnabled()) { - $output->writeln('Encryption is enabled. Aborted.'); - return 1; - } - $this->output = $output; + if ($this->encryptionManager->isEnabled()) { + $output->writeln('Encryption is enabled. Aborted.'); + return 1; + } + $this->output = $output; $this->userManager->callForSeenUsers(function (IUser $user) { $this->generateUserEntries($user); }); - // Close the exiftool process - \OCA\Memories\Exif::closeStaticExiftoolProc(); + // Close the exiftool process + \OCA\Memories\Exif::closeStaticExiftoolProc(); - // Show some stats - $endTime = microtime(true); - $execTime = intval(($endTime - $startTime)*1000)/1000 ; - $nTotal = $this->nInvalid + $this->nSkipped + $this->nProcessed; - $this->output->writeln("=========================================="); - $this->output->writeln("Checked $nTotal files in $execTime sec"); - $this->output->writeln($this->nInvalid . " not valid media items"); - $this->output->writeln($this->nSkipped . " skipped because unmodified"); - $this->output->writeln($this->nProcessed . " (re-)processed"); - $this->output->writeln("=========================================="); + // Show some stats + $endTime = microtime(true); + $execTime = intval(($endTime - $startTime)*1000)/1000 ; + $nTotal = $this->nInvalid + $this->nSkipped + $this->nProcessed; + $this->output->writeln("=========================================="); + $this->output->writeln("Checked $nTotal files in $execTime sec"); + $this->output->writeln($this->nInvalid . " not valid media items"); + $this->output->writeln($this->nSkipped . " skipped because unmodified"); + $this->output->writeln($this->nProcessed . " (re-)processed"); + $this->output->writeln("=========================================="); - return 0; - } + return 0; + } - private function generateUserEntries(IUser &$user): void { - \OC_Util::tearDownFS(); - \OC_Util::setupFS($user->getUID()); + private function generateUserEntries(IUser &$user): void { + \OC_Util::tearDownFS(); + \OC_Util::setupFS($user->getUID()); - $userFolder = $this->rootFolder->getUserFolder($user->getUID()); - $this->parseFolder($userFolder); - } + $userFolder = $this->rootFolder->getUserFolder($user->getUID()); + $this->parseFolder($userFolder); + } - private function parseFolder(Folder &$folder): void { - try { - $folderPath = $folder->getPath(); - $this->output->writeln('Scanning folder ' . $folderPath); + private function parseFolder(Folder &$folder): void { + try { + $folderPath = $folder->getPath(); + $this->output->writeln('Scanning folder ' . $folderPath); - $nodes = $folder->getDirectoryListing(); + $nodes = $folder->getDirectoryListing(); - foreach ($nodes as &$node) { - if ($node instanceof Folder) { - $this->parseFolder($node); - } elseif ($node instanceof File) { - $this->parseFile($node); - } - } - } catch (StorageNotAvailableException $e) { - $this->output->writeln(sprintf('Storage for folder folder %s is not available: %s', - $folder->getPath(), - $e->getHint() - )); - } - } + foreach ($nodes as &$node) { + if ($node instanceof Folder) { + $this->parseFolder($node); + } elseif ($node instanceof File) { + $this->parseFile($node); + } + } + } catch (StorageNotAvailableException $e) { + $this->output->writeln(sprintf('Storage for folder folder %s is not available: %s', + $folder->getPath(), + $e->getHint() + )); + } + } - private function parseFile(File &$file): void { - $res = $this->timelineWrite->processFile($file); - if ($res === 2) { - $this->nProcessed++; - } else if ($res === 1) { - $this->nSkipped++; - } else { - $this->nInvalid++; - } - } + private function parseFile(File &$file): void { + $res = $this->timelineWrite->processFile($file); + if ($res === 2) { + $this->nProcessed++; + } else if ($res === 1) { + $this->nSkipped++; + } else { + $this->nInvalid++; + } + } } \ No newline at end of file diff --git a/lib/Controller/ApiController.php b/lib/Controller/ApiController.php index cef617da..031ac4e8 100644 --- a/lib/Controller/ApiController.php +++ b/lib/Controller/ApiController.php @@ -41,172 +41,172 @@ use OCP\Files\FileInfo; use OCP\Files\Search\ISearchComparison; class ApiController extends Controller { - private IConfig $config; - private IUserSession $userSession; + private IConfig $config; + private IUserSession $userSession; private IDBConnection $connection; - private IRootFolder $rootFolder; - private TimelineQuery $timelineQuery; + private IRootFolder $rootFolder; + private TimelineQuery $timelineQuery; - public function __construct( - IRequest $request, - IConfig $config, - IUserSession $userSession, + public function __construct( + IRequest $request, + IConfig $config, + IUserSession $userSession, IDBConnection $connection, - IRootFolder $rootFolder) { + IRootFolder $rootFolder) { - parent::__construct(Application::APPNAME, $request); + parent::__construct(Application::APPNAME, $request); - $this->config = $config; - $this->userSession = $userSession; + $this->config = $config; + $this->userSession = $userSession; $this->connection = $connection; - $this->timelineQuery = new TimelineQuery($this->connection); - $this->rootFolder = $rootFolder; - } + $this->timelineQuery = new TimelineQuery($this->connection); + $this->rootFolder = $rootFolder; + } - /** - * @NoAdminRequired - * - * @return JSONResponse - */ - public function days(): JSONResponse { + /** + * @NoAdminRequired + * + * @return JSONResponse + */ + public function days(): JSONResponse { $user = $this->userSession->getUser(); - if (is_null($user)) { - return new JSONResponse([], Http::STATUS_PRECONDITION_FAILED); - } + if (is_null($user)) { + return new JSONResponse([], Http::STATUS_PRECONDITION_FAILED); + } $list = $this->timelineQuery->getDays($this->config, $user->getUID()); - return new JSONResponse($list, Http::STATUS_OK); - } + return new JSONResponse($list, Http::STATUS_OK); + } - /** - * @NoAdminRequired - * - * @return JSONResponse - */ - public function day(string $id): JSONResponse { + /** + * @NoAdminRequired + * + * @return JSONResponse + */ + public function day(string $id): JSONResponse { $user = $this->userSession->getUser(); - if (is_null($user) || !is_numeric($id)) { - return new JSONResponse([], Http::STATUS_PRECONDITION_FAILED); - } + if (is_null($user) || !is_numeric($id)) { + return new JSONResponse([], Http::STATUS_PRECONDITION_FAILED); + } $list = $this->timelineQuery->getDay($this->config, $user->getUID(), intval($id)); - return new JSONResponse($list, Http::STATUS_OK); - } + return new JSONResponse($list, Http::STATUS_OK); + } - /** - * Check if folder is allowed and get it if yes - */ - private function getAllowedFolder(int $folder, $user) { - // Get root if folder not specified - $root = $this->rootFolder->getUserFolder($user->getUID()); - if ($folder === 0) { - $folder = $root->getId(); - } + /** + * Check if folder is allowed and get it if yes + */ + private function getAllowedFolder(int $folder, $user) { + // Get root if folder not specified + $root = $this->rootFolder->getUserFolder($user->getUID()); + if ($folder === 0) { + $folder = $root->getId(); + } - // Check access to folder - $nodes = $root->getById($folder); - if (empty($nodes)) { - return NULL; - } + // Check access to folder + $nodes = $root->getById($folder); + if (empty($nodes)) { + return NULL; + } - // Check it is a folder - $node = $nodes[0]; - if (!$node instanceof \OCP\Files\Folder) { - return NULL; - } + // Check it is a folder + $node = $nodes[0]; + if (!$node instanceof \OCP\Files\Folder) { + return NULL; + } - return $node; - } + return $node; + } - /** - * @NoAdminRequired - * - * @return JSONResponse - */ - public function folder(string $folder): JSONResponse { + /** + * @NoAdminRequired + * + * @return JSONResponse + */ + public function folder(string $folder): JSONResponse { $user = $this->userSession->getUser(); - if (is_null($user) || !is_numeric($folder)) { - return new JSONResponse([], Http::STATUS_PRECONDITION_FAILED); - } + if (is_null($user) || !is_numeric($folder)) { + return new JSONResponse([], Http::STATUS_PRECONDITION_FAILED); + } - // Check permissions - $node = $this->getAllowedFolder(intval($folder), $user); - if (is_null($node)) { - return new JSONResponse([], Http::STATUS_FORBIDDEN); - } + // Check permissions + $node = $this->getAllowedFolder(intval($folder), $user); + if (is_null($node)) { + return new JSONResponse([], Http::STATUS_FORBIDDEN); + } - // Get response from db + // Get response from db $list = $this->timelineQuery->getDaysFolder($node->getId()); - // Get subdirectories - $sub = $node->search(new SearchQuery( - new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'mimetype', FileInfo::MIMETYPE_FOLDER), - 0, 0, [], $user)); - $sub = array_filter($sub, function ($item) use ($node) { - return $item->getParent()->getId() === $node->getId(); - }); + // Get subdirectories + $sub = $node->search(new SearchQuery( + new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'mimetype', FileInfo::MIMETYPE_FOLDER), + 0, 0, [], $user)); + $sub = array_filter($sub, function ($item) use ($node) { + return $item->getParent()->getId() === $node->getId(); + }); - // Sort by name - usort($sub, function($a, $b) { - return strnatcmp($a->getName(), $b->getName()); - }); + // Sort by name + usort($sub, function($a, $b) { + return strnatcmp($a->getName(), $b->getName()); + }); - // Map sub to JSON array - $subdirArray = [ - "dayid" => -0.1, - "detail" => array_map(function ($node) { - return [ - "fileid" => $node->getId(), - "name" => $node->getName(), - "is_folder" => 1, - "path" => $node->getPath(), - ]; - }, $sub, []), - ]; - $subdirArray["count"] = count($subdirArray["detail"]); - array_unshift($list, $subdirArray); + // Map sub to JSON array + $subdirArray = [ + "dayid" => -0.1, + "detail" => array_map(function ($node) { + return [ + "fileid" => $node->getId(), + "name" => $node->getName(), + "is_folder" => 1, + "path" => $node->getPath(), + ]; + }, $sub, []), + ]; + $subdirArray["count"] = count($subdirArray["detail"]); + array_unshift($list, $subdirArray); - return new JSONResponse($list, Http::STATUS_OK); - } + return new JSONResponse($list, Http::STATUS_OK); + } - /** - * @NoAdminRequired - * - * @return JSONResponse - */ - public function folderDay(string $folder, string $dayId): JSONResponse { + /** + * @NoAdminRequired + * + * @return JSONResponse + */ + public function folderDay(string $folder, string $dayId): JSONResponse { $user = $this->userSession->getUser(); - if (is_null($user) || !is_numeric($folder) || !is_numeric($dayId)) { - return new JSONResponse([], Http::STATUS_PRECONDITION_FAILED); - } + if (is_null($user) || !is_numeric($folder) || !is_numeric($dayId)) { + return new JSONResponse([], Http::STATUS_PRECONDITION_FAILED); + } - $node = $this->getAllowedFolder(intval($folder), $user); - if ($node === NULL) { - return new JSONResponse([], Http::STATUS_FORBIDDEN); - } + $node = $this->getAllowedFolder(intval($folder), $user); + if ($node === NULL) { + return new JSONResponse([], Http::STATUS_FORBIDDEN); + } $list = $this->timelineQuery->getDayFolder($node->getId(), intval($dayId)); - return new JSONResponse($list, Http::STATUS_OK); - } + return new JSONResponse($list, Http::STATUS_OK); + } - /** - * @NoAdminRequired - * - * update preferences (user setting) - * - * @param string key the identifier to change - * @param string value the value to set - * - * @return JSONResponse an empty JSONResponse with respective http status code - */ - public function setUserConfig(string $key, string $value): JSONResponse { - $user = $this->userSession->getUser(); - if (is_null($user)) { - return new JSONResponse([], Http::STATUS_PRECONDITION_FAILED); - } + /** + * @NoAdminRequired + * + * update preferences (user setting) + * + * @param string key the identifier to change + * @param string value the value to set + * + * @return JSONResponse an empty JSONResponse with respective http status code + */ + public function setUserConfig(string $key, string $value): JSONResponse { + $user = $this->userSession->getUser(); + if (is_null($user)) { + return new JSONResponse([], Http::STATUS_PRECONDITION_FAILED); + } - $userId = $user->getUid(); - $this->config->setUserValue($userId, Application::APPNAME, $key, $value); - return new JSONResponse([], Http::STATUS_OK); - } + $userId = $user->getUid(); + $this->config->setUserValue($userId, Application::APPNAME, $key, $value); + return new JSONResponse([], Http::STATUS_OK); + } } \ No newline at end of file diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index 20402e82..c7e834b4 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -13,60 +13,60 @@ use OCP\IUserSession; use OCP\Util; class PageController extends Controller { - protected string $userId; - protected $appName; - protected IEventDispatcher $eventDispatcher; - private IInitialState $initialState; - private IUserSession $userSession; - private IConfig $config; + protected string $userId; + protected $appName; + protected IEventDispatcher $eventDispatcher; + private IInitialState $initialState; + private IUserSession $userSession; + private IConfig $config; - public function __construct( - string $AppName, - IRequest $request, - string $UserId, - IEventDispatcher $eventDispatcher, - IInitialState $initialState, - IUserSession $userSession, - IConfig $config) { + public function __construct( + string $AppName, + IRequest $request, + string $UserId, + IEventDispatcher $eventDispatcher, + IInitialState $initialState, + IUserSession $userSession, + IConfig $config) { - parent::__construct($AppName, $request); - $this->userId = $UserId; - $this->appName = $AppName; - $this->eventDispatcher = $eventDispatcher; - $this->initialState = $initialState; - $this->userSession = $userSession; - $this->config = $config; - } + parent::__construct($AppName, $request); + $this->userId = $UserId; + $this->appName = $AppName; + $this->eventDispatcher = $eventDispatcher; + $this->initialState = $initialState; + $this->userSession = $userSession; + $this->config = $config; + } - /** - * @NoAdminRequired - * @NoCSRFRequired - */ - public function main() { - $user = $this->userSession->getUser(); - if (is_null($user)) { - return null; - } + /** + * @NoAdminRequired + * @NoCSRFRequired + */ + public function main() { + $user = $this->userSession->getUser(); + if (is_null($user)) { + return null; + } - Util::addScript($this->appName, 'memories-main'); - Util::addStyle($this->appName, 'custom-icons'); + Util::addScript($this->appName, 'memories-main'); + Util::addStyle($this->appName, 'custom-icons'); - $this->eventDispatcher->dispatchTyped(new LoadSidebar()); - $this->eventDispatcher->dispatchTyped(new LoadViewer()); + $this->eventDispatcher->dispatchTyped(new LoadSidebar()); + $this->eventDispatcher->dispatchTyped(new LoadViewer()); - $timelinePath = \OCA\Memories\Util::getPhotosPath($this->config, $user->getUid()); - $this->initialState->provideInitialState('timelinePath', $timelinePath); + $timelinePath = \OCA\Memories\Util::getPhotosPath($this->config, $user->getUid()); + $this->initialState->provideInitialState('timelinePath', $timelinePath); - $response = new TemplateResponse($this->appName, 'main'); - return $response; - } + $response = new TemplateResponse($this->appName, 'main'); + return $response; + } - /** - * @NoAdminRequired - * @NoCSRFRequired - */ - public function folder() { - return $this->main(); - } + /** + * @NoAdminRequired + * @NoCSRFRequired + */ + public function folder() { + return $this->main(); + } } diff --git a/lib/Db/TimelineQuery.php b/lib/Db/TimelineQuery.php index 8342b512..21a61739 100644 --- a/lib/Db/TimelineQuery.php +++ b/lib/Db/TimelineQuery.php @@ -8,11 +8,11 @@ use OCP\IConfig; use OCP\IDBConnection; class TimelineQuery { - protected IDBConnection $connection; + protected IDBConnection $connection; - public function __construct(IDBConnection $connection) { - $this->connection = $connection; - } + public function __construct(IDBConnection $connection) { + $this->connection = $connection; + } /** * Process the days response @@ -104,7 +104,7 @@ class TimelineQuery { ORDER BY `*PREFIX*memories`.`datetaken` DESC'; $path = "files" . Exif::getPhotosPath($config, $user) . "%"; - $rows = $this->connection->executeQuery($sql, [$path, $user, $dayId], [ + $rows = $this->connection->executeQuery($sql, [$path, $user, $dayId], [ \PDO::PARAM_STR, \PDO::PARAM_STR, \PDO::PARAM_INT, ])->fetchAll(); return $this->processDay($rows); @@ -126,7 +126,7 @@ class TimelineQuery { AND (`*PREFIX*filecache`.`parent`=? OR `*PREFIX*filecache`.`fileid`=?) WHERE `*PREFIX*memories`.`dayid`=? ORDER BY `*PREFIX*memories`.`datetaken` DESC'; - $rows = $this->connection->executeQuery($sql, [$folderId, $folderId, $dayId], [ + $rows = $this->connection->executeQuery($sql, [$folderId, $folderId, $dayId], [ \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT, ])->fetchAll(); return $this->processDay($rows); diff --git a/lib/Db/TimelineWrite.php b/lib/Db/TimelineWrite.php index 70fe7ebb..33173989 100644 --- a/lib/Db/TimelineWrite.php +++ b/lib/Db/TimelineWrite.php @@ -9,11 +9,11 @@ use OCP\Files\File; use OCP\IDBConnection; class TimelineWrite { - protected IDBConnection $connection; + protected IDBConnection $connection; - public function __construct(IDBConnection $connection) { - $this->connection = $connection; - } + public function __construct(IDBConnection $connection) { + $this->connection = $connection; + } /** * Process a file to insert Exif data into the database diff --git a/lib/Listeners/PostDeleteListener.php b/lib/Listeners/PostDeleteListener.php index b99c37d9..e4667476 100644 --- a/lib/Listeners/PostDeleteListener.php +++ b/lib/Listeners/PostDeleteListener.php @@ -34,20 +34,20 @@ use OCP\IDBConnection; class PostDeleteListener implements IEventListener { private TimelineWrite $util; - public function __construct(IDBConnection $connection) { + public function __construct(IDBConnection $connection) { $this->util = new TimelineWrite($connection); - } + } - public function handle(Event $event): void { - if (!($event instanceof NodeDeletedEvent)) { - return; - } + public function handle(Event $event): void { + if (!($event instanceof NodeDeletedEvent)) { + return; + } - $node = $event->getNode(); - if ($node instanceof Folder) { - return; - } + $node = $event->getNode(); + if ($node instanceof Folder) { + return; + } - $this->util->deleteFile($node); - } + $this->util->deleteFile($node); + } } \ No newline at end of file diff --git a/lib/Listeners/PostWriteListener.php b/lib/Listeners/PostWriteListener.php index 305425be..e6abfbc1 100644 --- a/lib/Listeners/PostWriteListener.php +++ b/lib/Listeners/PostWriteListener.php @@ -36,23 +36,23 @@ use OCP\IUserManager; class PostWriteListener implements IEventListener { private TimelineWrite $util; - public function __construct(IDBConnection $connection, - IUserManager $userManager) { - $this->userManager = $userManager; + public function __construct(IDBConnection $connection, + IUserManager $userManager) { + $this->userManager = $userManager; $this->util = new TimelineWrite($connection); - } + } - public function handle(Event $event): void { - if (!($event instanceof NodeWrittenEvent) && - !($event instanceof NodeTouchedEvent)) { - return; - } + public function handle(Event $event): void { + if (!($event instanceof NodeWrittenEvent) && + !($event instanceof NodeTouchedEvent)) { + return; + } - $node = $event->getNode(); - if ($node instanceof Folder) { - return; - } + $node = $event->getNode(); + if ($node instanceof Folder) { + return; + } - $this->util->processFile($node); - } + $this->util->processFile($node); + } } \ No newline at end of file diff --git a/lib/Migration/Version000000Date20220812163631.php b/lib/Migration/Version000000Date20220812163631.php index 641cacb1..b1a86511 100644 --- a/lib/Migration/Version000000Date20220812163631.php +++ b/lib/Migration/Version000000Date20220812163631.php @@ -58,19 +58,19 @@ class Version000000Date20220812163631 extends SimpleMigrationStep { 'notnull' => false, ]); $table->addColumn('fileid', Types::BIGINT, [ - 'notnull' => true, - 'length' => 20, - ]); + 'notnull' => true, + 'length' => 20, + ]); $table->addColumn('dayid', Types::INTEGER, [ - 'notnull' => true, - ]); + 'notnull' => true, + ]); $table->addColumn('isvideo', Types::BOOLEAN, [ - 'notnull' => false, + 'notnull' => false, 'default' => false - ]); + ]); $table->addColumn('mtime', Types::INTEGER, [ - 'notnull' => true, - ]); + 'notnull' => true, + ]); $table->setPrimaryKey(['id']); $table->addIndex(['uid'], 'memories_uid_index'); diff --git a/src/App.vue b/src/App.vue index cae4d62f..c5def13a 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,43 +1,43 @@ @@ -48,35 +48,35 @@ import Timeline from './components/Timeline.vue' import Settings from './components/Settings.vue' export default { - name: 'App', - components: { - NcContent, - NcAppContent, - NcAppNavigation, - NcAppNavigationItem, - NcAppNavigationSettings, + name: 'App', + components: { + NcContent, + NcAppContent, + NcAppNavigation, + NcAppNavigationItem, + NcAppNavigationSettings, - Timeline, - Settings, - }, - data() { - return { - loading: false, - show: true, - starred: false, - } - }, - methods: { - close() { - this.show = false - console.debug(arguments) - }, - newButtonAction() { - console.debug(arguments) - }, - log() { - console.debug(arguments) - }, - }, + Timeline, + Settings, + }, + data() { + return { + loading: false, + show: true, + starred: false, + } + }, + methods: { + close() { + this.show = false + console.debug(arguments) + }, + newButtonAction() { + console.debug(arguments) + }, + log() { + console.debug(arguments) + }, + }, } diff --git a/src/components/Settings.vue b/src/components/Settings.vue index b1979eb7..6f0f764c 100644 --- a/src/components/Settings.vue +++ b/src/components/Settings.vue @@ -21,7 +21,7 @@ -->