quản lí robot
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -18,6 +18,122 @@ textarea {
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
}
|
||||
|
||||
/* Compact navigation: only one branch is open, with native button keyboard support. */
|
||||
.sidebar-nav {
|
||||
padding: 0 0.75rem;
|
||||
overscroll-behavior: contain;
|
||||
scrollbar-width: thin;
|
||||
}
|
||||
|
||||
.sidebar-menu,
|
||||
.sidebar-children {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
gap: 0.2rem;
|
||||
}
|
||||
|
||||
.sidebar-link {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
width: 100%;
|
||||
min-height: 2.25rem;
|
||||
padding: 0.4375rem 0.625rem;
|
||||
border-radius: 0.375rem;
|
||||
color: #475569;
|
||||
font-size: 0.9375rem;
|
||||
line-height: 1.25rem;
|
||||
text-align: left;
|
||||
transition: color 0.15s, background-color 0.15s;
|
||||
}
|
||||
|
||||
.sidebar-link:hover {
|
||||
background: #e2e8f0;
|
||||
color: #0f172a;
|
||||
}
|
||||
|
||||
.sidebar-link:focus-visible {
|
||||
outline: 2px solid #3755c3;
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.sidebar-link .material-symbols-outlined {
|
||||
flex-shrink: 0;
|
||||
font-size: 1.125rem;
|
||||
}
|
||||
|
||||
.sidebar-text {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.sidebar-link[aria-current="page"] {
|
||||
background: #e2e8f0;
|
||||
color: #0f172a;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.sidebar-group-toggle[data-active="true"] {
|
||||
color: #0f172a;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.sidebar-link .sidebar-chevron {
|
||||
margin-left: auto;
|
||||
font-size: 1rem;
|
||||
transition: transform 0.15s;
|
||||
}
|
||||
|
||||
.sidebar-group-toggle[aria-expanded="true"] .sidebar-chevron {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
|
||||
.sidebar-children {
|
||||
margin: 0.25rem 0 0.375rem 1.375rem;
|
||||
padding-left: 0.375rem;
|
||||
border-left: 1px dashed #cbd5e1;
|
||||
gap: 0.125rem;
|
||||
}
|
||||
|
||||
.sidebar-children[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.sidebar-children .sidebar-link {
|
||||
min-height: 2.125rem;
|
||||
padding-top: 0.4375rem;
|
||||
padding-bottom: 0.4375rem;
|
||||
}
|
||||
|
||||
.sidebar-admin {
|
||||
margin-top: 0.5rem;
|
||||
padding-top: 0.5rem;
|
||||
border-top: 1px solid #e2e8f0;
|
||||
}
|
||||
|
||||
.dark .sidebar-link {
|
||||
color: #94a3b8;
|
||||
}
|
||||
|
||||
.dark .sidebar-link:hover,
|
||||
.dark .sidebar-link[aria-current="page"] {
|
||||
background: #1e293b;
|
||||
color: #f8fafc;
|
||||
}
|
||||
|
||||
.dark .sidebar-group-toggle[data-active="true"] {
|
||||
color: #f8fafc;
|
||||
}
|
||||
|
||||
.dark .sidebar-children,
|
||||
.dark .sidebar-admin {
|
||||
border-color: #334155;
|
||||
}
|
||||
|
||||
.table-wrap,
|
||||
.overflow-x-auto {
|
||||
overscroll-behavior-x: contain;
|
||||
|
||||
569
public/js/app.js
569
public/js/app.js
@@ -2,6 +2,7 @@
|
||||
// Main JavaScript functionality
|
||||
|
||||
const authenticatedFetch = window.fetch.bind(window);
|
||||
const DOCUMENT_FORMATS = window.DocumentFormats || { formats: {}, accept: '', description: 'Tài liệu' };
|
||||
let authRedirectInProgress = false;
|
||||
window.fetch = async (input, init = {}) => {
|
||||
const response = await authenticatedFetch(input, {
|
||||
@@ -69,6 +70,15 @@ class AccountManager {
|
||||
this.archivingAssets = false;
|
||||
this.consumables = [];
|
||||
this.documents = [];
|
||||
this.robots = [];
|
||||
this.robotTypes = [];
|
||||
this.robotTypeSearchTerm = '';
|
||||
this.robotTypesLoadError = '';
|
||||
this.robotSearchTerm = '';
|
||||
this.robotTypeFilter = '';
|
||||
this.robotPage = 1;
|
||||
this.robotPageSize = 12;
|
||||
this.robotLoadError = '';
|
||||
this.roles = [];
|
||||
this.notificationPreviewItems = [];
|
||||
this.notificationItems = [];
|
||||
@@ -277,6 +287,8 @@ class AccountManager {
|
||||
await this.fetchAssetDepartments();
|
||||
await this.fetchAssetProjects();
|
||||
await this.fetchDocuments();
|
||||
await this.fetchRobotTypes();
|
||||
await this.fetchRobots();
|
||||
await this.fetchNotificationPreview();
|
||||
|
||||
if (this.canCurrentUserManageAssets()) {
|
||||
@@ -363,6 +375,12 @@ class AccountManager {
|
||||
this.setupAddButtonListeners();
|
||||
this.setupFilters();
|
||||
this.setupAccountPagerListeners();
|
||||
} else if (page === 'robots') {
|
||||
mainContent.innerHTML = this.getRobotsContent();
|
||||
this.setupRobotListeners();
|
||||
} else if (page === 'robot-types') {
|
||||
mainContent.innerHTML = this.getRobotTypesContent();
|
||||
this.setupRobotTypeListeners();
|
||||
} else if (page === 'documents') {
|
||||
mainContent.innerHTML = this.getDocumentsContent();
|
||||
this.setupDocumentListeners();
|
||||
@@ -397,15 +415,43 @@ class AccountManager {
|
||||
}
|
||||
|
||||
setActiveNav(page) {
|
||||
let activeGroup = null;
|
||||
document.querySelectorAll('[data-nav]').forEach(link => {
|
||||
const isActive = link.dataset.nav === page;
|
||||
link.classList.toggle('border-l-4', isActive);
|
||||
link.classList.toggle('border-blue-600', isActive);
|
||||
link.classList.toggle('bg-slate-200/80', isActive);
|
||||
link.classList.toggle('dark:bg-slate-800', isActive);
|
||||
link.classList.toggle('text-slate-900', isActive);
|
||||
link.classList.toggle('dark:text-slate-50', isActive);
|
||||
link.classList.toggle('font-bold', isActive);
|
||||
if (isActive) {
|
||||
link.setAttribute('aria-current', 'page');
|
||||
activeGroup = link.closest('[data-nav-group]')?.dataset.navGroup || null;
|
||||
} else {
|
||||
link.removeAttribute('aria-current');
|
||||
}
|
||||
});
|
||||
document.querySelectorAll('[data-nav-toggle]').forEach(button => {
|
||||
button.dataset.active = String(button.dataset.navToggle === activeGroup);
|
||||
});
|
||||
// Refreshing a view should preserve a group the user opened or collapsed.
|
||||
if (this.activeSidebarPage !== page) {
|
||||
this.setOpenSidebarGroup(activeGroup);
|
||||
this.activeSidebarPage = page;
|
||||
}
|
||||
}
|
||||
|
||||
setOpenSidebarGroup(groupName = null) {
|
||||
document.querySelectorAll('[data-nav-toggle]').forEach(button => {
|
||||
const isOpen = button.dataset.navToggle === groupName;
|
||||
const panel = document.getElementById(button.getAttribute('aria-controls'));
|
||||
button.setAttribute('aria-expanded', String(isOpen));
|
||||
if (panel) panel.hidden = !isOpen;
|
||||
});
|
||||
}
|
||||
|
||||
setupSidebarNavigation() {
|
||||
document.querySelectorAll('[data-nav-toggle]').forEach(button => {
|
||||
if (button.dataset.boundSidebarToggle) return;
|
||||
button.addEventListener('click', () => {
|
||||
const nextGroup = button.getAttribute('aria-expanded') === 'true' ? null : button.dataset.navToggle;
|
||||
this.setOpenSidebarGroup(nextGroup);
|
||||
});
|
||||
button.dataset.boundSidebarToggle = 'true';
|
||||
});
|
||||
}
|
||||
|
||||
@@ -414,6 +460,7 @@ class AccountManager {
|
||||
}
|
||||
|
||||
setupResponsiveShell() {
|
||||
this.setupSidebarNavigation();
|
||||
const menuBtn = document.getElementById('mobileMenuBtn');
|
||||
const backdrop = document.getElementById('sidebarBackdrop');
|
||||
|
||||
@@ -3304,6 +3351,476 @@ class AccountManager {
|
||||
`;
|
||||
}
|
||||
|
||||
async fetchRobotTypes() {
|
||||
try {
|
||||
const response = await fetch(`${this.apiBase}/robots/types`, { cache: 'no-store' });
|
||||
const data = await response.json();
|
||||
if (!response.ok || !data.success) throw new Error(data.message || 'Không thể tải thể loại robot');
|
||||
this.robotTypes = Array.isArray(data.data) ? data.data : [];
|
||||
if (this.robotTypeFilter && !this.robotTypes.some(type => String(type.TypeId) === String(this.robotTypeFilter))) this.robotTypeFilter = '';
|
||||
this.robotTypesLoadError = '';
|
||||
} catch (error) { this.robotTypesLoadError = error.message || 'Không thể tải thể loại robot'; }
|
||||
}
|
||||
|
||||
getRobotTypeResultsContent() {
|
||||
const keyword = String(this.robotTypeSearchTerm || '').trim().toLocaleLowerCase('vi');
|
||||
const types = this.robotTypes.filter(type => !keyword || [type.Name, type.Description]
|
||||
.some(value => String(value || '').toLocaleLowerCase('vi').includes(keyword)));
|
||||
if (this.robotTypesLoadError) return `<p role="alert" class="rounded-xl border border-red-200 bg-red-50 p-5 text-sm text-red-700">${this.escapeHtml(this.robotTypesLoadError)}. Bấm Làm mới để thử lại.</p>`;
|
||||
if (!types.length) return `<div class="rounded-xl border border-slate-200 bg-white px-6 py-12 text-center">
|
||||
<span class="material-symbols-outlined text-slate-400" style="font-size:2rem">category</span>
|
||||
<h2 class="mt-3 font-bold text-slate-700">${keyword ? 'Không tìm thấy thể loại phù hợp' : 'Chưa có thể loại robot'}</h2>
|
||||
<p class="mt-1 text-sm text-slate-500">${keyword ? 'Hãy thử từ khóa khác.' : 'Thêm thể loại trước, sau đó chọn thể loại khi tạo robot.'}</p></div>`;
|
||||
const canManage = this.canCurrentUserManageAssets();
|
||||
return `<div class="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4">${types.map(type => {
|
||||
const used = Number(type.RobotCount) > 0;
|
||||
return `<article class="min-w-0 rounded-xl border border-slate-200 bg-white p-4 shadow-sm">
|
||||
<div class="flex items-start gap-3"><span class="material-symbols-outlined mt-1 text-slate-400">category</span>
|
||||
<div class="min-w-0 flex-1"><h2 class="break-words font-extrabold text-slate-900">${this.escapeHtml(type.Name)}</h2>
|
||||
<p class="mt-2 whitespace-pre-line break-words text-sm text-slate-500">${this.escapeHtml(type.Description || 'Chưa có mô tả.')}</p></div></div>
|
||||
<div class="mt-4 flex items-center gap-2 border-t border-slate-100 pt-3">
|
||||
<span class="mr-auto text-xs text-slate-500">${Number(type.RobotCount) || 0} robot</span>
|
||||
${canManage ? `<button type="button" data-robot-type-action="edit" data-type-id="${Number(type.TypeId)}" class="rounded-lg border border-slate-200 px-3 py-2 text-xs font-bold text-primary">Sửa</button>
|
||||
<button type="button" data-robot-type-action="delete" data-type-id="${Number(type.TypeId)}" ${used ? 'disabled' : ''} title="${used ? 'Chuyển robot sang thể loại khác trước khi xóa' : 'Xóa thể loại'}" class="rounded-lg px-3 py-2 text-xs font-bold text-red-600 disabled:cursor-not-allowed disabled:opacity-40">Xóa</button>` : ''}
|
||||
</div></article>`;
|
||||
}).join('')}</div>`;
|
||||
}
|
||||
|
||||
getRobotTypesContent() {
|
||||
return `<div class="robot-types-page h-full w-full overflow-y-auto p-4 md:p-6">
|
||||
<div class="page-header mb-5 flex items-center justify-between gap-4">
|
||||
<div><h1 class="text-2xl font-extrabold text-on-surface">Thể loại robot</h1>
|
||||
<p class="mt-1 text-sm text-slate-500">Quản lý danh mục thể loại để chọn khi thêm hoặc sửa robot.</p></div>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<button id="refreshRobotTypesBtn" type="button" class="inline-flex items-center justify-center gap-2 rounded-lg border border-slate-300 px-3 py-2 text-xs font-bold text-slate-700"><span class="material-symbols-outlined text-base">refresh</span>Làm mới</button>
|
||||
${this.canCurrentUserManageAssets() ? '<button id="addRobotTypeBtn" type="button" class="inline-flex items-center justify-center gap-2 rounded-lg bg-primary px-4 py-2 text-xs font-bold text-white"><span class="material-symbols-outlined text-base">add</span>Thêm thể loại</button>' : ''}
|
||||
</div></div>
|
||||
<label class="mb-4 block"><span class="sr-only">Tìm thể loại robot</span><input id="robotTypeSearch" type="search" value="${this.escapeHtml(this.robotTypeSearchTerm || '')}" placeholder="Tìm theo tên hoặc mô tả thể loại..." class="w-full rounded-lg border-slate-200 py-2 text-sm focus:ring-primary"></label>
|
||||
<div id="robotTypeResults">${this.getRobotTypeResultsContent()}</div>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
setupRobotTypeListeners() {
|
||||
const results = document.getElementById('robotTypeResults');
|
||||
document.getElementById('robotTypeSearch')?.addEventListener('input', event => {
|
||||
this.robotTypeSearchTerm = event.target.value;
|
||||
results.innerHTML = this.getRobotTypeResultsContent();
|
||||
});
|
||||
document.getElementById('addRobotTypeBtn')?.addEventListener('click', () => this.openRobotTypeForm());
|
||||
document.getElementById('refreshRobotTypesBtn')?.addEventListener('click', async event => {
|
||||
event.currentTarget.disabled = true;
|
||||
await this.fetchRobotTypes();
|
||||
if (this.currentPage === 'robot-types') this.renderView('robot-types');
|
||||
});
|
||||
results?.addEventListener('click', async event => {
|
||||
const button = event.target.closest('[data-robot-type-action]');
|
||||
if (!button || button.disabled) return;
|
||||
const type = this.robotTypes.find(item => Number(item.TypeId) === Number(button.dataset.typeId));
|
||||
if (!type) return;
|
||||
if (button.dataset.robotTypeAction === 'edit') this.openRobotTypeForm(type);
|
||||
else {
|
||||
button.disabled = true;
|
||||
try { await this.deleteRobotType(type); } finally { button.disabled = false; }
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
openRobotTypeForm(type = null) {
|
||||
if (!this.canCurrentUserManageAssets()) return;
|
||||
const dialog = this.showRobotDialog(`<form id="robotTypeForm">
|
||||
<div class="flex items-center justify-between gap-4 border-b border-slate-200 px-5 py-4">
|
||||
<h2 id="robotDialogTitle" class="text-lg font-extrabold">${type ? 'Sửa thể loại robot' : 'Thêm thể loại robot'}</h2>
|
||||
<button type="button" data-close-robot class="p-1 text-slate-500" aria-label="Đóng"><span class="material-symbols-outlined">close</span></button></div>
|
||||
<div class="space-y-4 p-5">
|
||||
<label class="block text-sm font-bold">Tên thể loại <span class="text-red-600">*</span>
|
||||
<input name="name" required maxlength="100" value="${this.escapeHtml(type?.Name || '')}" placeholder="VD: Robot cộng tác, Robot công nghiệp, AMR..." class="mt-1 w-full rounded-lg border-slate-200 py-2 text-sm focus:ring-primary"></label>
|
||||
<label class="block text-sm font-bold">Mô tả
|
||||
<textarea name="description" maxlength="500" rows="3" class="mt-1 w-full rounded-lg border-slate-200 text-sm focus:ring-primary">${this.escapeHtml(type?.Description || '')}</textarea></label>
|
||||
${Number(type?.RobotCount) > 0 ? `<p class="text-xs text-slate-500">Đổi tên sẽ cập nhật thể loại hiển thị cho ${Number(type.RobotCount)} robot đang sử dụng.</p>` : ''}
|
||||
</div><div class="flex justify-end gap-2 border-t border-slate-200 bg-slate-50 px-5 py-4">
|
||||
<button type="button" data-close-robot class="rounded-lg border border-slate-300 px-4 py-2 text-sm font-bold">Hủy</button>
|
||||
<button type="submit" class="rounded-lg bg-primary px-5 py-2 text-sm font-bold text-white disabled:opacity-50">Lưu thể loại</button></div></form>`);
|
||||
dialog.querySelector('#robotTypeForm').addEventListener('submit', async event => {
|
||||
event.preventDefault();
|
||||
if (dialog.dataset.saving === 'true') return;
|
||||
const form = event.currentTarget;
|
||||
const name = form.elements.namedItem('name').value.trim();
|
||||
if (!name) { this.notifyWarning('Vui lòng nhập tên thể loại.'); return; }
|
||||
const description = form.elements.namedItem('description').value.trim();
|
||||
dialog.dataset.saving = 'true';
|
||||
const controls = [...form.querySelectorAll('input, textarea, button')];
|
||||
controls.forEach(control => { control.disabled = true; });
|
||||
const submit = form.querySelector('[type="submit"]'); submit.textContent = 'Đang lưu...';
|
||||
try {
|
||||
const response = await fetch(`${this.apiBase}/robots/types${type ? `/${Number(type.TypeId)}` : ''}`, {
|
||||
method: type ? 'PUT' : 'POST', headers: this.getAuthHeaders(true), body: JSON.stringify({ name, description })
|
||||
});
|
||||
const data = await response.json();
|
||||
if (!response.ok || !data.success) throw new Error(data.message || 'Không thể lưu thể loại robot');
|
||||
dialog.close();
|
||||
await Promise.all([this.fetchRobotTypes(), this.fetchRobots()]);
|
||||
if (['robots', 'robot-types'].includes(this.currentPage)) this.renderView(this.currentPage);
|
||||
this.notifySuccess(data.message || 'Đã lưu thể loại robot');
|
||||
} catch (error) { this.notifyFailure(error.message); }
|
||||
finally { delete dialog.dataset.saving; controls.forEach(control => { control.disabled = false; }); submit.textContent = 'Lưu thể loại'; }
|
||||
});
|
||||
}
|
||||
|
||||
async deleteRobotType(type) {
|
||||
if (!this.canCurrentUserManageAssets() || Number(type.RobotCount) > 0) return;
|
||||
if (!window.confirm(`Xóa thể loại “${type.Name}”?`)) return;
|
||||
try {
|
||||
const response = await fetch(`${this.apiBase}/robots/types/${Number(type.TypeId)}`, { method: 'DELETE' });
|
||||
const data = await response.json();
|
||||
if (!response.ok || !data.success) throw new Error(data.message || 'Không thể xóa thể loại');
|
||||
await this.fetchRobotTypes();
|
||||
if (this.currentPage === 'robot-types') this.renderView('robot-types');
|
||||
this.notifySuccess(data.message || 'Đã xóa thể loại robot');
|
||||
} catch (error) { this.notifyFailure(error.message); }
|
||||
}
|
||||
|
||||
async fetchRobots() {
|
||||
try {
|
||||
const response = await fetch(`${this.apiBase}/robots`, { cache: 'no-store' });
|
||||
const data = await response.json();
|
||||
if (!response.ok || !data.success) throw new Error(data.message || 'Không thể tải danh sách robot');
|
||||
this.robots = Array.isArray(data.data) ? data.data : [];
|
||||
this.documentMaxFileSizeMb = Number(data.maxFileSizeMb) || 25;
|
||||
this.robotLoadError = '';
|
||||
} catch (error) {
|
||||
this.robotLoadError = error.message || 'Không thể tải danh sách robot';
|
||||
}
|
||||
}
|
||||
|
||||
getRobotAvatarHtml(robot, large = false) {
|
||||
const size = large ? 'h-32 w-32' : 'h-20 w-20';
|
||||
return `<div class="${size} shrink-0 overflow-hidden rounded-xl bg-slate-100 flex items-center justify-center">
|
||||
${robot?.HasAvatar ? `<img src="${this.apiBase}/robots/${Number(robot.RobotId)}/avatar?v=${encodeURIComponent(robot.UpdatedDate || '')}"
|
||||
alt="Ảnh ${this.escapeHtml(robot.Name)}" class="h-full w-full object-contain" loading="lazy">`
|
||||
: '<span class="material-symbols-outlined text-slate-400" style="font-size:2rem" aria-hidden="true">smart_toy</span>'}
|
||||
</div>`;
|
||||
}
|
||||
|
||||
getFilteredRobots() {
|
||||
const keyword = String(this.robotSearchTerm || '').trim().toLocaleLowerCase('vi');
|
||||
return this.robots.filter(robot => (!this.robotTypeFilter || String(robot.TypeId) === String(this.robotTypeFilter))
|
||||
&& (!keyword || [robot.Name, robot.Model, robot.Type]
|
||||
.some(value => String(value || '').toLocaleLowerCase('vi').includes(keyword))));
|
||||
}
|
||||
|
||||
getRobotResultsContent() {
|
||||
const page = this.getPaged(this.getFilteredRobots(), this.robotPage, this.robotPageSize);
|
||||
this.robotPage = page.current;
|
||||
const canManage = this.canCurrentUserManageAssets();
|
||||
if (this.robotLoadError) return `<div role="alert" class="rounded-xl border border-red-200 bg-red-50 p-6 text-sm text-red-700">${this.escapeHtml(this.robotLoadError)}. Bấm Làm mới để thử lại.</div>`;
|
||||
if (!page.total) return `<div class="rounded-xl border border-slate-200 bg-white px-6 py-16 text-center">
|
||||
<span class="material-symbols-outlined text-4xl text-slate-400">smart_toy</span>
|
||||
<h2 class="mt-3 font-bold text-slate-700">${this.robots.length ? 'Không tìm thấy robot phù hợp' : 'Chưa có robot'}</h2>
|
||||
<p class="mt-1 text-sm text-slate-500">${this.robots.length ? 'Hãy thử từ khóa hoặc loại robot khác.' : 'Thông tin, ảnh đại diện và tài liệu của robot sẽ được lưu tại đây.'}</p>
|
||||
</div>`;
|
||||
return `<div class="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4">
|
||||
${page.data.map(robot => `<article class="min-w-0 rounded-xl border border-slate-200 bg-white p-4 shadow-sm">
|
||||
<div class="flex items-start gap-4">
|
||||
${this.getRobotAvatarHtml(robot)}
|
||||
<div class="min-w-0 flex-1">
|
||||
<h2 class="break-words font-extrabold text-slate-900">${this.escapeHtml(robot.Name)}</h2>
|
||||
<p class="mt-1 break-words text-sm text-slate-600"><span class="text-slate-400">Model:</span> ${this.escapeHtml(robot.Model)}</p>
|
||||
<span class="mt-2 inline-block max-w-full break-words rounded-md bg-primary/10 px-2 py-1 text-xs font-semibold text-primary">${this.escapeHtml(robot.Type)}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-4 flex items-center gap-2 border-t border-slate-100 pt-3">
|
||||
<span class="mr-auto inline-flex items-center gap-1 text-xs text-slate-500"><span class="material-symbols-outlined text-base">attach_file</span>${Number(robot.DocumentCount) || 0} tài liệu</span>
|
||||
<button type="button" data-robot-action="view" data-robot-id="${Number(robot.RobotId)}" class="rounded-lg border border-slate-200 px-3 py-2 text-xs font-bold text-primary hover:bg-slate-50">Chi tiết</button>
|
||||
${canManage ? `<button type="button" data-robot-action="edit" data-robot-id="${Number(robot.RobotId)}" class="rounded-lg p-2 text-slate-500 hover:bg-slate-100 hover:text-primary" aria-label="Sửa ${this.escapeHtml(robot.Name)}"><span class="material-symbols-outlined text-lg">edit</span></button>
|
||||
<button type="button" data-robot-action="delete" data-robot-id="${Number(robot.RobotId)}" class="rounded-lg p-2 text-red-600 hover:bg-red-50" aria-label="Xóa ${this.escapeHtml(robot.Name)}"><span class="material-symbols-outlined text-lg">delete</span></button>` : ''}
|
||||
</div>
|
||||
</article>`).join('')}
|
||||
</div>
|
||||
<div class="page-pager mt-4 flex items-center justify-between gap-3 text-xs text-slate-500">
|
||||
<span>Hiển thị ${page.start}–${page.end} / ${page.total} robot</span>
|
||||
<div class="flex items-center gap-2">
|
||||
<button type="button" data-robot-page="${page.current - 1}" ${page.current === 1 ? 'disabled' : ''} class="rounded border border-slate-200 px-3 py-2 disabled:opacity-40">Trước</button>
|
||||
<span>Trang ${page.current} / ${page.totalPages}</span>
|
||||
<button type="button" data-robot-page="${page.current + 1}" ${page.current === page.totalPages ? 'disabled' : ''} class="rounded border border-slate-200 px-3 py-2 disabled:opacity-40">Sau</button>
|
||||
</div>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
getRobotsContent() {
|
||||
const types = this.robotTypes || [];
|
||||
return `<div class="robots-page h-full w-full overflow-y-auto p-4 md:p-6">
|
||||
<div class="page-header mb-5 flex items-center justify-between gap-4">
|
||||
<div><h1 class="text-2xl font-extrabold text-on-surface">Quản lý robot</h1>
|
||||
<p class="mt-1 text-sm text-slate-500">Thông tin robot, ảnh đại diện và tài liệu đi kèm.</p></div>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<button id="refreshRobotsBtn" type="button" class="inline-flex items-center justify-center gap-2 rounded-lg border border-slate-300 px-3 py-2 text-xs font-bold text-slate-700 hover:bg-slate-100"><span class="material-symbols-outlined text-base">refresh</span>Làm mới</button>
|
||||
${this.canCurrentUserManageAssets() ? '<button id="addRobotBtn" type="button" class="inline-flex items-center justify-center gap-2 rounded-lg bg-primary px-4 py-2 text-xs font-bold text-white hover:bg-primary-dim"><span class="material-symbols-outlined text-base">add</span>Thêm robot</button>' : ''}
|
||||
</div>
|
||||
</div>
|
||||
<div class="page-filters mb-4 flex items-center gap-3">
|
||||
<label class="relative flex-1"><span class="sr-only">Tìm robot</span><span class="material-symbols-outlined absolute left-3 top-1/2 -translate-y-1/2 text-slate-400">search</span>
|
||||
<input id="robotSearch" type="search" value="${this.escapeHtml(this.robotSearchTerm)}" placeholder="Tìm theo tên, model hoặc thể loại robot..." class="w-full rounded-lg border-slate-200 py-2 pl-10 pr-3 text-sm focus:ring-primary"></label>
|
||||
<label class="flex items-center gap-2 text-xs text-slate-500">Thể loại
|
||||
<select id="robotTypeFilter" class="rounded-lg border-slate-200 py-2 text-sm focus:ring-primary"><option value="">Tất cả thể loại</option>
|
||||
${types.map(type => `<option value="${Number(type.TypeId)}" ${String(this.robotTypeFilter) === String(type.TypeId) ? 'selected' : ''}>${this.escapeHtml(type.Name)}</option>`).join('')}</select></label>
|
||||
</div>
|
||||
<div id="robotResults">${this.getRobotResultsContent()}</div>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
setupRobotListeners() {
|
||||
const results = document.getElementById('robotResults');
|
||||
const refreshResults = () => { if (results) results.innerHTML = this.getRobotResultsContent(); };
|
||||
document.getElementById('robotSearch')?.addEventListener('input', event => {
|
||||
this.robotSearchTerm = event.target.value; this.robotPage = 1; refreshResults();
|
||||
});
|
||||
document.getElementById('robotTypeFilter')?.addEventListener('change', event => {
|
||||
this.robotTypeFilter = event.target.value; this.robotPage = 1; refreshResults();
|
||||
});
|
||||
document.getElementById('addRobotBtn')?.addEventListener('click', () => this.openRobotForm());
|
||||
document.getElementById('refreshRobotsBtn')?.addEventListener('click', async event => {
|
||||
const button = event.currentTarget; button.disabled = true;
|
||||
await Promise.all([this.fetchRobots(), this.fetchRobotTypes()]);
|
||||
if (this.currentPage === 'robots') this.renderView('robots');
|
||||
});
|
||||
results?.addEventListener('click', async event => {
|
||||
const pager = event.target.closest('[data-robot-page]');
|
||||
if (pager && !pager.disabled) { this.robotPage = Number(pager.dataset.robotPage); refreshResults(); return; }
|
||||
const button = event.target.closest('[data-robot-action]');
|
||||
if (!button || button.disabled) return;
|
||||
button.disabled = true;
|
||||
try {
|
||||
const id = Number(button.dataset.robotId);
|
||||
if (button.dataset.robotAction === 'view') await this.openRobotDetails(id);
|
||||
if (button.dataset.robotAction === 'edit') await this.openRobotForm(id);
|
||||
if (button.dataset.robotAction === 'delete') await this.deleteRobot(id);
|
||||
} finally { button.disabled = false; }
|
||||
});
|
||||
}
|
||||
|
||||
async getRobotDetails(robotId) {
|
||||
const response = await fetch(`${this.apiBase}/robots/${Number(robotId)}`, { cache: 'no-store' });
|
||||
const data = await response.json();
|
||||
if (!response.ok || !data.success) throw new Error(data.message || 'Không thể tải thông tin robot');
|
||||
return data.data;
|
||||
}
|
||||
|
||||
showRobotDialog(content) {
|
||||
document.getElementById('robotDialog')?.close();
|
||||
const dialog = document.createElement('dialog');
|
||||
dialog.id = 'robotDialog';
|
||||
dialog.setAttribute('aria-labelledby', 'robotDialogTitle');
|
||||
dialog.className = 'm-auto w-[min(94vw,48rem)] max-w-none max-h-[90dvh] overflow-y-auto rounded-xl border-0 bg-white p-0 text-slate-800 shadow-2xl backdrop:bg-slate-950/50';
|
||||
dialog.innerHTML = content;
|
||||
document.body.appendChild(dialog);
|
||||
dialog.addEventListener('click', event => {
|
||||
if (dialog.dataset.saving === 'true') return;
|
||||
if (event.target.closest('[data-close-robot]')) dialog.close();
|
||||
if (event.target === dialog) {
|
||||
const rect = dialog.getBoundingClientRect();
|
||||
if (event.clientX < rect.left || event.clientX > rect.right || event.clientY < rect.top || event.clientY > rect.bottom) dialog.close();
|
||||
}
|
||||
});
|
||||
dialog.addEventListener('cancel', event => { if (dialog.dataset.saving === 'true') event.preventDefault(); });
|
||||
dialog.addEventListener('close', () => {
|
||||
if (dialog.robotPreviewUrl) URL.revokeObjectURL(dialog.robotPreviewUrl);
|
||||
dialog.remove();
|
||||
}, { once: true });
|
||||
dialog.showModal();
|
||||
return dialog;
|
||||
}
|
||||
|
||||
async openRobotDetails(robotId) {
|
||||
try {
|
||||
const robot = await this.getRobotDetails(robotId);
|
||||
const dialog = this.showRobotDialog(`<div class="flex items-start justify-between gap-4 border-b border-slate-200 px-5 py-4">
|
||||
<h2 id="robotDialogTitle" class="break-words text-lg font-extrabold">${this.escapeHtml(robot.Name)}</h2>
|
||||
<button type="button" data-close-robot class="p-1 text-slate-500" aria-label="Đóng"><span class="material-symbols-outlined">close</span></button>
|
||||
</div>
|
||||
<div class="space-y-5 p-5">
|
||||
<div class="flex flex-wrap items-center gap-5">${this.getRobotAvatarHtml(robot, true)}
|
||||
<dl class="min-w-0 flex-1 space-y-2 text-sm"><div><dt class="text-xs text-slate-400">Model</dt><dd class="break-words font-semibold">${this.escapeHtml(robot.Model)}</dd></div>
|
||||
<div><dt class="text-xs text-slate-400">Thể loại robot</dt><dd class="break-words font-semibold">${this.escapeHtml(robot.Type)}</dd></div></dl></div>
|
||||
<section><h3 class="mb-3 font-bold">Tài liệu đi kèm (${robot.Documents.length})</h3>
|
||||
<div class="space-y-2">${robot.Documents.length ? robot.Documents.map(doc => `<div class="flex flex-wrap items-center gap-3 rounded-lg border border-slate-200 p-3">
|
||||
<span class="material-symbols-outlined ${this.getDocumentPresentation(doc).iconClass}">${this.getDocumentPresentation(doc).icon}</span>
|
||||
<div class="min-w-0 flex-1"><p class="break-words text-sm font-semibold">${this.escapeHtml(doc.Title)}</p><p class="break-words text-xs text-slate-500">${this.escapeHtml(doc.OriginalFileName)} · ${this.formatFileSize(doc.FileSize)}</p></div>
|
||||
${this.getDocumentPresentation(doc).preview ? `<a href="${this.apiBase}/documents/${Number(doc.DocumentId)}/file" target="_blank" rel="noopener noreferrer" class="rounded border border-slate-200 px-3 py-2 text-xs font-bold text-primary">Xem ${this.getDocumentPresentation(doc).label}</a>` : ''}
|
||||
<a href="${this.apiBase}/documents/${Number(doc.DocumentId)}/file?download=1" class="rounded border border-slate-200 px-3 py-2 text-xs font-bold text-slate-600">Tải xuống</a>
|
||||
</div>`).join('') : '<p class="text-sm text-slate-500">Robot chưa có tài liệu đi kèm.</p>'}</div>
|
||||
</section>
|
||||
</div>
|
||||
<div class="flex justify-end gap-2 border-t border-slate-200 bg-slate-50 px-5 py-4">
|
||||
<button type="button" data-close-robot class="rounded-lg border border-slate-300 px-4 py-2 text-sm font-bold">Đóng</button>
|
||||
${this.canCurrentUserManageAssets() ? '<button id="editRobotDetailsBtn" type="button" class="rounded-lg bg-primary px-4 py-2 text-sm font-bold text-white">Sửa robot</button>' : ''}
|
||||
</div>`);
|
||||
dialog.querySelector('#editRobotDetailsBtn')?.addEventListener('click', async event => {
|
||||
const button = event.currentTarget; button.disabled = true;
|
||||
try { await this.openRobotForm(robotId); } finally { button.disabled = false; }
|
||||
});
|
||||
} catch (error) { this.notifyFailure(error.message); }
|
||||
}
|
||||
|
||||
async openRobotForm(robotId = null) {
|
||||
if (!this.canCurrentUserManageAssets()) { this.notifyWarning('Chỉ Admin/Asset được thay đổi thông tin robot.'); return; }
|
||||
try {
|
||||
const [robot, libraryResponse, typesResponse] = await Promise.all([
|
||||
robotId ? this.getRobotDetails(robotId) : Promise.resolve(null),
|
||||
fetch(`${this.apiBase}/documents`, { cache: 'no-store' }),
|
||||
fetch(`${this.apiBase}/robots/types`, { cache: 'no-store' })
|
||||
]);
|
||||
const library = await libraryResponse.json();
|
||||
if (!libraryResponse.ok || !library.success) throw new Error(library.message || 'Không thể tải kho tài liệu');
|
||||
const types = await typesResponse.json();
|
||||
if (!typesResponse.ok || !types.success) throw new Error(types.message || 'Không thể tải thể loại robot');
|
||||
this.robotTypes = types.data || [];
|
||||
this.documents = library.data || [];
|
||||
this.documentMaxFileSizeMb = Number(library.maxFileSizeMb) || 25;
|
||||
const selectedIds = new Set((robot?.Documents || []).map(doc => Number(doc.DocumentId)));
|
||||
const fieldClass = 'w-full rounded-lg border-slate-200 py-2 text-sm focus:ring-primary';
|
||||
const dialog = this.showRobotDialog(`<form id="robotForm">
|
||||
<div class="flex items-center justify-between gap-4 border-b border-slate-200 px-5 py-4">
|
||||
<h2 id="robotDialogTitle" class="text-lg font-extrabold">${robot ? 'Sửa robot' : 'Thêm robot mới'}</h2>
|
||||
<button type="button" data-close-robot class="p-1 text-slate-500" aria-label="Đóng"><span class="material-symbols-outlined">close</span></button>
|
||||
</div>
|
||||
<div class="space-y-5 p-5">
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
<label class="block text-sm font-bold sm:col-span-2">Tên robot <span class="text-red-600">*</span><input name="name" required maxlength="255" value="${this.escapeHtml(robot?.Name || '')}" class="${fieldClass} mt-1" placeholder="Nhập tên robot"></label>
|
||||
<label class="block text-sm font-bold">Model <span class="text-red-600">*</span><input name="model" required maxlength="255" value="${this.escapeHtml(robot?.Model || '')}" class="${fieldClass} mt-1" placeholder="VD: UR10e"></label>
|
||||
<div><label class="block text-sm font-bold">Thể loại robot <span class="text-red-600">*</span>
|
||||
<select name="typeId" required class="${fieldClass} mt-1"><option value="">-- Chọn thể loại robot --</option>
|
||||
${this.robotTypes.map(type => `<option value="${Number(type.TypeId)}" ${Number(robot?.TypeId) === Number(type.TypeId) ? 'selected' : ''}>${this.escapeHtml(type.Name)}</option>`).join('')}</select></label>
|
||||
<a href="#robot-types" id="robotManageTypesLink" class="mt-2 inline-block text-xs font-semibold text-primary">${this.robotTypes.length ? 'Quản lý thể loại robot' : 'Chưa có thể loại. Bấm để thêm thể loại trước.'}</a></div>
|
||||
</div>
|
||||
<section><h3 class="mb-2 text-sm font-bold">Ảnh đại diện</h3>
|
||||
<div class="flex flex-wrap items-center gap-4"><div id="robotAvatarPreview">${this.getRobotAvatarHtml(robot)}</div>
|
||||
<div class="min-w-0 flex-1"><label for="robotAvatarFile" class="sr-only">Chọn ảnh đại diện</label><input id="robotAvatarFile" type="file" name="avatar" accept="image/jpeg,image/png,image/webp,.jpg,.jpeg,.png,.webp" class="block w-full text-sm">
|
||||
<p class="mt-2 text-xs text-slate-500">JPG, PNG hoặc WebP, tối đa 5 MB. Có thể bổ sung ảnh sau.</p>
|
||||
${robot?.HasAvatar ? '<label class="mt-2 inline-flex items-center gap-2 text-xs text-slate-600"><input id="robotRemoveAvatar" type="checkbox" class="rounded border-slate-300">Xóa ảnh hiện tại</label>' : ''}</div>
|
||||
</div>
|
||||
</section>
|
||||
<section><h3 class="text-sm font-bold">Tài liệu đi kèm</h3><p class="mt-1 text-xs text-slate-500">Tải tài liệu mới lên hoặc chọn file đã có trong kho. Có thể dùng cả hai cách.</p>
|
||||
<label for="robotDocumentFiles" class="mb-2 mt-3 block text-xs font-bold text-slate-600">Tải tài liệu mới</label>
|
||||
<input id="robotDocumentFiles" type="file" name="documents" multiple accept="${DOCUMENT_FORMATS.accept}" class="block w-full text-sm">
|
||||
<p class="mt-2 text-xs text-slate-500">${DOCUMENT_FORMATS.description}. Tối đa 10 file mỗi lần, ${this.documentMaxFileSizeMb} MB/file. File mới cũng được lưu trong mục Tài liệu.</p>
|
||||
<label for="robotDocumentSearch" class="mb-2 mt-4 block text-xs font-bold text-slate-600">Chọn từ kho tài liệu</label>
|
||||
<input id="robotDocumentSearch" type="search" class="${fieldClass}" placeholder="Tìm tên tài liệu hoặc tên file...">
|
||||
<div id="robotLibraryList" class="mt-2 max-h-48 overflow-y-auto rounded-lg border border-slate-200">
|
||||
${this.documents.length ? this.documents.map(doc => `<label data-robot-library-item data-search="${this.escapeHtml(`${doc.Title} ${doc.OriginalFileName}`.toLocaleLowerCase('vi'))}" class="flex items-start gap-3 border-b border-slate-100 p-3 text-sm last:border-b-0">
|
||||
<input type="checkbox" name="documentId" value="${Number(doc.DocumentId)}" ${selectedIds.has(Number(doc.DocumentId)) ? 'checked' : ''} class="mt-0.5 rounded border-slate-300">
|
||||
<span class="min-w-0"><span class="block break-words font-semibold">${this.escapeHtml(doc.Title)}</span><span class="block break-words text-xs text-slate-500">${this.escapeHtml(doc.OriginalFileName)}</span></span>
|
||||
</label>`).join('') : '<p class="p-3 text-sm text-slate-500">Kho chưa có tài liệu. Bạn có thể tải file mới lên ở trên.</p>'}
|
||||
</div><p id="robotDocumentSelection" aria-live="polite" class="mt-2 text-xs text-slate-500"></p>
|
||||
<p class="mt-1 text-xs text-slate-400">Bỏ chọn để gỡ tài liệu khỏi robot. File vẫn được giữ trong kho.</p>
|
||||
</section>
|
||||
</div>
|
||||
<div class="flex justify-end gap-2 border-t border-slate-200 bg-slate-50 px-5 py-4">
|
||||
<button type="button" data-close-robot class="rounded-lg border border-slate-300 px-4 py-2 text-sm font-bold">Hủy</button>
|
||||
<button id="robotSaveBtn" type="submit" ${this.robotTypes.length ? '' : 'disabled'} class="rounded-lg bg-primary px-5 py-2 text-sm font-bold text-white disabled:opacity-50">Lưu robot</button>
|
||||
</div>
|
||||
</form>`);
|
||||
const form = dialog.querySelector('#robotForm');
|
||||
form.querySelector('#robotManageTypesLink').addEventListener('click', event => {
|
||||
if (dialog.dataset.saving === 'true') { event.preventDefault(); return; }
|
||||
dialog.close();
|
||||
});
|
||||
const avatarInput = form.querySelector('#robotAvatarFile');
|
||||
const removeAvatar = form.querySelector('#robotRemoveAvatar');
|
||||
const updatePreview = () => {
|
||||
if (dialog.robotPreviewUrl) { URL.revokeObjectURL(dialog.robotPreviewUrl); dialog.robotPreviewUrl = null; }
|
||||
const file = avatarInput.files[0];
|
||||
if (file && (!['image/jpeg', 'image/png', 'image/webp'].includes(file.type) || file.size > 5 * 1024 * 1024)) {
|
||||
this.notifyWarning('Chọn ảnh JPG, PNG hoặc WebP, tối đa 5 MB.'); avatarInput.value = '';
|
||||
}
|
||||
if (avatarInput.files[0]) {
|
||||
dialog.robotPreviewUrl = URL.createObjectURL(avatarInput.files[0]);
|
||||
form.querySelector('#robotAvatarPreview').innerHTML = `<img src="${dialog.robotPreviewUrl}" alt="Xem trước ảnh robot" class="h-20 w-20 rounded-xl bg-slate-100 object-contain">`;
|
||||
} else form.querySelector('#robotAvatarPreview').innerHTML = this.getRobotAvatarHtml(removeAvatar?.checked ? null : robot);
|
||||
};
|
||||
avatarInput.addEventListener('change', () => { if (removeAvatar) removeAvatar.checked = false; updatePreview(); });
|
||||
removeAvatar?.addEventListener('change', () => { avatarInput.value = ''; updatePreview(); });
|
||||
form.querySelector('#robotDocumentSearch').addEventListener('input', event => {
|
||||
const keyword = event.target.value.trim().toLocaleLowerCase('vi');
|
||||
form.querySelectorAll('[data-robot-library-item]').forEach(item => { item.classList.toggle('hidden', !item.dataset.search.includes(keyword)); });
|
||||
});
|
||||
const updateSelection = () => {
|
||||
form.querySelector('#robotDocumentSelection').textContent = `Đã chọn ${form.querySelectorAll('[name="documentId"]:checked').length} tài liệu từ kho và ${form.querySelector('#robotDocumentFiles').files.length} file mới.`;
|
||||
};
|
||||
form.addEventListener('change', updateSelection); updateSelection();
|
||||
form.addEventListener('submit', event => this.saveRobotForm(event, robotId, dialog));
|
||||
} catch (error) { this.notifyFailure(error.message || 'Không thể mở form robot'); }
|
||||
}
|
||||
|
||||
async saveRobotForm(event, robotId, dialog) {
|
||||
event.preventDefault();
|
||||
if (dialog.dataset.saving === 'true' || !this.canCurrentUserManageAssets()) return;
|
||||
const form = event.currentTarget;
|
||||
const documentFiles = [...form.querySelector('#robotDocumentFiles').files];
|
||||
const documentIds = [...form.querySelectorAll('[name="documentId"]:checked')].map(input => Number(input.value));
|
||||
if (documentFiles.length > 10 || documentIds.length + documentFiles.length > 100) { this.notifyWarning('Tối đa 10 file mới mỗi lần và 100 tài liệu cho một robot.'); return; }
|
||||
if (documentFiles.some(file => !this.isSupportedDocumentName(file.name) || file.size > this.documentMaxFileSizeMb * 1024 * 1024)) {
|
||||
this.notifyWarning(`Chọn định dạng tài liệu được hỗ trợ, tối đa ${this.documentMaxFileSizeMb} MB mỗi file.`); return;
|
||||
}
|
||||
const payload = new FormData();
|
||||
for (const key of ['name', 'model', 'typeId']) {
|
||||
const value = form.elements.namedItem(key).value.trim();
|
||||
if (!value) { this.notifyWarning('Vui lòng nhập tên, model và chọn thể loại robot.'); return; }
|
||||
payload.append(key, value);
|
||||
}
|
||||
payload.append('documentIds', JSON.stringify(documentIds));
|
||||
payload.append('removeAvatar', String(Boolean(form.querySelector('#robotRemoveAvatar')?.checked)));
|
||||
const avatar = form.querySelector('#robotAvatarFile').files[0];
|
||||
if (avatar) payload.append('avatar', avatar);
|
||||
documentFiles.forEach(file => payload.append('documents', file));
|
||||
dialog.dataset.saving = 'true';
|
||||
const controls = [...form.querySelectorAll('input, select, button')];
|
||||
controls.forEach(control => { control.disabled = true; });
|
||||
const saveButton = form.querySelector('#robotSaveBtn'); saveButton.textContent = 'Đang lưu...';
|
||||
try {
|
||||
const response = await fetch(`${this.apiBase}/robots${robotId ? `/${Number(robotId)}` : ''}`, { method: robotId ? 'PUT' : 'POST', body: payload });
|
||||
const data = await response.json();
|
||||
if (!response.ok || !data.success) throw new Error(data.message || 'Không thể lưu robot');
|
||||
dialog.close();
|
||||
await Promise.all([this.fetchRobots(), this.fetchDocuments(), this.fetchRobotTypes()]);
|
||||
if (this.currentPage === 'robots') this.renderView('robots');
|
||||
this.notifySuccess(data.message || 'Đã lưu robot');
|
||||
} catch (error) { this.notifyFailure(error.message || 'Không thể lưu robot'); }
|
||||
finally { delete dialog.dataset.saving; controls.forEach(control => { control.disabled = false; }); saveButton.textContent = 'Lưu robot'; }
|
||||
}
|
||||
|
||||
async deleteRobot(robotId) {
|
||||
if (!this.canCurrentUserManageAssets()) return;
|
||||
const robot = this.robots.find(item => Number(item.RobotId) === Number(robotId));
|
||||
if (!robot || !window.confirm(`Xóa robot “${robot.Name}”? Các tài liệu vẫn được giữ trong kho.`)) return;
|
||||
try {
|
||||
const response = await fetch(`${this.apiBase}/robots/${Number(robotId)}`, { method: 'DELETE' });
|
||||
const data = await response.json();
|
||||
if (!response.ok || !data.success) throw new Error(data.message || 'Không thể xóa robot');
|
||||
await Promise.all([this.fetchRobots(), this.fetchRobotTypes()]);
|
||||
if (this.currentPage === 'robots') this.renderView('robots');
|
||||
this.notifySuccess(data.message || 'Đã xóa robot');
|
||||
} catch (error) { this.notifyFailure(error.message); }
|
||||
}
|
||||
|
||||
isSupportedDocumentName(fileName) {
|
||||
const extension = String(fileName || '').match(/\.[^.]+$/)?.[0].toLowerCase();
|
||||
return Boolean(DOCUMENT_FORMATS.formats[extension]);
|
||||
}
|
||||
|
||||
getDocumentPresentation(document) {
|
||||
const extension = String(document?.OriginalFileName || '').match(/\.[^.]+$/)?.[0].toLowerCase() || '';
|
||||
const format = DOCUMENT_FORMATS.formats[extension] || { label: 'File', icon: 'draft', tone: 'slate', preview: false };
|
||||
const colors = {
|
||||
red: { badgeClass: 'bg-red-100 text-red-600', iconClass: 'text-red-600' },
|
||||
blue: { badgeClass: 'bg-blue-100 text-blue-700', iconClass: 'text-blue-700' },
|
||||
green: { badgeClass: 'bg-emerald-100 text-emerald-700', iconClass: 'text-emerald-700' },
|
||||
orange: { badgeClass: 'bg-orange-100 text-orange-700', iconClass: 'text-orange-700' },
|
||||
purple: { badgeClass: 'bg-purple-100 text-purple-700', iconClass: 'text-purple-700' },
|
||||
slate: { badgeClass: 'bg-slate-100 text-slate-600', iconClass: 'text-slate-600' }
|
||||
};
|
||||
return { ...format, ...colors[format.tone], extension: extension.slice(1).toUpperCase() };
|
||||
}
|
||||
|
||||
formatFileSize(value) {
|
||||
const bytes = Number(value) || 0;
|
||||
if (bytes < 1024) return `${bytes} B`;
|
||||
@@ -3329,10 +3846,10 @@ class AccountManager {
|
||||
<div class="page-header flex items-end justify-between gap-4 mb-5">
|
||||
<div>
|
||||
<div class="flex items-center gap-2 text-red-600 mb-1">
|
||||
<span class="material-symbols-outlined">picture_as_pdf</span>
|
||||
<span class="material-symbols-outlined">folder_open</span>
|
||||
<span class="text-xs font-extrabold uppercase tracking-widest">Kho tài liệu</span>
|
||||
</div>
|
||||
<h1 class="text-2xl font-extrabold text-slate-900 dark:text-slate-50">Tài liệu PDF</h1>
|
||||
<h1 class="text-2xl font-extrabold text-slate-900 dark:text-slate-50">Tài liệu</h1>
|
||||
<p class="text-sm text-slate-500 mt-1">Lưu trữ, xem và tải xuống tài liệu dùng chung.</p>
|
||||
</div>
|
||||
<div class="document-header-actions flex flex-wrap items-center justify-end gap-3">
|
||||
@@ -3364,23 +3881,25 @@ class AccountManager {
|
||||
${documents.map(document => {
|
||||
const documentId = Number(document?.DocumentId);
|
||||
const canDelete = Boolean(document?.CanDelete);
|
||||
const presentation = this.getDocumentPresentation(document);
|
||||
return `
|
||||
<article class="flex min-w-0 gap-4 rounded-xl border border-slate-200 p-4 transition hover:border-red-200 hover:shadow-sm">
|
||||
<div class="flex h-12 w-12 shrink-0 items-center justify-center rounded-xl bg-red-100 text-red-600">
|
||||
<span class="material-symbols-outlined text-3xl">picture_as_pdf</span>
|
||||
<div class="flex h-12 w-12 shrink-0 items-center justify-center rounded-xl ${presentation.badgeClass}" title="${presentation.label}">
|
||||
<span class="material-symbols-outlined text-3xl">${presentation.icon}</span>
|
||||
</div>
|
||||
<div class="min-w-0 flex-1">
|
||||
<h2 class="truncate font-extrabold text-slate-800" title="${this.escapeHtml(document?.Title || '')}">${this.escapeHtml(document?.Title || 'Tài liệu PDF')}</h2>
|
||||
<h2 class="truncate font-extrabold text-slate-800" title="${this.escapeHtml(document?.Title || '')}">${this.escapeHtml(document?.Title || 'Tài liệu')}</h2>
|
||||
<p class="mt-0.5 truncate text-xs text-slate-500" title="${this.escapeHtml(document?.OriginalFileName || '')}">${this.escapeHtml(document?.OriginalFileName || '-')}</p>
|
||||
<div class="mt-2 flex flex-wrap gap-x-3 gap-y-1 text-[11px] text-slate-500">
|
||||
<span class="font-bold ${presentation.iconClass}">${this.escapeHtml(presentation.extension || 'FILE')}</span>
|
||||
<span class="inline-flex items-center gap-1"><span class="material-symbols-outlined text-sm">hard_drive</span>${this.formatFileSize(document?.FileSize)}</span>
|
||||
<span class="inline-flex items-center gap-1"><span class="material-symbols-outlined text-sm">person</span>${this.escapeHtml(document?.UploadedByName || '-')}</span>
|
||||
<span class="inline-flex items-center gap-1"><span class="material-symbols-outlined text-sm">schedule</span>${this.formatDateTime(document?.UploadedDate)}</span>
|
||||
</div>
|
||||
<div class="mt-3 flex flex-wrap items-center gap-2">
|
||||
<a href="${this.apiBase}/documents/${documentId}/file" target="_blank" rel="noopener noreferrer" class="inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-bold text-white hover:bg-primary-dim">
|
||||
<span class="material-symbols-outlined text-base">visibility</span>Xem PDF
|
||||
</a>
|
||||
${presentation.preview ? `<a href="${this.apiBase}/documents/${documentId}/file" target="_blank" rel="noopener noreferrer" class="inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-bold text-white hover:bg-primary-dim">
|
||||
<span class="material-symbols-outlined text-base">visibility</span>Xem ${presentation.label}
|
||||
</a>` : ''}
|
||||
<a href="${this.apiBase}/documents/${documentId}/file?download=1" class="inline-flex items-center gap-1.5 rounded-lg border border-slate-200 px-3 py-1.5 text-xs font-bold text-slate-700 hover:bg-slate-50">
|
||||
<span class="material-symbols-outlined text-base">download</span>Tải xuống
|
||||
</a>
|
||||
@@ -3400,7 +3919,7 @@ class AccountManager {
|
||||
<div class="flex h-16 w-16 items-center justify-center rounded-full bg-slate-100 text-slate-400">
|
||||
<span class="material-symbols-outlined text-4xl">folder_open</span>
|
||||
</div>
|
||||
<h2 class="mt-4 font-extrabold text-slate-700">${this.documentSearchTerm ? 'Không tìm thấy tài liệu' : 'Chưa có tài liệu PDF'}</h2>
|
||||
<h2 class="mt-4 font-extrabold text-slate-700">${this.documentSearchTerm ? 'Không tìm thấy tài liệu' : 'Chưa có tài liệu'}</h2>
|
||||
<p class="mt-1 max-w-md text-sm text-slate-500">${this.documentSearchTerm ? 'Hãy thử một từ khóa khác.' : 'Bấm “Thêm tài liệu” để lưu tài liệu đầu tiên.'}</p>
|
||||
</div>
|
||||
`}
|
||||
@@ -3415,7 +3934,7 @@ class AccountManager {
|
||||
<span class="material-symbols-outlined">upload_file</span>
|
||||
</div>
|
||||
<div class="min-w-0">
|
||||
<h2 id="documentUploadDialogTitle" class="text-lg font-extrabold text-slate-900">Thêm tài liệu PDF</h2>
|
||||
<h2 id="documentUploadDialogTitle" class="text-lg font-extrabold text-slate-900">Thêm tài liệu</h2>
|
||||
<p class="mt-0.5 text-xs text-slate-500">Tải tài liệu lên kho dùng chung.</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -3426,10 +3945,10 @@ class AccountManager {
|
||||
|
||||
<div class="space-y-4 px-5 py-5">
|
||||
<div>
|
||||
<label for="documentFile" class="mb-1.5 block text-sm font-bold text-slate-700">Chọn file PDF <span class="text-red-600">*</span></label>
|
||||
<input id="documentFile" name="file" type="file" accept="application/pdf,.pdf" required
|
||||
<label for="documentFile" class="mb-1.5 block text-sm font-bold text-slate-700">Chọn tài liệu <span class="text-red-600">*</span></label>
|
||||
<input id="documentFile" name="file" type="file" accept="${DOCUMENT_FORMATS.accept}" required
|
||||
class="block h-11 w-full rounded-lg border border-slate-200 bg-white p-0 pr-3 text-sm file:mr-4 file:h-full file:border-0 file:bg-slate-100 file:px-4 file:font-bold file:text-slate-700 hover:file:bg-slate-200" />
|
||||
<p class="mt-1.5 text-xs text-slate-500">Chỉ nhận định dạng PDF, tối đa ${this.documentMaxFileSizeMb} MB.</p>
|
||||
<p class="mt-1.5 text-xs text-slate-500">${DOCUMENT_FORMATS.description}. Tối đa ${this.documentMaxFileSizeMb} MB/file.</p>
|
||||
</div>
|
||||
<div>
|
||||
<label for="documentTitle" class="mb-1.5 block text-sm font-bold text-slate-700">Tên hiển thị <span class="font-normal text-slate-400">(không bắt buộc)</span></label>
|
||||
@@ -3539,18 +4058,18 @@ class AccountManager {
|
||||
async handleDocumentUpload(event) {
|
||||
event.preventDefault();
|
||||
const form = event.currentTarget;
|
||||
if (form.dataset.uploading === 'true') return;
|
||||
const fileInput = form.querySelector('#documentFile');
|
||||
const titleInput = form.querySelector('#documentTitle');
|
||||
const submitButton = form.querySelector('#documentUploadSubmit');
|
||||
const file = fileInput?.files?.[0];
|
||||
if (!file) {
|
||||
this.notifyWarning('Vui lòng chọn file PDF');
|
||||
this.notifyWarning('Vui lòng chọn tài liệu');
|
||||
return;
|
||||
}
|
||||
|
||||
const extensionIsPdf = String(file.name || '').toLowerCase().endsWith('.pdf');
|
||||
if (!extensionIsPdf || (file.type && file.type !== 'application/pdf')) {
|
||||
this.notifyFailure('Chỉ chấp nhận file PDF');
|
||||
if (!this.isSupportedDocumentName(file.name)) {
|
||||
this.notifyFailure(`Định dạng chưa được hỗ trợ. Chấp nhận: ${DOCUMENT_FORMATS.description}.`);
|
||||
return;
|
||||
}
|
||||
if (file.size > this.documentMaxFileSizeMb * 1024 * 1024) {
|
||||
@@ -3583,7 +4102,7 @@ class AccountManager {
|
||||
this.documentSearchTerm = '';
|
||||
await this.fetchDocuments();
|
||||
this.renderView('documents');
|
||||
this.notifySuccess(data.message || 'Đã lưu tài liệu PDF');
|
||||
this.notifySuccess(data.message || 'Đã lưu tài liệu');
|
||||
} catch (err) {
|
||||
console.error('Upload document error:', err);
|
||||
this.notifyFailure(err.message || 'Không thể tải tài liệu lên');
|
||||
|
||||
26
public/js/document-formats.js
Normal file
26
public/js/document-formats.js
Normal file
@@ -0,0 +1,26 @@
|
||||
(function () {
|
||||
const formats = {
|
||||
'.pdf': { mimeType: 'application/pdf', label: 'PDF', icon: 'picture_as_pdf', tone: 'red', preview: true },
|
||||
'.doc': { mimeType: 'application/msword', label: 'Word', icon: 'description', tone: 'blue' },
|
||||
'.docx': { mimeType: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', label: 'Word', icon: 'description', tone: 'blue' },
|
||||
'.xls': { mimeType: 'application/vnd.ms-excel', label: 'Excel', icon: 'table_chart', tone: 'green' },
|
||||
'.xlsx': { mimeType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', label: 'Excel', icon: 'table_chart', tone: 'green' },
|
||||
'.ppt': { mimeType: 'application/vnd.ms-powerpoint', label: 'PowerPoint', icon: 'slideshow', tone: 'orange' },
|
||||
'.pptx': { mimeType: 'application/vnd.openxmlformats-officedocument.presentationml.presentation', label: 'PowerPoint', icon: 'slideshow', tone: 'orange' },
|
||||
'.jpg': { mimeType: 'image/jpeg', label: 'Ảnh', icon: 'image', tone: 'purple', preview: true },
|
||||
'.jpeg': { mimeType: 'image/jpeg', label: 'Ảnh', icon: 'image', tone: 'purple', preview: true },
|
||||
'.png': { mimeType: 'image/png', label: 'Ảnh', icon: 'image', tone: 'purple', preview: true },
|
||||
'.gif': { mimeType: 'image/gif', label: 'Ảnh', icon: 'image', tone: 'purple', preview: true },
|
||||
'.webp': { mimeType: 'image/webp', label: 'Ảnh', icon: 'image', tone: 'purple', preview: true },
|
||||
'.bmp': { mimeType: 'image/bmp', label: 'Ảnh', icon: 'image', tone: 'purple', preview: true },
|
||||
'.tif': { mimeType: 'image/tiff', label: 'Ảnh TIFF', icon: 'image', tone: 'purple' },
|
||||
'.tiff': { mimeType: 'image/tiff', label: 'Ảnh TIFF', icon: 'image', tone: 'purple' },
|
||||
'.txt': { mimeType: 'text/plain', label: 'Văn bản', icon: 'text_snippet', tone: 'slate', preview: true },
|
||||
'.csv': { mimeType: 'text/csv', label: 'CSV', icon: 'table_chart', tone: 'green' },
|
||||
'.rtf': { mimeType: 'application/rtf', label: 'RTF', icon: 'description', tone: 'blue' },
|
||||
'.zip': { mimeType: 'application/zip', label: 'ZIP', icon: 'folder_zip', tone: 'slate' }
|
||||
};
|
||||
const config = { formats, accept: Object.keys(formats).join(','), description: 'PDF, Word, Excel, PowerPoint, ảnh, TXT, CSV, RTF, ZIP' };
|
||||
if (typeof module !== 'undefined' && module.exports) module.exports = config;
|
||||
if (typeof window !== 'undefined') window.DocumentFormats = config;
|
||||
}());
|
||||
@@ -9,7 +9,7 @@
|
||||
<link href="https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=Inter:wght@300;400;500;600&display=swap" rel="stylesheet"/>
|
||||
<!-- Material Symbols -->
|
||||
<link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&display=swap" rel="stylesheet"/>
|
||||
<link rel="stylesheet" href="../css/main.css?v=20260806-4" />
|
||||
<link rel="stylesheet" href="../css/main.css?v=20261019-4" />
|
||||
<!-- Notiflix Notify -->
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/notiflix@3.2.7/dist/notiflix-3.2.7.min.css" />
|
||||
<script src="https://cdn.jsdelivr.net/npm/notiflix@3.2.7/dist/notiflix-aio-3.2.7.min.js"></script>
|
||||
@@ -46,25 +46,6 @@
|
||||
transform: scale(1);
|
||||
}
|
||||
|
||||
.tree-label {
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
font-size: 10px;
|
||||
font-weight: 800;
|
||||
color: #64748b;
|
||||
padding: 0 0.75rem;
|
||||
margin-bottom: 0.35rem;
|
||||
}
|
||||
|
||||
.tree-branch {
|
||||
margin-left: 0.75rem;
|
||||
border-left: 1px dashed rgba(100, 116, 139, 0.5);
|
||||
padding-left: 0.6rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.2rem;
|
||||
}
|
||||
|
||||
body.app-shell {
|
||||
overflow: hidden;
|
||||
}
|
||||
@@ -268,102 +249,126 @@
|
||||
}
|
||||
|
||||
</style>
|
||||
<link rel="stylesheet" href="../css/responsive.css?v=20261013-1" />
|
||||
<link rel="stylesheet" href="../css/responsive.css?v=20261019-3" />
|
||||
</head>
|
||||
<body class="app-shell bg-background text-on-surface antialiased flex h-screen w-screen">
|
||||
<!-- SideNavBar -->
|
||||
<aside id="appSidebar" class="h-screen w-56 flex flex-col bg-slate-100 dark:bg-slate-900 font-manrope text-sm font-medium border-r border-outline-variant/10 shrink-0">
|
||||
<div class="flex flex-col h-full py-6">
|
||||
<aside id="appSidebar" class="h-screen w-64 flex flex-col bg-slate-100 dark:bg-slate-900 font-manrope text-sm font-medium border-r border-outline-variant/10 shrink-0">
|
||||
<div class="flex flex-col h-full min-h-0 py-4">
|
||||
<!-- Header -->
|
||||
<div class="px-6 mb-8">
|
||||
<div class="px-5 mb-4 shrink-0">
|
||||
<a href="#dashboard" class="sidebar-brand-link" aria-label="PNKX - Về trang tổng quan">
|
||||
<img src="../image/logo_PNKX.png" alt="PNKX" class="sidebar-brand-image"/>
|
||||
</a>
|
||||
</div>
|
||||
<!-- Primary Nav -->
|
||||
<nav class="flex-1 px-3 space-y-4 overflow-y-auto">
|
||||
<div>
|
||||
<div class="tree-label">Tài khoản</div>
|
||||
<div class="tree-branch">
|
||||
<a href="#dashboard" data-nav="dashboard" class="flex items-center gap-3 px-3 py-2 border-l-4 border-blue-600 bg-slate-200/80 dark:bg-slate-800 text-slate-900 dark:text-slate-50 font-bold group transition-all cursor-pointer rounded-r-lg">
|
||||
<span class="material-symbols-outlined">dashboard</span>
|
||||
<span>Tổng quan</span>
|
||||
<nav id="sidebarNav" class="sidebar-nav flex-1 min-h-0 overflow-y-auto" aria-label="Điều hướng chính">
|
||||
<ul class="sidebar-menu">
|
||||
<li>
|
||||
<a href="#dashboard" data-nav="dashboard" class="sidebar-link" aria-current="page">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">dashboard</span>
|
||||
<span class="sidebar-text">Tổng quan</span>
|
||||
</a>
|
||||
<a href="#applications" data-nav="applications" class="flex items-center gap-3 px-3 py-2 text-slate-600 dark:text-slate-400 hover:text-slate-900 hover:bg-slate-200/50 transition-all group cursor-pointer rounded-r-lg">
|
||||
<span class="material-symbols-outlined">apps</span>
|
||||
<span>Ứng dụng</span>
|
||||
</li>
|
||||
<li data-nav-group="accounts">
|
||||
<button id="sidebarAccountsToggle" type="button" class="sidebar-link sidebar-group-toggle" data-nav-toggle="accounts" aria-expanded="false" aria-controls="sidebarAccounts">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">manage_accounts</span>
|
||||
<span class="sidebar-text">Tài khoản</span>
|
||||
<span class="material-symbols-outlined sidebar-chevron" aria-hidden="true">chevron_right</span>
|
||||
</button>
|
||||
<ul id="sidebarAccounts" class="sidebar-children" aria-labelledby="sidebarAccountsToggle" hidden>
|
||||
<li><a href="#applications" data-nav="applications" class="sidebar-link">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">apps</span>
|
||||
<span class="sidebar-text">Ứng dụng</span>
|
||||
</a></li>
|
||||
<li><a href="#accounts" data-nav="accounts" class="sidebar-link">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">manage_accounts</span>
|
||||
<span class="sidebar-text">Tài khoản</span>
|
||||
</a></li>
|
||||
<li><a href="#notifications" data-nav="notifications" class="sidebar-link">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">notifications</span>
|
||||
<span class="sidebar-text">Thông báo</span>
|
||||
<span id="notificationNavBadge" class="hidden ml-auto min-w-[20px] h-5 px-1.5 rounded-full bg-red-600 text-white text-[10px] font-extrabold leading-5 text-center">0</span>
|
||||
</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li data-nav-group="assets">
|
||||
<button id="sidebarAssetsToggle" type="button" class="sidebar-link sidebar-group-toggle" data-nav-toggle="assets" aria-expanded="false" aria-controls="sidebarAssets">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">inventory_2</span>
|
||||
<span class="sidebar-text">Quản lý tài sản</span>
|
||||
<span class="material-symbols-outlined sidebar-chevron" aria-hidden="true">chevron_right</span>
|
||||
</button>
|
||||
<ul id="sidebarAssets" class="sidebar-children" aria-labelledby="sidebarAssetsToggle" hidden>
|
||||
<li><a href="#assets" data-nav="assets" class="sidebar-link">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">inventory_2</span>
|
||||
<span class="sidebar-text">Tài sản</span>
|
||||
</a></li>
|
||||
<li><a href="#asset-borrows" data-nav="asset-borrows" class="sidebar-link">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">assignment_returned</span>
|
||||
<span class="sidebar-text">Mượn/Trả tài sản</span>
|
||||
</a></li>
|
||||
<li><a href="#my-borrowed-assets" data-nav="my-borrowed-assets" class="sidebar-link">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">inventory</span>
|
||||
<span class="sidebar-text">Tài sản đang mượn</span>
|
||||
</a></li>
|
||||
<li><a href="#asset-departments" data-nav="asset-departments" class="sidebar-link">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">apartment</span>
|
||||
<span class="sidebar-text">Phòng ban</span>
|
||||
</a></li>
|
||||
<li><a href="#asset-projects" data-nav="asset-projects" class="sidebar-link">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">workspaces</span>
|
||||
<span class="sidebar-text">Dự án</span>
|
||||
</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li data-nav-group="consumables">
|
||||
<button id="sidebarConsumablesToggle" type="button" class="sidebar-link sidebar-group-toggle" data-nav-toggle="consumables" aria-expanded="false" aria-controls="sidebarConsumables">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">category</span>
|
||||
<span class="sidebar-text">Vật tư tiêu hao</span>
|
||||
<span class="material-symbols-outlined sidebar-chevron" aria-hidden="true">chevron_right</span>
|
||||
</button>
|
||||
<ul id="sidebarConsumables" class="sidebar-children" aria-labelledby="sidebarConsumablesToggle" hidden>
|
||||
<li><a href="#consumables" data-nav="consumables" class="sidebar-link">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">category</span>
|
||||
<span class="sidebar-text">Danh sách VTTH</span>
|
||||
</a></li>
|
||||
<li><a href="#consumable-exports" data-nav="consumable-exports" class="sidebar-link">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">outbox</span>
|
||||
<span class="sidebar-text">Lịch sử xuất</span>
|
||||
</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li data-nav-group="robots">
|
||||
<button id="sidebarRobotsToggle" type="button" class="sidebar-link sidebar-group-toggle" data-nav-toggle="robots" aria-expanded="false" aria-controls="sidebarRobots">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">smart_toy</span>
|
||||
<span class="sidebar-text">Quản lý robot</span>
|
||||
<span class="material-symbols-outlined sidebar-chevron" aria-hidden="true">chevron_right</span>
|
||||
</button>
|
||||
<ul id="sidebarRobots" class="sidebar-children" aria-labelledby="sidebarRobotsToggle" hidden>
|
||||
<li><a href="#robots" data-nav="robots" class="sidebar-link">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">smart_toy</span>
|
||||
<span class="sidebar-text">Danh sách robot</span>
|
||||
</a></li>
|
||||
<li><a href="#robot-types" data-nav="robot-types" class="sidebar-link">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">category</span>
|
||||
<span class="sidebar-text">Thể loại robot</span>
|
||||
</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#documents" data-nav="documents" class="sidebar-link">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">folder_open</span>
|
||||
<span class="sidebar-text">Tài liệu</span>
|
||||
</a></li>
|
||||
<li id="usersSection" class="sidebar-admin" style="display: none;">
|
||||
<a id="usersNav" href="#users" data-nav="users" class="sidebar-link" style="display: none;">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">people</span>
|
||||
<span class="sidebar-text">Người dùng</span>
|
||||
</a>
|
||||
<a href="#accounts" data-nav="accounts" class="flex items-center gap-3 px-3 py-2 text-slate-600 dark:text-slate-400 hover:text-slate-900 hover:bg-slate-200/50 transition-all group cursor-pointer rounded-r-lg">
|
||||
<span class="material-symbols-outlined">manage_accounts</span>
|
||||
<span>Tài khoản</span>
|
||||
</a>
|
||||
<a href="#notifications" data-nav="notifications" class="relative flex items-center gap-3 px-3 py-2 text-slate-600 dark:text-slate-400 hover:text-slate-900 hover:bg-slate-200/50 transition-all group cursor-pointer rounded-r-lg">
|
||||
<span class="material-symbols-outlined">notifications</span>
|
||||
<span>Thông báo</span>
|
||||
<span id="notificationNavBadge" class="hidden ml-auto min-w-[20px] h-5 px-1.5 rounded-full bg-red-600 text-white text-[10px] font-extrabold leading-5 text-center">0</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div class="tree-label">Quản lý tài sản</div>
|
||||
<div class="tree-branch">
|
||||
<a href="#assets" data-nav="assets" class="flex items-center gap-3 px-3 py-2 text-slate-600 dark:text-slate-400 hover:text-slate-900 hover:bg-slate-200/50 transition-all group cursor-pointer rounded-r-lg">
|
||||
<span class="material-symbols-outlined">inventory_2</span>
|
||||
<span>Tài sản</span>
|
||||
</a>
|
||||
<a href="#asset-borrows" data-nav="asset-borrows" class="flex items-center gap-3 px-3 py-2 text-slate-600 dark:text-slate-400 hover:text-slate-900 hover:bg-slate-200/50 transition-all group cursor-pointer rounded-r-lg">
|
||||
<span class="material-symbols-outlined">assignment_returned</span>
|
||||
<span>Mượn/Trả tài sản</span>
|
||||
</a>
|
||||
<a href="#my-borrowed-assets" data-nav="my-borrowed-assets" class="flex items-center gap-3 px-3 py-2 text-slate-600 dark:text-slate-400 hover:text-slate-900 hover:bg-slate-200/50 transition-all group cursor-pointer rounded-r-lg">
|
||||
<span class="material-symbols-outlined">inventory</span>
|
||||
<span>Tài sản đang mượn</span>
|
||||
</a>
|
||||
<a href="#asset-departments" data-nav="asset-departments" class="flex items-center gap-3 px-3 py-2 text-slate-600 dark:text-slate-400 hover:text-slate-900 hover:bg-slate-200/50 transition-all group cursor-pointer rounded-r-lg">
|
||||
<span class="material-symbols-outlined">apartment</span>
|
||||
<span> Phòng Ban</span>
|
||||
</a>
|
||||
<a href="#asset-projects" data-nav="asset-projects" class="flex items-center gap-3 px-3 py-2 text-slate-600 dark:text-slate-400 hover:text-slate-900 hover:bg-slate-200/50 transition-all group cursor-pointer rounded-r-lg">
|
||||
<span class="material-symbols-outlined">workspaces</span>
|
||||
<span>Dự án</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div class="tree-label">Vật tư tiêu hao</div>
|
||||
<div class="tree-branch">
|
||||
<a href="#consumables" data-nav="consumables" class="flex items-center gap-3 px-3 py-2 text-slate-600 dark:text-slate-400 hover:text-slate-900 hover:bg-slate-200/50 transition-all group cursor-pointer rounded-r-lg">
|
||||
<span class="material-symbols-outlined">category</span>
|
||||
<span>Danh sách VTTH</span>
|
||||
</a>
|
||||
<a href="#consumable-exports" data-nav="consumable-exports" class="flex items-center gap-3 px-3 py-2 text-slate-600 dark:text-slate-400 hover:text-slate-900 hover:bg-slate-200/50 transition-all group cursor-pointer rounded-r-lg">
|
||||
<span class="material-symbols-outlined">outbox</span>
|
||||
<span>Lịch sử xuất</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div class="tree-label">Tài liệu</div>
|
||||
<div class="tree-branch">
|
||||
<a href="#documents" data-nav="documents" class="flex items-center gap-3 px-3 py-2 text-slate-600 dark:text-slate-400 hover:text-slate-900 hover:bg-slate-200/50 transition-all group cursor-pointer rounded-r-lg">
|
||||
<span class="material-symbols-outlined">picture_as_pdf</span>
|
||||
<span>Tài liệu PDF</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="usersSection" class="pt-2 border-t border-outline-variant/10" style="display: none;">
|
||||
<a id="usersNav" href="#users" data-nav="users" class="flex items-center gap-3 px-3 py-2 text-slate-600 dark:text-slate-400 hover:text-slate-900 hover:bg-slate-200/50 transition-all group cursor-pointer rounded-lg" style="display: none;">
|
||||
<span class="material-symbols-outlined">people</span>
|
||||
<span>Người dùng (Quản trị)</span>
|
||||
</a>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<!-- Footer -->
|
||||
<div class="px-6 pt-4 border-t border-outline-variant/10">
|
||||
<div class="px-5 pt-3 mt-3 border-t border-outline-variant/10 shrink-0">
|
||||
<div class="text-[10px] font-bold text-on-surface-variant/40 uppercase tracking-widest">v1.0.0</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -425,6 +430,7 @@
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<script src="../js/app.js?v=20261013-3"></script>
|
||||
<script src="../js/document-formats.js?v=20261019-1"></script>
|
||||
<script src="../js/app.js?v=20261019-4"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user