From 2e4dbe7f7f40655db43a9dd43bd3ee00f5329d16 Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 28 Apr 2025 20:02:11 -0400 Subject: [PATCH] support custom expiration durations for file and folder shares (closes #26) --- CHANGELOG.md | 28 +++ public/js/filePreview.js | 156 ++++++++----- public/js/folderShareModal.js | 170 ++++++++------ public/js/i18n.js | 15 +- src/controllers/fileController.php | 319 +++++++++++++++------------ src/controllers/folderController.php | 57 +++-- src/models/FileModel.php | 4 +- src/models/FolderModel.php | 201 ++++++++--------- 8 files changed, 577 insertions(+), 373 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf9e077..35ac42d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,33 @@ # Changelog +## Changes 4/28/2025 + +**Added** + +- **Custom expiration** option to File Share modal + - Users can specify a value + unit (seconds, minutes, hours, days) + - Displays a warning when a custom duration is selected +- **Custom expiration** option to Folder Share modal (same value+unit picker and warning) + +**Changed** + +- **API parameters** for both endpoints: + - Replaced `expirationMinutes` with `expirationValue` + `expirationUnit` + - Front-end now sends `{ expirationValue, expirationUnit }` + - Back-end converts those into total seconds before saving +- **UI** + - FileShare and FolderShare modals updated to handle “Custom…” selection + +**Updated Models & Controllers** + +- **FileModel::createShareLink** now accepts expiration in seconds +- **FolderModel::createShareFolderLink** now accepts expiration in seconds +- **createShareLink.php** & **createShareFolderLink.php** updated to parse and convert new parameters + +**Documentation** + +- OpenAPI annotations for both endpoints updated to require `expirationValue` + `expirationUnit` (enum: seconds, minutes, hours, days) + ## Changes 4/27/2025 1.2.7 - **Select-All** checkbox now correctly toggles all `.file-checkbox` inputs diff --git a/public/js/filePreview.js b/public/js/filePreview.js index df18920..9c5ac52 100644 --- a/public/js/filePreview.js +++ b/public/js/filePreview.js @@ -4,36 +4,68 @@ import { fileData } from './fileListView.js'; import { t } from './i18n.js'; export function openShareModal(file, folder) { + // Remove any existing modal const existing = document.getElementById("shareModal"); if (existing) existing.remove(); + // Build the modal const modal = document.createElement("div"); modal.id = "shareModal"; modal.classList.add("modal"); modal.innerHTML = ` -