Compare commits
7 Commits
fafefff29b
...
944f4518e9
| Author | SHA1 | Date | |
|---|---|---|---|
| 944f4518e9 | |||
| 0c765f712c | |||
| 676547686b | |||
| 66606c5eca | |||
| a30fac029d | |||
| 796e61f4ea | |||
| 594c65d1a5 |
@@ -9,7 +9,7 @@ import { saveEntryPhoto, deleteEntryPhoto } from '../services/photoAttachments.j
|
|||||||
import { fileToCompressedJpegDataUrl } from '../utils/imageCompress.js'
|
import { fileToCompressedJpegDataUrl } from '../utils/imageCompress.js'
|
||||||
import { useLiveQuery } from 'dexie-react-hooks'
|
import { useLiveQuery } from 'dexie-react-hooks'
|
||||||
import { useDialog } from './ModalDialog.tsx'
|
import { useDialog } from './ModalDialog.tsx'
|
||||||
import { Camera, Image, Trash2, X } from 'lucide-react'
|
import { Camera, Image, Trash2, X, ChevronDown, ChevronUp } from 'lucide-react'
|
||||||
import { probeCameraAvailability } from '../utils/cameraAvailability.js'
|
import { probeCameraAvailability } from '../utils/cameraAvailability.js'
|
||||||
|
|
||||||
interface PhotoCaptureProps {
|
interface PhotoCaptureProps {
|
||||||
@@ -29,6 +29,7 @@ interface DecryptedPhoto {
|
|||||||
export default function PhotoCapture({ entryId, logbookId, readOnly = false, preloadedPhotos }: PhotoCaptureProps) {
|
export default function PhotoCapture({ entryId, logbookId, readOnly = false, preloadedPhotos }: PhotoCaptureProps) {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const { showConfirm } = useDialog()
|
const { showConfirm } = useDialog()
|
||||||
|
const [collapsed, setCollapsed] = useState(true)
|
||||||
const [caption, setCaption] = useState('')
|
const [caption, setCaption] = useState('')
|
||||||
const [uploading, setUploading] = useState(false)
|
const [uploading, setUploading] = useState(false)
|
||||||
const [error, setError] = useState<string | null>(null)
|
const [error, setError] = useState<string | null>(null)
|
||||||
@@ -165,11 +166,32 @@ export default function PhotoCapture({ entryId, logbookId, readOnly = false, pre
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="form-card mt-6">
|
<div className="form-card mt-6">
|
||||||
<div className="form-header mb-4">
|
<div
|
||||||
|
className="form-header accordion-header"
|
||||||
|
onClick={() => setCollapsed(!collapsed)}
|
||||||
|
onKeyDown={(e) => {
|
||||||
|
if (e.key === 'Enter' || e.key === ' ') {
|
||||||
|
e.preventDefault()
|
||||||
|
setCollapsed(!collapsed)
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
role="button"
|
||||||
|
aria-expanded={!collapsed}
|
||||||
|
tabIndex={0}
|
||||||
|
>
|
||||||
|
<div className="accordion-header-title">
|
||||||
<Camera size={20} className="form-icon" />
|
<Camera size={20} className="form-icon" />
|
||||||
<h3>{t('logs.photos_title')}</h3>
|
<h3>{t('logs.photos_title')}</h3>
|
||||||
</div>
|
</div>
|
||||||
|
{collapsed ? (
|
||||||
|
<ChevronDown size={20} className="accordion-chevron" />
|
||||||
|
) : (
|
||||||
|
<ChevronUp size={20} className="accordion-chevron" />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{!collapsed && (
|
||||||
|
<div style={{ marginTop: '16px' }}>
|
||||||
{error && <div className="auth-error mb-4">{error}</div>}
|
{error && <div className="auth-error mb-4">{error}</div>}
|
||||||
|
|
||||||
{/* Upload area */}
|
{/* Upload area */}
|
||||||
@@ -294,6 +316,8 @@ export default function PhotoCapture({ entryId, logbookId, readOnly = false, pre
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{maximizedPhoto && createPortal(
|
{maximizedPhoto && createPortal(
|
||||||
<div
|
<div
|
||||||
|
|||||||
+30
-17
@@ -70,6 +70,11 @@ DEFAULT_VERSION="0.1.0.0"
|
|||||||
MAX_WAIT=90
|
MAX_WAIT=90
|
||||||
|
|
||||||
REMOTE_USER="${REMOTE_USER:-root}"
|
REMOTE_USER="${REMOTE_USER:-root}"
|
||||||
|
# GIT_REMOTE="${GIT_REMOTE:-github}"
|
||||||
|
# GIT_REMOTE_URL="${GIT_REMOTE_URL:-https://github.com/elpatron68/kapteins-daagbok.git}"
|
||||||
|
GIT_REMOTE="${GIT_REMOTE:-origin}"
|
||||||
|
GIT_REMOTE_URL="${GIT_REMOTE_URL:-https://gitea.elpatron.me/elpatron/kapteins-daagbok.git}"
|
||||||
|
|
||||||
|
|
||||||
if [[ "$DEST" == "stage" ]]; then
|
if [[ "$DEST" == "stage" ]]; then
|
||||||
REMOTE_HOST="${REMOTE_HOST:-10.0.0.27}"
|
REMOTE_HOST="${REMOTE_HOST:-10.0.0.27}"
|
||||||
@@ -186,34 +191,34 @@ ensure_local_sync_with_origin() {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Syncing with origin..."
|
echo "Syncing with ${GIT_REMOTE}..."
|
||||||
git fetch --tags origin
|
git fetch --tags "${GIT_REMOTE}"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Error: git fetch origin failed." >&2
|
echo "Error: git fetch ${GIT_REMOTE} failed." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! git rev-parse --verify "origin/${branch}" >/dev/null 2>&1; then
|
if ! git rev-parse --verify "${GIT_REMOTE}/${branch}" >/dev/null 2>&1; then
|
||||||
echo "Error: origin/${branch} does not exist." >&2
|
echo "Error: ${GIT_REMOTE}/${branch} does not exist." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local_sha="$(git rev-parse HEAD)"
|
local_sha="$(git rev-parse HEAD)"
|
||||||
origin_sha="$(git rev-parse "origin/${branch}")"
|
origin_sha="$(git rev-parse "${GIT_REMOTE}/${branch}")"
|
||||||
|
|
||||||
if [ "$local_sha" = "$origin_sha" ]; then
|
if [ "$local_sha" = "$origin_sha" ]; then
|
||||||
echo "Local branch '$branch' matches origin/${branch} ($(git rev-parse --short HEAD))."
|
echo "Local branch '$branch' matches ${GIT_REMOTE}/${branch} ($(git rev-parse --short HEAD))."
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Error: Local '$branch' is not in sync with origin/${branch}." >&2
|
echo "Error: Local '$branch' is not in sync with ${GIT_REMOTE}/${branch}." >&2
|
||||||
echo " local: $(git rev-parse --short HEAD) $(git log -1 --format='%s' HEAD)" >&2
|
echo " local: $(git rev-parse --short HEAD) $(git log -1 --format='%s' HEAD)" >&2
|
||||||
echo " origin: $(git rev-parse --short "origin/${branch}") $(git log -1 --format='%s' "origin/${branch}")" >&2
|
echo " ${GIT_REMOTE}: $(git rev-parse --short "${GIT_REMOTE}/${branch}") $(git log -1 --format='%s' "${GIT_REMOTE}/${branch}")" >&2
|
||||||
|
|
||||||
if git merge-base --is-ancestor "$local_sha" "origin/${branch}" 2>/dev/null; then
|
if git merge-base --is-ancestor "$local_sha" "${GIT_REMOTE}/${branch}" 2>/dev/null; then
|
||||||
echo "Hint: run 'git pull' to fast-forward." >&2
|
echo "Hint: run 'git pull' to fast-forward." >&2
|
||||||
elif git merge-base --is-ancestor "origin/${branch}" "$local_sha" 2>/dev/null; then
|
elif git merge-base --is-ancestor "${GIT_REMOTE}/${branch}" "$local_sha" 2>/dev/null; then
|
||||||
echo "Hint: run 'git push origin ${branch}' before deploying." >&2
|
echo "Hint: run 'git push ${GIT_REMOTE} ${branch}' before deploying." >&2
|
||||||
else
|
else
|
||||||
echo "Hint: branches have diverged — reconcile manually before deploying." >&2
|
echo "Hint: branches have diverged — reconcile manually before deploying." >&2
|
||||||
fi
|
fi
|
||||||
@@ -246,12 +251,12 @@ prepare_release() {
|
|||||||
echo " Next prep: v${next_version}"
|
echo " Next prep: v${next_version}"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
read -r -p "Push commit and tag to origin? [Y/n] " push_answer
|
read -r -p "Push commit and tag to ${GIT_REMOTE}? [Y/n] " push_answer
|
||||||
if [[ ! "$push_answer" =~ ^[nN]$ ]]; then
|
if [[ ! "$push_answer" =~ ^[nN]$ ]]; then
|
||||||
current_branch="$(git branch --show-current)"
|
current_branch="$(git branch --show-current)"
|
||||||
git push origin "$current_branch"
|
git push "${GIT_REMOTE}" "$current_branch"
|
||||||
git push origin "$tag_name"
|
git push "${GIT_REMOTE}" "$tag_name"
|
||||||
echo "Pushed ${current_branch} and ${tag_name} to origin."
|
echo "Pushed ${current_branch} and ${tag_name} to ${GIT_REMOTE}."
|
||||||
else
|
else
|
||||||
echo "Skipped push. Remote host must receive this commit/tag manually."
|
echo "Skipped push. Remote host must receive this commit/tag manually."
|
||||||
fi
|
fi
|
||||||
@@ -281,7 +286,7 @@ echo "Deploying v${APP_VERSION} to ${REMOTE_TARGET}:${REMOTE_DIR}"
|
|||||||
echo "=================================================="
|
echo "=================================================="
|
||||||
|
|
||||||
ssh -o ConnectTimeout=10 "$REMOTE_TARGET" 'bash -s' -- \
|
ssh -o ConnectTimeout=10 "$REMOTE_TARGET" 'bash -s' -- \
|
||||||
"$REMOTE_DIR" "$COMPOSE_FILE" "$BACKEND_CONTAINER" "$MAX_WAIT" "$APP_URL" "$APP_VERSION" "$DEST" "$DEPLOY_BRANCH" <<'REMOTE_SCRIPT'
|
"$REMOTE_DIR" "$COMPOSE_FILE" "$BACKEND_CONTAINER" "$MAX_WAIT" "$APP_URL" "$APP_VERSION" "$DEST" "$DEPLOY_BRANCH" "$GIT_REMOTE_URL" <<'REMOTE_SCRIPT'
|
||||||
set -uo pipefail
|
set -uo pipefail
|
||||||
|
|
||||||
REMOTE_DIR="$1"
|
REMOTE_DIR="$1"
|
||||||
@@ -292,9 +297,17 @@ APP_URL="$5"
|
|||||||
APP_VERSION="$6"
|
APP_VERSION="$6"
|
||||||
DEST="$7"
|
DEST="$7"
|
||||||
DEPLOY_BRANCH="${8:-}"
|
DEPLOY_BRANCH="${8:-}"
|
||||||
|
GIT_REMOTE_URL="${9:-https://github.com/elpatron68/kapteins-daagbok.git}"
|
||||||
|
|
||||||
cd "$REMOTE_DIR" || { echo "Error: Remote directory '$REMOTE_DIR' not found."; exit 1; }
|
cd "$REMOTE_DIR" || { echo "Error: Remote directory '$REMOTE_DIR' not found."; exit 1; }
|
||||||
|
|
||||||
|
echo "Configuring git remote 'origin' URL to ${GIT_REMOTE_URL} on remote host..."
|
||||||
|
if git remote | grep -q "^origin$"; then
|
||||||
|
git remote set-url origin "$GIT_REMOTE_URL"
|
||||||
|
else
|
||||||
|
git remote add origin "$GIT_REMOTE_URL"
|
||||||
|
fi
|
||||||
|
|
||||||
if ! git diff-index --quiet HEAD -- || [ -n "$(git status --porcelain)" ]; then
|
if ! git diff-index --quiet HEAD -- || [ -n "$(git status --porcelain)" ]; then
|
||||||
echo "Warning: Local changes on deployment host will be discarded."
|
echo "Warning: Local changes on deployment host will be discarded."
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user