Compare commits
7
Commits
07cbeec816
..
V1.0.5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3cc1d1385c | ||
|
|
bd71076c72 | ||
|
|
944d3bc00a | ||
|
|
2be0f3e2b8 | ||
|
|
d3089ff2dd | ||
|
|
2f976bade1 | ||
|
|
ef054280bb |
@@ -0,0 +1,22 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Runs on `git push`. If a tag ref is among what's being pushed, build locally
|
||||||
|
# and deploy to the server. Normal branch pushes are untouched.
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
deploy=0
|
||||||
|
tag=""
|
||||||
|
while read -r local_ref _local_sha _remote_ref _remote_sha; do
|
||||||
|
case "$local_ref" in
|
||||||
|
refs/tags/*)
|
||||||
|
deploy=1
|
||||||
|
tag="${local_ref#refs/tags/}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$deploy" = "1" ]; then
|
||||||
|
echo "→ Tag '$tag' is being pushed — building locally and deploying to the server…"
|
||||||
|
exec "$(git rev-parse --show-toplevel)/scripts/deploy.sh"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
||||||
@@ -39,3 +39,6 @@ yarn-error.log*
|
|||||||
# typescript
|
# typescript
|
||||||
*.tsbuildinfo
|
*.tsbuildinfo
|
||||||
next-env.d.ts
|
next-env.d.ts
|
||||||
|
|
||||||
|
# local deploy secrets
|
||||||
|
.env.deploy
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
# Deployment
|
||||||
|
|
||||||
|
The site is a **static export**. It is built **on your machine** and the result
|
||||||
|
(`out/`) is copied to the server — nothing is built on the server.
|
||||||
|
|
||||||
|
- Server: `185.226.116.88`, user `ubuntu`
|
||||||
|
- Target dir: `/var/www/aramland-admin` (its contents are fully replaced each deploy)
|
||||||
|
|
||||||
|
## Deploy by pushing a git tag (automatic)
|
||||||
|
|
||||||
|
A versioned git hook ([`.githooks/pre-push`](.githooks/pre-push)) runs the local
|
||||||
|
build + upload whenever you push a **tag**:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git tag v1.0.0
|
||||||
|
git push origin v1.0.0 # ← hook builds locally, then uploads to the server
|
||||||
|
```
|
||||||
|
|
||||||
|
Normal branch pushes are unaffected — only tag pushes deploy.
|
||||||
|
|
||||||
|
> The hook path is set via `git config core.hooksPath .githooks` (already configured
|
||||||
|
> in this clone). On a fresh clone, run that once.
|
||||||
|
|
||||||
|
## Deploy manually (no tag)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run deploy # = bash scripts/deploy.sh : build locally + upload
|
||||||
|
```
|
||||||
|
|
||||||
|
## The password
|
||||||
|
|
||||||
|
Both paths use [`scripts/deploy.sh`](scripts/deploy.sh), which streams `out/` over a
|
||||||
|
single SSH connection. By default **SSH asks for the server password once** per deploy.
|
||||||
|
|
||||||
|
To make it **unattended** (no prompt), provide the password without committing it:
|
||||||
|
|
||||||
|
1. Create `.env.deploy` in the project root (already gitignored):
|
||||||
|
```bash
|
||||||
|
DEPLOY_PASSWORD=your-server-password
|
||||||
|
```
|
||||||
|
2. Install `sshpass` (the only piece that can feed a password to SSH non-interactively):
|
||||||
|
- Linux/WSL: `sudo apt-get install -y sshpass`
|
||||||
|
- macOS: `brew install hudochenkov/sshpass/sshpass`
|
||||||
|
- Windows Git Bash has no sshpass — either deploy from WSL, or just answer the one
|
||||||
|
password prompt.
|
||||||
|
|
||||||
|
Override the host/user/path too if needed (env or `.env.deploy`):
|
||||||
|
`DEPLOY_HOST`, `DEPLOY_USER`, `DEPLOY_PATH`.
|
||||||
|
|
||||||
|
> **More robust option:** set up an SSH **key** (`ssh-copy-id ubuntu@185.226.116.88`).
|
||||||
|
> Then deploys are unattended on any OS with no password or sshpass at all.
|
||||||
|
|
||||||
|
## Notes / troubleshooting
|
||||||
|
|
||||||
|
- **Permission denied** writing the target: the `ubuntu` user must own it →
|
||||||
|
on the server run `sudo chown -R ubuntu:ubuntu /var/www/aramland-admin`.
|
||||||
|
- **Web server:** point nginx's site root at `/var/www/aramland-admin`. The export uses
|
||||||
|
`trailingSlash: true`, so clean URLs resolve to `…/index.html`.
|
||||||
|
- The deploy replaces the directory **contents** (including dotfiles) in place; it does
|
||||||
|
not touch nginx config or sibling folders.
|
||||||
@@ -0,0 +1,195 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useCallback, useEffect, useState } from "react";
|
||||||
|
import { apiFetch, ApiError } from "@/lib/api";
|
||||||
|
import { useToast } from "@/components/toast";
|
||||||
|
import { DataTable, type Column } from "@/components/DataTable";
|
||||||
|
import { Button, Card, ConfirmDialog, PageHeader } from "@/components/ui";
|
||||||
|
import { TrashIcon } from "@/components/icons";
|
||||||
|
import { toFa } from "@/lib/utils";
|
||||||
|
|
||||||
|
interface Feedback {
|
||||||
|
id: number;
|
||||||
|
stars?: number | null;
|
||||||
|
content?: string | null;
|
||||||
|
created_at?: string;
|
||||||
|
user?: {
|
||||||
|
name?: string | null;
|
||||||
|
identifier?: string | null;
|
||||||
|
mobile?: string | null;
|
||||||
|
} | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Summary {
|
||||||
|
total: number;
|
||||||
|
rated: number;
|
||||||
|
with_comment: number;
|
||||||
|
average_stars: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface AdminResponse {
|
||||||
|
summary: Summary;
|
||||||
|
feedback: { data: Feedback[] };
|
||||||
|
}
|
||||||
|
|
||||||
|
function Stars({ value }: { value?: number | null }) {
|
||||||
|
if (!value) return <span className="text-muted">—</span>;
|
||||||
|
return (
|
||||||
|
<span className="text-amber-500" dir="ltr" title={toFa(value)}>
|
||||||
|
{"★".repeat(value)}
|
||||||
|
<span className="text-border">{"★".repeat(5 - value)}</span>
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function userName(u: Feedback["user"]): string {
|
||||||
|
return u?.name || u?.identifier || u?.mobile || "—";
|
||||||
|
}
|
||||||
|
|
||||||
|
function faDate(value?: string): string {
|
||||||
|
if (!value) return "—";
|
||||||
|
try {
|
||||||
|
return toFa(new Date(value).toLocaleDateString("fa-IR"));
|
||||||
|
} catch {
|
||||||
|
return "—";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function AppFeedbackPage() {
|
||||||
|
const toast = useToast();
|
||||||
|
|
||||||
|
const [rows, setRows] = useState<Feedback[]>([]);
|
||||||
|
const [summary, setSummary] = useState<Summary | null>(null);
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
|
const [deleting, setDeleting] = useState<Feedback | null>(null);
|
||||||
|
const [removing, setRemoving] = useState(false);
|
||||||
|
|
||||||
|
// Fetch without touching state synchronously (safe to call from an effect).
|
||||||
|
const fetchFeedback = useCallback(() => {
|
||||||
|
return apiFetch<AdminResponse>("/admin/app-feedback")
|
||||||
|
.then((res) => {
|
||||||
|
setRows(res.feedback?.data ?? []);
|
||||||
|
setSummary(res.summary ?? null);
|
||||||
|
setError(null);
|
||||||
|
})
|
||||||
|
.catch((e: unknown) =>
|
||||||
|
setError(e instanceof ApiError ? e.message : "خطا در دریافت اطلاعات"),
|
||||||
|
)
|
||||||
|
.finally(() => setLoading(false));
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
// Reload triggered by user actions (retry / after delete): show the spinner.
|
||||||
|
const reload = useCallback(() => {
|
||||||
|
setLoading(true);
|
||||||
|
setError(null);
|
||||||
|
fetchFeedback();
|
||||||
|
}, [fetchFeedback]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
fetchFeedback();
|
||||||
|
}, [fetchFeedback]);
|
||||||
|
|
||||||
|
async function confirmDelete() {
|
||||||
|
if (!deleting) return;
|
||||||
|
setRemoving(true);
|
||||||
|
try {
|
||||||
|
await apiFetch(`/admin/app-feedback/${deleting.id}`, { method: "DELETE" });
|
||||||
|
toast.success("بازخورد حذف شد.");
|
||||||
|
setDeleting(null);
|
||||||
|
reload();
|
||||||
|
} catch (err) {
|
||||||
|
toast.error(err instanceof ApiError ? err.message : "خطا در حذف");
|
||||||
|
} finally {
|
||||||
|
setRemoving(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const columns: Column<Feedback>[] = [
|
||||||
|
{ key: "id", header: "شناسه", render: (r) => toFa(r.id), className: "w-20" },
|
||||||
|
{ key: "user", header: "کاربر", render: (r) => userName(r.user) },
|
||||||
|
{
|
||||||
|
key: "stars",
|
||||||
|
header: "امتیاز",
|
||||||
|
className: "w-28",
|
||||||
|
render: (r) => <Stars value={r.stars} />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "content",
|
||||||
|
header: "ایده / نظر",
|
||||||
|
render: (r) => r.content || <span className="text-muted">—</span>,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "created_at",
|
||||||
|
header: "تاریخ",
|
||||||
|
className: "w-32",
|
||||||
|
render: (r) => faDate(r.created_at),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<PageHeader
|
||||||
|
title="نظرات و ایدهها"
|
||||||
|
subtitle="بازخورد کاربران درباره برنامه"
|
||||||
|
/>
|
||||||
|
|
||||||
|
{summary && (
|
||||||
|
<div className="mb-6 grid grid-cols-2 gap-3 sm:grid-cols-4">
|
||||||
|
<Card>
|
||||||
|
<p className="text-sm text-muted">میانگین امتیاز</p>
|
||||||
|
<p className="mt-1 text-2xl font-bold text-foreground">
|
||||||
|
{toFa(summary.average_stars)} <span className="text-amber-500">★</span>
|
||||||
|
</p>
|
||||||
|
</Card>
|
||||||
|
<Card>
|
||||||
|
<p className="text-sm text-muted">کل بازخوردها</p>
|
||||||
|
<p className="mt-1 text-2xl font-bold text-foreground">
|
||||||
|
{toFa(summary.total)}
|
||||||
|
</p>
|
||||||
|
</Card>
|
||||||
|
<Card>
|
||||||
|
<p className="text-sm text-muted">دارای امتیاز</p>
|
||||||
|
<p className="mt-1 text-2xl font-bold text-foreground">
|
||||||
|
{toFa(summary.rated)}
|
||||||
|
</p>
|
||||||
|
</Card>
|
||||||
|
<Card>
|
||||||
|
<p className="text-sm text-muted">دارای نظر</p>
|
||||||
|
<p className="mt-1 text-2xl font-bold text-foreground">
|
||||||
|
{toFa(summary.with_comment)}
|
||||||
|
</p>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<DataTable
|
||||||
|
columns={columns}
|
||||||
|
rows={rows}
|
||||||
|
loading={loading}
|
||||||
|
error={error}
|
||||||
|
onRetry={reload}
|
||||||
|
emptyMessage="هنوز بازخوردی ثبت نشده است."
|
||||||
|
actions={(row) => (
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
onClick={() => setDeleting(row)}
|
||||||
|
aria-label="حذف"
|
||||||
|
className="text-danger"
|
||||||
|
>
|
||||||
|
<TrashIcon className="h-4 w-4" />
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ConfirmDialog
|
||||||
|
open={!!deleting}
|
||||||
|
message={`آیا از حذف بازخورد «${userName(deleting?.user)}» مطمئن هستید؟`}
|
||||||
|
loading={removing}
|
||||||
|
onConfirm={confirmDelete}
|
||||||
|
onClose={() => setDeleting(null)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
ConfirmDialog,
|
ConfirmDialog,
|
||||||
Field,
|
Field,
|
||||||
Input,
|
Input,
|
||||||
|
Select,
|
||||||
Textarea,
|
Textarea,
|
||||||
Modal,
|
Modal,
|
||||||
PageHeader,
|
PageHeader,
|
||||||
@@ -19,24 +20,42 @@ import { MediaPreview } from "@/components/MediaPreview";
|
|||||||
import { pickUrl } from "@/lib/media";
|
import { pickUrl } from "@/lib/media";
|
||||||
import { toFa } from "@/lib/utils";
|
import { toFa } from "@/lib/utils";
|
||||||
|
|
||||||
|
type CategoryType = "media" | "playlist" | "breathing_template";
|
||||||
|
|
||||||
interface Category {
|
interface Category {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
|
type: CategoryType;
|
||||||
description?: string | null;
|
description?: string | null;
|
||||||
icon?: string | null;
|
icon?: string | null;
|
||||||
subcategories_count?: number;
|
subcategories_count?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// General category types, shared across media, playlists and breathing templates.
|
||||||
|
const TYPE_OPTIONS: { value: CategoryType; label: string }[] = [
|
||||||
|
{ value: "media", label: "رسانه" },
|
||||||
|
{ value: "playlist", label: "پلیلیست" },
|
||||||
|
{ value: "breathing_template", label: "قالب تنفس" },
|
||||||
|
];
|
||||||
|
|
||||||
|
const TYPE_LABELS: Record<CategoryType, string> = Object.fromEntries(
|
||||||
|
TYPE_OPTIONS.map((o) => [o.value, o.label]),
|
||||||
|
) as Record<CategoryType, string>;
|
||||||
|
|
||||||
// The icon is a direct image-file field on the category (not an image_id ref).
|
// The icon is a direct image-file field on the category (not an image_id ref).
|
||||||
const ICON_KEYS = ["icon", "icon_url"];
|
const ICON_KEYS = ["icon", "icon_url"];
|
||||||
|
|
||||||
export default function MediaCategoriesPage() {
|
export default function CategoriesPage() {
|
||||||
const { data, loading, error, reload } = useList<Category>("/categories");
|
const [typeFilter, setTypeFilter] = useState<CategoryType>("media");
|
||||||
|
const { data, loading, error, reload } = useList<Category>("/categories", {
|
||||||
|
type: typeFilter,
|
||||||
|
});
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
|
|
||||||
const [editing, setEditing] = useState<Category | null>(null);
|
const [editing, setEditing] = useState<Category | null>(null);
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const [name, setName] = useState("");
|
const [name, setName] = useState("");
|
||||||
|
const [type, setType] = useState<CategoryType>("media");
|
||||||
const [description, setDescription] = useState("");
|
const [description, setDescription] = useState("");
|
||||||
const [icon, setIcon] = useState<File | null>(null);
|
const [icon, setIcon] = useState<File | null>(null);
|
||||||
const [saving, setSaving] = useState(false);
|
const [saving, setSaving] = useState(false);
|
||||||
@@ -47,6 +66,7 @@ export default function MediaCategoriesPage() {
|
|||||||
function openCreate() {
|
function openCreate() {
|
||||||
setEditing(null);
|
setEditing(null);
|
||||||
setName("");
|
setName("");
|
||||||
|
setType(typeFilter);
|
||||||
setDescription("");
|
setDescription("");
|
||||||
setIcon(null);
|
setIcon(null);
|
||||||
setOpen(true);
|
setOpen(true);
|
||||||
@@ -54,6 +74,7 @@ export default function MediaCategoriesPage() {
|
|||||||
function openEdit(row: Category) {
|
function openEdit(row: Category) {
|
||||||
setEditing(row);
|
setEditing(row);
|
||||||
setName(row.name ?? "");
|
setName(row.name ?? "");
|
||||||
|
setType(row.type ?? "media");
|
||||||
setDescription(row.description ?? "");
|
setDescription(row.description ?? "");
|
||||||
setIcon(null);
|
setIcon(null);
|
||||||
setOpen(true);
|
setOpen(true);
|
||||||
@@ -68,6 +89,7 @@ export default function MediaCategoriesPage() {
|
|||||||
const body = toFormData({
|
const body = toFormData({
|
||||||
_method: "PUT",
|
_method: "PUT",
|
||||||
name,
|
name,
|
||||||
|
type,
|
||||||
description,
|
description,
|
||||||
icon,
|
icon,
|
||||||
});
|
});
|
||||||
@@ -76,7 +98,7 @@ export default function MediaCategoriesPage() {
|
|||||||
} else {
|
} else {
|
||||||
await apiFetch("/categories", {
|
await apiFetch("/categories", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: toFormData({ name, description, icon }),
|
body: toFormData({ name, type, description, icon }),
|
||||||
});
|
});
|
||||||
toast.success("دستهبندی افزوده شد.");
|
toast.success("دستهبندی افزوده شد.");
|
||||||
}
|
}
|
||||||
@@ -114,6 +136,12 @@ export default function MediaCategoriesPage() {
|
|||||||
),
|
),
|
||||||
},
|
},
|
||||||
{ key: "name", header: "نام دستهبندی" },
|
{ key: "name", header: "نام دستهبندی" },
|
||||||
|
{
|
||||||
|
key: "type",
|
||||||
|
header: "نوع",
|
||||||
|
render: (r) => TYPE_LABELS[r.type] ?? r.type,
|
||||||
|
className: "w-28",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: "description",
|
key: "description",
|
||||||
header: "توضیحات",
|
header: "توضیحات",
|
||||||
@@ -130,12 +158,26 @@ export default function MediaCategoriesPage() {
|
|||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<PageHeader
|
<PageHeader
|
||||||
title="دستهبندی رسانهها"
|
title="دستهبندیها"
|
||||||
subtitle="مدیریت دستهبندیهای اصلی محتوای صوتی و تصویری"
|
subtitle="مدیریت دستهبندیهای عمومی رسانه، پلیلیست و قالب تنفس"
|
||||||
action={
|
action={
|
||||||
|
<div className="flex items-center gap-3">
|
||||||
|
<Select
|
||||||
|
value={typeFilter}
|
||||||
|
onChange={(e) => setTypeFilter(e.target.value as CategoryType)}
|
||||||
|
aria-label="نوع دستهبندی"
|
||||||
|
className="w-40"
|
||||||
|
>
|
||||||
|
{TYPE_OPTIONS.map((o) => (
|
||||||
|
<option key={o.value} value={o.value}>
|
||||||
|
{o.label}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
<Button icon={<PlusIcon className="h-4 w-4" />} onClick={openCreate}>
|
<Button icon={<PlusIcon className="h-4 w-4" />} onClick={openCreate}>
|
||||||
دستهبندی جدید
|
دستهبندی جدید
|
||||||
</Button>
|
</Button>
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -184,6 +226,19 @@ export default function MediaCategoriesPage() {
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<form id="category-form" onSubmit={save} className="flex flex-col gap-4">
|
<form id="category-form" onSubmit={save} className="flex flex-col gap-4">
|
||||||
|
<Field label="نوع" required>
|
||||||
|
<Select
|
||||||
|
value={type}
|
||||||
|
onChange={(e) => setType(e.target.value as CategoryType)}
|
||||||
|
>
|
||||||
|
{TYPE_OPTIONS.map((o) => (
|
||||||
|
<option key={o.value} value={o.value}>
|
||||||
|
{o.label}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
|
</Field>
|
||||||
|
|
||||||
<Field label="نام دستهبندی" required>
|
<Field label="نام دستهبندی" required>
|
||||||
<Input
|
<Input
|
||||||
value={name}
|
value={name}
|
||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
ConfirmDialog,
|
ConfirmDialog,
|
||||||
Field,
|
Field,
|
||||||
Input,
|
Input,
|
||||||
|
Textarea,
|
||||||
Select,
|
Select,
|
||||||
Switch,
|
Switch,
|
||||||
Modal,
|
Modal,
|
||||||
@@ -17,7 +18,7 @@ import {
|
|||||||
Badge,
|
Badge,
|
||||||
} from "@/components/ui";
|
} from "@/components/ui";
|
||||||
import { EditIcon, PlusIcon, TrashIcon } from "@/components/icons";
|
import { EditIcon, PlusIcon, TrashIcon } from "@/components/icons";
|
||||||
import { formatMinutes } from "@/lib/utils";
|
import { formatMinutes, fileNameToTitle } from "@/lib/utils";
|
||||||
import { MediaPreview } from "@/components/MediaPreview";
|
import { MediaPreview } from "@/components/MediaPreview";
|
||||||
import { ImagePicker } from "@/components/ImagePicker";
|
import { ImagePicker } from "@/components/ImagePicker";
|
||||||
import { pickUrl, SOUND_KEYS, VIDEO_KEYS, IMAGE_KEYS } from "@/lib/media";
|
import { pickUrl, SOUND_KEYS, VIDEO_KEYS, IMAGE_KEYS } from "@/lib/media";
|
||||||
@@ -41,6 +42,9 @@ interface Media {
|
|||||||
is_premium?: boolean;
|
is_premium?: boolean;
|
||||||
external_url?: string | null;
|
external_url?: string | null;
|
||||||
image_id?: number | null;
|
image_id?: number | null;
|
||||||
|
image?: unknown;
|
||||||
|
detail_image_id?: number | null;
|
||||||
|
detail_image?: unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compact multi-select rendered as toggle chips.
|
// Compact multi-select rendered as toggle chips.
|
||||||
@@ -81,7 +85,9 @@ function ChipMultiSelect({
|
|||||||
export default function MediaPage() {
|
export default function MediaPage() {
|
||||||
const [search, setSearch] = useState("");
|
const [search, setSearch] = useState("");
|
||||||
const { data, loading, error, reload } = useList<Media>("/media", { search });
|
const { data, loading, error, reload } = useList<Media>("/media", { search });
|
||||||
const { data: categories } = useList<Category>("/categories");
|
const { data: categories } = useList<Category>("/categories", {
|
||||||
|
type: "media",
|
||||||
|
});
|
||||||
const { data: subCategories } = useList<Category>("/sub-categories");
|
const { data: subCategories } = useList<Category>("/sub-categories");
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
|
|
||||||
@@ -101,6 +107,8 @@ export default function MediaPage() {
|
|||||||
const [externalUrl, setExternalUrl] = useState("");
|
const [externalUrl, setExternalUrl] = useState("");
|
||||||
const [imageId, setImageId] = useState<number | null>(null);
|
const [imageId, setImageId] = useState<number | null>(null);
|
||||||
const [imageFile, setImageFile] = useState<File | null>(null);
|
const [imageFile, setImageFile] = useState<File | null>(null);
|
||||||
|
const [detailImageId, setDetailImageId] = useState<number | null>(null);
|
||||||
|
const [detailImageFile, setDetailImageFile] = useState<File | null>(null);
|
||||||
|
|
||||||
const [deleting, setDeleting] = useState<Media | null>(null);
|
const [deleting, setDeleting] = useState<Media | null>(null);
|
||||||
const [removing, setRemoving] = useState(false);
|
const [removing, setRemoving] = useState(false);
|
||||||
@@ -118,6 +126,8 @@ export default function MediaPage() {
|
|||||||
setExternalUrl("");
|
setExternalUrl("");
|
||||||
setImageId(null);
|
setImageId(null);
|
||||||
setImageFile(null);
|
setImageFile(null);
|
||||||
|
setDetailImageId(null);
|
||||||
|
setDetailImageFile(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
function openCreate() {
|
function openCreate() {
|
||||||
@@ -142,6 +152,8 @@ export default function MediaPage() {
|
|||||||
setExternalUrl(row.external_url ?? "");
|
setExternalUrl(row.external_url ?? "");
|
||||||
setImageId(row.image_id ?? null);
|
setImageId(row.image_id ?? null);
|
||||||
setImageFile(null);
|
setImageFile(null);
|
||||||
|
setDetailImageId(row.detail_image_id ?? null);
|
||||||
|
setDetailImageFile(null);
|
||||||
setOpen(true);
|
setOpen(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,6 +178,8 @@ export default function MediaPage() {
|
|||||||
external_url: externalUrl,
|
external_url: externalUrl,
|
||||||
image_id: imageId,
|
image_id: imageId,
|
||||||
image: imageFile,
|
image: imageFile,
|
||||||
|
detail_image_id: detailImageId,
|
||||||
|
detail_image: detailImageFile,
|
||||||
});
|
});
|
||||||
if (editing) {
|
if (editing) {
|
||||||
// File-bearing update: POST /media/:id (multipart, file optional)
|
// File-bearing update: POST /media/:id (multipart, file optional)
|
||||||
@@ -328,14 +342,14 @@ export default function MediaPage() {
|
|||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
<Field label="توضیحات">
|
<Field label="توضیحات">
|
||||||
<Input
|
<Textarea
|
||||||
value={caption}
|
value={caption}
|
||||||
onChange={(e) => setCaption(e.target.value)}
|
onChange={(e) => setCaption(e.target.value)}
|
||||||
placeholder="توضیح کوتاه"
|
placeholder="توضیح کوتاه"
|
||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
<Field label="تصویر شاخص" hint="انتخاب از کتابخانه یا بارگذاری تصویر جدید">
|
<Field label="تصویر لیست" hint="در فهرست نمایش داده میشود">
|
||||||
<ImagePicker
|
<ImagePicker
|
||||||
imageId={imageId}
|
imageId={imageId}
|
||||||
onPickId={setImageId}
|
onPickId={setImageId}
|
||||||
@@ -345,6 +359,16 @@ export default function MediaPage() {
|
|||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
|
<Field label="تصویر جزئیات" hint="در صفحه جزئیات نمایش داده میشود">
|
||||||
|
<ImagePicker
|
||||||
|
imageId={detailImageId}
|
||||||
|
onPickId={setDetailImageId}
|
||||||
|
file={detailImageFile}
|
||||||
|
onPickFile={setDetailImageFile}
|
||||||
|
existingUrl={editing ? pickUrl(editing, ["detail_image"]) : null}
|
||||||
|
/>
|
||||||
|
</Field>
|
||||||
|
|
||||||
<Field label="دستهبندیها">
|
<Field label="دستهبندیها">
|
||||||
<ChipMultiSelect
|
<ChipMultiSelect
|
||||||
options={categories}
|
options={categories}
|
||||||
@@ -375,7 +399,12 @@ export default function MediaPage() {
|
|||||||
<Input
|
<Input
|
||||||
type="file"
|
type="file"
|
||||||
accept="audio/*,video/*"
|
accept="audio/*,video/*"
|
||||||
onChange={(e) => setFile(e.target.files?.[0] ?? null)}
|
onChange={(e) => {
|
||||||
|
const f = e.target.files?.[0] ?? null;
|
||||||
|
setFile(f);
|
||||||
|
// Fill the title from the file name if still empty.
|
||||||
|
if (f && !title.trim()) setTitle(fileNameToTitle(f.name));
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
|
|||||||
@@ -15,12 +15,19 @@ import {
|
|||||||
PageHeader,
|
PageHeader,
|
||||||
} from "@/components/ui";
|
} from "@/components/ui";
|
||||||
import { EditIcon, PlusIcon, TrashIcon } from "@/components/icons";
|
import { EditIcon, PlusIcon, TrashIcon } from "@/components/icons";
|
||||||
|
import { ImagePicker } from "@/components/ImagePicker";
|
||||||
|
import { MediaPreview } from "@/components/MediaPreview";
|
||||||
|
import { pickUrl, IMAGE_KEYS } from "@/lib/media";
|
||||||
import { toFa } from "@/lib/utils";
|
import { toFa } from "@/lib/utils";
|
||||||
|
|
||||||
interface Playlist {
|
interface Playlist {
|
||||||
id: number;
|
id: number;
|
||||||
name?: string;
|
name?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
|
image_id?: number | null;
|
||||||
|
image?: unknown;
|
||||||
|
detail_image_id?: number | null;
|
||||||
|
detail_image?: unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MusicCategory {
|
interface MusicCategory {
|
||||||
@@ -42,6 +49,10 @@ export default function MusicPlaylistsPage() {
|
|||||||
const [description, setDescription] = useState("");
|
const [description, setDescription] = useState("");
|
||||||
const [categoryIds, setCategoryIds] = useState<number[]>([]);
|
const [categoryIds, setCategoryIds] = useState<number[]>([]);
|
||||||
const [subcategoryIds, setSubcategoryIds] = useState<number[]>([]);
|
const [subcategoryIds, setSubcategoryIds] = useState<number[]>([]);
|
||||||
|
const [imageId, setImageId] = useState<number | null>(null);
|
||||||
|
const [imageFile, setImageFile] = useState<File | null>(null);
|
||||||
|
const [detailImageId, setDetailImageId] = useState<number | null>(null);
|
||||||
|
const [detailImageFile, setDetailImageFile] = useState<File | null>(null);
|
||||||
|
|
||||||
const [deleting, setDeleting] = useState<Playlist | null>(null);
|
const [deleting, setDeleting] = useState<Playlist | null>(null);
|
||||||
const [removing, setRemoving] = useState(false);
|
const [removing, setRemoving] = useState(false);
|
||||||
@@ -56,6 +67,10 @@ export default function MusicPlaylistsPage() {
|
|||||||
setDescription("");
|
setDescription("");
|
||||||
setCategoryIds([]);
|
setCategoryIds([]);
|
||||||
setSubcategoryIds([]);
|
setSubcategoryIds([]);
|
||||||
|
setImageId(null);
|
||||||
|
setImageFile(null);
|
||||||
|
setDetailImageId(null);
|
||||||
|
setDetailImageFile(null);
|
||||||
setOpen(true);
|
setOpen(true);
|
||||||
}
|
}
|
||||||
function openEdit(row: Playlist) {
|
function openEdit(row: Playlist) {
|
||||||
@@ -64,6 +79,10 @@ export default function MusicPlaylistsPage() {
|
|||||||
setDescription(row.description ?? "");
|
setDescription(row.description ?? "");
|
||||||
setCategoryIds([]);
|
setCategoryIds([]);
|
||||||
setSubcategoryIds([]);
|
setSubcategoryIds([]);
|
||||||
|
setImageId(row.image_id ?? null);
|
||||||
|
setImageFile(null);
|
||||||
|
setDetailImageId(row.detail_image_id ?? null);
|
||||||
|
setDetailImageFile(null);
|
||||||
setOpen(true);
|
setOpen(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,10 +91,17 @@ export default function MusicPlaylistsPage() {
|
|||||||
setSaving(true);
|
setSaving(true);
|
||||||
try {
|
try {
|
||||||
if (editing) {
|
if (editing) {
|
||||||
// Update is JSON on /music-playlists/:id
|
// Update is multipart (POST) so an image file can be uploaded.
|
||||||
await apiFetch(`/music-playlists/${editing.id}`, {
|
await apiFetch(`/music-playlists/${editing.id}`, {
|
||||||
method: "PUT",
|
method: "POST",
|
||||||
body: { name, description },
|
body: toFormData({
|
||||||
|
name,
|
||||||
|
description,
|
||||||
|
image_id: imageId,
|
||||||
|
image: imageFile,
|
||||||
|
detail_image_id: detailImageId,
|
||||||
|
detail_image: detailImageFile,
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
toast.success("پلیلیست ویرایش شد.");
|
toast.success("پلیلیست ویرایش شد.");
|
||||||
} else {
|
} else {
|
||||||
@@ -87,6 +113,10 @@ export default function MusicPlaylistsPage() {
|
|||||||
description,
|
description,
|
||||||
category_ids: categoryIds,
|
category_ids: categoryIds,
|
||||||
subcategory_ids: subcategoryIds,
|
subcategory_ids: subcategoryIds,
|
||||||
|
image_id: imageId,
|
||||||
|
image: imageFile,
|
||||||
|
detail_image_id: detailImageId,
|
||||||
|
detail_image: detailImageFile,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
toast.success("پلیلیست افزوده شد.");
|
toast.success("پلیلیست افزوده شد.");
|
||||||
@@ -117,6 +147,14 @@ export default function MusicPlaylistsPage() {
|
|||||||
|
|
||||||
const columns: Column<Playlist>[] = [
|
const columns: Column<Playlist>[] = [
|
||||||
{ key: "id", header: "شناسه", render: (r) => toFa(r.id), className: "w-24" },
|
{ key: "id", header: "شناسه", render: (r) => toFa(r.id), className: "w-24" },
|
||||||
|
{
|
||||||
|
key: "image",
|
||||||
|
header: "تصویر",
|
||||||
|
className: "w-20",
|
||||||
|
render: (r) => (
|
||||||
|
<MediaPreview kind="image" src={pickUrl(r, IMAGE_KEYS)} label={r.name} />
|
||||||
|
),
|
||||||
|
},
|
||||||
{ key: "name", header: "نام" },
|
{ key: "name", header: "نام" },
|
||||||
{
|
{
|
||||||
key: "description",
|
key: "description",
|
||||||
@@ -199,6 +237,26 @@ export default function MusicPlaylistsPage() {
|
|||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
|
<Field label="تصویر لیست">
|
||||||
|
<ImagePicker
|
||||||
|
imageId={imageId}
|
||||||
|
onPickId={setImageId}
|
||||||
|
file={imageFile}
|
||||||
|
onPickFile={setImageFile}
|
||||||
|
existingUrl={editing ? pickUrl(editing, IMAGE_KEYS) : null}
|
||||||
|
/>
|
||||||
|
</Field>
|
||||||
|
|
||||||
|
<Field label="تصویر جزئیات">
|
||||||
|
<ImagePicker
|
||||||
|
imageId={detailImageId}
|
||||||
|
onPickId={setDetailImageId}
|
||||||
|
file={detailImageFile}
|
||||||
|
onPickFile={setDetailImageFile}
|
||||||
|
existingUrl={editing ? pickUrl(editing, ["detail_image"]) : null}
|
||||||
|
/>
|
||||||
|
</Field>
|
||||||
|
|
||||||
{!editing && (
|
{!editing && (
|
||||||
<>
|
<>
|
||||||
<Field label="دستهبندیها">
|
<Field label="دستهبندیها">
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import {
|
|||||||
PageHeader,
|
PageHeader,
|
||||||
} from "@/components/ui";
|
} from "@/components/ui";
|
||||||
import { EditIcon, PlusIcon, TrashIcon } from "@/components/icons";
|
import { EditIcon, PlusIcon, TrashIcon } from "@/components/icons";
|
||||||
import { formatMinutes } from "@/lib/utils";
|
import { formatMinutes, fileNameToTitle } from "@/lib/utils";
|
||||||
import { MediaPreview } from "@/components/MediaPreview";
|
import { MediaPreview } from "@/components/MediaPreview";
|
||||||
import { ImagePicker } from "@/components/ImagePicker";
|
import { ImagePicker } from "@/components/ImagePicker";
|
||||||
import { pickUrl, SOUND_KEYS, IMAGE_KEYS } from "@/lib/media";
|
import { pickUrl, SOUND_KEYS, IMAGE_KEYS } from "@/lib/media";
|
||||||
@@ -301,7 +301,12 @@ export default function MusicTracksPage() {
|
|||||||
<Input
|
<Input
|
||||||
type="file"
|
type="file"
|
||||||
accept="audio/*"
|
accept="audio/*"
|
||||||
onChange={(e) => setFile(e.target.files?.[0] ?? null)}
|
onChange={(e) => {
|
||||||
|
const f = e.target.files?.[0] ?? null;
|
||||||
|
setFile(f);
|
||||||
|
// Fill the title from the file name if still empty.
|
||||||
|
if (f && !title.trim()) setTitle(fileNameToTitle(f.name));
|
||||||
|
}}
|
||||||
required={!editing}
|
required={!editing}
|
||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
|
|||||||
+13
-6
@@ -33,14 +33,18 @@ export const NAV: NavSection[] = [
|
|||||||
icon: HomeIcon,
|
icon: HomeIcon,
|
||||||
items: [{ href: "/dashboard", label: "خانه" }],
|
items: [{ href: "/dashboard", label: "خانه" }],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: "عمومی",
|
||||||
|
icon: TagIcon,
|
||||||
|
items: [
|
||||||
|
{ href: "/dashboard/categories", label: "دستهبندیها" },
|
||||||
|
{ href: "/dashboard/sub-categories", label: "زیردستهها" },
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: "رسانهها",
|
label: "رسانهها",
|
||||||
icon: MediaIcon,
|
icon: MediaIcon,
|
||||||
items: [
|
items: [{ href: "/dashboard/media", label: "فهرست رسانهها" }],
|
||||||
{ href: "/dashboard/media", label: "فهرست رسانهها" },
|
|
||||||
{ href: "/dashboard/media/categories", label: "دستهبندیها" },
|
|
||||||
{ href: "/dashboard/media/sub-categories", label: "زیردستهها" },
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "موسیقی",
|
label: "موسیقی",
|
||||||
@@ -118,6 +122,9 @@ export const NAV: NavSection[] = [
|
|||||||
{
|
{
|
||||||
label: "محتوای کاربران",
|
label: "محتوای کاربران",
|
||||||
icon: TagIcon,
|
icon: TagIcon,
|
||||||
items: [{ href: "/dashboard/comments", label: "نظرات" }],
|
items: [
|
||||||
|
{ href: "/dashboard/comments", label: "نظرات" },
|
||||||
|
{ href: "/dashboard/app-feedback", label: "نظرات و ایدهها برنامه" },
|
||||||
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -19,6 +19,16 @@ export function formatDuration(seconds?: number | null): string {
|
|||||||
return toFa(`${m}:${String(s).padStart(2, "0")}`);
|
return toFa(`${m}:${String(s).padStart(2, "0")}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Derive a clean title from an uploaded file name: drop the extension and turn
|
||||||
|
// underscores/dashes into spaces (e.g. "morning_calm-01.mp3" -> "morning calm 01").
|
||||||
|
export function fileNameToTitle(name: string): string {
|
||||||
|
return name
|
||||||
|
.replace(/\.[^./\\]+$/, "")
|
||||||
|
.replace(/[_-]+/g, " ")
|
||||||
|
.replace(/\s+/g, " ")
|
||||||
|
.trim();
|
||||||
|
}
|
||||||
|
|
||||||
// Minutes -> Persian label. Media and music store `duration` in minutes.
|
// Minutes -> Persian label. Media and music store `duration` in minutes.
|
||||||
export function formatMinutes(minutes?: number | null): string {
|
export function formatMinutes(minutes?: number | null): string {
|
||||||
if (minutes === null || minutes === undefined) return "—";
|
if (minutes === null || minutes === undefined) return "—";
|
||||||
|
|||||||
Generated
+1
-24
@@ -277,30 +277,6 @@
|
|||||||
"node": ">=6.9.0"
|
"node": ">=6.9.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@emnapi/core": {
|
|
||||||
"version": "1.10.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.10.0.tgz",
|
|
||||||
"integrity": "sha512-yq6OkJ4p82CAfPl0u9mQebQHKPJkY7WrIuk205cTYnYe+k2Z8YBh11FrbRG/H6ihirqcacOgl2BIO8oyMQLeXw==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
|
||||||
"optional": true,
|
|
||||||
"peer": true,
|
|
||||||
"dependencies": {
|
|
||||||
"@emnapi/wasi-threads": "1.2.1",
|
|
||||||
"tslib": "^2.4.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@emnapi/runtime": {
|
|
||||||
"version": "1.10.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.10.0.tgz",
|
|
||||||
"integrity": "sha512-ewvYlk86xUoGI0zQRNq/mC+16R1QeDlKQy21Ki3oSYXNgLb45GV1P6A0M+/s6nyCuNDqe5VpaY84BzXGwVbwFA==",
|
|
||||||
"license": "MIT",
|
|
||||||
"optional": true,
|
|
||||||
"peer": true,
|
|
||||||
"dependencies": {
|
|
||||||
"tslib": "^2.4.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@emnapi/wasi-threads": {
|
"node_modules/@emnapi/wasi-threads": {
|
||||||
"version": "1.2.1",
|
"version": "1.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.1.tgz",
|
||||||
@@ -3312,6 +3288,7 @@
|
|||||||
"integrity": "sha512-whOE1HFo/qJDyX4SnXzP4N6zOWn79WhnCUY/iDR0mPfQZO8wcYE4JClzI2oZrhBnnMUCBCHZhO6VQyoBU95mZA==",
|
"integrity": "sha512-whOE1HFo/qJDyX4SnXzP4N6zOWn79WhnCUY/iDR0mPfQZO8wcYE4JClzI2oZrhBnnMUCBCHZhO6VQyoBU95mZA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@rtsao/scc": "^1.1.0",
|
"@rtsao/scc": "^1.1.0",
|
||||||
"array-includes": "^3.1.9",
|
"array-includes": "^3.1.9",
|
||||||
|
|||||||
+2
-1
@@ -6,7 +6,8 @@
|
|||||||
"dev": "next dev",
|
"dev": "next dev",
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
"lint": "eslint"
|
"lint": "eslint",
|
||||||
|
"deploy": "bash scripts/deploy.sh"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"next": "16.2.7",
|
"next": "16.2.7",
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Build the static site locally, then replace the server directory with it.
|
||||||
|
#
|
||||||
|
# - Builds on THIS machine (npm run build -> ./out).
|
||||||
|
# - Streams out/ over a single SSH connection (tar pipe) and swaps the
|
||||||
|
# contents of the target dir on the server. No rsync/sshpass required.
|
||||||
|
#
|
||||||
|
# Password handling:
|
||||||
|
# - If `sshpass` is installed AND DEPLOY_PASSWORD is set (env or .env.deploy),
|
||||||
|
# the deploy is fully unattended.
|
||||||
|
# - Otherwise SSH prompts for the password once (interactive).
|
||||||
|
#
|
||||||
|
# Config (override via env or .env.deploy):
|
||||||
|
set -euo pipefail
|
||||||
|
cd "$(git rev-parse --show-toplevel 2>/dev/null || dirname "$(dirname "$0")")"
|
||||||
|
|
||||||
|
# Optional local secrets file (gitignored).
|
||||||
|
[ -f .env.deploy ] && . ./.env.deploy
|
||||||
|
|
||||||
|
DEPLOY_HOST="${DEPLOY_HOST:-185.226.116.88}"
|
||||||
|
DEPLOY_USER="${DEPLOY_USER:-ubuntu}"
|
||||||
|
DEPLOY_PATH="${DEPLOY_PATH:-/var/www/aramland-admin}"
|
||||||
|
DEPLOY_PASSWORD="${DEPLOY_PASSWORD:-}"
|
||||||
|
|
||||||
|
echo "▸ Building locally…"
|
||||||
|
npm run build
|
||||||
|
|
||||||
|
if [ ! -d out ]; then
|
||||||
|
echo "✗ Build did not produce ./out" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Pick the SSH command: unattended with sshpass, else interactive prompt.
|
||||||
|
ssh_cmd=(ssh -o StrictHostKeyChecking=no "$DEPLOY_USER@$DEPLOY_HOST")
|
||||||
|
if command -v sshpass >/dev/null 2>&1 && [ -n "$DEPLOY_PASSWORD" ]; then
|
||||||
|
ssh_cmd=(sshpass -p "$DEPLOY_PASSWORD" "${ssh_cmd[@]}")
|
||||||
|
else
|
||||||
|
echo "ℹ sshpass/password not available — SSH will prompt for the password."
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "▸ Uploading to $DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH …"
|
||||||
|
# Replace the directory contents (incl. dotfiles) then extract the new build.
|
||||||
|
tar -C out -czf - . | "${ssh_cmd[@]}" \
|
||||||
|
"set -e; mkdir -p '$DEPLOY_PATH'; find '$DEPLOY_PATH' -mindepth 1 -delete; tar -C '$DEPLOY_PATH' -xzf -"
|
||||||
|
|
||||||
|
echo "✓ Deployed to $DEPLOY_HOST:$DEPLOY_PATH"
|
||||||
Reference in New Issue
Block a user