-ux
All checks were successful
Build Docker Image / Build Docker Image (push) Successful in 6m34s
Build Docker Image / Restart Docker Compose (push) Successful in 0s

-ui
ใหม่ ทั้งระบบ (ai little retouch)
This commit is contained in:
x2Skyz
2025-11-28 20:39:48 +07:00
parent 4db7ddaba2
commit 11018ae49d
9 changed files with 205 additions and 194 deletions

View File

@@ -1,69 +1,29 @@
import { Component, HostListener, OnInit } from '@angular/core';
import { Component, Input, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { trigger, state, style, transition, animate } from '@angular/animations';
import { JwtService } from '../../services/jwt.service';
@Component({
selector: 'app-sidebar',
standalone: false,
templateUrl: './sidebar.component.html',
styleUrls: ['./sidebar.component.css'],
animations: [
trigger('sidebarState', [
state('expanded', style({
width: '220px',
opacity: 1
})),
state('collapsed', style({
width: '70px',
opacity: 0.95
})),
transition('expanded <=> collapsed', [
animate('300ms ease-in-out')
])
])
]
styleUrls: ['./sidebar.component.css']
})
export class SidebarComponent implements OnInit {
isOpen = true; // ขยายไหม
isMobile = false; // ตรวจอุปกรณ์
showOverlay = false; // สำหรับ mobile overlay
@Input() isCollapsed: boolean = false; // รับค่าสถานะย่อ/ขยาย
constructor(
private router: Router,
private jwtService: JwtService
) {}
userData: any = {
name: 'Nuttakit',
role: 'Admin',
avatar: ''
};
ngOnInit() {
this.checkDevice();
window.addEventListener('resize', () => this.checkDevice());
}
constructor(private router: Router) { }
@HostListener('window:resize')
checkDevice() {
this.isMobile = window.innerWidth <= 768;
if (this.isMobile) {
this.isOpen = false; // ซ่อน sidebar ตอนเข้า mobile
} else {
this.isOpen = true; // เปิดไว้ตลอดใน desktop
this.showOverlay = false;
}
}
toggleSidebar() {
if (this.isMobile) {
this.showOverlay = !this.showOverlay;
this.isOpen = this.showOverlay;
} else {
this.isOpen = !this.isOpen;
}
}
navigate(path: string) {
this.router.navigate([path]);
ngOnInit(): void {
// โหลด User Data ถ้ามี
}
logout() {
this.jwtService.logout();
localStorage.removeItem('access_token');
this.router.navigate(['/login']);
}
}