Add site-wide media grid with combined filters and shared path bar
DC CMS qualification / qualify (push) Successful in 1m46s
DC CMS qualification / qualify (push) Successful in 1m46s
This commit is contained in:
+1
-1
File diff suppressed because one or more lines are too long
+88
-88
File diff suppressed because one or more lines are too long
+3
-2
@@ -159,13 +159,12 @@
|
|||||||
<span>Поиск</span>
|
<span>Поиск</span>
|
||||||
<input id="media-search" type="search" autocomplete="off" placeholder="Имя, папка, путь" />
|
<input id="media-search" type="search" autocomplete="off" placeholder="Имя, папка, путь" />
|
||||||
</label>
|
</label>
|
||||||
<div id="media-kind-filters" class="media-filter-row media-kind-row" aria-label="Тип файла"></div>
|
<div class="media-kind-row"><div id="media-kind-filters" class="media-filter-row" role="group" aria-label="Типы файлов"></div><span id="media-results" class="nodedc-description" role="status"></span><button id="media-flat-toggle" class="nodedc-icon-button" type="button" aria-label="Все файлы без папок" aria-pressed="false"></button></div>
|
||||||
<div id="media-root-filters" class="media-filter-row media-root-row" aria-label="Корень файлов"></div>
|
<div id="media-root-filters" class="media-filter-row media-root-row" aria-label="Корень файлов"></div>
|
||||||
<button id="media-upload" class="primary-btn media-upload-btn" type="button">+ Загрузить</button>
|
<button id="media-upload" class="primary-btn media-upload-btn" type="button">+ Загрузить</button>
|
||||||
</div>
|
</div>
|
||||||
<div id="media-drop-zone" class="media-browser media-browser-columns">
|
<div id="media-drop-zone" class="media-browser media-browser-columns">
|
||||||
<section class="media-main">
|
<section class="media-main">
|
||||||
<div id="media-breadcrumbs" class="media-breadcrumbs"></div>
|
|
||||||
<div id="media-list" class="media-columns"></div>
|
<div id="media-list" class="media-columns"></div>
|
||||||
<div id="media-empty" class="media-empty hidden">Папка пуста.</div>
|
<div id="media-empty" class="media-empty hidden">Папка пуста.</div>
|
||||||
</section>
|
</section>
|
||||||
@@ -197,6 +196,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</aside>
|
</aside>
|
||||||
</div>
|
</div>
|
||||||
|
<nav id="media-breadcrumbs"></nav>
|
||||||
<footer class="template-modal-foot media-modal-foot">
|
<footer class="template-modal-foot media-modal-foot">
|
||||||
<span id="media-size-status" class="nodedc-description" role="status">Размер окна сохраняется в профиле</span>
|
<span id="media-size-status" class="nodedc-description" role="status">Размер окна сохраняется в профиле</span>
|
||||||
<button id="media-size-retry" class="ghost-btn" type="button" hidden>Повторить</button>
|
<button id="media-size-retry" class="ghost-btn" type="button" hidden>Повторить</button>
|
||||||
@@ -309,4 +309,5 @@
|
|||||||
<template id="ds-icon-refresh"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-refresh-cw" aria-hidden="true" focusable="false"><path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"></path><path d="M21 3v5h-5"></path><path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"></path><path d="M8 16H3v5"></path></svg></template>
|
<template id="ds-icon-refresh"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-refresh-cw" aria-hidden="true" focusable="false"><path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"></path><path d="M21 3v5h-5"></path><path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"></path><path d="M8 16H3v5"></path></svg></template>
|
||||||
<template id="ds-icon-move"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-move" aria-hidden="true" focusable="false"><path d="M12 2v20"></path><path d="m15 19-3 3-3-3"></path><path d="m19 9 3 3-3 3"></path><path d="M2 12h20"></path><path d="m5 9-3 3 3 3"></path><path d="m9 5 3-3 3 3"></path></svg></template>
|
<template id="ds-icon-move"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-move" aria-hidden="true" focusable="false"><path d="M12 2v20"></path><path d="m15 19-3 3-3-3"></path><path d="m19 9 3 3-3 3"></path><path d="M2 12h20"></path><path d="m5 9-3 3 3 3"></path><path d="m9 5 3-3 3 3"></path></svg></template>
|
||||||
<template id="ds-icon-edit"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-pencil" aria-hidden="true" focusable="false"><path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"></path><path d="m15 5 4 4"></path></svg></template>
|
<template id="ds-icon-edit"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-pencil" aria-hidden="true" focusable="false"><path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"></path><path d="m15 5 4 4"></path></svg></template>
|
||||||
|
<template id="ds-icon-grid"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-layout-dashboard" aria-hidden="true" focusable="false"><rect width="7" height="9" x="3" y="3" rx="1"></rect><rect width="7" height="5" x="14" y="3" rx="1"></rect><rect width="7" height="9" x="14" y="12" rx="1"></rect><rect width="7" height="5" x="3" y="16" rx="1"></rect></svg></template>
|
||||||
<script type="module" src="./admin.js"></script></body></html>
|
<script type="module" src="./admin.js"></script></body></html>
|
||||||
|
|||||||
@@ -125,3 +125,19 @@ model save/render/publish flow; no carousel-specific CMS state or new CSS is
|
|||||||
introduced. Mission Core uses this for its per-carousel image-opening setting.
|
introduced. Mission Core uses this for its per-carousel image-opening setting.
|
||||||
Local UI acceptance: toggle on → Save → reload retains true, toggle off → Save
|
Local UI acceptance: toggle on → Save → reload retains true, toggle off → Save
|
||||||
removes the image links while preserving the other carousels.
|
removes the image links while preserving the other carousels.
|
||||||
|
|
||||||
|
## File manager window and navigation
|
||||||
|
|
||||||
|
The ui-dom package is pinned separately at `1326ec6` (`modal.2` archive) in
|
||||||
|
`ui/design-system.lock.json`; the existing Mission Core palette and other
|
||||||
|
packages keep their original pinned versions. CMS consumes the shared
|
||||||
|
`createModalSizeController` and `renderPathBar` exports, including the package's
|
||||||
|
path-bar stylesheet. The application adapter supplies site paths, standard
|
||||||
|
Icon templates and navigation callbacks. It does not copy either component.
|
||||||
|
Window geometry and appearance persist in the authenticated user's server-side
|
||||||
|
GUI metadata. File type controls reuse IconButton, support combined selection,
|
||||||
|
and switch between the site's flat asset index and existing folder browser.
|
||||||
|
|
||||||
|
Acceptance: mixed image/video/3D filtering, deep-folder search and path navigation,
|
||||||
|
isolation between two sites, 390 px layout, resize/reopen/reload and theme
|
||||||
|
persistence. Source tests cover the flat index's site boundary and exclusions.
|
||||||
|
|||||||
@@ -49,6 +49,15 @@ runtime-зависимостей. Лимит — 2 ГБ и 60 000 файлов.
|
|||||||
в этом режиме не подставляют файл в открытое поле и не меняют черновик страницы.
|
в этом режиме не подставляют файл в открытое поле и не меняют черновик страницы.
|
||||||
Загрузки без привязки к полю сохраняются в `assets/uploads/media/library`.
|
Загрузки без привязки к полю сохраняются в `assets/uploads/media/library`.
|
||||||
|
|
||||||
|
Менеджер из шапки открывается общей сеткой файлов из всех вложенных каталогов
|
||||||
|
`assets`. Фильтры-иконки изображений, видео и 3D можно сочетать; «Все» сбрасывает
|
||||||
|
выбор типов. Поиск проверяет имя и полный путь. Справа переключается общий
|
||||||
|
список и просмотр папок. Нижняя строка пути использует общий `renderPathBar`:
|
||||||
|
нейтральные иконки папок, компактные названия и переход по любому каталогу.
|
||||||
|
Выбор файла показывает его полный путь, исходное имя и кнопку скачивания.
|
||||||
|
Индекс исключает скрытые/служебные каталоги и символические ссылки, не выходит
|
||||||
|
за пределы выбранного сайта. Обычный picker сохраняет ограничение типа поля.
|
||||||
|
|
||||||
После выбора файла кнопка «Скачать» передаёт его исходные байты и имя через
|
После выбора файла кнопка «Скачать» передаёт его исходные байты и имя через
|
||||||
авторизованный `GET /s/<site-id>/api/media/download?path=assets/...`.
|
авторизованный `GET /s/<site-id>/api/media/download?path=assets/...`.
|
||||||
Видео передаются потоком без сборки ZIP и без загрузки целого файла в память
|
Видео передаются потоком без сборки ZIP и без загрузки целого файла в память
|
||||||
|
|||||||
+11
-34
@@ -1,5 +1,5 @@
|
|||||||
import { createReadStream, statSync } from "node:fs";
|
import { createReadStream, statSync } from "node:fs";
|
||||||
import { appendFile, copyFile, cp, mkdir, mkdtemp, readFile, readdir, rename, rm, stat, writeFile } from "node:fs/promises";
|
import { appendFile, copyFile, cp, lstat, mkdir, mkdtemp, readFile, readdir, rename, rm, stat, writeFile } from "node:fs/promises";
|
||||||
import { tmpdir } from "node:os";
|
import { tmpdir } from "node:os";
|
||||||
import { extname, join, normalize, relative, resolve } from "node:path";
|
import { extname, join, normalize, relative, resolve } from "node:path";
|
||||||
import { fileURLToPath } from "node:url";
|
import { fileURLToPath } from "node:url";
|
||||||
@@ -64,36 +64,7 @@ const trashStores = [
|
|||||||
displayPrefix: "assets/uploads/.trash",
|
displayPrefix: "assets/uploads/.trash",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
const mediaRoots = [
|
const mediaRoots = [{ id: "assets", label: "Файлы сайта", rootPath: join(repoRoot, "assets"), urlPrefix: "./assets", writable: true }];
|
||||||
{
|
|
||||||
id: "uploads",
|
|
||||||
label: "Uploads",
|
|
||||||
rootPath: uploadRoot,
|
|
||||||
urlPrefix: "./assets/uploads",
|
|
||||||
writable: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "media",
|
|
||||||
label: "Legacy media",
|
|
||||||
rootPath: join(repoRoot, "assets", "media"),
|
|
||||||
urlPrefix: "./assets/media",
|
|
||||||
writable: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "site-images",
|
|
||||||
label: "Site images",
|
|
||||||
rootPath: join(repoRoot, "assets", "site", "images"),
|
|
||||||
urlPrefix: "./assets/site/images",
|
|
||||||
writable: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "custom-assets",
|
|
||||||
label: "Custom assets",
|
|
||||||
rootPath: join(repoRoot, "assets", "custom"),
|
|
||||||
urlPrefix: "./assets/custom",
|
|
||||||
writable: true,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
const MEDIA_EXTENSIONS = new Set([
|
const MEDIA_EXTENSIONS = new Set([
|
||||||
".avif",
|
".avif",
|
||||||
".gif",
|
".gif",
|
||||||
@@ -1364,16 +1335,19 @@ async function scanMediaRoot(root) {
|
|||||||
let entries = [];
|
let entries = [];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
const directoryStat = await lstat(directory);
|
||||||
|
if (!directoryStat.isDirectory() || directoryStat.isSymbolicLink()) return;
|
||||||
entries = await readdir(directory, { withFileTypes: true });
|
entries = await readdir(directory, { withFileTypes: true });
|
||||||
} catch {
|
} catch (error) {
|
||||||
return;
|
if (error.code === "ENOENT") return;
|
||||||
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const entry of entries) {
|
for (const entry of entries) {
|
||||||
const filePath = join(directory, entry.name);
|
const filePath = join(directory, entry.name);
|
||||||
const relativePath = relative(root.rootPath, filePath).replace(/\\/g, "/");
|
const relativePath = relative(root.rootPath, filePath).replace(/\\/g, "/");
|
||||||
|
|
||||||
if (!relativePath || relativePath.split("/").includes(".trash")) continue;
|
if (!relativePath || relativePath.split("/").some(part => part.startsWith(".") || BROWSER_EXCLUDED_DIRS.has(part))) continue;
|
||||||
|
|
||||||
if (entry.isDirectory()) {
|
if (entry.isDirectory()) {
|
||||||
await walk(filePath);
|
await walk(filePath);
|
||||||
@@ -1391,6 +1365,9 @@ async function scanMediaRoot(root) {
|
|||||||
|
|
||||||
files.push({
|
files.push({
|
||||||
id: `${root.id}:${relativePath}`,
|
id: `${root.id}:${relativePath}`,
|
||||||
|
type: "file",
|
||||||
|
path: relative(repoRoot, filePath).replace(/\\/g, "/"),
|
||||||
|
selectable: true,
|
||||||
rootId: root.id,
|
rootId: root.id,
|
||||||
rootLabel: root.label,
|
rootLabel: root.label,
|
||||||
writable: root.writable,
|
writable: root.writable,
|
||||||
|
|||||||
@@ -81,6 +81,19 @@ test('independent sites, rendering, secrets and publication ownership', async t
|
|||||||
assert.equal(await readFile(join(original,'index.html'),'utf8'),'<h1>Original</h1>');
|
assert.equal(await readFile(join(original,'index.html'),'utf8'),'<h1>Original</h1>');
|
||||||
assert.equal(await (await fetch(base+'/s/mission-core/index.html')).text(),'<h1>Mission edited</h1>');
|
assert.equal(await (await fetch(base+'/s/mission-core/index.html')).text(),'<h1>Mission edited</h1>');
|
||||||
});
|
});
|
||||||
|
await t.test('flat media spans deep asset folders and remains site-scoped', async () => {
|
||||||
|
const mission = join(projects, 'sites/mission-core');
|
||||||
|
for (const name of ['assets/top.svg','assets/arbitrary/a/b/deep.webp','assets/other/video.mp4','assets/models/rover.glb','assets/.private/hidden.png','assets/.trash/deleted.png']) {
|
||||||
|
const path = join(mission, name); await mkdir(join(path,'..'),{recursive:true}); await writeFile(path,'fixture');
|
||||||
|
}
|
||||||
|
await symlink(join(original,'index.html'),join(mission,'assets/linked.png'));
|
||||||
|
const files=(await api('/s/mission-core/api/media/assets')).files;
|
||||||
|
assert.deepEqual(files.map(f=>f.path).sort(),['assets/arbitrary/a/b/deep.webp','assets/models/rover.glb','assets/other/video.mp4','assets/top.svg']);
|
||||||
|
assert.ok(files.every(f=>f.type==='file' && f.selectable && f.writable));
|
||||||
|
assert.deepEqual(new Set(files.map(f=>f.kind)),new Set(['image','video','model']));
|
||||||
|
assert.equal((await api('/s/nodedc/api/media/assets')).files.length,0);
|
||||||
|
for (const name of ['top.svg','arbitrary','other','models','.private','.trash','linked.png']) await rm(join(mission,'assets',name),{recursive:true,force:true});
|
||||||
|
});
|
||||||
await t.test('media downloads keep original bytes, filename and selected-site ownership',async()=>{
|
await t.test('media downloads keep original bytes, filename and selected-site ownership',async()=>{
|
||||||
for (const [site,expected] of [['nodedc','original-asset'],['mission-core','mission-asset']]) {
|
for (const [site,expected] of [['nodedc','original-asset'],['mission-core','mission-asset']]) {
|
||||||
const response=await fetch(`${base}/s/${site}/api/media/download?path=assets%2Fproof.txt`);
|
const response=await fetch(`${base}/s/${site}/api/media/download?path=assets%2Fproof.txt`);
|
||||||
|
|||||||
+1
-1
@@ -35,7 +35,7 @@ const nav = h(AdminNavigationPanel, { eyebrow: "NODE.DC / CMS", title: h("span",
|
|||||||
const actions = h("div", { className: "cms-editor-actions" }, h(StatusBadge, { id: "dirty-state", "data-dirty": "false" }, "\u0421\u0438\u043D\u0445\u0440\u043E\u043D\u0438\u0437\u0438\u0440\u043E\u0432\u0430\u043D\u043E"), ib("reload", "\u041F\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C \u0434\u0430\u043D\u043D\u044B\u0435", "refresh"), btn("save", "\u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C \u043C\u043E\u0434\u0435\u043B\u044C", "primary"), btn("render", "\u041E\u0431\u043D\u043E\u0432\u0438\u0442\u044C \u0441\u0430\u0439\u0442"), h(Button, { id: "publish", className: "hidden", tone: "neutral" }, "\u041E\u043F\u0443\u0431\u043B\u0438\u043A\u043E\u0432\u0430\u0442\u044C"), h(Button, {id: "download-backup", variant: "secondary", tone: "neutral", className: "hidden"}, "Скачать бэкап"));
|
const actions = h("div", { className: "cms-editor-actions" }, h(StatusBadge, { id: "dirty-state", "data-dirty": "false" }, "\u0421\u0438\u043D\u0445\u0440\u043E\u043D\u0438\u0437\u0438\u0440\u043E\u0432\u0430\u043D\u043E"), ib("reload", "\u041F\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C \u0434\u0430\u043D\u043D\u044B\u0435", "refresh"), btn("save", "\u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C \u043C\u043E\u0434\u0435\u043B\u044C", "primary"), btn("render", "\u041E\u0431\u043D\u043E\u0432\u0438\u0442\u044C \u0441\u0430\u0439\u0442"), h(Button, { id: "publish", className: "hidden", tone: "neutral" }, "\u041E\u043F\u0443\u0431\u043B\u0438\u043A\u043E\u0432\u0430\u0442\u044C"), h(Button, {id: "download-backup", variant: "secondary", tone: "neutral", className: "hidden"}, "Скачать бэкап"));
|
||||||
const content = h(ApplicationPanel, { eyebrow: h("span", { id: "editor-heading" }, "\u041D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0438 \u0441\u0430\u0439\u0442\u0430"), title: "\u041A\u043E\u043D\u0442\u0435\u043D\u0442", description: "\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0440\u0430\u0437\u0434\u0435\u043B", headerTools: actions, expanded: true, onClose: noop }, h("div", { className: "cms-editor", dangerouslySetInnerHTML: { __html: await read("editor.html") } }));
|
const content = h(ApplicationPanel, { eyebrow: h("span", { id: "editor-heading" }, "\u041D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0438 \u0441\u0430\u0439\u0442\u0430"), title: "\u041A\u043E\u043D\u0442\u0435\u043D\u0442", description: "\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0440\u0430\u0437\u0434\u0435\u043B", headerTools: actions, expanded: true, onClose: noop }, h("div", { className: "cms-editor", dangerouslySetInnerHTML: { __html: await read("editor.html") } }));
|
||||||
const shell = html(h(ApplicationShell, { id: "cms-shell", header, stage: h("div", { className: "cms-stage" }, h("p", null, "\u0423\u043F\u0440\u0430\u0432\u043B\u0435\u043D\u0438\u0435 \u0441\u0430\u0439\u0442\u0430\u043C\u0438 NODE.DC"), btn("open-navigation", "\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0440\u0430\u0437\u0434\u0435\u043B\u044B")), navigation: nav, content, navigationOpen: true, contentOpen: true, contentExpanded: true }));
|
const shell = html(h(ApplicationShell, { id: "cms-shell", header, stage: h("div", { className: "cms-stage" }, h("p", null, "\u0423\u043F\u0440\u0430\u0432\u043B\u0435\u043D\u0438\u0435 \u0441\u0430\u0439\u0442\u0430\u043C\u0438 NODE.DC"), btn("open-navigation", "\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0440\u0430\u0437\u0434\u0435\u043B\u044B")), navigation: nav, content, navigationOpen: true, contentOpen: true, contentExpanded: true }));
|
||||||
const icons = ["close", "plus", "chevron-up", "chevron-down", "copy", "clipboard", "trash", "eye", "eye-off", "layers", "panel", "file", "settings", "folder", "image", "video", "refresh", "move", "edit"];
|
const icons = ["close", "plus", "chevron-up", "chevron-down", "copy", "clipboard", "trash", "eye", "eye-off", "layers", "panel", "file", "settings", "folder", "image", "video", "refresh", "move", "edit", "grid"];
|
||||||
const templates = Object.entries({ settingRow: h(SettingsCard, { title: "Настройка", actions: h("span", { "data-slot": "control" }) }), nestedSurface: h(GlassSurface, {tone:"group", padding:"md", materialRim:false}, h("span")), dragHandle: h(DragHandle, {label:"Перетащить блок"}), button: h(Button, null, "\u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0435"), iconButton: h(IconButton, { label: "\u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0435" }, icon("plus")), field: h(FieldFrame, { label: "\u041F\u043E\u043B\u0435" }, h("span", { "data-slot": "control" })), text: h(TextField, { id: "template-field", label: "\u041F\u043E\u043B\u0435" }), card: h(SettingsCard, { eyebrow: "\u0420\u0430\u0437\u0434\u0435\u043B", title: "\u041D\u0430\u0437\u0432\u0430\u043D\u0438\u0435", description: "\u041E\u043F\u0438\u0441\u0430\u043D\u0438\u0435" }, h("div", { "data-slot": "body" })), media: h(MediaSourceField, { label: "\u041C\u0435\u0434\u0438\u0430", source: "file", url: "", onSourceChange: noop, onUrlChange: noop, onFileChange: noop }), ...Object.fromEntries(icons.map((name) => ["icon-" + name, icon(name)])) }).map(([name, node]) => `<template id="ds-${name}">${html(node)}</template>`).join("\n");
|
const templates = Object.entries({ settingRow: h(SettingsCard, { title: "Настройка", actions: h("span", { "data-slot": "control" }) }), nestedSurface: h(GlassSurface, {tone:"group", padding:"md", materialRim:false}, h("span")), dragHandle: h(DragHandle, {label:"Перетащить блок"}), button: h(Button, null, "\u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0435"), iconButton: h(IconButton, { label: "\u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0435" }, icon("plus")), field: h(FieldFrame, { label: "\u041F\u043E\u043B\u0435" }, h("span", { "data-slot": "control" })), text: h(TextField, { id: "template-field", label: "\u041F\u043E\u043B\u0435" }), card: h(SettingsCard, { eyebrow: "\u0420\u0430\u0437\u0434\u0435\u043B", title: "\u041D\u0430\u0437\u0432\u0430\u043D\u0438\u0435", description: "\u041E\u043F\u0438\u0441\u0430\u043D\u0438\u0435" }, h("div", { "data-slot": "body" })), media: h(MediaSourceField, { label: "\u041C\u0435\u0434\u0438\u0430", source: "file", url: "", onSourceChange: noop, onUrlChange: noop, onFileChange: noop }), ...Object.fromEntries(icons.map((name) => ["icon-" + name, icon(name)])) }).map(([name, node]) => `<template id="ds-${name}">${html(node)}</template>`).join("\n");
|
||||||
const page = `<!doctype html>
|
const page = `<!doctype html>
|
||||||
<html lang="ru" data-nodedc-ui="true" data-nodedc-theme="dark" data-nodedc-appearance="mission" data-nodedc-edges="flat"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="design-system-commit" content="${lock.sourceCommit}"><title>NODE.DC \u2014 CMS</title><link rel="stylesheet" href="./admin.css"></head><body>${shell}
|
<html lang="ru" data-nodedc-ui="true" data-nodedc-theme="dark" data-nodedc-appearance="mission" data-nodedc-edges="flat"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="design-system-commit" content="${lock.sourceCommit}"><title>NODE.DC \u2014 CMS</title><link rel="stylesheet" href="./admin.css"></head><body>${shell}
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
"nodedc-tokens-0.6.0-mission.2.tgz": "11386a46868f8e7dafa2743770d15dc201e1df46d036921f03475c15a7351b9c",
|
"nodedc-tokens-0.6.0-mission.2.tgz": "11386a46868f8e7dafa2743770d15dc201e1df46d036921f03475c15a7351b9c",
|
||||||
"nodedc-ui-core-0.7.0-mission.2.tgz": "6360deed064a7c3c5af9538fac38a31f9937d4521153705375c431e7afd56fe8",
|
"nodedc-ui-core-0.7.0-mission.2.tgz": "6360deed064a7c3c5af9538fac38a31f9937d4521153705375c431e7afd56fe8",
|
||||||
"nodedc-ui-react-0.7.0-mission.2.tgz": "cecf33a767e4c998e8c5cbcc70b20936844460424790d0a81aefa847c45f662e",
|
"nodedc-ui-react-0.7.0-mission.2.tgz": "cecf33a767e4c998e8c5cbcc70b20936844460424790d0a81aefa847c45f662e",
|
||||||
"nodedc-ui-dom-0.7.0-modal.1.tgz": "6e2d74f3b8e9aa797477ea82252f1e43d5efc041abceea3cd4319ba13d62969e"
|
"nodedc-ui-dom-0.7.0-modal.2.tgz": "85667985b73fd88855c64e446905e6bf24f7143fdf8c08920f5776940af3607e"
|
||||||
},
|
},
|
||||||
"packageSourceCommits": {
|
"packageSourceCommits": {
|
||||||
"nodedc-ui-dom-0.7.0-modal.1.tgz": "1ec17b30981e6f084ba288a530ee08280ab1f2a6"
|
"nodedc-ui-dom-0.7.0-modal.2.tgz": "1326ec6cc9ee0a2f4f3e75eaf4e22250c3fbafe5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -56,13 +56,12 @@
|
|||||||
<span>Поиск</span>
|
<span>Поиск</span>
|
||||||
<input id="media-search" type="search" autocomplete="off" placeholder="Имя, папка, путь" />
|
<input id="media-search" type="search" autocomplete="off" placeholder="Имя, папка, путь" />
|
||||||
</label>
|
</label>
|
||||||
<div id="media-kind-filters" class="media-filter-row media-kind-row" aria-label="Тип файла"></div>
|
<div class="media-kind-row"><div id="media-kind-filters" class="media-filter-row" role="group" aria-label="Типы файлов"></div><span id="media-results" class="nodedc-description" role="status"></span><button id="media-flat-toggle" class="nodedc-icon-button" type="button" aria-label="Все файлы без папок" aria-pressed="false"></button></div>
|
||||||
<div id="media-root-filters" class="media-filter-row media-root-row" aria-label="Корень файлов"></div>
|
<div id="media-root-filters" class="media-filter-row media-root-row" aria-label="Корень файлов"></div>
|
||||||
<button id="media-upload" class="primary-btn media-upload-btn" type="button">+ Загрузить</button>
|
<button id="media-upload" class="primary-btn media-upload-btn" type="button">+ Загрузить</button>
|
||||||
</div>
|
</div>
|
||||||
<div id="media-drop-zone" class="media-browser media-browser-columns">
|
<div id="media-drop-zone" class="media-browser media-browser-columns">
|
||||||
<section class="media-main">
|
<section class="media-main">
|
||||||
<div id="media-breadcrumbs" class="media-breadcrumbs"></div>
|
|
||||||
<div id="media-list" class="media-columns"></div>
|
<div id="media-list" class="media-columns"></div>
|
||||||
<div id="media-empty" class="media-empty hidden">Папка пуста.</div>
|
<div id="media-empty" class="media-empty hidden">Папка пуста.</div>
|
||||||
</section>
|
</section>
|
||||||
@@ -94,6 +93,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</aside>
|
</aside>
|
||||||
</div>
|
</div>
|
||||||
|
<nav id="media-breadcrumbs"></nav>
|
||||||
<footer class="template-modal-foot media-modal-foot">
|
<footer class="template-modal-foot media-modal-foot">
|
||||||
<span id="media-size-status" class="nodedc-description" role="status">Размер окна сохраняется в профиле</span>
|
<span id="media-size-status" class="nodedc-description" role="status">Размер окна сохраняется в профиле</span>
|
||||||
<button id="media-size-retry" class="ghost-btn" type="button" hidden>Повторить</button>
|
<button id="media-size-retry" class="ghost-btn" type="button" hidden>Повторить</button>
|
||||||
|
|||||||
Generated
+3
-3
@@ -8,7 +8,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nodedc/tokens": "file:vendor/nodedc-tokens-0.6.0-mission.2.tgz",
|
"@nodedc/tokens": "file:vendor/nodedc-tokens-0.6.0-mission.2.tgz",
|
||||||
"@nodedc/ui-core": "file:vendor/nodedc-ui-core-0.7.0-mission.2.tgz",
|
"@nodedc/ui-core": "file:vendor/nodedc-ui-core-0.7.0-mission.2.tgz",
|
||||||
"@nodedc/ui-dom": "file:vendor/nodedc-ui-dom-0.7.0-modal.1.tgz",
|
"@nodedc/ui-dom": "file:vendor/nodedc-ui-dom-0.7.0-modal.2.tgz",
|
||||||
"@nodedc/ui-react": "file:vendor/nodedc-ui-react-0.7.0-mission.2.tgz",
|
"@nodedc/ui-react": "file:vendor/nodedc-ui-react-0.7.0-mission.2.tgz",
|
||||||
"esbuild": "0.28.1",
|
"esbuild": "0.28.1",
|
||||||
"react": "19.2.7",
|
"react": "19.2.7",
|
||||||
@@ -499,8 +499,8 @@
|
|||||||
},
|
},
|
||||||
"node_modules/@nodedc/ui-dom": {
|
"node_modules/@nodedc/ui-dom": {
|
||||||
"version": "0.7.0",
|
"version": "0.7.0",
|
||||||
"resolved": "file:vendor/nodedc-ui-dom-0.7.0-modal.1.tgz",
|
"resolved": "file:vendor/nodedc-ui-dom-0.7.0-modal.2.tgz",
|
||||||
"integrity": "sha512-aG7ZLz63g5j9Ln4o0eWHgCyo9GKSw1PRFQBFuQiMk8LodRMfQHvKLh50TMMbMhLdCXqmvbAEonAMUpM/QqyJaw==",
|
"integrity": "sha512-2uR0Ufk+Ocv5t1phemMPtMub+ogSfqEp70emVKDILOJ62XxZqHQL9Seuug32AWf6AMsEjD3U7y0BoAp+XuD5lw==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nodedc/ui-core": "0.7.0"
|
"@nodedc/ui-core": "0.7.0"
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -9,7 +9,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nodedc/tokens": "file:vendor/nodedc-tokens-0.6.0-mission.2.tgz",
|
"@nodedc/tokens": "file:vendor/nodedc-tokens-0.6.0-mission.2.tgz",
|
||||||
"@nodedc/ui-core": "file:vendor/nodedc-ui-core-0.7.0-mission.2.tgz",
|
"@nodedc/ui-core": "file:vendor/nodedc-ui-core-0.7.0-mission.2.tgz",
|
||||||
"@nodedc/ui-dom": "file:vendor/nodedc-ui-dom-0.7.0-modal.1.tgz",
|
"@nodedc/ui-dom": "file:vendor/nodedc-ui-dom-0.7.0-modal.2.tgz",
|
||||||
"@nodedc/ui-react": "file:vendor/nodedc-ui-react-0.7.0-mission.2.tgz",
|
"@nodedc/ui-react": "file:vendor/nodedc-ui-react-0.7.0-mission.2.tgz",
|
||||||
"react": "19.2.7",
|
"react": "19.2.7",
|
||||||
"react-dom": "19.2.7",
|
"react-dom": "19.2.7",
|
||||||
|
|||||||
+89
-40
@@ -1,3 +1,4 @@
|
|||||||
|
import { renderPathBar } from '@nodedc/ui-dom';
|
||||||
const sitePrefix = window.location.pathname.match(/^\/s\/[a-z][a-z0-9-]*/)?.[0] || "";
|
const sitePrefix = window.location.pathname.match(/^\/s\/[a-z][a-z0-9-]*/)?.[0] || "";
|
||||||
const siteUrl = path => `${sitePrefix}/${String(path).replace(/^\.?\//, "")}`;
|
const siteUrl = path => `${sitePrefix}/${String(path).replace(/^\.?\//, "")}`;
|
||||||
function siteFetch(url, options) { return fetch(siteUrl(url), options); }
|
function siteFetch(url, options) { return fetch(siteUrl(url), options); }
|
||||||
@@ -139,7 +140,9 @@ const state = {
|
|||||||
selectedEntry: null,
|
selectedEntry: null,
|
||||||
selectedUrl: "",
|
selectedUrl: "",
|
||||||
root: "",
|
root: "",
|
||||||
kind: "all",
|
kinds: [],
|
||||||
|
view: "flat",
|
||||||
|
loadId: 0,
|
||||||
query: "",
|
query: "",
|
||||||
loaded: false,
|
loaded: false,
|
||||||
dragEntryPath: "",
|
dragEntryPath: "",
|
||||||
@@ -275,6 +278,8 @@ const el = {
|
|||||||
mediaTrashToggle: document.querySelector("#media-trash-toggle"),
|
mediaTrashToggle: document.querySelector("#media-trash-toggle"),
|
||||||
mediaSearch: document.querySelector("#media-search"),
|
mediaSearch: document.querySelector("#media-search"),
|
||||||
mediaKindFilters: document.querySelector("#media-kind-filters"),
|
mediaKindFilters: document.querySelector("#media-kind-filters"),
|
||||||
|
mediaFlatToggle: document.querySelector("#media-flat-toggle"),
|
||||||
|
mediaResults: document.querySelector("#media-results"),
|
||||||
mediaRootFilters: document.querySelector("#media-root-filters"),
|
mediaRootFilters: document.querySelector("#media-root-filters"),
|
||||||
mediaUpload: document.querySelector("#media-upload"),
|
mediaUpload: document.querySelector("#media-upload"),
|
||||||
mediaRefresh: document.querySelector("#media-refresh"),
|
mediaRefresh: document.querySelector("#media-refresh"),
|
||||||
@@ -2998,16 +3003,28 @@ function renderMediaFilterButtons() {
|
|||||||
el.mediaRootFilters.innerHTML = "";
|
el.mediaRootFilters.innerHTML = "";
|
||||||
const activeRoot = activeMediaRootFilter();
|
const activeRoot = activeMediaRootFilter();
|
||||||
|
|
||||||
|
const flat = state.mediaLibrary.view === "flat" && !state.mediaLibrary.trashMode;
|
||||||
|
el.mediaRootFilters.hidden = flat;
|
||||||
|
el.mediaFlatToggle.disabled = state.mediaLibrary.trashMode;
|
||||||
|
el.mediaFlatToggle.setAttribute("aria-pressed", String(flat));
|
||||||
|
el.mediaFlatToggle.title = flat ? "Показать папки" : "Все файлы без папок";
|
||||||
|
el.mediaFlatToggle.setAttribute("aria-label", el.mediaFlatToggle.title);
|
||||||
|
el.mediaFlatToggle.classList.add("nodedc-icon-button");
|
||||||
|
el.mediaFlatToggle.replaceChildren(document.querySelector(`#ds-icon-${flat ? "folder" : "grid"}`).content.firstElementChild.cloneNode(true));
|
||||||
for (const [kind, label] of MEDIA_KIND_FILTERS) {
|
for (const [kind, label] of MEDIA_KIND_FILTERS) {
|
||||||
if (state.mediaLibrary.context?.requiredKind && kind !== state.mediaLibrary.context.requiredKind) continue;
|
if (state.mediaLibrary.context?.requiredKind && kind !== state.mediaLibrary.context.requiredKind) continue;
|
||||||
const button = document.createElement("button");
|
const button = document.querySelector('#ds-iconButton').content.firstElementChild.cloneNode(true);
|
||||||
button.type = "button";
|
button.classList.add("media-filter-button");
|
||||||
button.className = "media-filter-button";
|
const active = kind === "all" ? state.mediaLibrary.kinds.length === 0 : state.mediaLibrary.kinds.includes(kind);
|
||||||
button.dataset.active = String(state.mediaLibrary.kind === kind);
|
button.dataset.active = String(active); button.dataset.kind = kind;
|
||||||
|
button.setAttribute("aria-pressed", String(active)); button.setAttribute("aria-label", label); button.title = label;
|
||||||
button.disabled = state.mediaLibrary.trashMode;
|
button.disabled = state.mediaLibrary.trashMode;
|
||||||
button.textContent = label;
|
const icon = {all:"file",image:"image",video:"video",model:"layers"}[kind];
|
||||||
|
button.replaceChildren(document.querySelector(`#ds-icon-${icon}`).content.firstElementChild.cloneNode(true));
|
||||||
button.addEventListener("click", () => {
|
button.addEventListener("click", () => {
|
||||||
state.mediaLibrary.kind = kind;
|
if (state.mediaLibrary.context?.requiredKind) return;
|
||||||
|
const kinds = state.mediaLibrary.kinds;
|
||||||
|
state.mediaLibrary.kinds = kind === "all" ? [] : kinds.includes(kind) ? kinds.filter(value => value !== kind) : [...kinds,kind];
|
||||||
renderMediaLibrary();
|
renderMediaLibrary();
|
||||||
});
|
});
|
||||||
el.mediaKindFilters.append(button);
|
el.mediaKindFilters.append(button);
|
||||||
@@ -3380,8 +3397,7 @@ function entryMatchesMediaFilters(entry) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (entry.type === "directory") return true;
|
if (entry.type === "directory") return true;
|
||||||
if (state.mediaLibrary.kind === "all") return true;
|
return state.mediaLibrary.kinds.length === 0 || state.mediaLibrary.kinds.includes(entry.kind);
|
||||||
return entry.kind === state.mediaLibrary.kind;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function findEntryByUrl(url) {
|
function findEntryByUrl(url) {
|
||||||
@@ -3481,6 +3497,7 @@ function openMediaContextMenu(event, { entry = null, columnPath = state.mediaLib
|
|||||||
}
|
}
|
||||||
|
|
||||||
function scrollMediaBrowserToSelection() {
|
function scrollMediaBrowserToSelection() {
|
||||||
|
if (state.mediaLibrary.view === "flat" && !state.mediaLibrary.trashMode) return;
|
||||||
window.requestAnimationFrame(() => {
|
window.requestAnimationFrame(() => {
|
||||||
const columns = [...el.mediaList.querySelectorAll(".media-column")];
|
const columns = [...el.mediaList.querySelectorAll(".media-column")];
|
||||||
const targetColumn = columns.at(-1);
|
const targetColumn = columns.at(-1);
|
||||||
@@ -3529,7 +3546,23 @@ function scrollMediaBrowserToSelection() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function loadFlatMedia({ selectedUrl = state.mediaLibrary.selectedUrl } = {}) {
|
||||||
|
const loadId = ++state.mediaLibrary.loadId;
|
||||||
|
state.mediaLibrary.trashMode = false;
|
||||||
|
el.mediaResults.textContent = "Загрузка файлов…";
|
||||||
|
const response = await siteFetch('/api/media/assets');
|
||||||
|
const payload = await readApiJson(response, "Не удалось загрузить файлы сайта");
|
||||||
|
if (loadId !== state.mediaLibrary.loadId || !state.mediaLibrary.context) return;
|
||||||
|
state.mediaLibrary.columns = [{path: "assets", entries: payload.files || []}];
|
||||||
|
state.mediaLibrary.loaded = true;
|
||||||
|
state.mediaLibrary.selectedUrl = selectedUrl || "";
|
||||||
|
state.mediaLibrary.selectedEntry = selectedUrl ? findEntryByUrl(selectedUrl) : null;
|
||||||
|
renderMediaLibrary();
|
||||||
|
}
|
||||||
|
|
||||||
async function loadMediaColumns(targetPath, { selectedUrl = state.mediaLibrary.selectedUrl } = {}) {
|
async function loadMediaColumns(targetPath, { selectedUrl = state.mediaLibrary.selectedUrl } = {}) {
|
||||||
|
if (state.mediaLibrary.view === "flat") return loadFlatMedia({selectedUrl});
|
||||||
|
const loadId = ++state.mediaLibrary.loadId;
|
||||||
const path = String(targetPath || "").replace(/^\/+/, "");
|
const path = String(targetPath || "").replace(/^\/+/, "");
|
||||||
const chain = mediaPathChain(path);
|
const chain = mediaPathChain(path);
|
||||||
const columns = [];
|
const columns = [];
|
||||||
@@ -3541,6 +3574,7 @@ async function loadMediaColumns(targetPath, { selectedUrl = state.mediaLibrary.s
|
|||||||
columns.push(await browseMediaPath(columnPath));
|
columns.push(await browseMediaPath(columnPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (loadId !== state.mediaLibrary.loadId || !state.mediaLibrary.context) return;
|
||||||
state.mediaLibrary.columns = columns;
|
state.mediaLibrary.columns = columns;
|
||||||
state.mediaLibrary.selectedPath = path;
|
state.mediaLibrary.selectedPath = path;
|
||||||
state.mediaLibrary.loaded = true;
|
state.mediaLibrary.loaded = true;
|
||||||
@@ -3552,9 +3586,11 @@ async function loadMediaColumns(targetPath, { selectedUrl = state.mediaLibrary.s
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function loadMediaTrash({ selectedTrashPath = "" } = {}) {
|
async function loadMediaTrash({ selectedTrashPath = "" } = {}) {
|
||||||
|
const loadId = ++state.mediaLibrary.loadId;
|
||||||
setStatus("Открываем удалённые файлы...");
|
setStatus("Открываем удалённые файлы...");
|
||||||
const column = await browseMediaTrash();
|
const column = await browseMediaTrash();
|
||||||
|
|
||||||
|
if (loadId !== state.mediaLibrary.loadId || !state.mediaLibrary.context) return;
|
||||||
state.mediaLibrary.trashMode = true;
|
state.mediaLibrary.trashMode = true;
|
||||||
state.mediaLibrary.columns = [column];
|
state.mediaLibrary.columns = [column];
|
||||||
state.mediaLibrary.selectedPath = "__trash__";
|
state.mediaLibrary.selectedPath = "__trash__";
|
||||||
@@ -3566,23 +3602,17 @@ async function loadMediaTrash({ selectedTrashPath = "" } = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function renderMediaBreadcrumbs() {
|
function renderMediaBreadcrumbs() {
|
||||||
el.mediaBreadcrumbs.innerHTML = "";
|
const flat = state.mediaLibrary.view === "flat" && !state.mediaLibrary.trashMode;
|
||||||
const breadcrumbs = state.mediaLibrary.columns.at(-1)?.breadcrumbs || [{ name: "NODEDC_SITE", path: "" }];
|
const selected = state.mediaLibrary.selectedEntry;
|
||||||
|
const path = selected?.path || (flat ? "" : state.mediaLibrary.selectedPath);
|
||||||
breadcrumbs.forEach((crumb, index) => {
|
const parts = state.mediaLibrary.trashMode ? [] : mediaPathParts(path);
|
||||||
const button = document.createElement("button");
|
const crumbs = [{label: state.mediaLibrary.trashMode ? "Удалённые файлы" : state.projectConfig?.name || "Файлы сайта",path:"",kind:"folder"}];
|
||||||
button.type = "button";
|
parts.forEach((part,index) => crumbs.push({label:part,path:parts.slice(0,index+1).join('/'),kind:index === parts.length-1 && selected?.type === 'file' ? 'file' : 'folder',current:index === parts.length-1}));
|
||||||
button.className = "media-breadcrumb-button";
|
renderPathBar(el.mediaBreadcrumbs, crumbs, {icon: kind => document.querySelector(`#ds-icon-${kind}`).content.firstElementChild.cloneNode(true), onNavigate: path => {
|
||||||
button.textContent = crumb.name;
|
state.mediaLibrary.view = "folders"; state.mediaLibrary.root = path;
|
||||||
button.dataset.active = String(index === breadcrumbs.length - 1);
|
state.mediaLibrary.selectedEntry = null; state.mediaLibrary.selectedUrl = "";
|
||||||
button.addEventListener("click", () => {
|
loadMediaColumns(path).catch(error => setStatus(`Ошибка медиатеки: ${error.message}`));
|
||||||
state.mediaLibrary.root = crumb.path;
|
}});
|
||||||
state.mediaLibrary.selectedEntry = null;
|
|
||||||
state.mediaLibrary.selectedUrl = "";
|
|
||||||
loadMediaColumns(crumb.path).catch((error) => setStatus(`Ошибка медиатеки: ${error.message}`));
|
|
||||||
});
|
|
||||||
el.mediaBreadcrumbs.append(button);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderMediaEntry(entry, columnPath) {
|
function renderMediaEntry(entry, columnPath) {
|
||||||
@@ -3616,7 +3646,7 @@ function renderMediaEntry(entry, columnPath) {
|
|||||||
image.loading = "lazy";
|
image.loading = "lazy";
|
||||||
image.decoding = "async";
|
image.decoding = "async";
|
||||||
icon.append(image);
|
icon.append(image);
|
||||||
} else if (entry.type === "file" && entry.url && entry.kind === "video") {
|
} else if (entry.type === "file" && entry.url && entry.kind === "video" && state.mediaLibrary.view !== "flat") {
|
||||||
const video = document.createElement("video");
|
const video = document.createElement("video");
|
||||||
icon.classList.add("is-preview");
|
icon.classList.add("is-preview");
|
||||||
video.src = adminPreviewUrl(entry.url);
|
video.src = adminPreviewUrl(entry.url);
|
||||||
@@ -3635,6 +3665,10 @@ function renderMediaEntry(entry, columnPath) {
|
|||||||
: entry.extension?.toUpperCase() || "FILE";
|
: entry.extension?.toUpperCase() || "FILE";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (state.mediaLibrary.view === "flat" && entry.kind !== "image") {
|
||||||
|
const iconName = entry.kind === "video" ? "video" : entry.kind === "model" ? "layers" : "file";
|
||||||
|
icon.replaceChildren(document.querySelector(`#ds-icon-${iconName}`).content.firstElementChild.cloneNode(true));
|
||||||
|
}
|
||||||
copy.className = "media-entry-copy";
|
copy.className = "media-entry-copy";
|
||||||
name.className = "media-entry-name";
|
name.className = "media-entry-name";
|
||||||
name.textContent = entry.name;
|
name.textContent = entry.name;
|
||||||
@@ -3643,6 +3677,7 @@ function renderMediaEntry(entry, columnPath) {
|
|||||||
entry.type === "directory"
|
entry.type === "directory"
|
||||||
? entry.path || "Корень проекта"
|
? entry.path || "Корень проекта"
|
||||||
: [mediaUsageLabel(entry), entry.extension, formatFileSize(entry.size)].filter(Boolean).join(" · ");
|
: [mediaUsageLabel(entry), entry.extension, formatFileSize(entry.size)].filter(Boolean).join(" · ");
|
||||||
|
if (state.mediaLibrary.view === "flat") { const path = document.createElement("span"); path.className = "media-entry-meta media-entry-path"; path.textContent = parentMediaPath(entry.path); path.title = path.textContent; copy.append(path); }
|
||||||
copy.append(name, meta);
|
copy.append(name, meta);
|
||||||
|
|
||||||
statusDot.className = "media-status-dot media-entry-status";
|
statusDot.className = "media-status-dot media-entry-status";
|
||||||
@@ -3884,7 +3919,7 @@ function renderMediaPreviewPanel() {
|
|||||||
if (!entry) {
|
if (!entry) {
|
||||||
el.mediaPreviewName.textContent = "Выберите файл или папку";
|
el.mediaPreviewName.textContent = "Выберите файл или папку";
|
||||||
el.mediaPreviewPath.textContent = state.mediaLibrary.selectedPath || "NODEDC_SITE";
|
el.mediaPreviewPath.textContent = state.mediaLibrary.selectedPath || "NODEDC_SITE";
|
||||||
el.mediaPreviewMeta.textContent = "Column view проекта";
|
el.mediaPreviewMeta.textContent = state.mediaLibrary.view === "flat" ? "Все файлы выбранного сайта" : "Файлы выбранной папки";
|
||||||
el.mediaPreviewUsage.dataset.status = "idle";
|
el.mediaPreviewUsage.dataset.status = "idle";
|
||||||
if (usageText) usageText.textContent = "Нет выбора";
|
if (usageText) usageText.textContent = "Нет выбора";
|
||||||
return;
|
return;
|
||||||
@@ -3933,21 +3968,26 @@ function renderMediaPreviewPanel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function renderMediaLibrary() {
|
function renderMediaLibrary() {
|
||||||
|
const flat = state.mediaLibrary.view === "flat" && !state.mediaLibrary.trashMode;
|
||||||
|
const scrollTop = el.mediaList.scrollTop;
|
||||||
el.mediaTrashToggle.dataset.active = String(state.mediaLibrary.trashMode);
|
el.mediaTrashToggle.dataset.active = String(state.mediaLibrary.trashMode);
|
||||||
el.mediaUpload.textContent = state.mediaLibrary.trashMode ? "Очистить корзину" : "+ Загрузить";
|
el.mediaUpload.textContent = state.mediaLibrary.trashMode ? "Очистить корзину" : "+ Загрузить";
|
||||||
renderMediaFilterButtons();
|
renderMediaFilterButtons(); renderMediaBreadcrumbs();
|
||||||
renderMediaBreadcrumbs();
|
el.mediaList.replaceChildren();
|
||||||
el.mediaList.innerHTML = "";
|
el.mediaList.classList.toggle("media-gallery", flat);
|
||||||
el.mediaList.classList.add("media-columns");
|
el.mediaList.classList.toggle("media-columns", !flat);
|
||||||
|
|
||||||
const columns = state.mediaLibrary.columns || [];
|
const columns = state.mediaLibrary.columns || [];
|
||||||
el.mediaEmpty.classList.toggle("hidden", columns.length > 0);
|
const entries = columns.flatMap(column => column.entries || []).filter(entryMatchesMediaFilters);
|
||||||
for (const column of columns) {
|
el.mediaResults.textContent = flat ? `Файлов: ${entries.length}` : "";
|
||||||
el.mediaList.append(renderMediaColumn(column));
|
el.mediaEmpty.classList.add("hidden");
|
||||||
|
if (flat) {
|
||||||
|
for (const entry of entries) el.mediaList.append(renderMediaEntry(entry, parentMediaPath(entry.path)));
|
||||||
|
if (!entries.length) { const empty = document.createElement('div'); empty.className = 'media-column-empty'; empty.textContent = 'По выбранным фильтрам файлы не найдены.'; el.mediaList.append(empty); }
|
||||||
|
el.mediaList.scrollTop = scrollTop;
|
||||||
|
} else {
|
||||||
|
for (const column of columns) el.mediaList.append(renderMediaColumn(column));
|
||||||
}
|
}
|
||||||
|
renderMediaPreviewPanel(); scrollMediaBrowserToSelection();
|
||||||
renderMediaPreviewPanel();
|
|
||||||
scrollMediaBrowserToSelection();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function refreshMediaLibrary() {
|
async function refreshMediaLibrary() {
|
||||||
@@ -3990,7 +4030,9 @@ async function openMediaLibrary(context) {
|
|||||||
state.mediaLibrary.selectedPath = startPath;
|
state.mediaLibrary.selectedPath = startPath;
|
||||||
state.mediaLibrary.query = "";
|
state.mediaLibrary.query = "";
|
||||||
state.mediaLibrary.root = startPath;
|
state.mediaLibrary.root = startPath;
|
||||||
state.mediaLibrary.kind = context.requiredKind || "all";
|
state.mediaLibrary.kinds = context.requiredKind ? [context.requiredKind] : [];
|
||||||
|
state.mediaLibrary.view = managing ? "flat" : "folders";
|
||||||
|
state.mediaLibrary.columns = [];
|
||||||
el.mediaSearch.value = "";
|
el.mediaSearch.value = "";
|
||||||
el.mediaModalTitle.textContent = managing ? `Файлы — ${state.projectConfig?.name || state.projectConfig?.id || "текущий сайт"}` : context.editableField.label || "Выбрать файл";
|
el.mediaModalTitle.textContent = managing ? `Файлы — ${state.projectConfig?.name || state.projectConfig?.id || "текущий сайт"}` : context.editableField.label || "Выбрать файл";
|
||||||
el.mediaModalSubtitle.textContent = managing ? "Изображения, видео и другие файлы выбранного сайта." : `${context.editableField.path} -> ${suggestedPath}`;
|
el.mediaModalSubtitle.textContent = managing ? "Изображения, видео и другие файлы выбранного сайта." : `${context.editableField.path} -> ${suggestedPath}`;
|
||||||
@@ -4008,6 +4050,7 @@ async function openMediaLibrary(context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function closeMediaLibrary() {
|
function closeMediaLibrary() {
|
||||||
|
state.mediaLibrary.loadId++;
|
||||||
const managing = state.mediaLibrary.context?.mode === "manage";
|
const managing = state.mediaLibrary.context?.mode === "manage";
|
||||||
closeMediaContextMenu();
|
closeMediaContextMenu();
|
||||||
el.mediaModal.classList.add("hidden");
|
el.mediaModal.classList.add("hidden");
|
||||||
@@ -6117,6 +6160,12 @@ el.mediaSearch.addEventListener("input", () => {
|
|||||||
state.mediaLibrary.query = el.mediaSearch.value;
|
state.mediaLibrary.query = el.mediaSearch.value;
|
||||||
renderMediaLibrary();
|
renderMediaLibrary();
|
||||||
});
|
});
|
||||||
|
el.mediaFlatToggle.addEventListener("click", async () => {
|
||||||
|
state.mediaLibrary.view = state.mediaLibrary.view === "flat" ? "folders" : "flat";
|
||||||
|
closeMediaContextMenu();
|
||||||
|
try { await loadMediaColumns(state.mediaLibrary.selectedEntry ? parentMediaPath(state.mediaLibrary.selectedEntry.path) : state.mediaLibrary.selectedPath || 'assets'); }
|
||||||
|
catch (error) { setStatus(`Ошибка медиатеки: ${error.message}`); }
|
||||||
|
});
|
||||||
el.mediaRefresh.addEventListener("click", () => refreshMediaLibrary().catch((error) => setStatus(`Ошибка медиатеки: ${error.message}`)));
|
el.mediaRefresh.addEventListener("click", () => refreshMediaLibrary().catch((error) => setStatus(`Ошибка медиатеки: ${error.message}`)));
|
||||||
el.mediaUpload.addEventListener("click", () => {
|
el.mediaUpload.addEventListener("click", () => {
|
||||||
if (state.mediaLibrary.trashMode) {
|
if (state.mediaLibrary.trashMode) {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
@import "@nodedc/ui-dom/styles.css";
|
||||||
/* CMS domain layout; component geometry and materials belong to @nodedc/ui-core. */
|
/* CMS domain layout; component geometry and materials belong to @nodedc/ui-core. */
|
||||||
@import "@nodedc/ui-core/styles.css";
|
@import "@nodedc/ui-core/styles.css";
|
||||||
* {
|
* {
|
||||||
@@ -427,7 +428,9 @@ dialog.site-dialog p {
|
|||||||
}
|
}
|
||||||
.media-kind-row {
|
.media-kind-row {
|
||||||
grid-column: 1/-1;
|
grid-column: 1/-1;
|
||||||
|
display: flex; align-items: center; gap: var(--nodedc-space-2);
|
||||||
}
|
}
|
||||||
|
#media-flat-toggle { margin-inline-start: auto; }
|
||||||
.media-root-row {
|
.media-root-row {
|
||||||
grid-column: 1;
|
grid-column: 1;
|
||||||
}
|
}
|
||||||
@@ -777,3 +780,15 @@ dialog.site-dialog p {
|
|||||||
min-width: 0;
|
min-width: 0;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.media-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--nodedc-space-3); overflow: auto; min-height: 0; flex: 1; align-content: start; }
|
||||||
|
.media-gallery .media-entry { display: flex; flex-direction: column; align-items: stretch; position: relative; border-radius: var(--nodedc-radius-card); min-width: 0; }
|
||||||
|
.media-gallery .media-entry-icon { width: 100%; height: 8rem; border-radius: var(--nodedc-radius-control-compact); background: var(--nodedc-surface-group); }
|
||||||
|
.media-gallery .media-entry-icon img { width: 100%; height: 100%; min-height: 0; max-height: 8rem; object-fit: contain; }
|
||||||
|
.media-gallery .media-entry-icon > svg { width: 2rem; height: 2rem; }
|
||||||
|
.media-gallery .media-entry-copy { flex: none; }
|
||||||
|
.media-gallery .media-entry-path { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; order: 3; }
|
||||||
|
.media-gallery .media-entry-status { position: absolute; top: var(--nodedc-space-3); right: var(--nodedc-space-3); }
|
||||||
|
.media-gallery .media-entry-arrow { display: none; }
|
||||||
|
.media-modal .media-gallery { min-height: 0; }
|
||||||
|
.media-modal #media-breadcrumbs { margin-block-start: var(--nodedc-space-2); }
|
||||||
|
|||||||
BIN
Binary file not shown.
Reference in New Issue
Block a user